Skip to content

Commit

Permalink
Revert "Revert "more integration tests for fatal error""
Browse files Browse the repository at this point in the history
This reverts commit eb05207.
  • Loading branch information
samsonasik committed Sep 20, 2018
1 parent d434c0f commit f3d0028
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,24 @@
});
});

describe('/error-preview/fatal', function() {

it('show error page', function() {

$request = $this->application->getRequest();
$request->setMethod('GET');
$request->setUri('http://example.com/error-preview/fatal');
$request->setRequestUri('/error-preview/fatal');

\ob_start();
$this->application->run();
$content = \ob_get_clean();

expect($content)->toContain('<title>Error');
expect($content)->toContain('<p>We have encountered a problem and we can not fulfill your request');
expect($this->application->getResponse()->getStatusCode())->toBe(500);

});
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,24 @@
});
});

describe('/error-preview/fatal', function() {

it('show error page', function() {

$request = $this->application->getRequest();
$request->setMethod('GET');
$request->setUri('http://example.com/error-preview/fatal');
$request->setRequestUri('/error-preview/fatal');

\ob_start();
$this->application->run();
$content = \ob_get_clean();

expect($content)->toContain('<title>Error');
expect($content)->toContain('<p>We have encountered a problem and we can not fulfill your request');
expect($this->application->getResponse()->getStatusCode())->toBe(500);

});
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,55 @@

});

describe('/error-preview/fatal', function() {

it('show error page', function() {

$this->tableGateway->delete([]);
$countBefore = \count($this->tableGateway->select());

$request = $this->application->getRequest();
$request->setMethod('GET');
$request->setUri('http://example.com/error-preview/fatal');
$request->setRequestUri('/error-preview/fatal');

\ob_start();
$this->application->run();
$content = \ob_get_clean();

expect($content)->toContain('<title>Error');
expect($content)->toContain('<p>We have encountered a problem and we can not fulfill your request');

$countAfter = \count($this->tableGateway->select());

expect($countBefore)->toBe(0);
expect($countAfter)->toBe(1);

});

it('show error page, idempotent for error exist check in DB', function() {

$countBefore = \count($this->tableGateway->select());

$request = $this->application->getRequest();
$request->setMethod('GET');
$request->setUri('http://example.com/error-preview/fatal');
$request->setRequestUri('/error-preview/fatal');

\ob_start();
$this->application->run();
$content = \ob_get_clean();

expect($content)->toContain('<title>Error');
expect($content)->toContain('<p>We have encountered a problem and we can not fulfill your request');

$countAfter = \count($this->tableGateway->select());

expect($countBefore)->toBe(1);
expect($countAfter)->toBe(1);

});

});

});
20 changes: 20 additions & 0 deletions spec/Integration/IntegrationViaErrorPreviewControllerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,24 @@
});
});

describe('/error-preview/fatal', function() {

it('show error page', function() {

$request = $this->application->getRequest();
$request->setMethod('GET');
$request->setUri('http://example.com/error-preview/fatal');
$request->setRequestUri('/error-preview/fatal');

\ob_start();
$this->application->run();
$content = \ob_get_clean();

expect($content)->toContain('<title>Error');
expect($content)->toContain('<p>We have encountered a problem and we can not fulfill your request');
expect($this->application->getResponse()->getStatusCode())->toBe(500);

});
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,27 @@

});

describe('/error-preview/fatal', function() {

it('show error page for fatal error', function() {

Quit::disable();

$request = $this->application->getRequest();
$request->setMethod('GET');
$request->setUri('http://example.com/error-preview/fatal');
$request->setRequestUri('/error-preview/fatal');

\ob_start();
$this->application->run();
$content = \ob_get_clean();

expect($content)->toContain('<title>Error');
expect($content)->toContain('<p>We have encountered a problem and we can not fulfill your request');
expect($this->application->getResponse()->getStatusCode())->toBe(500);

});

});

});
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,27 @@

});

describe('/error-preview/fatal', function() {

it('show error page for fatal error', function() {

Quit::disable();

$request = $this->application->getRequest();
$request->setMethod('GET');
$request->setUri('http://example.com/error-preview/fatal');
$request->setRequestUri('/error-preview/fatal');

\ob_start();
$this->application->run();
$content = \ob_get_clean();

expect($content)->toContain('<title>Error');
expect($content)->toContain('<p>We have encountered a problem and we can not fulfill your request');
expect($this->application->getResponse()->getStatusCode())->toBe(500);

});

});

});

0 comments on commit f3d0028

Please sign in to comment.