public function initializeCorrectlySkipsExcludedPathsFromScanningLocales()
{
mkdir('vfs://Foo/Bar/Public/node_modules/foo/bar', 0777, true);
mkdir('vfs://Foo/Bar/Public/app/.git/refs/heads', 0777, true);
mkdir('vfs://Foo/Bar/Private/Translations', 0777, true);
foreach (['en', 'sr_Cyrl_RS'] as $localeIdentifier) {
file_put_contents('vfs://Foo/Bar/Public/node_modules/foo/bar/foobar.' . $localeIdentifier . '.baz', 'FooBar');
file_put_contents('vfs://Foo/Bar/Public/app/.git/refs/heads/' . $localeIdentifier . '.dev', 'FooBar');
}
foreach (['en_GB', 'sr'] as $localeIdentifier) {
file_put_contents('vfs://Foo/Bar/Private/Translations/' . $localeIdentifier . '.xlf', 'FooBar');
}
$mockPackage = $this->createMock(PackageInterface::class);
$mockPackage->expects($this->any())->method('getResourcesPath')->will($this->returnValue('vfs://Foo/Bar/'));
$mockPackageManager = $this->createMock(PackageManagerInterface::class);
$mockPackageManager->expects($this->any())->method('getActivePackages')->will($this->returnValue([$mockPackage]));
$mockLocaleCollection = $this->createMock(I18n\LocaleCollection::class);
$mockLocaleCollection->expects($this->exactly(2))->method('addLocale');
$mockSettings = ['i18n' => ['defaultLocale' => 'sv_SE', 'fallbackRule' => ['strict' => false, 'order' => []], 'scan' => ['includePaths' => ['/Private/' => true, '/Public/' => true], 'excludePatterns' => ['/node_modules/' => true, '/\\..*/' => true]]]];
$mockCache = $this->getMockBuilder(VariableFrontend::class)->disableOriginalConstructor()->getMock();
$mockCache->expects($this->once())->method('has')->with('availableLocales')->will($this->returnValue(false));
$service = $this->getAccessibleMock(I18n\Service::class, ['dummy']);
$service->_set('localeBasePath', 'vfs://Foo/');
$this->inject($service, 'packageManager', $mockPackageManager);
$this->inject($service, 'localeCollection', $mockLocaleCollection);
$service->injectSettings($mockSettings);
$this->inject($service, 'cache', $mockCache);
$service->initializeObject();
}