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

CompositeTranslatorResourceProviderSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_implements_translator_resource_provider_interface() 0 4 1
A it_aggregates_the_resources() 0 13 1
A it_aggregates_the_resources_locales() 0 11 1
A it_aggregates_the_unique_resources_locales() 0 11 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
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