當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Config::expects方法代碼示例

本文整理匯總了PHP中Magento\Tax\Model\Config::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP Config::expects方法的具體用法?PHP Config::expects怎麽用?PHP Config::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Tax\Model\Config的用法示例。


在下文中一共展示了Config::expects方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetShippingDataObject

 /**
  * @param array $addressData
  * @param bool $useBaseCurrency
  * @param string $shippingTaxClass
  * @param bool shippingPriceInclTax
  * @param array $expectedValue
  * @dataProvider getShippingDataObjectDataProvider
  */
 public function testGetShippingDataObject(array $addressData, $useBaseCurrency, $shippingTaxClass, $shippingPriceInclTax)
 {
     $baseShippingAmount = $addressData['base_shipping_amount'];
     $shippingAmount = $addressData['shipping_amount'];
     $itemMock = $this->getMock('Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterface');
     $this->taxConfig->expects($this->any())->method('getShippingTaxClass')->with($this->store)->will($this->returnValue($shippingTaxClass));
     $this->taxConfig->expects($this->any())->method('shippingPriceIncludesTax')->with($this->store)->will($this->returnValue($shippingPriceInclTax));
     $this->address->expects($this->atLeastOnce())->method('getShippingDiscountAmount')->willReturn($shippingAmount);
     if ($shippingAmount) {
         if ($useBaseCurrency && $shippingAmount != 0) {
             $this->address->expects($this->once())->method('getBaseShippingDiscountAmount')->willReturn($baseShippingAmount);
             $this->quoteDetailsItemBuilderMock->expects($this->once())->method('setDiscountAmount')->with($baseShippingAmount);
         } else {
             $this->address->expects($this->never())->method('getBaseShippingDiscountAmount');
             $this->quoteDetailsItemBuilderMock->expects($this->once())->method('setDiscountAmount')->with($shippingAmount);
         }
     }
     foreach ($addressData as $key => $value) {
         $this->address->setData($key, $value);
     }
     $this->taxClassKeyBuilderMock->expects($this->any())->method('setType')->willReturnSelf();
     $this->taxClassKeyBuilderMock->expects($this->any())->method('setValue')->with($shippingTaxClass)->willReturnSelf();
     $this->quoteDetailsItemBuilderMock->expects($this->once())->method('create')->willReturn($itemMock);
     $this->assertEquals($itemMock, $this->commonTaxCollector->getShippingDataObject($this->address, $useBaseCurrency));
 }
開發者ID:ViniciusAugusto,項目名稱:magento2,代碼行數:33,代碼來源:CommonTaxCollectorTest.php

示例2: testGetShippingDataObject

 /**
  * @param array $addressData
  * @param bool $useBaseCurrency
  * @param string $shippingTaxClass
  * @param bool $shippingPriceInclTax
  * @dataProvider getShippingDataObjectDataProvider
  */
 public function testGetShippingDataObject(array $addressData, $useBaseCurrency, $shippingTaxClass, $shippingPriceInclTax)
 {
     $shippingAssignmentMock = $this->getMock('Magento\\Quote\\Api\\Data\\ShippingAssignmentInterface');
     $methods = ['getShippingDiscountAmount', 'getShippingTaxCalculationAmount', 'setShippingTaxCalculationAmount', 'getShippingAmount', 'setBaseShippingTaxCalculationAmount', 'getBaseShippingAmount', 'getBaseShippingDiscountAmount'];
     $totalsMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Address\\Total', $methods, [], '', false);
     $shippingMock = $this->getMock('Magento\\Quote\\Api\\Data\\ShippingInterface');
     $shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn($shippingMock);
     $shippingMock->expects($this->once())->method('getAddress')->willReturn($this->address);
     $baseShippingAmount = $addressData['base_shipping_amount'];
     $shippingAmount = $addressData['shipping_amount'];
     $totalsMock->expects($this->any())->method('getShippingTaxCalculationAmount')->willReturn($shippingAmount);
     $this->taxConfig->expects($this->any())->method('getShippingTaxClass')->with($this->store)->will($this->returnValue($shippingTaxClass));
     $this->taxConfig->expects($this->any())->method('shippingPriceIncludesTax')->with($this->store)->will($this->returnValue($shippingPriceInclTax));
     $totalsMock->expects($this->atLeastOnce())->method('getShippingDiscountAmount')->willReturn($shippingAmount);
     if ($shippingAmount) {
         if ($useBaseCurrency && $shippingAmount != 0) {
             $totalsMock->expects($this->once())->method('getBaseShippingDiscountAmount')->willReturn($baseShippingAmount);
             $expectedDiscountAmount = $baseShippingAmount;
         } else {
             $totalsMock->expects($this->never())->method('getBaseShippingDiscountAmount');
             $expectedDiscountAmount = $shippingAmount;
         }
     }
     foreach ($addressData as $key => $value) {
         $totalsMock->setData($key, $value);
     }
     $this->assertEquals($this->quoteDetailsItemDataObject, $this->commonTaxCollector->getShippingDataObject($shippingAssignmentMock, $totalsMock, $useBaseCurrency));
     if ($shippingAmount) {
         $this->assertEquals($expectedDiscountAmount, $this->quoteDetailsItemDataObject->getDiscountAmount());
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:38,代碼來源:CommonTaxCollectorTest.php

示例3: testGetShippingDataObject

 /**
  * @param array $addressData
  * @param bool $useBaseCurrency
  * @param string $shippingTaxClass
  * @param bool $shippingPriceInclTax
  * @dataProvider getShippingDataObjectDataProvider
  */
 public function testGetShippingDataObject(array $addressData, $useBaseCurrency, $shippingTaxClass, $shippingPriceInclTax)
 {
     $baseShippingAmount = $addressData['base_shipping_amount'];
     $shippingAmount = $addressData['shipping_amount'];
     $this->taxConfig->expects($this->any())->method('getShippingTaxClass')->with($this->store)->will($this->returnValue($shippingTaxClass));
     $this->taxConfig->expects($this->any())->method('shippingPriceIncludesTax')->with($this->store)->will($this->returnValue($shippingPriceInclTax));
     $this->address->expects($this->atLeastOnce())->method('getShippingDiscountAmount')->willReturn($shippingAmount);
     if ($shippingAmount) {
         if ($useBaseCurrency && $shippingAmount != 0) {
             $this->address->expects($this->once())->method('getBaseShippingDiscountAmount')->willReturn($baseShippingAmount);
             $expectedDiscountAmount = $baseShippingAmount;
         } else {
             $this->address->expects($this->never())->method('getBaseShippingDiscountAmount');
             $expectedDiscountAmount = $shippingAmount;
         }
     }
     foreach ($addressData as $key => $value) {
         $this->address->setData($key, $value);
     }
     $this->assertEquals($this->quoteDetailsItemDataObject, $this->commonTaxCollector->getShippingDataObject($this->address, $useBaseCurrency));
     if ($shippingAmount) {
         $this->assertEquals($expectedDiscountAmount, $this->quoteDetailsItemDataObject->getDiscountAmount());
     }
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:31,代碼來源:CommonTaxCollectorTest.php

示例4: testCollectUsingTaxInclShippingAmount

 /**
  * situation: The admin user specified the desired refund amount that has taxes embedded within it
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function testCollectUsingTaxInclShippingAmount()
 {
     $this->taxConfig->expects($this->any())->method('displaySalesShippingInclTax')->willReturn(true);
     $orderShippingAmount = 15;
     $shippingTaxAmount = 3;
     $orderShippingInclTax = $orderShippingAmount + $shippingTaxAmount;
     $orderShippingAmountRefunded = 5;
     $shippingTaxRefunded = 1;
     $refundedInclTax = $orderShippingAmountRefunded + $shippingTaxRefunded;
     $currencyMultiple = 2;
     $baseOrderShippingAmount = $orderShippingAmount * $currencyMultiple;
     $baseShippingTaxAmount = $shippingTaxAmount * $currencyMultiple;
     $baseOrderShippingInclTax = $orderShippingInclTax * $currencyMultiple;
     $baseOrderShippingAmountRefunded = $orderShippingAmountRefunded * $currencyMultiple;
     $baseShippingTaxRefunded = $shippingTaxRefunded * $currencyMultiple;
     $baseRefundedInclTax = $refundedInclTax * $currencyMultiple;
     //determine expected amounts
     $desiredRefundAmount = $baseOrderShippingInclTax - $baseRefundedInclTax;
     $expectedShippingAmount = $orderShippingAmount - $orderShippingAmountRefunded;
     $expectedShippingAmountInclTax = $orderShippingInclTax - $refundedInclTax;
     $expectedBaseShippingAmount = $expectedShippingAmount * $currencyMultiple;
     $expectedBaseShippingAmountInclTax = $expectedShippingAmountInclTax * $currencyMultiple;
     $grandTotalBefore = 100;
     $baseGrandTotalBefore = 200;
     $expectedGrandTotal = $grandTotalBefore + $expectedShippingAmount;
     $expectedBaseGrandTtoal = $baseGrandTotalBefore + $expectedBaseShippingAmount;
     $order = new \Magento\Framework\DataObject(['shipping_amount' => $orderShippingAmount, 'base_shipping_amount' => $baseOrderShippingAmount, 'shipping_refunded' => $orderShippingAmountRefunded, 'base_shipping_refunded' => $baseOrderShippingAmountRefunded, 'shipping_incl_tax' => $orderShippingInclTax, 'base_shipping_incl_tax' => $baseOrderShippingInclTax, 'shipping_tax_amount' => $shippingTaxAmount, 'shipping_tax_refunded' => $shippingTaxRefunded, 'base_shipping_tax_amount' => $baseShippingTaxAmount, 'base_shipping_tax_refunded' => $baseShippingTaxRefunded]);
     $this->creditmemoMock->expects($this->once())->method('getOrder')->willReturn($order);
     $this->creditmemoMock->expects($this->once())->method('hasBaseShippingAmount')->willReturn(true);
     $this->creditmemoMock->expects($this->once())->method('getBaseShippingAmount')->willReturn($desiredRefundAmount);
     $this->creditmemoMock->expects($this->once())->method('getGrandTotal')->willReturn($grandTotalBefore);
     $this->creditmemoMock->expects($this->once())->method('getBaseGrandTotal')->willReturn($baseGrandTotalBefore);
     //verify
     $this->creditmemoMock->expects($this->once())->method('setShippingAmount')->with($expectedShippingAmount)->willReturnSelf();
     $this->creditmemoMock->expects($this->once())->method('setBaseShippingAmount')->with($expectedBaseShippingAmount)->willReturnSelf();
     $this->creditmemoMock->expects($this->once())->method('setShippingInclTax')->with($expectedShippingAmountInclTax)->willReturnSelf();
     $this->creditmemoMock->expects($this->once())->method('setBaseShippingInclTax')->with($expectedBaseShippingAmountInclTax)->willReturnSelf();
     $this->creditmemoMock->expects($this->once())->method('setGrandTotal')->with($expectedGrandTotal)->willReturnSelf();
     $this->creditmemoMock->expects($this->once())->method('setBaseGrandTotal')->with($expectedBaseGrandTtoal)->willReturnSelf();
     $this->shippingCollector->collect($this->creditmemoMock);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:46,代碼來源:ShippingTest.php

示例5: testGetDisplaySubtotalBoth

 public function testGetDisplaySubtotalBoth()
 {
     $this->taxConfig->expects($this->once())->method('displayCartSubtotalBoth');
     $this->totalsObj->getDisplaySubtotalBoth();
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:5,代碼來源:TotalsTest.php


注:本文中的Magento\Tax\Model\Config::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。