From 15913fdf79b8e41049e3263e5e27e6690effc65e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 20 Dec 2013 18:13:53 +0100 Subject: [ticket/11997] Move expected redirect returns to controller and output to HTML The controller will now output the expected redirect returns the same way the redirect returns are output. The extension controller test will compare those 2 outputs. PHPBB3-11997 --- tests/functional/extension_controller_test.php | 27 ++++------ .../fixtures/ext/foo/bar/controller/controller.php | 61 +++++++++++++++++----- .../styles/prosilver/template/redirect_body.html | 3 ++ 3 files changed, 63 insertions(+), 28 deletions(-) diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index ab90223c48..5127aa7f47 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -121,23 +121,18 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $this->phpbb_extension_manager->enable('foo/bar'); $crawler = self::request('GET', 'app.php/foo/redirect'); - $test_redirects = array( - 'index.php', - 'index.php', - 'tests/index.php', - 'tests/index.php', - 'app.php/index', - 'app.php/index', - 'app.php/index', - 'app.php/tests/index', - 'app.php/tests/index', - 'app.php/tests/index', - 'app.php/tests/index', - ); - - foreach ($test_redirects as $row_num => $redirect) + $nodes = $crawler->filter('div')->extract(array('id')); + + foreach ($nodes as $redirect) { - $this->assertContains($filesystem->clean_path(self::$root_url) . $redirect, $crawler->filter('#redirect_' . $row_num)->text()); + if (strpos($redirect, 'redirect_expected') !== 0) + { + continue; + } + + $row_num = str_replace('redirect_expected_', '', $redirect); + + $this->assertContains($filesystem->clean_path(self::$root_url) . $crawler->filter('#redirect_expected_' . $row_num)->text(), $crawler->filter('#redirect_' . $row_num)->text()); } $this->phpbb_extension_manager->purge('foo/bar'); diff --git a/tests/functional/fixtures/ext/foo/bar/controller/controller.php b/tests/functional/fixtures/ext/foo/bar/controller/controller.php index ebb259af2f..18ec756d3c 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php @@ -41,23 +41,60 @@ class controller public function redirect() { $redirects = array( - append_sid($this->root_path . 'index.' . $this->php_ext), - append_sid($this->root_path . '../index.' . $this->php_ext), - append_sid($this->root_path . 'tests/index.' . $this->php_ext), - append_sid($this->root_path . '../tests/index.' . $this->php_ext), - $this->helper->url('index'), - $this->helper->url('../index'), - $this->helper->url('../../index'), - $this->helper->url('tests/index'), - $this->helper->url('../tests/index'), - $this->helper->url('../../tests/index'), - $this->helper->url('../tests/../index'), + array( + append_sid($this->root_path . 'index.' . $this->php_ext), + 'index.php', + ), + array( + append_sid($this->root_path . '../index.' . $this->php_ext), + 'index.php', + ), + array( + append_sid($this->root_path . 'tests/index.' . $this->php_ext), + 'tests/index.php', + ), + array( + append_sid($this->root_path . '../tests/index.' . $this->php_ext), + 'tests/index.php', + ), + array( + $this->helper->url('index'), + 'app.php/index', + ), + array( + $this->helper->url('../index'), + 'app.php/index', + ), + array( + $this->helper->url('../../index'), + 'app.php/index', + ), + array( + $this->helper->url('tests/index'), + 'app.php/tests/index', + ), + array( + $this->helper->url('../tests/index'), + 'app.php/tests/index', + ), + array( + $this->helper->url('../../tests/index'), + 'app.php/tests/index', + ), + array( + $this->helper->url('../tests/../index'), + 'app.php/tests/index', + ), ); foreach ($redirects as $redirect) { $this->template->assign_block_vars('redirects', array( - 'URL' => redirect($redirect, true), + 'URL' => redirect($redirect[0], true), + )); + + $this->template->assign_block_vars('redirects_expected', array( + 'URL' => $redirect[1], )); } diff --git a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/redirect_body.html b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/redirect_body.html index 0c261f10ea..2b70b0fe59 100644 --- a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/redirect_body.html +++ b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/redirect_body.html @@ -2,4 +2,7 @@
{redirects.URL}
+ +
{redirects_expected.URL}
+ -- cgit v1.2.1