22 private $orderItemRepositoryMock;
27 private $orderItemMock;
32 private $createQuantityValidator;
46 $this->orderItemRepositoryMock = $this->getMockBuilder(OrderItemRepositoryInterface::class)
47 ->disableOriginalConstructor()
49 ->getMockForAbstractClass();
51 $this->orderItemMock = $this->getMockBuilder(Item::class)
52 ->disableOriginalConstructor()
53 ->getMockForAbstractClass();
55 $this->entity = $this->getMockBuilder(\stdClass::class)
56 ->disableOriginalConstructor()
57 ->setMethods([
'getOrderItemId',
'getQty'])
67 $this->entity->expects($this->once())
68 ->method(
'getOrderItemId')
69 ->willReturn($orderItemId);
71 $this->orderItemRepositoryMock->expects($this->once())
74 ->willReturn($this->orderItemMock);
76 $this->entity->expects($this->once())
77 ->method(
'getOrderItemId')
81 $this->contexMock =
null;
83 $this->contexMock = $this->getMockBuilder(OrderInterface::class)
84 ->disableOriginalConstructor()
85 ->getMockForAbstractClass();
87 $this->entity->expects($this->once())
93 $this->orderItemRepositoryMock,
97 $this->assertEquals($expectedResult, $this->createQuantityValidator->validate($this->entity));
106 'testValidateCreditMemoProductItems' => [
108 [
__(
'The creditmemo contains product item that is not part of the original order.')],
110 'testValidateWithException' => [
112 [
__(
'The creditmemo contains product item that is not part of the original order.')]
114 'testValidateWithContext' => [
116 [
__(
'The quantity to refund must not be greater than the unrefunded quantity.')],
testValidateCreditMemoProductItems($orderItemId, $expectedResult, $withContext=false)