1010
1111namespace Phergie \Irc \Tests \Plugin \React \YouTube ;
1212
13+ use GuzzleHttp \Message \Response as Response ;
1314use Phake ;
1415use Phergie \Irc \Bot \React \EventQueueInterface as Queue ;
1516use Phergie \Irc \Plugin \React \Command \CommandEvent as Event ;
@@ -67,6 +68,7 @@ protected function setUp()
6768 $ this ->queue = Phake::mock ('\Phergie\Irc\Bot\React\EventQueueInterface ' );
6869 $ this ->emitter = Phake::mock ('\Evenement\EventEmitterInterface ' );
6970 $ this ->logger = Phake::mock ('\Psr\Log\LoggerInterface ' );
71+ $ this ->response = Phake::mock ('\GuzzleHttp\Message\Response ' );
7072 $ this ->plugin = $ this ->getPlugin ();
7173
7274 date_default_timezone_set ('America/Chicago ' );
@@ -215,8 +217,8 @@ public function testResolveWithApiError()
215217 Phake::verifyNoFurtherInteraction ($ this ->queue );
216218 $ requestConfig = $ this ->testHandleUrlWithVideoUrl ('http://youtu.be/HFuTvTVAO-M ' );
217219 $ resolve = $ requestConfig ['resolveCallback ' ];
218- $ data = '{"error":"foo"} ' ;
219- $ resolve ($ data , $ this ->event , $ this ->queue );
220+ Phake:: when ( $ this -> response )-> getBody ()-> thenReturn ( '{"error":"foo"} ' ) ;
221+ $ resolve ($ this -> response , $ this ->event , $ this ->queue );
220222 Phake::verify ($ this ->logger )->warning (
221223 'Query response contained an error ' ,
222224 array (
@@ -234,8 +236,8 @@ public function testResolveWithNoResults()
234236 Phake::verifyNoFurtherInteraction ($ this ->queue );
235237 $ requestConfig = $ this ->testHandleUrlWithVideoUrl ('http://youtu.be/HFuTvTVAO-M ' );
236238 $ resolve = $ requestConfig ['resolveCallback ' ];
237- $ data = file_get_contents (__DIR__ . '/_files/empty.json ' );
238- $ resolve ($ data , $ this ->event , $ this ->queue );
239+ Phake:: when ( $ this -> response )-> getBody ()-> thenReturn ( file_get_contents (__DIR__ . '/_files/empty.json ' ) );
240+ $ resolve ($ this -> response , $ this ->event , $ this ->queue );
239241 Phake::verify ($ this ->logger )->warning (
240242 'Query returned no results ' ,
241243 array (
@@ -302,8 +304,8 @@ public function testResolveWithResults(array $config, $message)
302304 Phake::when ($ this ->event )->getSource ()->thenReturn ('#channel ' );
303305 $ requestConfig = $ this ->testHandleUrlWithVideoUrl ('http://youtu.be/HFuTvTVAO-M ' );
304306 $ resolve = $ requestConfig ['resolveCallback ' ];
305- $ data = file_get_contents (__DIR__ . '/_files/success.json ' );
306- $ resolve ($ data , $ this ->event , $ this ->queue );
307+ Phake:: when ( $ this -> response )-> getBody ()-> thenReturn ( file_get_contents (__DIR__ . '/_files/success.json ' ) );
308+ $ resolve ($ this -> response , $ this ->event , $ this ->queue );
307309 Phake::verify ($ this ->queue )->ircPrivmsg ('#channel ' , $ message );
308310 }
309311
0 commit comments