Skip to content

Commit

Permalink
Add more tests for client
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessel Strengholt committed Dec 20, 2016
1 parent bc9a237 commit 8b932c3
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Tests/Shivella/Bitly/Client/BitlyClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,49 @@ public function testGetUrlInvalidResponse()
$this->bitlyClient->getUrl('https:www.test.com/foo');
}

/**
* @expectedException \Shivella\Bitly\Exceptions\InvalidResponseException
*/
public function testGetUrlInvalidResponseNotFound()
{
$this->guzzle->expects($this->once())
->method('send')
->willReturn($this->response);

$this->response->expects($this->exactly(2))
->method('getStatusCode')
->willReturn(400);

$this->response->expects($this->never())
->method('getBody');

$this->bitlyClient->getUrl('https:www.test.com/foo');
}

/**
* @expectedException \Shivella\Bitly\Exceptions\InvalidResponseException
*/
public function testGetUrlInvalidResponseInvalidStatusCodeResponse()
{
$this->guzzle->expects($this->once())
->method('send')
->willReturn($this->response);

$this->response->expects($this->exactly(2))
->method('getStatusCode')
->willReturn(200);

$this->response->expects($this->once())
->method('getBody')
->willReturn($this->stream);

$this->stream->expects($this->once())
->method('getContents')
->willReturn(file_get_contents(__DIR__ . '/response_statuscode.json'));

$this->bitlyClient->getUrl('https:www.test.com/foo');
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|Request
*/
Expand Down

0 comments on commit 8b932c3

Please sign in to comment.