Completed
Push — master ( d998d0...abb41b )
by Kamil
38:34
created

OrderingTranslationFilesFinderSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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\Finder;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
17
use Sylius\Bundle\ThemeBundle\Translation\Finder\OrderingTranslationFilesFinder;
18
use Sylius\Bundle\ThemeBundle\Translation\Finder\TranslationFilesFinderInterface;
19
20
/**
21
 * @mixin OrderingTranslationFilesFinder
22
 *
23
 * @author Kamil Kokot <[email protected]>
24
 */
25
class OrderingTranslationFilesFinderSpec extends ObjectBehavior
26
{
27
    function let(TranslationFilesFinderInterface $translationFilesFinder)
28
    {
29
        $this->beConstructedWith($translationFilesFinder);
30
    }
31
32
    function it_is_initializable()
33
    {
34
        $this->shouldHaveType('Sylius\Bundle\ThemeBundle\Translation\Finder\OrderingTranslationFilesFinder');
35
    }
36
37
    function it_implements_Translation_Files_Finder_interface()
38
    {
39
        $this->shouldImplement(TranslationFilesFinderInterface::class);
40
    }
41
42
    function it_puts_application_translations_files_before_bundle_translations_files(
43
        TranslationFilesFinderInterface $translationFilesFinder,
44
        ThemeInterface $theme
45
    ) {
46
        $translationFilesFinder->findTranslationFiles($theme)->willReturn([
47
            '/some/path/to/theme/AcmeBundle/messages.en.yml',
48
            '/some/path/to/theme/translations/messages.en.yml',
49
            '/some/path/to/theme/YcmeBundle/messages.en.yml',
50
        ]);
51
52
        $this->findTranslationFiles($theme)->shouldHaveFirstElement('/some/path/to/theme/translations/messages.en.yml');
53
    }
54
55
    public function getMatchers()
56
    {
57
        return [
58
            'haveFirstElement' => function ($subject, $element) {
59
                if ($element !== reset($subject)) {
60
                    throw new \InvalidArgumentException(sprintf(
61
                        'Expected "%s" as the first element, actual value was "%s".',
62
                        $element,
63
                        reset($subject)
64
                    ));
65
                }
66
67
                return true;
68
            },
69
        ];
70
    }
71
}
72