本文整理汇总了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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}