Exemplo n.º 1
0
 /**
  * Test get/set genre.
  */
 public function testGenre()
 {
     $this->assertEmpty($this->item->getGenres());
     /* @var $genre \PHPUnit_Framework_MockObject_MockObject|Genre */
     $genre = $this->getMock('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Widget\\Genre');
     $genre->expects($this->once())->method('setItem')->with($this->item)->will($this->returnSelf());
     $this->assertEquals($this->item, $this->item->addGenre($genre));
     $this->assertEquals($this->item, $this->item->addGenre($genre));
     /* @var $coll \Doctrine\Common\Collections\Collection */
     $coll = $this->item->getGenres();
     $this->assertEquals(1, $coll->count());
     $this->assertEquals($genre, $coll->first());
 }
Exemplo n.º 2
0
 /**
  * Get widget item
  *
  * @param array $item
  *
  * @return \AnimeDb\Bundle\CatalogBundle\Entity\Widget\Item
  */
 public function getWidgetItem(array $item)
 {
     $entity = new ItemWidget();
     $entity->setName($this->getItemName($item));
     $entity->setLink($this->browser->getHost() . $item['url']);
     $entity->setCover($this->browser->getHost() . $item['image']['original']);
     $catalog_item = $this->getCatalogItem($item);
     if ($catalog_item instanceof Item) {
         $entity->setItem($catalog_item);
     } elseif ($this->filler instanceof Filler) {
         $entity->setLinkForFill($this->filler->getLinkForFill($entity->getLink()));
     }
     return $entity;
 }