public function setUp()
{
$findBestMatchingLocaleCallback = function () {
$args = func_get_args();
$localeIdentifier = (string) $args[0];
if (in_array($localeIdentifier, ['en_US_POSIX', 'en_Shaw'])) {
return new I18n\Locale('en');
} elseif ($localeIdentifier === 'en_GB') {
return new I18n\Locale('en_GB');
} elseif ($localeIdentifier === 'sr_RS') {
return new I18n\Locale('sr');
} else {
return null;
}
};
$mockLocaleCollection = $this->createMock(I18n\LocaleCollection::class);
$mockLocaleCollection->expects($this->any())->method('findBestMatchingLocale')->will($this->returnCallback($findBestMatchingLocaleCallback));
$mockLocalizationService = $this->createMock(I18n\Service::class);
$mockLocalizationService->expects($this->any())->method('getConfiguration')->will($this->returnValue(new I18n\Configuration('sv_SE')));
$this->detector = $this->getAccessibleMock(I18n\Detector::class, ['dummy']);
$this->detector->_set('localeBasePath', 'vfs://Foo/');
$this->detector->injectLocaleCollection($mockLocaleCollection);
$this->detector->injectLocalizationService($mockLocalizationService);
}