Exemplo n.º 1
0
 /**
  * @test
  */
 public function shouldConstructCastAndCredits()
 {
     $data = $this->loadByFile('movie/all.json');
     /**
      * @var MovieFactory $movieFactory
      */
     $movieFactory = new MovieFactory();
     /**
      * @var Movie $movie
      */
     $movie = $movieFactory->create($data);
     $credits = $movie->getCredits();
     $this->assertInstanceOf('Tmdb\\Model\\Collection\\CreditsCollection', $credits);
     $cast = $credits->getCast();
     $crew = $credits->getCrew();
     $this->assertInstanceOf('Tmdb\\Model\\Collection\\People\\Cast', $cast);
     $this->assertInstanceOf('Tmdb\\Model\\Collection\\People\\Crew', $crew);
 }
 /**
  * Create an generic collection of an array that consists out of a mix of movies and tv shows
  *
  * @param  array             $data
  * @return GenericCollection
  */
 protected function createGenericCollectionFromMediaTypes($data = [])
 {
     $movieFactory = new MovieFactory($this->getHttpClient());
     $tvFactory = new TvFactory($this->getHttpClient());
     $collection = new GenericCollection();
     foreach ($data as $item) {
         switch ($item['media_type']) {
             case "movie":
                 $collection->add(null, $movieFactory->create($item));
                 break;
             case "tv":
                 $collection->add(null, $tvFactory->create($item));
                 break;
             default:
                 throw new \RuntimeException('Unknown media type "%s"', $item['media_type']);
         }
     }
     return $collection;
 }