/** * @param array $orderItemAppliedTaxes * @param array $expected * @return void * @dataProvider getOrderTaxDetailsDataProvider */ public function testGetOrderTaxDetails($orderItemAppliedTaxes, $expected) { $orderId = 1; $this->orderMock->expects($this->once())->method('load')->with($orderId)->will($this->returnSelf()); $this->taxItemResourceMock->expects($this->once())->method('getTaxItemsByOrderId')->with($orderId)->will($this->returnValue($orderItemAppliedTaxes)); $this->assertEquals($this->orderTaxDetailsDataObject, $this->taxManagement->getOrderTaxDetails($orderId)); $this->assertEquals($expected['code'], $this->appliedTaxDataObject->getCode()); $this->assertEquals($expected['title'], $this->appliedTaxDataObject->getTitle()); $this->assertEquals($expected['tax_percent'], $this->appliedTaxDataObject->getPercent()); $this->assertEquals($expected['real_amount'], $this->appliedTaxDataObject->getAmount()); $this->assertEquals($expected['real_base_amount'], $this->appliedTaxDataObject->getBaseAmount()); }
/** * @param array $orderItemAppliedTaxes * @return void * @dataProvider getOrderTaxDetailsDataProvider */ public function testGetOrderTaxDetails($orderItemAppliedTaxes) { $orderId = 1; $appliedTaxDetailsMock = $this->getMock('Magento\\Tax\\Api\\Data\\OrderTaxDetailsAppliedTaxInterface'); $data = $orderItemAppliedTaxes[0]; $this->appliedTaxBuilderMock->expects($this->at(0))->method('setCode')->with($data['code']); $this->appliedTaxBuilderMock->expects($this->at(1))->method('setTitle')->with($data['title']); $this->appliedTaxBuilderMock->expects($this->at(2))->method('setPercent')->with($data['tax_percent']); $this->appliedTaxBuilderMock->expects($this->at(3))->method('setAmount')->with($data['real_amount']); $this->appliedTaxBuilderMock->expects($this->at(4))->method('setBaseAmount')->with($data['real_base_amount']); $this->appliedTaxBuilderMock->expects($this->atLeastOnce())->method('create')->willReturn($appliedTaxDetailsMock); $itemMock = $this->getMock('Magento\\Tax\\Api\\Data\\OrderTaxDetailsItemInterface'); $this->itemBuilderMock->expects($this->atLeastOnce())->method('create')->willReturn($itemMock); $itemMock->expects($this->atLeastOnce())->method('getAppliedTaxes')->willReturn([$appliedTaxDetailsMock]); $this->orderFactoryMock->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->orderMock)); $this->orderMock->expects($this->once())->method('load')->with($orderId)->will($this->returnSelf()); $this->taxItemFactoryMock->expects($this->once())->method('create')->willReturn($this->taxItemResourceMock); $this->taxItemResourceMock->expects($this->once())->method('getTaxItemsByOrderId')->with($orderId)->will($this->returnValue($orderItemAppliedTaxes)); $orderTaxDetailsMock = $this->getMock('Magento\\Tax\\Api\\Data\\OrderTaxDetailsInterface'); $this->orderTaxDetailsBuilderMock->expects($this->once())->method('create')->willReturn($orderTaxDetailsMock); $this->assertEquals($orderTaxDetailsMock, $this->taxManagement->getOrderTaxDetails($orderId)); }