Ejemplo n.º 1
0
 public function testFreez()
 {
     $em = $this->getMockBuilder('\\Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $em->expects($this->atLeastOnce())->method('getReference')->will($this->returnCallback(function ($class_name, $id) {
         $ref = new \stdClass();
         $ref->class = $class_name;
         $ref->id = $id;
         return $ref;
     }));
     /* @var $doctrine \PHPUnit_Framework_MockObject_MockObject|Registry */
     $doctrine = $this->getMockBuilder('\\Doctrine\\Bundle\\DoctrineBundle\\Registry')->disableOriginalConstructor()->getMock();
     $doctrine->expects($this->once())->method('getManager')->will($this->returnValue($em));
     // set related entities
     $country = $this->getRef('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Country', 'setCountry');
     $storage = $this->getRef('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Storage', 'setStorage');
     $type = $this->getRef('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Type', 'setType');
     $genre1 = $this->getRef('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Genre', 'addGenre');
     $genre2 = $this->getRef('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Genre', 'addGenre');
     $this->item->freez($doctrine);
     // test freez result
     $this->assertEquals($country, $this->item->getCountry());
     $this->assertEquals($storage, $this->item->getStorage());
     $this->assertEquals($type, $this->item->getType());
     $this->assertEquals($genre1, $this->item->getGenres()[0]);
     $this->assertEquals($genre2, $this->item->getGenres()[1]);
 }
Ejemplo n.º 2
0
 /**
  * @param Item $item
  * @param Request $request
  *
  * @return Response
  */
 public function showAction(Item $item, Request $request)
 {
     $date = [$item->getDateUpdate()];
     // use storage update date
     if ($item->getStorage() instanceof Storage) {
         $date[] = $item->getStorage()->getDateUpdate();
     }
     $response = $this->getCacheTimeKeeper()->getResponse($date);
     // response was not modified for this request
     if ($response->isNotModified($request)) {
         return $response;
     }
     return $this->render('AnimeDbCatalogBundle:Item:show.html.twig', ['item' => $item, 'widget_bottom' => self::WIDGET_PALCE_BOTTOM, 'widget_in_content' => self::WIDGET_PALCE_IN_CONTENT, 'widget_right' => self::WIDGET_PALCE_RIGHT], $response);
 }