diff --git a/spec/Translation/Finder/TranslationFilesFinderSpec.php b/spec/Translation/Finder/TranslationFilesFinderSpec.php index 9320f39..0c0b670 100644 --- a/spec/Translation/Finder/TranslationFilesFinderSpec.php +++ b/spec/Translation/Finder/TranslationFilesFinderSpec.php @@ -21,23 +21,24 @@ final class TranslationFilesFinderSpec extends ObjectBehavior { - function let(FinderFactoryInterface $finderFactory): void + public function let(FinderFactoryInterface $finderFactory): void { $this->beConstructedWith($finderFactory); } - function it_implements_translation_resource_finder_interface(): void + public function it_implements_translation_resource_finder_interface(): void { $this->shouldImplement(TranslationFilesFinderInterface::class); } - function it_returns_an_array_of_translation_resources_paths( + public function it_returns_an_array_of_translation_resources_paths( FinderFactoryInterface $finderFactory, Finder $finder, ): void { $finderFactory->create()->willReturn($finder); $finder->ignoreUnreadableDirs()->shouldBeCalled()->willReturn($finder); + $finder->followLinks()->shouldBeCalled()->willReturn($finder); $finder->in('/theme/translations')->shouldBeCalled()->willReturn($finder); $finder->getIterator()->willReturn(new \ArrayIterator([ @@ -51,13 +52,14 @@ function it_returns_an_array_of_translation_resources_paths( ]); } - function it_does_not_provide_any_translation_resources_paths_if_translation_directory_does_not_exist( + public function it_does_not_provide_any_translation_resources_paths_if_translation_directory_does_not_exist( FinderFactoryInterface $finderFactory, Finder $finder, ): void { $finderFactory->create()->willReturn($finder); $finder->ignoreUnreadableDirs()->willReturn($finder); + $finder->followLinks()->willReturn($finder); $finder->in('/theme/translations')->willThrow(DirectoryNotFoundException::class); $this->findTranslationFiles('/theme')->shouldReturn([]); diff --git a/src/Translation/Finder/TranslationFilesFinder.php b/src/Translation/Finder/TranslationFilesFinder.php index 914c740..4224511 100644 --- a/src/Translation/Finder/TranslationFilesFinder.php +++ b/src/Translation/Finder/TranslationFilesFinder.php @@ -54,6 +54,7 @@ private function getFiles(string $path): iterable $finder ->ignoreUnreadableDirs() + ->followLinks() ->in($path . '/translations') ; diff --git a/tests/Application/private/translations/messages.fr.yml b/tests/Application/private/translations/messages.fr.yml new file mode 100644 index 0000000..27ffdb5 --- /dev/null +++ b/tests/Application/private/translations/messages.fr.yml @@ -0,0 +1,4 @@ +test: + app: 'traductions' + theme: 'traductions' + parent_theme: 'traductions' diff --git a/tests/Application/themes/MyTheme/translations/messages.fr.yml b/tests/Application/themes/MyTheme/translations/messages.fr.yml new file mode 120000 index 0000000..080c2fd --- /dev/null +++ b/tests/Application/themes/MyTheme/translations/messages.fr.yml @@ -0,0 +1 @@ +../../../private/translations/messages.fr.yml \ No newline at end of file diff --git a/tests/Translation/Finder/TranslationFilesFinderTest.php b/tests/Translation/Finder/TranslationFilesFinderTest.php new file mode 100644 index 0000000..6cdeacc --- /dev/null +++ b/tests/Translation/Finder/TranslationFilesFinderTest.php @@ -0,0 +1,28 @@ +createMock(FinderFactoryInterface::class); + $finderFactory->method('create')->willReturn($finder); + + $translationsFilesFinder = new TranslationFilesFinder($finderFactory); + $files = $translationsFilesFinder->findTranslationFiles('tests/Application/themes/MyTheme'); + + $this->assertContains('tests/Application/themes/MyTheme/translations/messages.fr.yml', $files); + } +}