예제 #1
0
 public function testItemNotAvailableForReorderWhenProductNotExist()
 {
     $this->stockItemMock->expects($this->never())->method('getIsInStock');
     $this->stockRegistry->expects($this->any())->method('getStockItem')->will($this->returnValue($this->stockItemMock));
     $orderItem = $this->getMock('Magento\\Sales\\Model\\Order\\Item', [], [], '', false);
     $orderItem->expects($this->any())->method('getProduct')->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException());
     $this->createBlockObject();
     $this->assertSame(false, $this->block->isItemAvailableForReorder($orderItem));
 }
예제 #2
0
 /**
  * @param int|bool $productId
  * @param bool $result
  * @dataProvider isItemAvailableForReorderDataProvider
  */
 public function testIsItemAvailableForReorder($productId, $result)
 {
     if ($productId) {
         $product = $this->getMock('Magento\\Catalog\\Model\\Product', ['getId', '__wakeup'], [], '', false);
         $product->expects($this->once())->method('getId')->will($this->returnValue($productId));
         $this->stockItemService->expects($this->once())->method('getIsInStock')->with($this->equalTo($productId))->will($this->returnValue($result));
     } else {
         $product = false;
     }
     $orderItem = $this->getMock('Magento\\Sales\\Model\\Order\\Item', [], [], '', false);
     $orderItem->expects($this->any())->method('getProduct')->will($this->returnValue($product));
     $this->createBlockObject();
     $this->assertSame($result, $this->block->isItemAvailableForReorder($orderItem));
 }