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\Component\Product\Model; |
13
|
|
|
|
14
|
|
|
use Doctrine\Common\Collections\Collection; |
15
|
|
|
use PhpSpec\ObjectBehavior; |
16
|
|
|
use Sylius\Component\Product\Model\ProductOption; |
17
|
|
|
use Sylius\Component\Product\Model\ProductOptionInterface; |
18
|
|
|
use Sylius\Component\Product\Model\ProductOptionValue; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Grzegorz Sadowski <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
final class ProductOptionSpec extends ObjectBehavior |
24
|
|
|
{ |
25
|
|
|
public function let() |
26
|
|
|
{ |
27
|
|
|
$this->setCurrentLocale('en_US'); |
28
|
|
|
$this->setFallbackLocale('en_US'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
function it_is_initializable() |
32
|
|
|
{ |
33
|
|
|
$this->shouldHaveType(ProductOption::class); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
function it_implements_product_option_interface() |
37
|
|
|
{ |
38
|
|
|
$this->shouldHaveType(ProductOptionInterface::class); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
function it_has_no_id_by_default() |
42
|
|
|
{ |
43
|
|
|
$this->getId()->shouldReturn(null); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
function it_has_no_code_by_default() |
47
|
|
|
{ |
48
|
|
|
$this->getCode()->shouldReturn(null); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
function its_code_is_mutable() |
52
|
|
|
{ |
53
|
|
|
$this->setCode('color'); |
54
|
|
|
$this->getCode()->shouldReturn('color'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
function it_has_no_name_by_default() |
58
|
|
|
{ |
59
|
|
|
$this->getName()->shouldReturn(null); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
function its_name_is_mutable() |
63
|
|
|
{ |
64
|
|
|
$this->setName('Color'); |
65
|
|
|
$this->getName()->shouldReturn('Color'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
function it_has_no_position_by_default() |
69
|
|
|
{ |
70
|
|
|
$this->getPosition()->shouldReturn(null); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
function its_position_is_mutable() |
74
|
|
|
{ |
75
|
|
|
$this->setPosition(10); |
76
|
|
|
$this->getPosition()->shouldReturn(10); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
function it_has_an_empty_collection_of_values_by_default() |
80
|
|
|
{ |
81
|
|
|
$this->getValues()->shouldHaveType(Collection::class); |
82
|
|
|
$this->getValues()->count()->shouldReturn(0); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
function it_can_have_a_value_added(ProductOptionValue $value) |
86
|
|
|
{ |
87
|
|
|
$this->addValue($value); |
88
|
|
|
$this->hasValue($value)->shouldReturn(true); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
function it_can_have_a_locale_removed(ProductOptionValue $value) |
92
|
|
|
{ |
93
|
|
|
$this->addValue($value); |
94
|
|
|
$this->removeValue($value); |
95
|
|
|
$this->hasValue($value)->shouldReturn(false); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|