コード例 #1
0
ファイル: MovieTest.php プロジェクト: n10ty/api
 /**
  * @test
  */
 public function shouldAllowOverridingDefaultCollectionObjects()
 {
     $movie = new Movie();
     $class = new ResultCollection();
     $className = get_class($class);
     $movie->setChanges($class);
     $movie->setProductionCompanies($class);
     $movie->setProductionCountries($class);
     $movie->setSpokenLanguages($class);
     $movie->setCredits(new CreditsCollection());
     $movie->setLists($class);
     $movie->setVideos($class);
     $this->assertInstancesOf($movie, array('getChanges' => $className, 'getProductionCompanies' => $className, 'getProductionCountries' => $className, 'getSpokenLanguages' => $className, 'getCredits' => 'Tmdb\\Model\\Collection\\CreditsCollection', 'getLists' => $className, 'getVideos' => $className));
 }
コード例 #2
0
 /**
  * @test
  */
 public function shouldGetProfileImages()
 {
     $cast = $this->movie->getCredits()->getCast();
     /**
      * @var CastMember $c
      */
     foreach ($cast as $c) {
         if ($c->hasProfileImage()) {
             $filePath = $c->getProfileImage()->getFilePath();
             $this->assertEquals(false, empty($filePath));
         } else {
             $this->assertEquals(null, $c->getProfileImage());
         }
     }
 }
コード例 #3
0
 /**
  * @param FixtureMovieData $f
  * @param Movie            $m
  */
 private function writeLookupSuccessMovie(FixtureMovieData $f, Movie $m)
 {
     try {
         $fileSize = $f->getFile()->getSizeHuman();
     } catch (\RuntimeException $e) {
         $fileSize = 'UNKNOWN';
         $this->io()->warning(sprintf('An error occured while retrieving the file size for %s', $f->getFile()->getPathname()));
     }
     $rows = [['Tvdb Id', $m->getId() . ($m->getImdbId() === null ? '' : '/' . $m->getImdbId())], ['File Path', $f->getFile()->getPathname()], ['Movie Title', $m->getTitle()], ['Release Date', $m->getReleaseDate()->format('Y\\-m\\-d')], ['Size', $fileSize], ['API Match', sprintf('<fg=green>OKAY: %d</>', $m->getId())]];
     $this->ioVerbose(function (StyleInterface $style) use($rows) {
         $style->table($rows, []);
     });
     $rows = [['File Path', $f->getFile()->getPathname()], ['Movie Title', $m->getTitle()], ['Release Date', $m->getReleaseDate()->format('Y\\-m\\-d')], ['Size', $fileSize], ['API Match', sprintf('<fg=green>OKAY: %d</>', $m->getId())]];
     $this->ioNotVerbose(function (StyleInterface $style) use($rows) {
         $style->table($rows, []);
     });
 }
コード例 #4
0
 /**
  * @test
  */
 public function shouldWatchlistMovieObject()
 {
     $repository = $this->getRepositoryWithMockedHttpAdapter();
     $this->getAdapter()->expects($this->once())->method('post')->with($this->getRequest('account/' . self::ACCOUNT_ID . '/watchlist', [], 'POST', [], ['media_id' => self::MOVIE_ID, 'media_type' => 'movie', 'watchlist' => true]));
     $movie = new Movie();
     $movie->setId(self::MOVIE_ID);
     $repository->watchlist(self::ACCOUNT_ID, $movie, true);
 }
コード例 #5
0
ファイル: MovieFactory.php プロジェクト: nioc/ampache
 /**
  * @param  array $data
  * @return Movie
  */
 public function create(array $data = array())
 {
     if (!$data) {
         return null;
     }
     $movie = new Movie();
     if (array_key_exists('alternative_titles', $data) && array_key_exists('titles', $data['alternative_titles'])) {
         $movie->setAlternativeTitles($this->createGenericCollection($data['alternative_titles']['titles'], new Movie\AlternativeTitle()));
     }
     if (array_key_exists('credits', $data)) {
         if (array_key_exists('cast', $data['credits'])) {
             $movie->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast']));
         }
         if (array_key_exists('crew', $data['credits'])) {
             $movie->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew']));
         }
     }
     /** Genres */
     if (array_key_exists('genres', $data)) {
         $movie->setGenres($this->getGenreFactory()->createCollection($data['genres']));
     }
     /** Images */
     if (array_key_exists('backdrop_path', $data)) {
         $movie->setBackdropImage($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
     }
     if (array_key_exists('images', $data)) {
         $movie->setImages($this->getImageFactory()->createCollectionFromMovie($data['images']));
     }
     if (array_key_exists('poster_path', $data)) {
         $movie->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
     }
     /** Keywords */
     if (array_key_exists('keywords', $data)) {
         $movie->setKeywords($this->getKeywordFactory()->createCollection($data['keywords']));
     }
     if (array_key_exists('releases', $data) && array_key_exists('countries', $data['releases'])) {
         $movie->setReleases($this->createGenericCollection($data['releases']['countries'], new Movie\Release()));
     }
     /**
      * @TODO actually implement more providers?
      * ( Can't seem to find any quicktime related trailers anyways? ). For now KISS
      */
     if (array_key_exists('trailers', $data) && array_key_exists('youtube', $data['trailers'])) {
         $movie->setTrailers($this->createGenericCollection($data['trailers']['youtube'], new Youtube()));
     }
     if (array_key_exists('videos', $data)) {
         $movie->setVideos($this->getVideoFactory()->createCollection($data['videos']));
     }
     if (array_key_exists('translations', $data) && array_key_exists('translations', $data['translations'])) {
         $movie->setTranslations($this->createGenericCollection($data['translations']['translations'], new Translation()));
     }
     if (array_key_exists('similar_movies', $data)) {
         $movie->setSimilarMovies($this->createResultCollection($data['similar_movies']));
     }
     if (array_key_exists('reviews', $data)) {
         $movie->setReviews($this->getReviewFactory()->createResultCollection($data['reviews']));
     }
     if (array_key_exists('lists', $data)) {
         $movie->setLists($this->getListItemFactory()->createResultCollection($data['lists']));
     }
     if (array_key_exists('changes', $data)) {
         $movie->setChanges($this->getChangeFactory()->createCollection($data['changes']));
     }
     if (array_key_exists('production_companies', $data)) {
         $movie->setProductionCompanies($this->createGenericCollection($data['production_companies'], new Company()));
     }
     if (array_key_exists('production_countries', $data)) {
         $movie->setProductionCountries($this->createGenericCollection($data['production_countries'], new Country()));
     }
     return $this->hydrate($movie, $data);
 }
コード例 #6
0
ファイル: AccountRepositoryTest.php プロジェクト: n10ty/api
 /**
  * @test
  */
 public function shouldWatchlistMovieObject()
 {
     $repository = $this->getRepositoryWithMockedHttpClient();
     $movie = new Movie();
     $movie->setId(self::MOVIE_ID);
     $repository->watchlist(self::ACCOUNT_ID, $movie, true);
 }
コード例 #7
0
 /**
  * @param  array $data
  * @return Movie
  */
 public function create(array $data = [])
 {
     if (!$data) {
         return null;
     }
     $movie = new Movie();
     if (array_key_exists('alternative_titles', $data) && array_key_exists('titles', $data['alternative_titles'])) {
         $movie->setAlternativeTitles($this->createGenericCollection($data['alternative_titles']['titles'], new Movie\AlternativeTitle()));
     }
     if (array_key_exists('credits', $data)) {
         if (array_key_exists('cast', $data['credits'])) {
             $movie->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast']));
         }
         if (array_key_exists('crew', $data['credits'])) {
             $movie->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew']));
         }
     }
     /** Genres */
     if (array_key_exists('genres', $data)) {
         $movie->setGenres($this->getGenreFactory()->createCollection($data['genres']));
     }
     /** Genres */
     if (array_key_exists('genre_ids', $data)) {
         $formattedData = [];
         foreach ($data['genre_ids'] as $genreId) {
             $formattedData[] = ['id' => $genreId];
         }
         $movie->setGenres($this->getGenreFactory()->createCollection($formattedData));
     }
     /** Images */
     if (array_key_exists('backdrop_path', $data)) {
         $movie->setBackdropImage($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
     }
     if (array_key_exists('images', $data)) {
         $movie->setImages($this->getImageFactory()->createCollectionFromMovie($data['images']));
     }
     if (array_key_exists('poster_path', $data)) {
         $movie->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
     }
     /** Keywords */
     if (array_key_exists('keywords', $data)) {
         $movie->setKeywords($this->getKeywordFactory()->createCollection($data['keywords']));
     }
     if (array_key_exists('releases', $data) && array_key_exists('countries', $data['releases'])) {
         $movie->setReleases($this->createGenericCollection($data['releases']['countries'], new Movie\Release()));
     }
     if (array_key_exists('videos', $data)) {
         $movie->setVideos($this->getVideoFactory()->createCollection($data['videos']));
     }
     if (array_key_exists('translations', $data) && array_key_exists('translations', $data['translations'])) {
         $movie->setTranslations($this->createGenericCollection($data['translations']['translations'], new Translation()));
     }
     if (array_key_exists('similar', $data)) {
         $movie->setSimilar($this->createResultCollection($data['similar']));
     }
     if (array_key_exists('reviews', $data)) {
         $movie->setReviews($this->getReviewFactory()->createResultCollection($data['reviews']));
     }
     if (array_key_exists('lists', $data)) {
         $movie->setLists($this->getListItemFactory()->createResultCollection($data['lists']));
     }
     if (array_key_exists('changes', $data)) {
         $movie->setChanges($this->getChangeFactory()->createCollection($data['changes']));
     }
     if (array_key_exists('production_companies', $data)) {
         $movie->setProductionCompanies($this->createGenericCollection($data['production_companies'], new Company()));
     }
     if (array_key_exists('production_countries', $data)) {
         $movie->setProductionCountries($this->createGenericCollection($data['production_countries'], new Country()));
     }
     if (array_key_exists('spoken_languages', $data)) {
         $movie->setSpokenLanguages($this->createGenericCollection($data['spoken_languages'], new SpokenLanguage()));
     }
     return $this->hydrate($movie, $data);
 }