Completed
Push — scalar-types/theme ( 71f30c )
by Kamil
21:15
created

it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
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
declare(strict_types=1);
13
14
namespace spec\Sylius\Bundle\ThemeBundle\Translation\Provider;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Bundle\ThemeBundle\Translation\Provider\Resource\CompositeTranslatorResourceProvider;
18
use Sylius\Bundle\ThemeBundle\Translation\Provider\Resource\TranslatorResourceProviderInterface;
19
use Sylius\Bundle\ThemeBundle\Translation\Resource\TranslationResourceInterface;
20
21
/**
22
 * @author Kamil Kokot <[email protected]>
23
 */
24
final class CompositeTranslatorResourceProviderSpec extends ObjectBehavior
25
{
26
    function it_implements_translator_resource_provider_interface(): void
27
    {
28
        $this->shouldImplement(TranslatorResourceProviderInterface::class);
29
    }
30
31
    function it_aggregates_the_resources(
32
        TranslatorResourceProviderInterface $firstResourceProvider,
33
        TranslatorResourceProviderInterface $secondResourceProvider,
34
        TranslationResourceInterface $firstResource,
35
        TranslationResourceInterface $secondResource
36
    ): void {
37
        $this->beConstructedWith([$firstResourceProvider, $secondResourceProvider]);
38
39
        $firstResourceProvider->getResources()->willReturn([$firstResource]);
40
        $secondResourceProvider->getResources()->willReturn([$secondResource, $firstResource]);
41
42
        $this->getResources()->shouldReturn([$firstResource, $secondResource, $firstResource]);
43
    }
44
45
    function it_aggregates_the_resources_locales(
46
        TranslatorResourceProviderInterface $firstResourceProvider,
47
        TranslatorResourceProviderInterface $secondResourceProvider
48
    ): void {
49
        $this->beConstructedWith([$firstResourceProvider, $secondResourceProvider]);
50
51
        $firstResourceProvider->getResourcesLocales()->willReturn(['first-locale']);
52
        $secondResourceProvider->getResourcesLocales()->willReturn(['second-locale']);
53
54
        $this->getResourcesLocales()->shouldReturn(['first-locale', 'second-locale']);
55
    }
56
57
    function it_aggregates_the_unique_resources_locales(
58
        TranslatorResourceProviderInterface $firstResourceProvider,
59
        TranslatorResourceProviderInterface $secondResourceProvider
60
    ): void {
61
        $this->beConstructedWith([$firstResourceProvider, $secondResourceProvider]);
62
63
        $firstResourceProvider->getResourcesLocales()->willReturn(['first-locale']);
64
        $secondResourceProvider->getResourcesLocales()->willReturn(['second-locale', 'first-locale', 'second-locale']);
65
66
        $this->getResourcesLocales()->shouldReturn(['first-locale', 'second-locale']);
67
    }
68
}
69