/** * @expectedException \RuntimeException */ public function testGetUrlBodyError() { $guzzleResponse = $this->getMock('\\Psr\\Http\\Message\\ResponseInterface'); $guzzleResponse->method('getStatusCode')->will($this->returnValue(404)); $guzzleResponse->method('getBody')->will($this->returnValue('mock')); $this->httpClient->method('request')->will($this->returnValue($guzzleResponse)); $this->client->getUrlBody('http://google.com/notfound'); }
/** * Test Guzzle with exception logged */ public function testExceptionMessageLoggedOnDownload() { $message = uniqid(); $exception = new Exception($message); $this->guzzle->method('send')->will($this->throwException($exception)); $logger = $this->getMock('\\Psr\\Log\\LoggerInterface'); $spy = $this->any(); $logger->expects($spy)->method('warning'); $this->fixture->setLogger($logger); $this->fixture->download(); $invocationList = $spy->getInvocations(); $firstWarning = $invocationList[0]->parameters[0]; $secondWarning = $invocationList[1]->parameters[0]; $this->assertEquals('Client response was not a success', $firstWarning); $this->assertEquals('0: `' . $message . '`', $secondWarning); }