Completed
Push — theme-bundle ( 69304b...bce4cb )
by Kamil
18:15
created

it_implements_translation_resource_finder_interface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace spec\Sylius\Bundle\ThemeBundle\Translation;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\ThemeBundle\Factory\FinderFactoryInterface;
17
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
18
use Sylius\Bundle\ThemeBundle\Translation\TranslationFilesFinder;
19
use Sylius\Bundle\ThemeBundle\Translation\TranslationFilesFinderInterface;
20
use Symfony\Component\Finder\Finder;
21
22
/**
23
 * @mixin TranslationFilesFinder
24
 *
25
 * @author Kamil Kokot <[email protected]>
26
 */
27
class TranslationFilesFinderSpec extends ObjectBehavior
28
{
29
    function let(FinderFactoryInterface $finderFactory)
30
    {
31
        $this->beConstructedWith($finderFactory);
32
    }
33
    
34
    function it_is_initializable()
35
    {
36
        $this->shouldHaveType('Sylius\Bundle\ThemeBundle\Translation\TranslationFilesFinder');
37
    }
38
39
    function it_implements_translation_resource_finder_interface()
40
    {
41
        $this->shouldImplement(TranslationFilesFinderInterface::class);
42
    }
43
44
    function it_returns_an_array_of_translation_resources_paths(
45
        FinderFactoryInterface $finderFactory,
46
        Finder $finder,
47
        ThemeInterface $theme
48
    ) {
49
        $finderFactory->create()->willReturn($finder);
50
        $theme->getPath()->willReturn('/theme');
51
52
        $finder->in('/theme')->shouldBeCalled()->willReturn($finder);
53
        $finder->ignoreUnreadableDirs()->shouldBeCalled()->willReturn($finder);
54
55
        $finder->getIterator()->willReturn(new \ArrayIterator([
56
            '/theme/messages.en.yml',
57
            '/theme/translations/messages.en.yml',
58
            '/theme/translations/messages.en.yml.jpg',
59
            '/theme/translations/messages.yml',
60
            '/theme/AcmeBundle/translations/messages.pl_PL.yml',
61
        ]));
62
63
        $this->findTranslationFiles($theme)->shouldReturn([
64
            '/theme/translations/messages.en.yml',
65
            '/theme/AcmeBundle/translations/messages.pl_PL.yml',
66
        ]);
67
    }
68
}
69