Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
thellimist committed Jul 29, 2016
1 parent cd704ee commit a7775b1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/Test/API/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,37 @@ public function testResponseOkReturnsTrueForValidResponse()

$this->assertTrue($this->mockClientAPI->responseOk($v4APIResponse));
}

public function testGetErrorMessageSuccess()
{
$errorMessage = 'I am an error message';

$error = $this->getMockBuilder('GuzzleHttp\Exception\RequestException')
->disableOriginalConstructor()
->setMethods(array('getResponse', 'getBody', 'getMessage'))
->getMock();

$errorJSON = json_encode(
array(
'success' => false,
'errors' => array(
array(
'message' => $errorMessage,
),
),
)
);

$error->expects($this->any())
->method('getMessage')
->will($this->returnValue('Not this message'));
$error->expects($this->any())
->method('getResponse')
->will($this->returnSelf());
$error->expects($this->any())
->method('getBody')
->will($this->returnValue($errorJSON));

$this->assertEquals($errorMessage, $this->mockClientAPI->getErrorMessage($error));
}
}

0 comments on commit a7775b1

Please sign in to comment.