Skip to content

Commit

Permalink
Fix broken AppTest
Browse files Browse the repository at this point in the history
Due to the request being called in the router creation process the tests
failed, because you cannot overwrite request once it had been created
  • Loading branch information
JoeBengalen committed Aug 16, 2015
1 parent 78678de commit 32d45fb
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/AppTest.php
Expand Up @@ -760,16 +760,6 @@ public function testExceptionErrorHandler()
{
$app = new App();

$mw = function ($req, $res, $next) {
throw new \Exception('middleware exception');
};

$app->add($mw);

$app->get('/foo', function ($req, $res) {
return $res;
});

// Prepare request and response objects
$env = Environment::mock([
'SCRIPT_NAME' => '/index.php',
Expand All @@ -785,6 +775,17 @@ public function testExceptionErrorHandler()
$res = new Response();
$app->getContainer()['request'] = $req;
$app->getContainer()['response'] = $res;

$mw = function ($req, $res, $next) {
throw new \Exception('middleware exception');
};

$app->add($mw);

$app->get('/foo', function ($req, $res) {
return $res;
});

$resOut = $app->run();

$this->assertEquals(500, $resOut->getStatusCode());
Expand Down

0 comments on commit 32d45fb

Please sign in to comment.