mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 08:47:45 +02:00
[feature/controller] Check for proper status codes from controllers
PHPBB3-10864
This commit is contained in:
@@ -116,11 +116,20 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||
{
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
$crawler = $this->request('GET', 'app.php?controller=foo/baz');
|
||||
$this->assertEquals(404, $this->client->getResponse()->getStatus());
|
||||
$this->assertEquals(500, $this->client->getResponse()->getStatus());
|
||||
$this->assertContains('Missing value for argument #1: test in class phpbb_ext_foo_bar_controller:baz', $crawler->filter('body')->text());
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
}
|
||||
|
||||
public function test_exception_thrown_status_code()
|
||||
{
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
$crawler = $this->request('GET', 'app.php?controller=foo/exception');
|
||||
$this->assertEquals(500, $this->client->getResponse()->getStatus());
|
||||
$this->assertContains('Exception thrown from foo/exception route', $crawler->filter('body')->text());
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the error produced by extension at ./ext/does/not/exist.
|
||||
*
|
||||
@@ -133,6 +142,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||
public function test_error_ext_disabled_or_404()
|
||||
{
|
||||
$crawler = $this->request('GET', 'app.php?controller=does/not/exist');
|
||||
// This is 500 response because the exception is thrown from within Symfony
|
||||
// and does not provide a exception code, so we assign it 500 by default
|
||||
$this->assertEquals(404, $this->client->getResponse()->getStatus());
|
||||
$this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
|
||||
}
|
||||
|
Reference in New Issue
Block a user