Skip to content

Commit

Permalink
Fixed exception test to expect a guzzle exception to be thrown.
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhenry committed Jun 22, 2015
1 parent 6781634 commit 6bfbe90
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions api/tests/json/ExceptionTest.php
@@ -1,6 +1,7 @@
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\ServerException;

class RestExceptionTest extends TestCase
{
Expand Down Expand Up @@ -62,15 +63,21 @@ public function testFatalError()
'base_url' => 'http://'.$webhostIp.':8080'
]);

$jsonResponse = $request->get('/test/fatal-error');

$object = json_decode($jsonResponse);
try {
$request->get('/test/fatal-error');
$this->fail('Expected exception GuzzleHttp\Exception\ServerException not thrown');
} catch (ServerException $e) {
$response = $e->getResponse();

$this->assertTrue(is_object($object), 'Response is an object');
$object = json_decode($response->getBody());

$this->assertObjectHasAttribute('message', $object);
$this->assertTrue(is_string($object->message), 'message attribute is text');
$this->assertTrue(is_object($object), 'Response is an object');

$this->assertObjectHasAttribute('message', $object);
$this->assertTrue(is_string($object->message), 'message attribute is text');

}

}

Expand Down

0 comments on commit 6bfbe90

Please sign in to comment.