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

LocaleSpec::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\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