6 declare(strict_types=1);
24 private $localeResolver;
34 private $resolverMock;
43 $this->configMock = $this->createMock(Config::class);
44 $this->resolverMock = $this->createMock(ResolverInterface::class);
45 $this->localeResolver =
new LocaleResolver($this->resolverMock, $this->configMock);
55 $expected =
'general/locale/code';
56 $this->resolverMock->expects($this->once())->method(
'getDefaultLocalePath')->willReturn($expected);
57 $actual = $this->localeResolver->getDefaultLocalePath();
58 self::assertEquals($expected, $actual);
68 $defaultLocale =
'en_US';
69 $this->resolverMock->expects($this->once())->method(
'setDefaultLocale')->with($defaultLocale);
70 $this->localeResolver->setDefaultLocale($defaultLocale);
81 $this->resolverMock->expects($this->once())->method(
'getDefaultLocale')->willReturn($expected);
82 $actual = $this->localeResolver->getDefaultLocale();
83 self::assertEquals($expected, $actual);
94 $this->resolverMock->expects($this->once())->method(
'setLocale')->with($locale);
95 $this->localeResolver->setLocale($locale);
106 $allowedLocales =
'en_US,en_GB,en_AU,da_DK,fr_FR,fr_CA,de_DE,zh_HK,it_IT,nl_NL';
107 $this->resolverMock->expects($this->once())->method(
'getLocale')->willReturn($locale);
108 $this->configMock->expects($this->once())->method(
'getValue')->with(
'supported_locales')
109 ->willReturn($allowedLocales);
112 $actual = $this->localeResolver->getLocale();
113 self::assertEquals($expected, $actual);
124 $this->resolverMock->expects($this->once())->method(
'emulate')->with($scopeId);
125 $this->localeResolver->emulate($scopeId);
135 $this->resolverMock->expects($this->once())->method(
'revert');
136 $this->localeResolver->revert();
testGetDefaultLocalePath()