23 private $orderItemRepositoryMock;
28 private $creditMemoMock;
33 private $creditMemoItemMock;
38 private $orderItemMock;
43 private $returnValidator;
47 $this->orderItemRepositoryMock = $this->getMockBuilder(OrderItemRepositoryInterface::class)
48 ->disableOriginalConstructor()
51 $this->creditMemoMock = $this->getMockBuilder(CreditmemoInterface::class)
52 ->disableOriginalConstructor()
55 $this->creditMemoItemMock = $this->getMockBuilder(CreditmemoItemInterface::class)
56 ->disableOriginalConstructor()
59 $this->orderItemMock = $this->getMockBuilder(OrderItemInterface::class)
60 ->disableOriginalConstructor()
64 $this->orderItemRepositoryMock
78 $this->creditMemoMock->expects($this->once())
80 ->willReturn([$this->creditMemoItemMock]);
82 $this->orderItemRepositoryMock->expects($this->once())
84 ->with($returnToStockItems[0])
85 ->willReturn($this->orderItemMock);
87 $this->orderItemMock->expects($this->once())
89 ->willReturn($orderItemId);
91 $this->creditMemoItemMock->expects($this->once())
92 ->method(
'getOrderItemId')
93 ->willReturn($creditMemoItemId);
96 $this->orderItemMock->expects($this->once())
98 ->willReturn($productSku);
102 $this->returnValidator->validate($returnToStockItems, $this->creditMemoMock),
109 $returnToStockItems = [1];
110 $this->creditMemoMock->expects($this->once())
112 ->willReturn([$this->creditMemoItemMock]);
113 $this->orderItemRepositoryMock->expects($this->once())
115 ->with($returnToStockItems[0])
119 $this->returnValidator->validate($returnToStockItems, $this->creditMemoMock),
120 __(
'The return to stock argument contains product item that is not part of the original order.')
130 'PostirivValidationTest' => [
null, [1], 1, 1],
131 'WithWrongReturnToStockItems' => [
132 __(
'The "%1" product is not part of the current creditmemo.',
'sku1'), [2], 2, 1,
'sku1',
testValidate( $expectedResult, $returnToStockItems, $orderItemId, $creditMemoItemId, $productSku=null)
testValidationWithWrongOrderItems()