|
@@ 83-97 (lines=15) @@
|
| 80 |
|
$this->validator->onComplete($completeEvent, 'name'); |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
public function testMissingFieldWillThrowAnException() |
| 84 |
|
{ |
| 85 |
|
$completeEvent = m::mock(CompleteEvent::class); |
| 86 |
|
$response = m::mock('GuzzleHttp\Message\ResponseInterface'); |
| 87 |
|
$completeEvent->shouldReceive('getResponse') |
| 88 |
|
->andReturn($response); |
| 89 |
|
$response->shouldReceive('getBody')->andReturn(TestFixtures::getFixture('missing_field')); |
| 90 |
|
|
| 91 |
|
static::setExpectedException( |
| 92 |
|
'Graze\Gigya\Exception\UnknownResponseException', |
| 93 |
|
"The contents of the response could not be determined. Missing required field: 'statusReason'" |
| 94 |
|
); |
| 95 |
|
|
| 96 |
|
$this->validator->onComplete($completeEvent, 'name'); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
public function testNoBodyWillFail() |
| 100 |
|
{ |
|
@@ 115-129 (lines=15) @@
|
| 112 |
|
$this->validator->onComplete($completeEvent, 'name'); |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
public function testInvalidBody() |
| 116 |
|
{ |
| 117 |
|
$completeEvent = m::mock(CompleteEvent::class); |
| 118 |
|
$response = m::mock('GuzzleHttp\Message\ResponseInterface'); |
| 119 |
|
$completeEvent->shouldReceive('getResponse') |
| 120 |
|
->andReturn($response); |
| 121 |
|
$response->shouldReceive('getBody')->andReturn(TestFixtures::getFixture('invalid_json')); |
| 122 |
|
|
| 123 |
|
static::setExpectedException( |
| 124 |
|
'Graze\Gigya\Exception\UnknownResponseException', |
| 125 |
|
'The contents of the response could not be determined. Could not decode the body' |
| 126 |
|
); |
| 127 |
|
|
| 128 |
|
$this->validator->onComplete($completeEvent, 'name'); |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
public function testUnknownResponseContainsTheOriginalResponse() |
| 132 |
|
{ |