Completed
Push — master ( 6570ae...141d1f )
by Kamil
25:19 queued 17s
created

ProviderBasedLocaleContextSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 29
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_a_locale_context() 0 4 1
A it_returns_the_channels_default_locale() 0 7 1
A it_throws_a_locale_not_found_exception_if_default_locale_is_not_available() 0 8 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\Component\Locale\Context;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Locale\Context\LocaleContextInterface;
18
use Sylius\Component\Locale\Context\LocaleNotFoundException;
19
use Sylius\Component\Locale\Provider\LocaleProviderInterface;
20
21
/**
22
 * @author Kamil Kokot <[email protected]>
23
 */
24
final class ProviderBasedLocaleContextSpec extends ObjectBehavior
25
{
26
    function let(LocaleProviderInterface $localeProvider): void
27
    {
28
        $this->beConstructedWith($localeProvider);
29
    }
30
31
    function it_is_a_locale_context(): void
32
    {
33
        $this->shouldImplement(LocaleContextInterface::class);
34
    }
35
36
    function it_returns_the_channels_default_locale(LocaleProviderInterface $localeProvider): void
37
    {
38
        $localeProvider->getAvailableLocalesCodes()->willReturn(['pl_PL', 'en_US']);
39
        $localeProvider->getDefaultLocaleCode()->willReturn('pl_PL');
40
41
        $this->getLocaleCode()->shouldReturn('pl_PL');
42
    }
43
44
    function it_throws_a_locale_not_found_exception_if_default_locale_is_not_available(
45
        LocaleProviderInterface $localeProvider
46
    ): void {
47
        $localeProvider->getAvailableLocalesCodes()->willReturn(['es_ES', 'en_US']);
48
        $localeProvider->getDefaultLocaleCode()->willReturn('pl_PL');
49
50
        $this->shouldThrow(LocaleNotFoundException::class)->during('getLocaleCode');
51
    }
52
}
53