public function setUp()
 {
     $client = new Client(new ApiToken('abcdef'));
     $factory = new \Tmdb\Factory\ConfigurationFactory($client->getHttpClient());
     $data = $this->loadByFile('configuration/get.json');
     $configuration = $factory->create($data);
     $this->helper = new \Tmdb\Helper\ImageHelper($configuration);
 }
Example #2
0
 /**
  * Get a TMDB Client with an mocked HTTP dependency
  *
  * @return \Tmdb\Client
  */
 protected function getClientWithMockedHttpClient()
 {
     $token = new ApiToken('abcdef');
     $httpClient = $this->getMockedHttpClient();
     $httpClient->expects($this->any())->method('send');
     $mock = $this->getMock('Tmdb\\HttpClient\\HttpClientInterface', array(), array(array(), $httpClient));
     $client = new \Tmdb\Client($token, $httpClient);
     $client->setHttpClient($mock);
     return $client;
 }
Example #3
0
 public function setUp()
 {
     $client = new Client(new ApiToken('abcdef'));
     $this->collection = new Images();
     foreach ($this->images as $image) {
         $factory = new ImageFactory($client->getHttpClient());
         $object = $factory->create($image);
         $this->collection->addImage($object);
     }
 }
 /**
  * @todo
  */
 public function shouldBeAbleSetLogging()
 {
     $path = '/tmp/php-tmdb-api.log';
     $this->client->setLogging(true, $path);
     $this->assertEquals(true, $this->client->getLogEnabled());
     $this->assertEquals($path, $this->client->getLogPath());
 }
Example #5
0
 /**
  * Send a PATCH request
  *
  * @param $path
  * @param  null  $body
  * @param  array $parameters
  * @param  array $headers
  * @return mixed
  */
 public function patch($path, $body = null, array $parameters = array(), $headers = array())
 {
     /**
      * @var Response $response
      */
     $response = $this->client->getHttpClient()->patch($path, $body, $parameters, $headers);
     return $response->json();
 }
Example #6
0
 /**
  * @link http://help.themoviedb.org/kb/api/company-movies
  */
 public function movies($language = null, $page = 1)
 {
     $db = \TMDB\Client::getInstance();
     $movies = array();
     $info = $db->info(self::$type, $this->id, 'movies', array('language' => $language, 'page' => $page));
     foreach ($info->results as $index => $movie) {
         $movies[$movie->id] = new Movie($movie);
     }
     return $movies;
 }
Example #7
0
 /**
  * @link http://help.themoviedb.org/kb/api/person-images
  */
 public function images($size = false)
 {
     $db = \TMDB\Client::getInstance();
     $info = $db->info(self::$type, $this->id, 'images');
     foreach ($info as $type => $images) {
         if (!is_array($images)) {
             continue;
         }
         foreach ($images as $index => $data) {
             if ($size) {
                 $info->{$type}[$index]->file_path = $db->image_url(substr($type, 0, strlen($type) - 1), $size, $data->file_path);
             }
         }
     }
     return $info;
 }
Example #8
0
 /**
  * Get an image base method
  * @param unknown_type $type 'backdrop', 'poster', 'profile', 'logo', ...
  * @param unknown_type $size int or preset
  * @param unknown_type $random true or false
  * @param unknown_type $language optional language to return the image in
  */
 public function image($type, $size = false, $random = false, $language = null)
 {
     $image = false;
     $typeset = $type . 's';
     // multiple
     $path_key = $type . '_path';
     if ($random) {
         $images = $this->images($language, false);
         if (count($images) > 1) {
             $index = rand(0, count($images->{$typeset}) - 1);
             $this->{$path_key} = $images->{$typeset}[$index]->file_path;
         }
     }
     if (isset($this->{$path_key})) {
         if ($size) {
             $db = \TMDB\Client::getInstance();
             $image = $db->image_url($type, $size, $this->{$path_key});
         } else {
             $image = $this->{$path_key};
         }
     }
     return $image;
 }
Example #9
0
 /**
  * Shortcut to obtain the http client adapter
  *
  * @return \Tmdb\HttpClient\Adapter\AdapterInterface
  */
 protected function getAdapter()
 {
     return $this->_client->getHttpClient()->getAdapter();
 }
Example #10
0
 protected function getHttpClient()
 {
     return $this->client->getHttpClient();
 }
Example #11
0
 public function testGetInstance()
 {
     $instance = \TMDB\Client::getInstance();
     $this->assertInstanceOf("\\TMDB\\Client", $instance);
     $this->assertEmpty($instance->error);
 }