Completed
Push — scalar-types/customer ( db66a3...ff9fd6 )
by Kamil
24:23
created

LocaleConverterSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_a_locale_converter() 0 4 1
A it_converts_locale_name_to_locale_code() 0 6 1
A it_converts_locale_code_to_locale_name() 0 6 1
A it_throws_invalid_argument_exception_if_cannot_convert_name_to_code() 0 4 1
A it_throws_invalid_argument_exception_if_cannot_convert_code_to_name() 0 4 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\Converter;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Locale\Converter\LocaleConverterInterface;
18
19
/**
20
 * @author Arkadiusz Krakowiak <[email protected]>
21
 */
22
final class LocaleConverterSpec extends ObjectBehavior
23
{
24
    function it_is_a_locale_converter(): void
25
    {
26
        $this->shouldImplement(LocaleConverterInterface::class);
27
    }
28
29
    function it_converts_locale_name_to_locale_code(): void
30
    {
31
        $this->convertNameToCode('German')->shouldReturn('de');
32
        $this->convertNameToCode('Norwegian')->shouldReturn('no');
33
        $this->convertNameToCode('Polish')->shouldReturn('pl');
34
    }
35
36
    function it_converts_locale_code_to_locale_name(): void
37
    {
38
        $this->convertCodeToName('de')->shouldReturn('German');
39
        $this->convertCodeToName('no')->shouldReturn('Norwegian');
40
        $this->convertCodeToName('pl')->shouldReturn('Polish');
41
    }
42
43
    function it_throws_invalid_argument_exception_if_cannot_convert_name_to_code(): void
44
    {
45
        $this->shouldThrow(\InvalidArgumentException::class)->during('convertNameToCode', ['xyz']);
46
    }
47
48
    function it_throws_invalid_argument_exception_if_cannot_convert_code_to_name(): void
49
    {
50
        $this->shouldThrow(\InvalidArgumentException::class)->during('convertCodeToName', ['xyz']);
51
    }
52
}
53