1 | <?php |
||
23 | final class TaxonSpec 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(Taxon::class); |
||
34 | } |
||
35 | |||
36 | function it_implements_taxon_interface() |
||
37 | { |
||
38 | $this->shouldImplement(TaxonInterface::class); |
||
39 | } |
||
40 | |||
41 | function it_has_no_id_by_default() |
||
42 | { |
||
43 | $this->getId()->shouldReturn(null); |
||
44 | } |
||
45 | |||
46 | function its_code_is_mutable() |
||
47 | { |
||
48 | $this->setCode('TX2'); |
||
49 | $this->getCode()->shouldReturn('TX2'); |
||
50 | } |
||
51 | |||
52 | function it_has_no_parent_by_default() |
||
53 | { |
||
54 | $this->getParent()->shouldReturn(null); |
||
55 | } |
||
56 | |||
57 | function its_parent_is_mutable(TaxonInterface $taxon) |
||
58 | { |
||
59 | $this->setParent($taxon); |
||
60 | $this->getParent()->shouldReturn($taxon); |
||
61 | } |
||
62 | |||
63 | function it_returns_an_array_of_all_parent_taxons( |
||
64 | TaxonInterface $categoryTaxon, |
||
65 | TaxonInterface $tshirtsTaxon |
||
66 | ) { |
||
67 | $tshirtsTaxon->getParent()->willReturn($categoryTaxon); |
||
68 | |||
69 | $tshirtsTaxon->addChild($this)->shouldBeCalled(); |
||
70 | $this->setParent($tshirtsTaxon); |
||
71 | |||
72 | $this->getParents()->shouldReturn([$tshirtsTaxon, $categoryTaxon]); |
||
73 | } |
||
74 | |||
75 | function it_returns_an_array_of_with_a_single_parent_taxon(TaxonInterface $parentTaxon) |
||
76 | { |
||
77 | $parentTaxon->getParent()->willReturn(null); |
||
78 | $parentTaxon->addChild($this)->shouldBeCalled(); |
||
79 | $this->setParent($parentTaxon); |
||
80 | |||
81 | $this->getParents()->shouldReturn([$parentTaxon]); |
||
82 | } |
||
83 | |||
84 | function it_returns_empty_array_for_root_taxon() |
||
88 | |||
89 | function it_is_root_by_default() |
||
93 | |||
94 | function it_is_not_root_when_has_parent(TaxonInterface $taxon) |
||
99 | |||
100 | function it_is_root_when_has_no_parent(TaxonInterface $taxon) |
||
110 | |||
111 | function it_is_unnamed_by_default() |
||
115 | |||
116 | function its_name_is_mutable() |
||
121 | |||
122 | function it_returns_name_when_converted_to_string() |
||
127 | |||
128 | function it_has_no_description_by_default() |
||
132 | |||
133 | function its_description_is_mutable() |
||
138 | |||
139 | function it_has_no_slug_by_default() |
||
143 | |||
144 | function its_slug_is_mutable() |
||
149 | |||
150 | function it_initializes_child_taxon_collection_by_default() |
||
151 | { |
||
152 | $this->getChildren()->shouldHaveType(Collection::class); |
||
153 | } |
||
154 | |||
155 | function it_allows_to_check_if_given_taxon_is_its_child(TaxonInterface $taxon) |
||
156 | { |
||
157 | $this->hasChild($taxon)->shouldReturn(false); |
||
158 | } |
||
159 | |||
160 | function it_allows_to_add_child_taxons(TaxonInterface $taxon) |
||
167 | |||
168 | function it_allows_to_remove_child_taxons(TaxonInterface $taxon) |
||
179 | |||
180 | function it_has_position() |
||
185 | |||
186 | function it_has_not_children_by_default() |
||
190 | |||
191 | function it_has_children_when_you_have_added_child(TaxonInterface $taxon) |
||
197 | } |
||
198 |