本文整理汇总了PHP中Magento\Catalog\Helper\Data::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::expects方法的具体用法?PHP Data::expects怎么用?PHP Data::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Helper\Data
的用法示例。
在下文中一共展示了Data::expects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->_helper = $this->getMock('Magento\\Catalog\\Helper\\Data', array('isPriceGlobal'), array(), '', false);
$this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true));
$loggerMock = $this->getMock('Magento\\Framework\\Logger', array(), array(), '', false);
$currencyFactoryMock = $this->getMock('Magento\\Directory\\Model\\CurrencyFactory', array(), array(), '', false);
$storeManagerMock = $this->getMock('Magento\\Framework\\StoreManagerInterface', array(), array(), '', false);
$productTypeMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type', array(), array(), '', false);
$configMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
$this->_model = $this->getMockForAbstractClass('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Groupprice\\AbstractGroupprice', array('logger' => $loggerMock, 'currencyFactory' => $currencyFactoryMock, 'storeManager' => $storeManagerMock, 'catalogData' => $this->_helper, 'config' => $configMock, 'catalogProductType' => $productTypeMock));
$resource = $this->getMock('StdClass', array('getMainTable'));
$resource->expects($this->any())->method('getMainTable')->will($this->returnValue('table'));
$this->_model->expects($this->any())->method('_getResource')->will($this->returnValue($resource));
}
示例2: setUp
protected function setUp()
{
$this->_helper = $this->getMock('Magento\\Catalog\\Helper\\Data', ['isPriceGlobal'], [], '', false);
$this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true));
$currencyFactoryMock = $this->getMock('Magento\\Directory\\Model\\CurrencyFactory', ['create'], [], '', false);
$storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface', [], [], '', false);
$productTypeMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type', [], [], '', false);
$configMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
$localeFormatMock = $this->getMock('\\Magento\\Framework\\Locale\\FormatInterface', [], [], '', false);
$groupManagement = $this->getMock('Magento\\Customer\\Api\\GroupManagementInterface', [], [], '', false);
$metadataPool = $this->getMock('Magento\\Framework\\Model\\Entity\\MetadataPool', [], [], '', false);
$this->_model = $this->getMockForAbstractClass('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\GroupPrice\\AbstractGroupPrice', ['currencyFactory' => $currencyFactoryMock, 'storeManager' => $storeManagerMock, 'catalogData' => $this->_helper, 'config' => $configMock, 'localeFormat' => $localeFormatMock, 'catalogProductType' => $productTypeMock, 'groupManagement' => $groupManagement, 'metadataPool' => $metadataPool]);
$resource = $this->getMock('StdClass', ['getMainTable']);
$resource->expects($this->any())->method('getMainTable')->will($this->returnValue('table'));
$this->_model->expects($this->any())->method('_getResource')->will($this->returnValue($resource));
}
示例3: testSavePrices
public function testSavePrices()
{
$rowSet = [0 => ['value_id' => '1', 'product_super_attribute_id' => '1', 'value_index' => '12', 'is_percent' => '0', 'pricing_value' => '3.0000', 'website_id' => '0'], 1 => ['value_id' => '2', 'product_super_attribute_id' => '1', 'value_index' => '13', 'is_percent' => '0', 'pricing_value' => '8.0000', 'website_id' => '0']];
$values = [12 => ['value_index' => '12', 'pricing_value' => '', 'is_percent' => '0', 'include' => '1'], 13 => ['value_index' => '13', 'pricing_value' => '5', 'is_percent' => '0', 'include' => '1'], 14 => ['value_index' => '14', 'pricing_value' => '3', 'is_percent' => '0', 'include' => '1']];
$attribute = $this->getMockBuilder('Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable\\Attribute')->setMethods(['getValues', 'getId'])->disableOriginalConstructor()->getMock();
$adapterMock = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMock();
$selectMock = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock();
$this->resource->expects($this->once())->method('getConnection')->with('core_write')->willReturn($adapterMock);
$this->catalogData->expects($this->any())->method('isPriceGlobal')->willReturn(1);
$attribute->expects($this->once())->method('getValues')->willReturn($values);
$adapterMock->expects($this->once())->method('select')->willReturn($selectMock);
$selectMock->expects($this->once())->method('from')->with(null)->will($this->returnSelf());
$selectMock->expects($this->at(1))->method('where')->with('product_super_attribute_id = :product_super_attribute_id')->will($this->returnSelf());
$selectMock->expects($this->at(2))->method('where')->with('website_id = :website_id')->will($this->returnSelf());
$attribute->expects($this->any())->method('getId')->willReturn(1);
$adapterMock->expects($this->once())->method('fetchAll')->with($selectMock, ['product_super_attribute_id' => 1, 'website_id' => 0])->willReturn($rowSet);
$this->assertEquals($this->model, $this->model->savePrices($attribute));
}
示例4: addMocks
/**
* Additional function to break up mocks initialization
*
* @return void
*/
protected function addMocks()
{
$resIteratorcallback = function () {
$arguments = func_get_args();
$arguments[2]['results'] = [['use_special' => false, 'price' => 10, 'final_price' => 20]];
};
$this->storeMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue(0));
$this->storeMock->expects($this->once())->method('getFrontendName')->will($this->returnValue('store name'));
$this->catalogHelperMock->expects($this->once())->method('canApplyMsrp')->will($this->returnValue(false));
$this->resourceIteratorMock->expects($this->once())->method('walk')->will($this->returnCallback($resIteratorcallback));
$this->imageHelperMock->expects($this->once())->method('init')->will($this->returnSelf());
}
示例5: testGetRssData
public function testGetRssData()
{
$this->rssUrlBuilder->expects($this->once())->method('getUrl')->with(['type' => 'special_products', 'store_id' => 1])->will($this->returnValue('http://magento.com/rss/feed/index/type/special_products/store_id/1'));
$item = $this->getItemMock();
$this->rssModel->expects($this->once())->method('getProductsCollection')->will($this->returnValue([$item]));
$this->msrpHelper->expects($this->once())->method('canApplyMsrp')->will($this->returnValue(false));
$this->localeDate->expects($this->once())->method('formatDateTime')->will($this->returnValue(date('Y-m-d')));
$this->priceCurrency->expects($this->any())->method('convertAndFormat')->will($this->returnArgument(0));
$this->imageHelper->expects($this->once())->method('init')->with($item, 'rss_thumbnail')->will($this->returnSelf());
$this->imageHelper->expects($this->once())->method('getUrl')->will($this->returnValue('image_link'));
$this->outputHelper->expects($this->once())->method('productAttribute')->will($this->returnValue(''));
$data = ['title' => 'Store 1 - Special Products', 'description' => 'Store 1 - Special Products', 'link' => 'http://magento.com/rss/feed/index/type/special_products/store_id/1', 'charset' => 'UTF-8', 'language' => 'en_US', 'entries' => [['title' => 'Product Name', 'link' => 'http://magento.com/product-name.html']]];
$rssData = $this->block->getRssData();
$description = $rssData['entries'][0]['description'];
unset($rssData['entries'][0]['description']);
$this->assertEquals($data, $rssData);
$this->assertContains('<a href="http://magento.com/product-name.html"><', $description);
$this->assertContains(sprintf('<p>Price: Special Price: 10<br />Special Expires On: %s</p>', date('Y-m-d')), $description);
$this->assertContains('<img src="image_link" alt="" border="0" align="left" height="75" width="75" />', $description);
}