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

OrderingTranslationFilesFinderSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 47
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_Translation_Files_Finder_interface() 0 4 1
A it_puts_application_translations_files_before_bundle_translations_files() 0 12 1
A getMatchers() 0 16 2
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