当前位置: 首页>>代码示例>>PHP>>正文


PHP ResolverInterface::expects方法代码示例

本文整理汇总了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);
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:7,代码来源:DesignTest.php

示例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();
     });
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:DateTest.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:AggregateSalesReportBestsellersDataTest.php

示例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());
 }
开发者ID:nja78,项目名称:magento2,代码行数:11,代码来源:PayPalTest.php

示例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());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:9,代码来源:CacheManagerTest.php

示例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));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:SidebarTest.php

示例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));
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:14,代码来源:LocaleQuantityProcessorTest.php

示例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;
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:15,代码来源:AggregateSalesReportInvoicedDataTest.php

示例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());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:ConfigProviderTest.php

示例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));
 }
开发者ID:nja78,项目名称:magento2,代码行数:23,代码来源:DateTest.php

示例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();
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:25,代码来源:EmulationTest.php

示例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');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:32,代码来源:CurrencysymbolTest.php

示例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));
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:12,代码来源:TranslateTest.php

示例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);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:18,代码来源:ConfigTest.php

示例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());
 }
开发者ID:magento-japan,项目名称:m2-jplocalize,代码行数:16,代码来源:CollectionTest.php


注:本文中的Magento\Framework\Locale\ResolverInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。