Skip to content

Commit

Permalink
Bubble up exception if it is clearly to be not swallowed away.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Scherer committed Apr 27, 2015
1 parent 89b0a2f commit 82b6100
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/TestSuite/IntegrationTestCase.php
Expand Up @@ -50,6 +50,13 @@ abstract class IntegrationTestCase extends TestCase
*/
protected $_response;

/**
* The exception being thrown if the case.
*
* @var \Cake\Core\Exception\Exception
*/
protected $_exception;

/**
* Session data to use in the next request.
*
Expand Down Expand Up @@ -115,6 +122,7 @@ public function tearDown()
$this->_session = [];
$this->_cookie = [];
$this->_response = null;
$this->_exception = null;
$this->_controller = null;
$this->_viewName = null;
$this->_layoutName = null;
Expand Down Expand Up @@ -280,6 +288,7 @@ protected function _sendRequest($url, $method, $data = [])
} catch (\PHPUnit_Exception $e) {
throw $e;
} catch (\Exception $e) {
$this->_exception = $e;
$this->_handleError($e);
}
}
Expand Down Expand Up @@ -445,6 +454,11 @@ protected function _assertStatus($min, $max, $message)
$this->fail('No response set, cannot assert status code.');
}
$status = $this->_response->statusCode();

if ($this->_exception && ($status < $min || $status > $max)) {
throw $this->_exception;
}

$this->assertGreaterThanOrEqual($min, $status, $message);
$this->assertLessThanOrEqual($max, $status, $message);
}
Expand Down

0 comments on commit 82b6100

Please sign in to comment.