Пример #1
0
 /**
  * Get the expected request that will deliver a response
  *
  * @param $path
  * @param  array   $parameters
  * @param  string  $method
  * @param  array   $headers
  * @param  null    $body
  * @return Request
  */
 protected function getRequest($path, $parameters = [], $method = 'GET', $headers = [], $body = null)
 {
     if ($method == 'POST' || $method == 'PUT' || $method == 'PATCH' || $method == 'DELETE') {
         $headers['Content-Type'] = 'application/json';
     }
     $parameters['api_key'] = 'abcdef';
     $headers['Accept'] = 'application/json';
     $headers['User-Agent'] = sprintf('wtfzdotnet/php-tmdb-api (v%s)', Client::VERSION);
     $request = new Request($path, $method, new ParameterBag($parameters), new ParameterBag($headers));
     $request->setOptions(new ParameterBag(['token' => new ApiToken('abcdef'), 'secure' => true, 'cache' => ['enabled' => true, 'handler' => new FilesystemCache(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-tmdb-api'), 'path' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-tmdb-api', 'subscriber' => null], 'log' => ['enabled' => false, 'level' => 'debug', 'handler' => null, 'path' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-tmdb-api.log', 'subscriber' => null], 'adapter' => $this->getMock('Tmdb\\HttpClient\\Adapter\\AdapterInterface'), 'host' => 'api.themoviedb.org/3/', 'base_url' => 'https://api.themoviedb.org/3/', 'session_token' => null, 'event_dispatcher' => $this->eventDispatcher]));
     if ($body !== null) {
         $request->setBody(is_array($body) ? json_encode($body) : $body);
     }
     return $request;
 }
Пример #2
0
 /**
  * @test
  */
 public function doesSetGetOptions()
 {
     $request = new Request();
     $request->setOptions(new ParameterBag(['api_key' => new ApiToken('abcdef')]));
     $this->assertEquals(new ApiToken('abcdef'), $request->getOptions()->get('api_key'));
 }