Пример #1
0
 public function addItem(Title $title, Label $label, $description)
 {
     $count = count($this->items);
     $this->items[$count]['title'] = $title->toArray();
     $this->items[$count]['label'] = $label->toArray();
     $this->items[$count]['description'] = $description;
 }
Пример #2
0
 public function addItem(Title $title, $label, $description)
 {
     $count = count($this->items);
     $this->items[$count]['title'] = $title->toArray();
     if ($label instanceof Label) {
         $this->items[$count]['label'] = $label->toArray();
     }
     $this->items[$count]['description'] = $description;
 }
Пример #3
0
 /**
  * @test
  */
 public function canHaveNoLabel()
 {
     $widget = new ItemList();
     $title = new Title();
     $title->setText("Title text");
     $title->setHighlight(true);
     $widget->addItem($title, null, 'description');
     $json = json_encode($widget->getData());
     $this->assertEquals('[{"title":{"text":"Title text","highlight":true},"description":"description"}]', $json);
 }
Пример #4
0
 /**
  * @test
  */
 public function canAddMultipleItems()
 {
     $widget = new ItemList();
     $title = new Title();
     $title->setText("Title text");
     $title->setHighlight(true);
     $title2 = new Title();
     $title2->setText("Title2 text");
     $title2->setHighlight(false);
     $label = new Label();
     $label->setName("Label name");
     $label->setColor("red");
     $label2 = new Label();
     $label2->setName("Label2 name");
     $label2->setColor("blue");
     $widget->addItem($title, $label, 'description1');
     $widget->addItem($title2, $label2, 'description2');
     $json = json_encode($widget->getData());
     $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);
 }