当前位置: 首页>>代码示例>>PHP>>正文


PHP Data::expects方法代码示例

本文整理汇总了PHP中Magento\Tax\Helper\Data::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::expects方法的具体用法?PHP Data::expects怎么用?PHP Data::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Tax\Helper\Data的用法示例。


在下文中一共展示了Data::expects方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAfterPrepareAdjustmentConfig

 /**
  * test for method afterPrepareAdjustmentConfig
  */
 public function testAfterPrepareAdjustmentConfig()
 {
     $this->productMock->expects($this->once())->method('getTaxClassId')->will($this->returnValue('tax-class-id'));
     $this->calculationMock->expects($this->exactly(2))->method('getRateRequest')->will($this->returnValue($this->rateRequestMock));
     $this->calculationMock->expects($this->exactly(2))->method('getRate')->with($this->equalTo($this->rateRequestMock))->will($this->returnValue(99.09999999999999));
     $this->productMock->expects($this->once())->method('getPriceInfo')->will($this->returnValue($this->priceInfoMock));
     $this->priceInfoMock->expects($this->once())->method('getAdjustment')->with($this->equalTo(\Magento\Tax\Pricing\Adjustment::ADJUSTMENT_CODE))->will($this->returnValue($this->adjustmentMock));
     $this->adjustmentMock->expects($this->once())->method('isIncludedInBasePrice')->will($this->returnValue(true));
     $this->taxHelperMock->expects($this->once())->method('displayPriceIncludingTax')->will($this->returnValue(true));
     $this->taxHelperMock->expects($this->once())->method('displayBothPrices')->will($this->returnValue(true));
     $expected = ['product' => $this->productMock, 'defaultTax' => 99.09999999999999, 'currentTax' => 99.09999999999999, 'customerId' => 1, 'includeTax' => true, 'showIncludeTax' => true, 'showBothPrices' => true];
     $this->assertEquals($expected, $this->plugin->afterPrepareAdjustmentConfig($this->attributePriceMock, ['product' => $this->productMock, 'defaultTax' => 0, 'currentTax' => 0, 'customerId' => 1]));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:16,代码来源:AttributePriceTest.php

示例2: testGetWeeeAttributesForBundle

 /**
  * @dataProvider dataProviderGetWeeeAttributesForBundle
  * @param int $priceIncludesTax
  * @param bool $priceDisplay
  * @param array $expectedAmount
  */
 public function testGetWeeeAttributesForBundle($priceDisplay, $priceIncludesTax, $expectedAmount)
 {
     $prodId1 = 1;
     $prodId2 = 2;
     $fptCode1 = 'fpt' . $prodId1;
     $fptCode2 = 'fpt' . $prodId2;
     $weeeObject1 = new \Magento\Framework\DataObject(['code' => $fptCode1, 'amount' => '15', 'amount_excl_tax' => '15.0000', 'tax_amount' => '1']);
     $weeeObject2 = new \Magento\Framework\DataObject(['code' => $fptCode2, 'amount' => '10', 'amount_excl_tax' => '10.0000', 'tax_amount' => '5']);
     $expectedObject1 = new \Magento\Framework\DataObject(['code' => $fptCode1, 'amount' => $expectedAmount[0], 'amount_excl_tax' => '15.0000', 'tax_amount' => '1']);
     $expectedObject2 = new \Magento\Framework\DataObject(['code' => $fptCode2, 'amount' => $expectedAmount[1], 'amount_excl_tax' => '10.0000', 'tax_amount' => '5']);
     $expectedArray = [$prodId1 => [$fptCode1 => $expectedObject1], $prodId2 => [$fptCode2 => $expectedObject2]];
     $this->weeeTax->expects($this->any())->method('getProductWeeeAttributes')->will($this->returnValue([$weeeObject1, $weeeObject2]));
     $this->taxData->expects($this->any())->method('getPriceDisplayType')->willReturn($priceDisplay);
     $this->taxData->expects($this->any())->method('priceIncludesTax')->willReturn($priceIncludesTax);
     $productSimple = $this->getMock('\\Magento\\Catalog\\Model\\Product\\Type\\Simple', ['getId'], [], '', false);
     $productSimple->expects($this->at(0))->method('getId')->will($this->returnValue($prodId1));
     $productSimple->expects($this->at(1))->method('getId')->will($this->returnValue($prodId2));
     $productInstance = $this->getMock('\\Magento\\Bundle\\Model\\Product\\Type', [], [], '', false);
     $productInstance->expects($this->any())->method('getSelectionsCollection')->will($this->returnValue([$productSimple]));
     $store = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false);
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $this->getMock('\\Magento\\Bundle\\Model\\Product', ['getTypeInstance', 'getStoreId', 'getStore', 'getTypeId'], [], '', false);
     $product->expects($this->any())->method('getTypeInstance')->will($this->returnValue($productInstance));
     $product->expects($this->any())->method('getStoreId')->will($this->returnValue(1));
     $product->expects($this->any())->method('getStore')->will($this->returnValue($store));
     $product->expects($this->any())->method('getTypeId')->will($this->returnValue('bundle'));
     $registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $registry->expects($this->any())->method('registry')->with('current_product')->will($this->returnValue($product));
     $result = $this->helperData->getWeeeAttributesForBundle($product);
     $this->assertEquals($expectedArray, $result);
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:37,代码来源:DataTest.php

示例3: testAfterAddressSave

 public function testAfterAddressSave()
 {
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->taxHelperMock->expects($this->any())->method('isCatalogPriceDisplayAffectedByTax')->willReturn(true);
     $address = $this->objectManager->getObject('Magento\\Customer\\Model\\Address');
     $address->setIsDefaultShipping(true);
     $address->setIsDefaultBilling(true);
     $address->setIsPrimaryBilling(true);
     $address->setIsPrimaryShipping(true);
     $address->setCountryId(1);
     $address->setData('postcode', 11111);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->observerMock->expects($this->once())->method('getCustomerAddress')->willReturn($address);
     $this->session->afterAddressSave($this->observerMock);
 }
开发者ID:kid17,项目名称:magento2,代码行数:17,代码来源:SessionTest.php

示例4: _prepareTestGetShippingPrice

 /**
  * @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));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:12,代码来源:ProgressTest.php

示例5: testAroundDispatch

 public function testAroundDispatch()
 {
     $this->moduleManagerMock->expects($this->any())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->any())->method('isEnabled')->willReturn(true);
     $this->taxHelperMock->expects($this->any())->method('isCatalogPriceDisplayAffectedByTax')->willReturn(true);
     $this->customerSessionMock->expects($this->once())->method('getDefaultTaxBillingAddress')->willReturn(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('getDefaultTaxShippingAddress')->willReturn(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('getCustomerTaxClassId')->willReturn(1);
     $this->taxCalculationMock->expects($this->once())->method('getTaxRates')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111], ['country_id' => 1, 'region_id' => null, 'postcode' => 11111], 1)->willReturn([]);
     $this->httpContextMock->expects($this->once())->method('setValue')->with('tax_rates', [], 0);
     $action = $this->objectManager->getObject('Magento\\Framework\\App\\Action\\Action');
     $request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getActionName'], [], '', false);
     $expectedResult = 'expectedResult';
     $proceed = function ($request) use($expectedResult) {
         return $expectedResult;
     };
     $this->contextPlugin->aroundDispatch($action, $proceed, $request);
 }
开发者ID:kid17,项目名称:magento2,代码行数:18,代码来源:ContextPluginTest.php

示例6: testExecute

 /**
  * test Execute
  * @dataProvider getPriceConfigurationProvider
  * @param array $testArray
  * @param array $expectedArray
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecute($testArray, $expectedArray)
 {
     $configObj = new \Magento\Framework\DataObject(['config' => $testArray]);
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $className = '\\Magento\\Framework\\Registry';
     $this->registry = $this->getMock($className, [], [], '', false);
     $className = '\\Magento\\Tax\\Helper\\Data';
     $this->taxData = $this->getMock($className, [], [], '', false);
     $observerObject = $this->getMock('Magento\\Framework\\Event\\Observer', [], [], '', false);
     $observerObject->expects($this->any())->method('getData')->with('configObj')->will($this->returnValue($configObj));
     $baseAmount = $this->getMock('Magento\\Framework\\Pricing\\Amount\\Base', ['getBaseAmount', 'getAdjustmentAmount', 'hasAdjustment'], [], '', false);
     $baseAmount->expects($this->any())->method('hasAdjustment')->will($this->returnValue(true));
     $baseAmount->expects($this->any())->method('getBaseAmount')->will($this->returnValue(33.5));
     $baseAmount->expects($this->any())->method('getAdjustmentAmount')->will($this->returnValue(1.5));
     $priceInfo = $this->getMock('Magento\\Framework\\Pricing\\Priceinfo\\Base', ['getPrice'], [], '', false);
     $basePrice = $this->getMock('Magento\\Catalog\\Price\\BasePrice', ['getAmount'], [], '', false);
     $basePrice->expects($this->any())->method('getAmount')->will($this->returnValue($baseAmount));
     $priceInfo->expects($this->any())->method('getPrice')->will($this->returnValue($basePrice));
     $prod1 = $this->getMock('Magento\\Catalog\\Model\\Product', ['getId', 'getPriceInfo'], [], '', false);
     $prod2 = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false);
     $prod1->expects($this->any())->method('getId')->will($this->returnValue(1));
     $prod1->expects($this->any())->method('getPriceInfo')->will($this->returnValue($priceInfo));
     $optionCollection = $this->getMock('Magento\\Bundle\\Model\\ResourceModel\\Selection\\Collection', ['getItems'], [], '', false);
     $optionCollection->expects($this->any())->method('getItems')->will($this->returnValue([$prod1, $prod2]));
     $productInstance = $this->getMock('Magento\\Catalog\\Model\\Product\\Type', ['setStoreFilter', 'getSelectionsCollection', 'getOptionsIds'], [], '', false);
     $product = $this->getMock('\\Magento\\Bundle\\Model\\Product\\Type', ['getTypeInstance', 'getTypeId', 'getStoreId', 'getSelectionsCollection'], [], '', false);
     $product->expects($this->any())->method('getTypeInstance')->will($this->returnValue($productInstance));
     $product->expects($this->any())->method('getTypeId')->will($this->returnValue('bundle'));
     $product->expects($this->any())->method('getStoreId')->will($this->returnValue(null));
     $productInstance->expects($this->any())->method('getSelectionsCollection')->will($this->returnValue($optionCollection));
     $productInstance->expects($this->any())->method('getOptionsIds')->will($this->returnValue(true));
     $this->registry->expects($this->any())->method('registry')->with('current_product')->will($this->returnValue($product));
     $this->taxData->expects($this->any())->method('displayPriceIncludingTax')->will($this->returnValue(true));
     $objectManager = new ObjectManager($this);
     $this->model = $objectManager->getObject('Magento\\Tax\\Observer\\GetPriceConfigurationObserver', ['taxData' => $this->taxData, 'registry' => $this->registry]);
     $this->model->execute($observerObject);
     $this->assertEquals($expectedArray, $configObj->getData('config'));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:45,代码来源:GetPriceConfigurationObserverTest.php

示例7: testExecute

 public function testExecute()
 {
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->taxHelperMock->expects($this->any())->method('isCatalogPriceDisplayAffectedByTax')->willReturn(true);
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\Customer')->disableOriginalConstructor()->getMock();
     $this->observerMock->expects($this->once())->method('getData')->with('customer')->willReturn($customerMock);
     $customerMock->expects($this->once())->method('getGroupId')->willReturn(1);
     $customerGroupMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\Group')->disableOriginalConstructor()->getMock();
     $this->groupRepositoryMock->expects($this->once())->method('getById')->with(1)->willReturn($customerGroupMock);
     $customerGroupMock->expects($this->once())->method('getTaxClassId')->willReturn(1);
     $this->customerSessionMock->expects($this->once())->method('setCustomerTaxClassId')->with(1);
     $address = $this->objectManager->getObject('Magento\\Customer\\Model\\Data\\Address');
     $address->setIsDefaultShipping(true);
     $address->setIsDefaultBilling(true);
     $address->setCountryId(1);
     $address->setPostCode(11111);
     $addresses = [$address];
     $customerMock->expects($this->once())->method('getAddresses')->willReturn($addresses);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->session->execute($this->observerMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:23,代码来源:CustomerLoggedInObserverTest.php

示例8: testAroundDispatchBasedOnShipping

 public function testAroundDispatchBasedOnShipping()
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->weeeHelperMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->taxHelperMock->expects($this->once())->method('getTaxBasedOn')->willReturn('shipping');
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $storeMock->expects($this->once())->method('getWebsiteId')->willReturn(1);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
     $this->scopeConfigMock->expects($this->at(0))->method('getValue')->with(\Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_COUNTRY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->willReturn('US');
     $this->scopeConfigMock->expects($this->at(1))->method('getValue')->with(\Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_REGION, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->willReturn(0);
     $this->customerSessionMock->expects($this->once())->method('getDefaultTaxShippingAddress')->willReturn(['country_id' => 'US', 'region_id' => 1]);
     $this->weeeTaxMock->expects($this->once())->method('isWeeeInLocation')->with('US', 1, 1)->willReturn(true);
     $this->httpContextMock->expects($this->once())->method('setValue')->with('weee_tax_region', ['countryId' => 'US', 'regionId' => 1], 0);
     $action = $this->objectManager->getObject('Magento\\Framework\\App\\Test\\Unit\\Action\\Stub\\ActionStub');
     $request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getActionName'], [], '', false);
     $expectedResult = 'expectedResult';
     $proceed = function ($request) use($expectedResult) {
         return $expectedResult;
     };
     $this->contextPlugin->aroundDispatch($action, $proceed, $request);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:23,代码来源:ContextPluginTest.php


注:本文中的Magento\Tax\Helper\Data::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。