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