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
|
|
|
namespace spec\Sylius\Bundle\ThemeBundle\Model; |
13
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
15
|
|
|
use Sylius\Bundle\ThemeBundle\Model\Theme; |
16
|
|
|
use Sylius\Bundle\ThemeBundle\Model\ThemeAuthor; |
17
|
|
|
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface; |
18
|
|
|
use Sylius\Bundle\ThemeBundle\Model\ThemeScreenshot; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Kamil Kokot <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
final class ThemeSpec extends ObjectBehavior |
24
|
|
|
{ |
25
|
|
|
function let() |
26
|
|
|
{ |
27
|
|
|
$this->beConstructedWith('theme/name', '/theme/path'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function it_is_initializable() |
31
|
|
|
{ |
32
|
|
|
$this->shouldHaveType(Theme::class); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function it_implements_theme_interface() |
36
|
|
|
{ |
37
|
|
|
$this->shouldImplement(ThemeInterface::class); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function its_name_cannot_have_underscores() |
41
|
|
|
{ |
42
|
|
|
$this->beConstructedWith('first_theme/name', '/theme/path'); |
43
|
|
|
|
44
|
|
|
$this->shouldThrow(\InvalidArgumentException::class)->duringInstantiation(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
function it_has_immutable_name() |
48
|
|
|
{ |
49
|
|
|
$this->getName()->shouldReturn('theme/name'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
function its_name_might_contain_numbers() |
53
|
|
|
{ |
54
|
|
|
$this->beConstructedWith('1e/e7', '/theme/path'); |
55
|
|
|
|
56
|
|
|
$this->getName()->shouldReturn('1e/e7'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function its_name_might_contain_uppercase_characters() |
60
|
|
|
{ |
61
|
|
|
$this->beConstructedWith('AbC/DeF', '/theme/path'); |
62
|
|
|
|
63
|
|
|
$this->getName()->shouldReturn('AbC/DeF'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
function it_has_immutable_path() |
67
|
|
|
{ |
68
|
|
|
$this->getPath()->shouldReturn('/theme/path'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
function it_has_title() |
72
|
|
|
{ |
73
|
|
|
$this->getTitle()->shouldReturn(null); |
74
|
|
|
|
75
|
|
|
$this->setTitle('Foo Bar'); |
76
|
|
|
$this->getTitle()->shouldReturn('Foo Bar'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
function it_has_description() |
80
|
|
|
{ |
81
|
|
|
$this->getDescription()->shouldReturn(null); |
82
|
|
|
|
83
|
|
|
$this->setDescription('Lorem ipsum.'); |
84
|
|
|
$this->getDescription()->shouldReturn('Lorem ipsum.'); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
function it_has_authors() |
88
|
|
|
{ |
89
|
|
|
$themeAuthor = new ThemeAuthor(); |
90
|
|
|
|
91
|
|
|
$this->getAuthors()->shouldHaveCount(0); |
92
|
|
|
|
93
|
|
|
$this->addAuthor($themeAuthor); |
94
|
|
|
$this->getAuthors()->shouldHaveCount(1); |
95
|
|
|
|
96
|
|
|
$this->removeAuthor($themeAuthor); |
97
|
|
|
$this->getAuthors()->shouldHaveCount(0); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
function it_has_parents(ThemeInterface $theme) |
101
|
|
|
{ |
102
|
|
|
$this->getParents()->shouldHaveCount(0); |
103
|
|
|
|
104
|
|
|
$this->addParent($theme); |
105
|
|
|
$this->getParents()->shouldHaveCount(1); |
106
|
|
|
|
107
|
|
|
$this->removeParent($theme); |
108
|
|
|
$this->getParents()->shouldHaveCount(0); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
function it_has_screenshots() |
112
|
|
|
{ |
113
|
|
|
$themeScreenshot = new ThemeScreenshot('some path'); |
114
|
|
|
|
115
|
|
|
$this->getScreenshots()->shouldHaveCount(0); |
116
|
|
|
|
117
|
|
|
$this->addScreenshot($themeScreenshot); |
118
|
|
|
$this->getScreenshots()->shouldHaveCount(1); |
119
|
|
|
|
120
|
|
|
$this->removeScreenshot($themeScreenshot); |
121
|
|
|
$this->getScreenshots()->shouldHaveCount(0); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|