1 | <?php |
||
9 | class ItemListTest extends \PHPUnit_Framework_TestCase |
||
10 | { |
||
11 | /** |
||
12 | * @test |
||
13 | */ |
||
14 | public function getDataWithNoItems() |
||
21 | |||
22 | /** |
||
23 | * @test |
||
24 | */ |
||
25 | public function canAddSingleItem() |
||
26 | { |
||
27 | $widget = new ItemList(); |
||
28 | |||
29 | $title = new Title(); |
||
30 | $title->setText('Title text'); |
||
31 | $title->setHighlight(true); |
||
32 | |||
33 | $label = new Label(); |
||
34 | $label->setName('Label name'); |
||
35 | $label->setColor('red'); |
||
36 | |||
37 | $widget->addItem($title, $label, 'description'); |
||
38 | $json = json_encode($widget->getData()); |
||
39 | $this->assertEquals('[{"title":{"text":"Title text","highlight":true},"label":{"name":"Label name","color":"red"},"description":"description"}]', $json); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @test |
||
44 | */ |
||
45 | public function canAddMultipleItems() |
||
46 | { |
||
47 | $widget = new ItemList(); |
||
48 | |||
49 | $title = new Title(); |
||
50 | $title->setText('Title text'); |
||
51 | $title->setHighlight(true); |
||
52 | |||
53 | $title2 = new Title(); |
||
54 | $title2->setText('Title2 text'); |
||
55 | $title2->setHighlight(false); |
||
56 | |||
57 | $label = new Label(); |
||
58 | $label->setName('Label name'); |
||
59 | $label->setColor('red'); |
||
60 | |||
61 | $label2 = new Label(); |
||
62 | $label2->setName('Label2 name'); |
||
63 | $label2->setColor('blue'); |
||
64 | |||
65 | $widget->addItem($title, $label, 'description1'); |
||
66 | $widget->addItem($title2, $label2, 'description2'); |
||
67 | $json = json_encode($widget->getData()); |
||
68 | $this->assertEquals('[{"title":{"text":"Title text","highlight":true},"label":{"name":"Label name","color":"red"},"description":"description1"},{"title":{"text":"Title2 text","highlight":false},"label":{"name":"Label2 name","color":"blue"},"description":"description2"}]', $json); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @test |
||
73 | */ |
||
74 | public function canHaveNoLabel() |
||
86 | } |
||
87 |