本文整理汇总了PHP中Magento\Framework\Locale\ResolverInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ResolverInterface::expects方法的具体用法?PHP ResolverInterface::expects怎么用?PHP ResolverInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Locale\ResolverInterface
的用法示例。
在下文中一共展示了ResolverInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetLocale
public function testGetLocale()
{
$expected = 'locale';
$this->locale->expects($this->once())->method('getLocaleCode')->will($this->returnValue($expected));
$actual = $this->model->getLocale();
$this->assertSame($expected, $actual);
}
示例2: mockGridDateRendererBehaviorWithLocale
/**
* @param string $locale
*/
private function mockGridDateRendererBehaviorWithLocale($locale)
{
$this->resolverMock->expects($this->any())->method('getLocale')->willReturn($locale);
$this->localeDate->expects($this->any())->method('getDateFormat')->willReturnCallback(function ($value) use($locale) {
return (new \IntlDateFormatter($locale, $value, \IntlDateFormatter::NONE))->getPattern();
});
}
示例3: setupAggregate
/**
* Set up aggregate
*
* @return \DateTime
*/
protected function setupAggregate()
{
$this->localeResolverMock->expects($this->once())->method('emulate')->with(0);
$this->localeResolverMock->expects($this->once())->method('revert');
$date = (new \DateTime())->sub(new \DateInterval('PT25H'));
$this->localeDateMock->expects($this->once())->method('date')->will($this->returnValue($date));
return $date;
}
示例4: testGetConfig
/**
* @dataProvider getConfigDataProvider
*/
public function testGetConfig($configData, $locale, $expectedResult)
{
foreach ($configData as $key => $value) {
$this->configMock->expects($this->any())->method($key)->willReturn($value);
}
$this->localResolverMock->expects($this->any())->method('getLocale')->willReturn($locale);
$this->assertEquals($expectedResult, $this->model->getConfig());
}
示例5: testUpdateAndGetTranslations
public function testUpdateAndGetTranslations()
{
$translations = ['phrase1' => 'translated1', 'phrase2' => 'translated2'];
$this->eventManagerMock->expects($this->once())->method('dispatch');
$this->translateResourceMock->expects($this->once())->method('getTranslationArray')->willReturn($translations);
$this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn('en_US');
$this->fileManagerMock->expects($this->once())->method('updateTranslationFileContent');
$this->assertEquals($translations, $this->model->updateAndGetTranslations());
}
示例6: testUpdateQuoteItemWithZeroQty
public function testUpdateQuoteItemWithZeroQty()
{
$itemId = 1;
$itemQty = 0;
$this->resolverMock->expects($this->never())->method('getLocale');
$this->cartMock->expects($this->once())->method('updateItems')->with([$itemId => ['qty' => $itemQty]])->willReturnSelf();
$this->cartMock->expects($this->once())->method('save')->willReturnSelf();
$this->assertEquals($this->sidebar, $this->sidebar->updateQuoteItem($itemId, $itemQty));
}
示例7: testProcess
/**
* @param int $qtyResult
* @param int|null $expectedResult
* @dataProvider processDataProvider
*/
public function testProcess($qtyResult, $expectedResult)
{
$qty = 10;
$localCode = 'en_US';
$this->resolver->expects($this->once())->method('getLocale')->willReturn($localCode);
$this->filter->expects($this->once())->method('setOptions')->with(['locale' => $localCode])->willReturnSelf();
$this->filter->expects($this->once())->method('filter')->with($qty)->willReturn($qtyResult);
$this->assertEquals($expectedResult, $this->processor->process($qty));
}
示例8: setupAggregate
/**
* Set up aggregate
*
* @return \Magento\Framework\Stdlib\DateTime\DateInterface
*/
protected function setupAggregate()
{
$date = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\Date', ['emulate', 'revert'], [], '', false);
$this->localeResolverMock->expects($this->once())->method('emulate')->with(0);
$this->localeResolverMock->expects($this->once())->method('revert');
$dateMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime\\DateInterface')->disableOriginalConstructor()->getMock();
$dateMock->expects($this->once())->method('subHour')->with(25)->will($this->returnValue($date));
$this->localeDateMock->expects($this->once())->method('date')->will($this->returnValue($dateMock));
return $date;
}
示例9: testGetConfig
/**
* Run test getConfig method
*
* @param array $config
* @param array $expected
* @dataProvider getConfigDataProvider
*/
public function testGetConfig($config, $expected)
{
$this->braintreeAdapter->expects(static::once())->method('generate')->willReturn(self::CLIENT_TOKEN);
foreach ($config as $method => $value) {
$this->config->expects(static::once())->method($method)->willReturn($value);
}
$this->payPalConfig->expects(static::once())->method('isActive')->willReturn(true);
$this->payPalConfig->expects(static::once())->method('isAllowToEditShippingAddress')->willReturn(true);
$this->payPalConfig->expects(static::once())->method('getMerchantName')->willReturn('Test');
$this->payPalConfig->expects(static::once())->method('getTitle')->willReturn('Payment Title');
$this->localeResolver->expects(static::once())->method('getLocale')->willReturn('en_US');
static::assertEquals($expected, $this->configProvider->getConfig());
}
示例10: testRender
/**
* @param string $data
* @param string $index
* @param string $locale
* @param string $period
* @param string $result
* @dataProvider datesDataProvider
* @return void
*/
public function testRender($data, $index, $locale, $period, $result)
{
$this->resolverMock->expects($this->any())->method('getLocale')->will($this->returnValue($locale));
$this->localeDate->expects($this->any())->method('getDateFormat')->willReturnCallback(function ($value) use($locale) {
return (new \IntlDateFormatter($locale, $value, \IntlDateFormatter::NONE))->getPattern();
});
$objectMock = $this->getMockBuilder('Magento\\Framework\\Object')->setMethods(['getData'])->getMock();
$objectMock->expects($this->once())->method('getData')->will($this->returnValue($data));
$columnMock = $this->getMockBuilder('Magento\\Backend\\Block\\Widget\\Grid\\Column')->disableOriginalConstructor()->setMethods(['getIndex', 'getPeriodType'])->getMock();
$columnMock->expects($this->once())->method('getIndex')->will($this->returnValue($index));
$columnMock->expects($this->atLeastOnce())->method('getPeriodType')->will($this->returnValue($period));
$this->date->setColumn($columnMock);
$this->assertEquals($result, $this->date->render($objectMock));
}
示例11: testStop
public function testStop()
{
// Test data
$initArea = 'initial area';
$initTheme = 'initial design theme';
$initLocale = 'initial locale code';
$initialStore = 1;
$initTranslateInline = false;
$this->inlineTranslationMock->expects($this->once())->method('isEnabled')->willReturn($initTranslateInline);
$this->viewDesignMock->expects($this->once())->method('getArea')->willReturn($initArea);
$this->viewDesignMock->expects($this->once())->method('getDesignTheme')->willReturn($initTheme);
$this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
$this->storeMock->expects($this->once())->method('getStoreId')->willReturn($initialStore);
$this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn($initLocale);
$this->model->storeCurrentEnvironmentInfo();
// Expectations
$this->inlineTranslationMock->expects($this->once())->method('resume')->with($initTranslateInline);
$this->viewDesignMock->expects($this->once())->method('setDesignTheme')->with($initTheme, $initArea);
$this->storeManagerMock->expects($this->once())->method('setCurrentStore')->with($initialStore);
$this->localeResolverMock->expects($this->once())->method('setLocale')->with($initLocale);
$this->translateMock->expects($this->once())->method('setLocale')->with($initLocale);
$this->translateMock->expects($this->once())->method('loadData')->with($initArea);
// Test
$this->model->stopEnvironmentEmulation();
}
示例12: prepareMocksForGetCurrencySymbolsData
/**
* Prepare mocks for getCurrencySymbolsData
*
* @param int $websiteId
* @param int $groupId
* @param string $currencies
*/
protected function prepareMocksForGetCurrencySymbolsData($websiteId, $groupId, $currencies)
{
/**
* @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
*/
$websiteMock = $this->getMock('Magento\\Store\\Model\\Website', ['getId', 'getConfig'], [], '', false);
/**
* @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject
*/
$groupMock = $this->getMock('Magento\\Store\\Model\\Group', ['getId', 'getWebsiteId'], [], '', false);
/**
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
*/
$storeMock = $this->getMock('Magento\\Store\\Model\\Store', ['getGroupId'], [], '', false);
$this->systemStoreMock->expects($this->once())->method('getWebsiteCollection')->willReturn([$websiteMock]);
$this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn([$groupMock]);
$this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn([$storeMock]);
$websiteMock->expects($this->any())->method('getId')->willReturn($websiteId);
$groupMock->expects($this->any())->method('getWebsiteId')->willReturn($websiteId);
$groupMock->expects($this->any())->method('getId')->willReturn($groupId);
$storeMock->expects($this->any())->method('getGroupId')->willReturn($groupId);
$this->scopeConfigMock->expects($this->any())->method('getValue')->willReturnMap([[CurrencySymbol::XML_PATH_CUSTOM_CURRENCY_SYMBOL, ScopeInterface::SCOPE_STORE, null, ''], [CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, $storeMock, $currencies], [CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, null, $currencies], [CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, $storeMock, $currencies]]);
$websiteMock->expects($this->any())->method('getConfig')->with(CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES)->willReturn($currencies);
$this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn('en');
}
示例13: expectsSetConfig
/**
* Declare calls expectation for setConfig() method
*/
protected function expectsSetConfig($themeId, $localeCode = 'en_US')
{
$this->locale->expects($this->any())->method('getLocaleCode')->will($this->returnValue($localeCode));
$scope = new \Magento\Framework\Object(['code' => 'frontendCode', 'id' => 1]);
$scopeAdmin = new \Magento\Framework\Object(['code' => 'adminCode', 'id' => 0]);
$this->scopeResolver->expects($this->any())->method('getScope')->will($this->returnValueMap([[null, $scope], ['admin', $scopeAdmin]]));
$designTheme = new \Magento\Framework\Object(['id' => $themeId]);
$this->viewDesign->expects($this->any())->method('getDesignTheme')->will($this->returnValue($designTheme));
}
示例14: setUp
protected function setUp()
{
$this->assetRepo = $this->getMock('Magento\\Framework\\View\\Asset\\Repository', [], [], '', false);
$this->pageAssets = $this->getMock('Magento\\Framework\\View\\Asset\\GroupedCollection', [], [], '', false);
$this->scopeConfig = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface', [], [], '', false);
$this->favicon = $this->getMock('Magento\\Framework\\View\\Page\\FaviconInterface', [], [], '', false);
$this->builder = $this->getMock('Magento\\Framework\\View\\Layout\\BuilderInterface', [], [], '', false);
$this->asset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false);
$this->remoteAsset = $this->getMock('\\Magento\\Framework\\View\\Asset\\Remote', [], [], '', false);
$this->title = $this->getMock('Magento\\Framework\\View\\Page\\Title', [], [], '', false);
$this->localeMock = $this->getMockForAbstractClass('Magento\\Framework\\Locale\\ResolverInterface', [], '', false);
$this->localeMock->expects($this->any())->method('getLocale')->willReturn(Resolver::DEFAULT_LOCALE);
$this->model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Framework\\View\\Page\\Config', ['assetRepo' => $this->assetRepo, 'pageAssets' => $this->pageAssets, 'scopeConfig' => $this->scopeConfig, 'favicon' => $this->favicon, 'localeResolver' => $this->localeMock]);
$this->areaResolverMock = $this->getMock('Magento\\Framework\\App\\State', [], [], '', false);
$areaResolverReflection = (new \ReflectionClass(get_class($this->model)))->getProperty('areaResolver');
$areaResolverReflection->setAccessible(true);
$areaResolverReflection->setValue($this->model, $this->areaResolverMock);
}
示例15: testToOptionArrayForEn
/**
* Test for toOptionArray (non-Japanese)
*
* @return void
* @throws \Exception
*/
public function testToOptionArrayForEn()
{
$this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn('en_US');
$items = [['name' => 'Hokkaido', 'default_name' => 'Hokkaido', 'region_id' => 1, 'country_id' => 1], ['name' => 'Aomori', 'default_name' => 'Aomori', 'region_id' => 2, 'country_id' => 1]];
foreach ($items as $itemData) {
$this->collection->addItem(new DataObject($itemData));
}
$expectedResult = [['label' => __('Please select a region, state or province.'), 'value' => null, 'title' => null], ['value' => 1, 'title' => 'Hokkaido', 'country_id' => 1, 'label' => 'Hokkaido'], ['value' => 2, 'title' => 'Aomori', 'country_id' => 1, 'label' => 'Aomori']];
$this->assertEquals($expectedResult, $this->collection->toOptionArray());
}