Skip to content

Commit

Permalink
Dev: Better error message from test run
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Oct 27, 2017
1 parent 4fcbd5c commit 28c2c08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions application/core/LSYii_Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,15 @@ public function getPlugin()
*/
public function onException($event){
if(Yii::app() instanceof CWebApplication){
if($event->exception->statusCode=='404'){
Yii::app()->setComponent('errorHandler',array(
'errorAction'=>'surveys/error',
));
if (defined('PHP_ENV') && PHP_ENV == 'test') {
// If run from phpunit, die with exception message.
die($event->exception->getMessage());
} else {
if($event->exception->statusCode=='404'){
Yii::app()->setComponent('errorHandler',array(
'errorAction'=>'surveys/error',
));
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,5 @@
require_once(__DIR__ . '/TestHelper.php');
require_once(__DIR__ . '/TestBaseClass.php');
require_once(__DIR__ . '/DummyController.php');

define('PHP_ENV', 'test');

0 comments on commit 28c2c08

Please sign in to comment.