Пример #1
0
 /**
  * @test
  */
 public function shouldConstructTvSeason()
 {
     $this->assertInstanceOf('Tmdb\\Model\\Tv\\Season', $this->season);
     $this->assertInstanceOf('\\DateTime', $this->season->getAirDate());
     $this->assertInstanceOf('Tmdb\\Model\\Collection\\CreditsCollection', $this->season->getCredits());
     $this->assertInstanceOf('Tmdb\\Model\\Common\\ExternalIds', $this->season->getExternalIds());
     $this->assertInstanceOf('Tmdb\\Model\\Collection\\Images', $this->season->getImages());
     $this->assertInstanceOf('Tmdb\\Model\\Common\\GenericCollection', $this->season->getEpisodes());
     $this->assertInstanceOf('Tmdb\\Model\\Image\\PosterImage', $this->season->getPosterImage());
 }
Пример #2
0
 /**
  * @test
  */
 public function shouldBeAbleToOverrideDefaultCollections()
 {
     $season = new Season();
     $class = new \stdClass();
     $season->setCredits($class);
     $this->assertInstanceOf('stdClass', $season->getCredits());
 }
 /**
  * {@inheritdoc}
  */
 public function create(array $data = [])
 {
     if (!$data) {
         return null;
     }
     $tvSeason = new Season();
     if (array_key_exists('credits', $data)) {
         if (array_key_exists('cast', $data['credits']) && $data['credits']['cast'] !== null) {
             $tvSeason->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new CastMember()));
         }
         if (array_key_exists('crew', $data['credits']) && $data['credits']['crew'] !== null) {
             $tvSeason->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new CrewMember()));
         }
     }
     /** External ids */
     if (array_key_exists('external_ids', $data) && $data['external_ids'] !== null) {
         $tvSeason->setExternalIds($this->hydrate(new ExternalIds(), $data['external_ids']));
     }
     /** Images */
     if (array_key_exists('images', $data) && $data['images'] !== null) {
         $tvSeason->setImages($this->getImageFactory()->createCollectionFromTvSeason($data['images']));
     }
     if (array_key_exists('poster_path', $data)) {
         $tvSeason->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
     }
     /** Episodes */
     if (array_key_exists('episodes', $data) && $data['episodes'] !== null) {
         $tvSeason->setEpisodes($this->getTvEpisodeFactory()->createCollection($data['episodes']));
     }
     if (array_key_exists('videos', $data) && $data['videos'] !== null) {
         $tvSeason->setVideos($this->getVideoFactory()->createCollection($data['videos']));
     }
     if (array_key_exists('changes', $data) && $data['changes'] !== null) {
         $tvSeason->setChanges($this->getChangesFactory()->createCollection($data['changes']));
     }
     return $this->hydrate($tvSeason, $data);
 }