Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions spec/Translation/Finder/TranslationFilesFinderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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([]);
Expand Down
1 change: 1 addition & 0 deletions src/Translation/Finder/TranslationFilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private function getFiles(string $path): iterable

$finder
->ignoreUnreadableDirs()
->followLinks()
->in($path . '/translations')
;

Expand Down
4 changes: 4 additions & 0 deletions tests/Application/private/translations/messages.fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test:
app: 'traductions'
theme: 'traductions'
parent_theme: 'traductions'
28 changes: 28 additions & 0 deletions tests/Translation/Finder/TranslationFilesFinderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Sylius\Bundle\ThemeBundle\Tests\Translation\Finder;

use PHPUnit\Framework\TestCase;
use Sylius\Bundle\ThemeBundle\Factory\FinderFactoryInterface;
use Sylius\Bundle\ThemeBundle\Translation\Finder\TranslationFilesFinder;
use Symfony\Component\Finder\Finder;

final class TranslationFilesFinderTest extends TestCase
{
/**
* @test
*/
public function it_can_follow_symlinks(): void
{
$finder = new Finder();
$finderFactory = $this->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);
}
}