Exemple #1
0
 /**
  * Test getShippingRate method
  */
 public function testGetShippingRate()
 {
     $rate = $this->getMock('Magento\\Sales\\Model\\Quote\\Address\\Rate', ['__wakeup'], [], '', false);
     $this->shippingAddress->setShippingMethod(self::SHIPPING_METHOD);
     $this->shippingAddress->expects($this->once())->method('getShippingRateByCode')->with(self::SHIPPING_METHOD)->will($this->returnValue($rate));
     $this->assertEquals($rate, $this->model->getShippingRate());
 }
Exemple #2
0
 public function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->taxConfig = $this->getMockBuilder('\\Magento\\Tax\\Model\\Config')->disableOriginalConstructor()->setMethods(['getShippingTaxClass', 'shippingPriceIncludesTax'])->getMock();
     $this->store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock();
     $this->quote = $this->getMockBuilder('\\Magento\\Sales\\Model\\Quote')->disableOriginalConstructor()->setMethods(['__wakeup', 'getStore'])->getMock();
     $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->address = $this->getMockBuilder('\\Magento\\Sales\\Model\\Quote\\Address')->disableOriginalConstructor()->setMethods(['__wakeup', 'getQuote'])->getMock();
     $this->address->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
     $this->commonTaxCollector = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Total\\Quote\\CommonTaxCollector', ['taxConfig' => $this->taxConfig]);
 }
 /**
  * @param bool $inclTax
  */
 private function _prepareTestGetShippingPrice($inclTax)
 {
     $rate = $this->getMock('Magento\\Sales\\Model\\Quote\\Address\\Rate', ['__wakeup'], [], '', false);
     $rate->setPrice(self::SHIPPING_PRICE);
     $this->shippingAddress->setShippingMethod(self::SHIPPING_METHOD);
     $this->shippingAddress->expects($this->once())->method('getShippingRateByCode')->with(self::SHIPPING_METHOD)->will($this->returnValue($rate));
     $this->taxHelper->expects($this->once())->method('getShippingPrice')->with(self::SHIPPING_PRICE, $inclTax ? $this->isTrue() : $this->isFalse(), $this->shippingAddress)->will($this->returnValue(self::SHIPPING_PRICE_WITH_TAX));
     $this->store->expects($this->once())->method('formatPrice')->with(self::SHIPPING_PRICE_WITH_TAX)->will($this->returnValue(self::SHIPPING_PRICE_FORMATTED));
 }
Exemple #4
0
 public function testValidateMiniumumAmountNegative()
 {
     $storeId = 1;
     $this->quote->setStoreId($storeId);
     $valueMap = [['sales/minimum_order/active', ScopeInterface::SCOPE_STORE, $storeId, true], ['sales/minimum_order/multi_address', ScopeInterface::SCOPE_STORE, $storeId, true], ['sales/minimum_order/amount', ScopeInterface::SCOPE_STORE, $storeId, 20], ['sales/minimum_order/tax_including', ScopeInterface::SCOPE_STORE, $storeId, true]];
     $this->scopeConfig->expects($this->any())->method('isSetFlag')->will($this->returnValueMap($valueMap));
     $this->quoteAddressMock->expects($this->once())->method('validateMinimumAmount')->willReturn(false);
     $this->quoteAddressCollectionMock->expects($this->once())->method('setQuoteFilter')->willReturn([$this->quoteAddressMock]);
     $this->assertFalse($this->quote->validateMinimumAmount());
 }
 /**
  * @covers \Magento\SalesRule\Model\Rule\Action\Discount\CartFixed::calculate
  */
 public function testCalculate()
 {
     $this->rule->setData(array('id' => 1, 'discount_amount' => 10.0));
     $this->address->expects($this->any())->method('getCartFixedRules')->will($this->returnValue(array()));
     $store = $this->getMock('Magento\\Store\\Model\\Store', array(), array(), '', false);
     $this->priceCurrency->expects($this->atLeastOnce())->method('convert')->will($this->returnArgument(0));
     $this->priceCurrency->expects($this->atLeastOnce())->method('round')->will($this->returnArgument(0));
     $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($store));
     /** validators data */
     $this->validator->expects($this->once())->method('getItemPrice')->with($this->item)->will($this->returnValue(100));
     $this->validator->expects($this->once())->method('getItemBasePrice')->with($this->item)->will($this->returnValue(100));
     $this->validator->expects($this->once())->method('getItemOriginalPrice')->with($this->item)->will($this->returnValue(100));
     $this->validator->expects($this->once())->method('getItemBaseOriginalPrice')->with($this->item)->will($this->returnValue(100));
     $this->address->expects($this->once())->method('setCartFixedRules')->with(array(1 => 0.0));
     $this->model->calculate($this->rule, $this->item, 1);
     $this->assertEquals($this->data->getAmount(), 10);
     $this->assertEquals($this->data->getBaseAmount(), 10);
     $this->assertEquals($this->data->getOriginalAmount(), 10);
     $this->assertEquals($this->data->getBaseOriginalAmount(), 100);
 }
Exemple #6
0
 public function testRemoveAllAddresses()
 {
     $id = 1;
     $this->quoteAddressCollectionMock->expects($this->once())->method('setQuoteFilter')->with($id)->will($this->returnSelf());
     $this->quoteAddressMock->expects($this->any())->method('getAddressType')->will($this->returnValue(\Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING));
     $this->quoteAddressMock->expects($this->any())->method('isDeleted')->will($this->returnValue(false));
     $this->quoteAddressMock->expects($this->once())->method('getId')->will($this->returnValue($id));
     $this->quoteAddressMock->expects($this->once())->method('getDeleteImmediately')->will($this->returnValue(true));
     $iterator = new \ArrayIterator([$id => $this->quoteAddressMock]);
     $this->quoteAddressCollectionMock->expects($this->any())->method('getIterator')->will($this->returnValue($iterator));
     $this->quoteAddressCollectionMock->expects($this->once())->method('removeItemByKey')->with($id)->will($this->returnValue($iterator));
     $this->quote->setId($id);
     $result = $this->quote->removeAllAddresses();
     $this->assertInstanceOf('Magento\\Sales\\Model\\Quote', $result);
 }