Completed
Push — scalar-types/resource ( 4814fd )
by Kamil
23:02
created

LocaleSpec   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

10 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_implements_a_locale_interface() 0 4 1
A it_is_timestampable() 0 4 1
A it_does_not_have_id_by_default() 0 4 1
A it_has_no_code_by_default() 0 4 1
A its_code_is_mutable() 0 5 1
A it_has_a_name() 0 10 1
A it_returns_name_when_converted_to_string() 0 8 1
A it_initializes_creation_date_by_default() 0 4 1
A it_does_not_have_last_update_date_by_default() 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\Model;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Locale\Model\LocaleInterface;
18
use Sylius\Component\Resource\Model\TimestampableInterface;
19
20
/**
21
 * @author Kamil Kokot <[email protected]>
22
 */
23
final class LocaleSpec extends ObjectBehavior
24
{
25
    function let(): void
26
    {
27
        \Locale::setDefault('en');
28
    }
29
30
    function it_implements_a_locale_interface(): void
31
    {
32
        $this->shouldImplement(LocaleInterface::class);
33
    }
34
35
    function it_is_timestampable(): void
36
    {
37
        $this->shouldImplement(TimestampableInterface::class);
38
    }
39
40
    function it_does_not_have_id_by_default(): void
41
    {
42
        $this->getId()->shouldReturn(null);
43
    }
44
45
    function it_has_no_code_by_default(): void
46
    {
47
        $this->getCode()->shouldReturn(null);
48
    }
49
50
    function its_code_is_mutable(): void
51
    {
52
        $this->setCode('de_DE');
53
        $this->getCode()->shouldReturn('de_DE');
54
    }
55
56
    function it_has_a_name(): void
57
    {
58
        $this->setCode('pl_PL');
59
        $this->getName()->shouldReturn('Polish (Poland)');
60
        $this->getName('es')->shouldReturn('polaco (Polonia)');
61
62
        $this->setCode('pl');
63
        $this->getName()->shouldReturn('Polish');
64
        $this->getName('es')->shouldReturn('polaco');
65
    }
66
67
    function it_returns_name_when_converted_to_string(): void
68
    {
69
        $this->setCode('pl_PL');
70
        $this->__toString()->shouldReturn('Polish (Poland)');
71
72
        $this->setCode('pl');
73
        $this->__toString()->shouldReturn('Polish');
74
    }
75
76
    function it_initializes_creation_date_by_default(): void
77
    {
78
        $this->getCreatedAt()->shouldHaveType(\DateTimeInterface::class);
79
    }
80
81
    function it_does_not_have_last_update_date_by_default(): void
82
    {
83
        $this->getUpdatedAt()->shouldReturn(null);
84
    }
85
}
86