From 4ab178f3efd2ec497081bc1b3e57e4566d2eee6d Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 15 Nov 2012 08:19:40 -0500 Subject: [ticket/11202] Add a heuristic function to check for response success. This tries to account for php sending fatal errors with 200 status code. PHPBB3-11202 --- tests/test_framework/phpbb_functional_test_case.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d35913e415..09f52effec 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -182,7 +182,7 @@ class phpbb_functional_test_case extends phpbb_test_case $login = $this->client->submit($form, array('username' => 'admin', 'password' => 'admin')); $cookies = $this->cookieJar->all(); - + // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie foreach ($cookies as $cookie); { @@ -229,4 +229,19 @@ class phpbb_functional_test_case extends phpbb_test_case return call_user_func_array('sprintf', $args); } + + /** + * Heuristic function to check that the response is success. + * + * When php decides to die with a fatal error, it still sends 200 OK + * status code. This assertion tries to catch that. + * + * @param string $message Optional failure message + */ + public function assert_response_success($message = null) + { + $this->assertEquals(200, $this->client->getResponse()->getStatus()); + $content = $this->client->getResponse()->getContent(); + $this->assertNotContains('Fatal error:', $content); + } } -- cgit v1.2.1 From dc61fd1091d7cf7994eb1559691c4dfabec740f5 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 15 Nov 2012 08:20:07 -0500 Subject: [ticket/11202] Check response success before content assertions. This does not change tests that perform requests which are either clearly not supposed to succeed or are a gray area. PHPBB3-11202 --- tests/functional/browse_test.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index 26c18c4c1f..b5748059c6 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -15,18 +15,21 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case public function test_index() { $crawler = $this->request('GET', 'index.php'); + $this->assert_response_success(); $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); } public function test_viewforum() { $crawler = $this->request('GET', 'viewforum.php?f=2'); + $this->assert_response_success(); $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); } public function test_viewtopic() { $crawler = $this->request('GET', 'viewtopic.php?t=1'); + $this->assert_response_success(); $this->assertGreaterThan(0, $crawler->filter('.postbody')->count()); } } -- cgit v1.2.1 From af7ab2d3ac287db1a2c9ed623e21393cb429203f Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 15 Nov 2012 08:40:29 -0500 Subject: [ticket/11202] Custom message does not make sense here, delete it. PHPBB3-11202 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 09f52effec..de04783bce 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -236,9 +236,9 @@ class phpbb_functional_test_case extends phpbb_test_case * When php decides to die with a fatal error, it still sends 200 OK * status code. This assertion tries to catch that. * - * @param string $message Optional failure message + * @return null */ - public function assert_response_success($message = null) + public function assert_response_success() { $this->assertEquals(200, $this->client->getResponse()->getStatus()); $content = $this->client->getResponse()->getContent(); -- cgit v1.2.1