本文整理汇总了PHP中Magento\Store\Model\Website::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Website::expects方法的具体用法?PHP Website::expects怎么用?PHP Website::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Store\Model\Website
的用法示例。
在下文中一共展示了Website::expects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetStoreValuesForForm
/**
* @dataProvider getStoreValuesForFormDataProvider
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function testGetStoreValuesForForm($empty, $all, $storeId, $groupId, $websiteId, $storeName, $groupName, $websiteName, $storeGroupId, $groupWebsiteId, $expectedResult)
{
$this->websiteMock->expects($this->any())->method('getId')->willReturn($websiteId);
$this->websiteMock->expects($this->any())->method('getName')->willReturn($websiteName);
$this->groupMock->expects($this->any())->method('getId')->willReturn($groupId);
$this->groupMock->expects($this->any())->method('getName')->willReturn($groupName);
$this->groupMock->expects($this->any())->method('getWebsiteId')->willReturn($groupWebsiteId);
$this->storeMock->expects($this->any())->method('getId')->willReturn($storeId);
$this->storeMock->expects($this->any())->method('getName')->willReturn($storeName);
$this->storeMock->expects($this->any())->method('getGroupId')->willReturn($storeGroupId);
$this->model->setIsAdminScopeAllowed(true);
$this->assertEquals($this->model->getStoreValuesForForm($empty, $all), $expectedResult);
}
示例2: setUp
/**
* Set up
*/
public function setUp()
{
$this->sessionMock = $this->getMock('Magento\\Framework\\Session\\Generic', ['getCurrencyCode'], [], '', false);
$this->httpContextMock = $this->getMock('Magento\\Framework\\App\\Http\\Context', [], [], '', false);
$this->httpRequestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', ['getParam'], [], '', false);
$this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface');
$this->storeCookieManager = $this->getMock('Magento\\Store\\Api\\StoreCookieManagerInterface');
$this->storeMock = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
$this->currentStoreMock = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
$this->websiteMock = $this->getMock('Magento\\Store\\Model\\Website', ['getDefaultStore', '__wakeup'], [], '', false);
$this->closureMock = function () {
return 'ExpectedValue';
};
$this->subjectMock = $this->getMock('Magento\\Framework\\App\\Action\\Action', [], [], '', false);
$this->requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->plugin = (new ObjectManager($this))->getObject('Magento\\Store\\App\\Action\\Plugin\\Context', ['session' => $this->sessionMock, 'httpContext' => $this->httpContextMock, 'httpRequest' => $this->httpRequestMock, 'storeManager' => $this->storeManager, 'storeCookieManager' => $this->storeCookieManager]);
$this->storeManager->expects($this->once())->method('getWebsite')->will($this->returnValue($this->websiteMock));
$this->storeManager->method('getDefaultStoreView')->willReturn($this->storeMock);
$this->storeManager->method('getStore')->willReturn($this->currentStoreMock);
$this->websiteMock->expects($this->once())->method('getDefaultStore')->will($this->returnValue($this->storeMock));
$this->storeMock->expects($this->once())->method('getDefaultCurrencyCode')->will($this->returnValue(self::CURRENCY_DEFAULT));
$this->storeMock->expects($this->once())->method('getCode')->willReturn('default');
$this->currentStoreMock->expects($this->once())->method('getCode')->willReturn('custom_store');
$this->storeCookieManager->expects($this->once())->method('getStoreCodeFromCookie')->will($this->returnValue('storeCookie'));
$this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue('default'));
$this->currentStoreMock->expects($this->any())->method('getDefaultCurrencyCode')->will($this->returnValue(self::CURRENCY_CURRENT_STORE));
}
示例3: setUp
protected function setUp()
{
$this->objectManager = new ObjectManager($this);
$this->assignedWebsites = [self::SECOND_WEBSITE_ID];
$this->websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
$this->secondWebsiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
$this->websiteRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\WebsiteRepositoryInterface')->setMethods(['getList', 'getDefault'])->getMockForAbstractClass();
$this->websiteRepositoryMock->expects($this->any())->method('getDefault')->willReturn($this->websiteMock);
$this->websiteRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
$this->groupRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\GroupRepositoryInterface')->setMethods(['getList'])->getMockForAbstractClass();
$this->storeRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\StoreRepositoryInterface')->setMethods(['getList'])->getMockForAbstractClass();
$this->locatorMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Locator\\LocatorInterface')->setMethods(['getProduct', 'getWebsiteIds'])->getMockForAbstractClass();
$this->productMock = $this->getMockBuilder('Magento\\Catalog\\Api\\Data\\ProductInterface')->setMethods(['getId'])->getMockForAbstractClass();
$this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
$this->locatorMock->expects($this->any())->method('getWebsiteIds')->willReturn($this->assignedWebsites);
$this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->setMethods(['isSingleStoreMode'])->getMockForAbstractClass();
$this->storeManagerMock->expects($this->any())->method('isSingleStoreMode')->willReturn(false);
$this->groupMock = $this->getMockBuilder('Magento\\Store\\Model\\ResourceModel\\Group\\Collection')->setMethods(['getId', 'getName', 'getWebsiteId'])->disableOriginalConstructor()->getMock();
$this->groupMock->expects($this->any())->method('getWebsiteId')->willReturn(self::WEBSITE_ID);
$this->groupMock->expects($this->any())->method('getId')->willReturn(self::GROUP_ID);
$this->groupRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->groupMock]);
$this->storeViewMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getName', 'getId', 'getStoreGroupId'])->disableOriginalConstructor()->getMock();
$this->storeViewMock->expects($this->any())->method('getName')->willReturn(self::STORE_VIEW_NAME);
$this->storeViewMock->expects($this->any())->method('getStoreGroupId')->willReturn(self::GROUP_ID);
$this->storeViewMock->expects($this->any())->method('getId')->willReturn(self::STORE_VIEW_ID);
$this->storeRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->storeViewMock]);
$this->productMock->expects($this->any())->method('getId')->willReturn(self::PRODUCT_ID);
$this->secondWebsiteMock->expects($this->any())->method('getId')->willReturn($this->assignedWebsites[0]);
$this->websiteMock->expects($this->any())->method('getId')->willReturn(self::WEBSITE_ID);
}
示例4: testGetStoreIds
public function testGetStoreIds()
{
$expectedStoreIds = [1, 2, 3];
$websiteIds = ['test'];
$this->resource->expects($this->once())->method('getWebsiteIds')->will($this->returnValue($websiteIds));
$this->website->expects($this->once())->method('getStoreIds')->will($this->returnValue($expectedStoreIds));
$this->assertEquals($expectedStoreIds, $this->model->getStoreIds());
}
示例5: testToOptionArray
public function testToOptionArray()
{
$websiteCollection = [$this->websiteMock];
$groupCollection = [$this->groupMock];
$storeCollection = [$this->storeMock];
$expectedOptions = [['label' => __('All Store Views'), 'value' => '0'], ['label' => 'Main Website', 'value' => [['label' => ' Main Website Store', 'value' => [['label' => ' Default Store View', 'value' => '1']]]]]];
$this->systemStoreMock->expects($this->once())->method('getWebsiteCollection')->willReturn($websiteCollection);
$this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn($groupCollection);
$this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn($storeCollection);
$this->websiteMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
$this->websiteMock->expects($this->any())->method('getName')->willReturn('Main Website');
$this->groupMock->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn('1');
$this->groupMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
$this->groupMock->expects($this->atLeastOnce())->method('getName')->willReturn('Main Website Store');
$this->storeMock->expects($this->atLeastOnce())->method('getGroupId')->willReturn('1');
$this->storeMock->expects($this->atLeastOnce())->method('getName')->willReturn('Default Store View');
$this->storeMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
$this->escaperMock->expects($this->atLeastOnce())->method('escapeHtml')->willReturnMap([['Default Store View', null, 'Default Store View'], ['Main Website Store', null, 'Main Website Store'], ['Main Website', null, 'Main Website']]);
$this->assertEquals($expectedOptions, $this->options->toOptionArray());
}
示例6: testCallbackValidateProduct
/**
* @dataProvider dataProviderCallbackValidateProduct
* @param bool $validate
*
* @return void
*/
public function testCallbackValidateProduct($validate)
{
$args['product'] = $this->productModel;
$args['attributes'] = [];
$args['idx'] = 0;
$args['row'] = ['entity_id' => '1', 'entity_type_id' => '4', 'attribute_set_id' => '4', 'type_id' => 'simple', 'sku' => 'Product', 'has_options' => '0', 'required_options' => '0', 'created_at' => '2014-06-25 13:14:30', 'updated_at' => '2014-06-25 14:37:15'];
$this->storeManager->expects($this->any())->method('getWebsites')->with(false)->will($this->returnValue([$this->websiteModel, $this->websiteModel]));
$this->websiteModel->expects($this->at(0))->method('getId')->will($this->returnValue('1'));
$this->websiteModel->expects($this->at(2))->method('getId')->will($this->returnValue('2'));
$this->websiteModel->expects($this->any())->method('getDefaultStore')->will($this->returnValue($this->storeModel));
$this->storeModel->expects($this->at(0))->method('getId')->will($this->returnValue('1'));
$this->storeModel->expects($this->at(1))->method('getId')->will($this->returnValue('2'));
$this->combineFactory->expects($this->any())->method('create')->will($this->returnValue($this->condition));
$this->condition->expects($this->any())->method('validate')->will($this->returnValue($validate));
$this->condition->expects($this->any())->method('setRule')->will($this->returnSelf());
$this->productModel->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->rule->callbackValidateProduct($args);
$matchingProducts = $this->rule->getMatchingProductIds();
foreach ($matchingProducts['1'] as $matchingRules) {
$this->assertEquals($validate, $matchingRules);
}
}
示例7: testTierPrices
/**
* testGetTierPrices
* testSetTierPrices
*
* @dataProvider pricesDataProvider
*/
public function testTierPrices($priceScope, $expectedWebsiteId)
{
// establish the behavior of the mocks
$this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue($priceScope));
$this->websiteMock->expects($this->any())->method('getId')->will($this->returnValue($expectedWebsiteId));
$this->tpFactory->expects($this->any())->method('create')->will($this->returnCallback(function () {
return $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\TierPrice');
}));
// create sample TierPrice objects that would be coming from a REST call
$tp1 = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\TierPrice');
$tp1->setValue(10);
$tp1->setCustomerGroupId(1);
$tp1->setQty(11);
$tp2 = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\TierPrice');
$tp2->setValue(20);
$tp2->setCustomerGroupId(2);
$tp2->setQty(22);
$tps = [$tp1, $tp2];
// force the product to have null tier prices
$this->product->setData($this::KEY_TIER_PRICE, null);
$this->assertNull($this->product->getData($this::KEY_TIER_PRICE));
// set the product with the TierPrice objects
$this->model->setTierPrices($this->product, $tps);
// test the data actually set on the product
$tpArray = $this->product->getData($this::KEY_TIER_PRICE);
$this->assertNotNull($tpArray);
$this->assertTrue(is_array($tpArray));
$this->assertEquals(sizeof($tps), sizeof($tpArray));
for ($i = 0; $i < sizeof($tps); $i++) {
$tpData = $tpArray[$i];
$this->assertEquals($expectedWebsiteId, $tpData['website_id'], 'Website Id does not match');
$this->assertEquals($tps[$i]->getValue(), $tpData['price'], 'Price/Value does not match');
$this->assertEquals($tps[$i]->getValue(), $tpData['website_price'], 'WebsitePrice/Value does not match');
$this->assertEquals($tps[$i]->getCustomerGroupId(), $tpData['cust_group'], 'Customer group Id does not match');
$this->assertEquals($tps[$i]->getQty(), $tpData['price_qty'], 'Qty does not match');
}
// test with the data retrieved as a REST object
$tpRests = $this->model->getTierPrices($this->product);
$this->assertNotNull($tpRests);
$this->assertTrue(is_array($tpRests));
$this->assertEquals(sizeof($tps), sizeof($tpRests));
for ($i = 0; $i < sizeof($tps); $i++) {
$this->assertEquals($tps[$i]->getValue(), $tpRests[$i]->getValue(), 'REST: Price/Value does not match');
$this->assertEquals($tps[$i]->getCustomerGroupId(), $tpRests[$i]->getCustomerGroupId(), 'REST: Customer group Id does not match');
$this->assertEquals($tps[$i]->getQty(), $tpRests[$i]->getQty(), 'REST: Qty does not match');
}
}