From 277e9a7a850165b002901926838d6cee1bec0f57 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 24 Jun 2014 18:49:31 +0200 Subject: [ticket/9801] Add viewonline_helper service to allow proper testing The viewonline_helper service can and will be extended in the future which will allow us to also test the viewonline page better. PHPBB3-9801 --- tests/viewonline/helper_test.php | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/viewonline/helper_test.php (limited to 'tests/viewonline/helper_test.php') diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php new file mode 100644 index 0000000000..e4950bb51a --- /dev/null +++ b/tests/viewonline/helper_test.php @@ -0,0 +1,42 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +class phpbb_viewonline_helper_test extends phpbb_test_case +{ + public function setUp() + { + parent::setUp(); + + $this->viewonline_helper = new \phpbb\viewonline_helper(); + } + + public function session_pages_data() + { + return array( + array('index.php', 'index.php'), + array('foobar/test.php', 'foobar/test.php'), + array('', ''), + array('../index.php', '../index.php'), + ); + } + + /** + * @dataProvider session_pages_data + */ + public function test_get_user_page($expected, $session_page) + { + $on_page = $this->viewonline_helper->get_user_page($session_page); + $this->assertArrayHasKey(1, $on_page); + $this->assertSame($expected, $on_page[1]); + } +} -- cgit v1.2.1 From 633a5177915682492f90499ebb53fc0d87c15785 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 8 Jul 2014 17:53:06 +0200 Subject: [ticket/12834] Fix tests to match what we want to have PHPBB3-12834 --- tests/viewonline/helper_test.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tests/viewonline/helper_test.php') diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php index e4950bb51a..2c903c6b23 100644 --- a/tests/viewonline/helper_test.php +++ b/tests/viewonline/helper_test.php @@ -23,17 +23,21 @@ class phpbb_viewonline_helper_test extends phpbb_test_case public function session_pages_data() { return array( - array('index.php', 'index.php'), - array('foobar/test.php', 'foobar/test.php'), + array('index.php', 'index'), + array('foobar/test.php', 'foobar/test'), array('', ''), - array('../index.php', '../index.php'), + array('./../../index.php', '../../index'), + array('../subdir/index.php', '../subdir/index'), + array('../index.php', '../index'), + array('././index.php', 'index'), + array('./index.php', 'index'), ); } /** * @dataProvider session_pages_data */ - public function test_get_user_page($expected, $session_page) + public function test_get_user_page($session_page, $expected) { $on_page = $this->viewonline_helper->get_user_page($session_page); $this->assertArrayHasKey(1, $on_page); -- cgit v1.2.1 From e3e236da72f9bb8985fcecc25758c98559f76179 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 8 Jul 2014 17:53:32 +0200 Subject: [ticket/12834] Correctly match directories in session page Also clean path before working with it PHPBB3-12834 --- tests/viewonline/helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/viewonline/helper_test.php') diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php index 2c903c6b23..bbbed59de7 100644 --- a/tests/viewonline/helper_test.php +++ b/tests/viewonline/helper_test.php @@ -17,7 +17,7 @@ class phpbb_viewonline_helper_test extends phpbb_test_case { parent::setUp(); - $this->viewonline_helper = new \phpbb\viewonline_helper(); + $this->viewonline_helper = new \phpbb\viewonline_helper(new \phpbb\filesystem()); } public function session_pages_data() -- cgit v1.2.1