Ejemplo n.º 1
0
 /**
  * @test
  */
 public function shouldBeAbleToSetFactories()
 {
     $this->setUp();
     $factory = new TvFactory();
     $class = new \stdClass();
     $factory->setCastFactory($class);
     $factory->setCrewFactory($class);
     $factory->setGenreFactory($class);
     $factory->setImageFactory($class);
     $factory->setTvSeasonFactory($class);
     $this->assertInstanceOf('stdClass', $factory->getCastFactory());
     $this->assertInstanceOf('stdClass', $factory->getCrewFactory());
     $this->assertInstanceOf('stdClass', $factory->getGenreFactory());
     $this->assertInstanceOf('stdClass', $factory->getImageFactory());
     $this->assertInstanceOf('stdClass', $factory->getTvSeasonFactory());
     $model = new Tv();
     $model->setCredits($class);
     $this->assertInstanceOf('stdClass', $model->getCredits());
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }