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


PHP Data::expects方法代碼示例

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


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

示例1: 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->weeeHelperMock->expects($this->any())->method('isEnabled')->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:nja78,項目名稱:magento2,代碼行數:17,代碼來源:SessionTest.php

示例2: 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->weeeHelperMock->expects($this->any())->method('isEnabled')->willReturn(true);
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\Customer')->disableOriginalConstructor()->getMock();
     $this->observerMock->expects($this->once())->method('getData')->with('customer')->willReturn($customerMock);
     $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:tingyeeh,項目名稱:magento2,代碼行數:18,代碼來源:CustomerLoggedInTest.php

示例3: testGetBaseTotalAmount

 public function testGetBaseTotalAmount()
 {
     $baseRowTotal = 100;
     $baseTaxAmount = 10;
     $baseDiscountTaxCompensationAmount = 2;
     $baseDiscountAmount = 20;
     $baseWeeeAmount = 5;
     $expectedValue = $baseRowTotal + $baseTaxAmount + $baseDiscountTaxCompensationAmount - $baseDiscountAmount + $baseWeeeAmount;
     $itemMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->setMethods(['getBaseRowTotal', 'getBaseTaxAmount', 'getBaseDiscountTaxCompensationAmount', 'getBaseDiscountAmount', '__wakeup'])->getMock();
     $itemMock->expects($this->once())->method('getBaseRowTotal')->will($this->returnValue($baseRowTotal));
     $itemMock->expects($this->once())->method('getBaseTaxAmount')->will($this->returnValue($baseTaxAmount));
     $itemMock->expects($this->once())->method('getBaseDiscountTaxCompensationAmount')->will($this->returnValue($baseDiscountTaxCompensationAmount));
     $itemMock->expects($this->once())->method('getBaseDiscountAmount')->will($this->returnValue($baseDiscountAmount));
     $this->weeeHelper->expects($this->once())->method('getBaseRowWeeeTaxInclTax')->with($itemMock)->will($this->returnValue($baseWeeeAmount));
     $this->assertEquals($expectedValue, $this->renderer->getBaseTotalAmount($itemMock));
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:16,代碼來源:RendererTest.php

示例4: 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

示例5: testGetWeeeTaxAttributes

 /**
  * Test for method getWeeeTaxAttributes
  *
  * @param int $typeOfDisplay
  * @param array $attributes
  * @param array $expectedResult
  * @dataProvider getWeeeTaxAttributesDataProvider
  */
 public function testGetWeeeTaxAttributes($typeOfDisplay, $attributes, $expectedResult)
 {
     /** @var \Magento\Framework\Pricing\Render\Amount $amountRender */
     $amountRender = $this->getMockBuilder('Magento\\Framework\\Pricing\\Render\\Amount')->disableOriginalConstructor()->setMethods(['getSaleableItem', 'getDisplayValue', 'getAmount'])->getMock();
     /** @var \Magento\Catalog\Model\Product $saleable */
     $saleable = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock();
     /** @var \Magento\Framework\Pricing\Amount\Base $baseAmount */
     $baseAmount = $this->getMockBuilder('Magento\\Framework\\Pricing\\Amount\\Base')->disableOriginalConstructor()->setMethods(['getValue'])->getMock();
     $amountRender->expects($this->any())->method('getAmount')->will($this->returnValue($baseAmount));
     $callback = function ($argument) use($typeOfDisplay) {
         if (is_array($argument)) {
             return in_array($typeOfDisplay, $argument);
         } else {
             return $argument == $typeOfDisplay;
         }
     };
     $this->weeeHelperMock->expects($this->any())->method('typeOfDisplay')->will($this->returnCallback($callback));
     $this->weeeHelperMock->expects($this->any())->method('getProductWeeeAttributesForDisplay')->will($this->returnValue($attributes));
     $amountRender->expects($this->any())->method('getSaleableItem')->will($this->returnValue($saleable));
     $this->model->render($amountRender);
     $result = $this->model->getWeeeTaxAttributes();
     $this->assertEquals($expectedResult, $result);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:31,代碼來源:AdjustmentTest.php


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