/**
  * Create a basic options for
  * guzzle connection.
  *
  * @test
  */
 public function createBasicSettings()
 {
     $options = new GuzzleSettings();
     $options->setTimeout(3)->setDecodeContent(false);
     $this->assertObjectHasAttribute('settings', $options);
     $this->assertInstanceOf('\\ComicApi\\Http\\Connection\\SettingsInterface', $options);
     $this->assertEquals(['timeout' => 3, 'decode_content' => false], $options->getOptions());
 }
 /**
  * Get content from onet changing
  * timeout to 1 second.
  *
  * @test
  */
 public function getContentFromOnetWithOptions()
 {
     $options = new GuzzleSettings();
     $options->setTimeout(1);
     $request = new GuzzleConnection();
     $response = $request->createRequest('http://192.168.33.10/', 'GET', $options->getOptions());
     $this->assertNotEmpty($response->getResponse());
     $this->assertEquals(200, $response->getStatusCode());
 }
Example #3
0
 /**
  * @test
  */
 public function getSpiderManFromMarvel()
 {
     $keys = ComicAPI::createPool()->store(new Token($this->randStr(32), ComicAPI::MARVEL))->store(new Token($this->randStr(40), ComicAPI::COMICVINE));
     $options = new GuzzleSettings();
     $options->setTimeout(2);
     $options->setHeaders(['Content-type', 'application/json']);
     $mockHandler = new \GuzzleHttp\Handler\MockHandler([new \GuzzleHttp\Psr7\Response(200)]);
     $handler = \GuzzleHttp\HandlerStack::create($mockHandler);
     $connection = new GuzzleConnection($handler);
     $request = ComicAPI::createFromObject($keys)->fromMarvel($options->getOptions(), $connection)->getCharacters(['name' => 'Spider-man', 'limit' => 1]);
     $this->assertEquals(200, $request->getStatusCode());
 }