Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #9 from phergie/dev
Browse files Browse the repository at this point in the history
Merge PR from sitedyno
  • Loading branch information
svpernova09 committed Feb 10, 2016
2 parents dd52738 + f9e4684 commit e31aba9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ protected function getApiRequest($url, Event $event, Queue $queue)
* Handles a successful request for video data.
*
* @param string $url URL of the request
* @param string $data Response body
* @param \GuzzleHttp\Message\Response $data Response body
* @param \Phergie\Irc\EventInterface $event
* @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
*/
public function resolve($url, $data, Event $event, Queue $queue)
public function resolve($url, \GuzzleHttp\Message\Response $data, Event $event, Queue $queue)
{
$logger = $this->getLogger();
$json = json_decode($data);
$json = json_decode($data->getBody());
$logger->info('resolve', array('url' => $url, 'json' => $json));

if (isset($json->error)) {
Expand Down
14 changes: 8 additions & 6 deletions tests/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Phergie\Irc\Tests\Plugin\React\YouTube;

use GuzzleHttp\Message\Response as Response;
use Phake;
use Phergie\Irc\Bot\React\EventQueueInterface as Queue;
use Phergie\Irc\Plugin\React\Command\CommandEvent as Event;
Expand Down Expand Up @@ -67,6 +68,7 @@ protected function setUp()
$this->queue = Phake::mock('\Phergie\Irc\Bot\React\EventQueueInterface');
$this->emitter = Phake::mock('\Evenement\EventEmitterInterface');
$this->logger = Phake::mock('\Psr\Log\LoggerInterface');
$this->response = Phake::mock('\GuzzleHttp\Message\Response');
$this->plugin = $this->getPlugin();

date_default_timezone_set('America/Chicago');
Expand Down Expand Up @@ -215,8 +217,8 @@ public function testResolveWithApiError()
Phake::verifyNoFurtherInteraction($this->queue);
$requestConfig = $this->testHandleUrlWithVideoUrl('http://youtu.be/HFuTvTVAO-M');
$resolve = $requestConfig['resolveCallback'];
$data = '{"error":"foo"}';
$resolve($data, $this->event, $this->queue);
Phake::when($this->response)->getBody()->thenReturn('{"error":"foo"}');
$resolve($this->response, $this->event, $this->queue);
Phake::verify($this->logger)->warning(
'Query response contained an error',
array(
Expand All @@ -234,8 +236,8 @@ public function testResolveWithNoResults()
Phake::verifyNoFurtherInteraction($this->queue);
$requestConfig = $this->testHandleUrlWithVideoUrl('http://youtu.be/HFuTvTVAO-M');
$resolve = $requestConfig['resolveCallback'];
$data = file_get_contents(__DIR__ . '/_files/empty.json');
$resolve($data, $this->event, $this->queue);
Phake::when($this->response)->getBody()->thenReturn(file_get_contents(__DIR__ . '/_files/empty.json'));
$resolve($this->response, $this->event, $this->queue);
Phake::verify($this->logger)->warning(
'Query returned no results',
array(
Expand Down Expand Up @@ -302,8 +304,8 @@ public function testResolveWithResults(array $config, $message)
Phake::when($this->event)->getSource()->thenReturn('#channel');
$requestConfig = $this->testHandleUrlWithVideoUrl('http://youtu.be/HFuTvTVAO-M');
$resolve = $requestConfig['resolveCallback'];
$data = file_get_contents(__DIR__ . '/_files/success.json');
$resolve($data, $this->event, $this->queue);
Phake::when($this->response)->getBody()->thenReturn(file_get_contents(__DIR__ . '/_files/success.json'));
$resolve($this->response, $this->event, $this->queue);
Phake::verify($this->queue)->ircPrivmsg('#channel', $message);
}

Expand Down

0 comments on commit e31aba9

Please sign in to comment.