Esempio n. 1
0
 public function testCollectDoesNotCalculateTaxIfThereIsNoItemsRelatedToGivenAddress()
 {
     $storeId = 1;
     $storeMock = $this->getMockObject('Magento\\Store\\Model\\Store', ['store_id' => $storeId]);
     $quoteMock = $this->getMockObject('Magento\\Quote\\Model\\Quote', ['store' => $storeMock]);
     $addressMock = $this->getMockObject('Magento\\Quote\\Model\\Quote\\Address', ['all_items' => [], 'shipping_tax_calculation_amount' => 100, 'base_shipping_tax_calculation_amount' => 200, 'shipping_discount_amount' => 10, 'base_shipping_discount_amount' => 20, 'quote' => $quoteMock]);
     $this->taxCalculationMock->expects($this->never())->method('calculateTax');
     $this->model->collect($addressMock);
 }
 public function testCollectDoesNotCalculateTaxIfThereIsNoItemsRelatedToGivenAddress()
 {
     $storeId = 1;
     $this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($storeId);
     $addressMock = $this->getMockObject('Magento\\Quote\\Model\\Quote\\Address', ['all_items' => [], 'shipping_tax_calculation_amount' => 100, 'base_shipping_tax_calculation_amount' => 200, 'shipping_discount_amount' => 10, 'base_shipping_discount_amount' => 20, 'quote' => $this->quoteMock]);
     $this->taxCalculationMock->expects($this->never())->method('calculateTax');
     $shippingMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\ShippingInterface');
     $shippingMock->expects($this->atLeastOnce())->method('getAddress')->willReturn($addressMock);
     $shippingAssignmentMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\ShippingAssignmentInterface');
     $shippingAssignmentMock->expects($this->atLeastOnce())->method('getShipping')->willReturn($shippingMock);
     $shippingAssignmentMock->expects($this->once())->method('getItems')->willReturn([$this->getMock('\\Magento\\Quote\\Api\\Data\\CartItemInterface')]);
     $totalMock = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Address\\Total', [], [], '', false);
     $this->model->collect($this->quoteMock, $shippingAssignmentMock, $totalMock);
 }