Closed svpernova09 closed 8 years ago
@svpernova09 Wowzer, it's been a while since I've used phake. Had to remind myself how it works. Mockery ftw.
So it's currently passing a json string to doResolveTest (ie https://github.com/chrismou/phergie-irc-plugin-react-google/blob/master/tests/PluginTest.php#L117) whereas now it'll need a phake object passed in, with a return value being set. Something like:
$this->apiResponse = Phake::mock('GuzzleHttp\Message\Response');
in setUp(), then something like:
$data = file_get_contents(__DIR__ . '/_data/webSearchResults.json');
Phake::when($this->apiResponse)->getBody()->thenReturn($data);
everywhere where doResolveTest is called (with the relevant json being loaded in)
Then the docblocks will need to be updated, because scrutinzer is beefing about the declared parameter types being incorrect now
Or alternatively, you could change https://github.com/chrismou/phergie-irc-plugin-react-google/commit/1d6b37355caadf676cd6e52c2fdca6ae16ae10fa#diff-f7fcf01b75ab0236c970de527853c3abR136 to pass in $response->getBody(). That'll probably still require some changes, but they'll be more centralised.
TBH, I could buy into either approach, though part of me feels like passing the json to getSuccessLines makes more sense, as there's no need for that method to concern itself with what http client is being used. It should just be able to take a json array and process it.
@chrismou Your changes in master look good. Should be good to tag a version. Thanks!
:+1: Cheers. I'll get this and the other's all sorted and tagged tomorrow
Fixes empty API responses when used with phergie/phergie-irc-plugin-react-url version 2+
Not sure how to get around the test failure since you're actually using mocked up JSON results.
Tests will currently fail because your tests are using string JSON instead of actual mocked Guzzle responses.