From a18c293739d00be2ca9bce8b6e0cb367325dee60 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 20 May 2014 11:37:42 -0700 Subject: [ticket/12564] Remove version definitions from modules in tests PHPBB3-12564 --- tests/extension/ext/vendor2/bar/acp/a_info.php | 1 - tests/extension/ext/vendor2/foo/acp/a_info.php | 1 - tests/extension/ext/vendor2/foo/acp/fail_info.php | 1 - tests/extension/ext/vendor2/foo/mcp/a_info.php | 1 - tests/extension/includes/acp/info/acp_foobar.php | 1 - tests/extension/modules_test.php | 10 ---------- tests/functional/fixtures/ext/foo/bar/acp/main_info.php | 1 - tests/functional/fixtures/ext/foo/bar/ucp/main_info.php | 1 - 8 files changed, 17 deletions(-) (limited to 'tests') diff --git a/tests/extension/ext/vendor2/bar/acp/a_info.php b/tests/extension/ext/vendor2/bar/acp/a_info.php index 8132df587f..8268006f9f 100644 --- a/tests/extension/ext/vendor2/bar/acp/a_info.php +++ b/tests/extension/ext/vendor2/bar/acp/a_info.php @@ -9,7 +9,6 @@ class a_info return array( 'filename' => 'vendor2\\bar\\acp\\a_module', 'title' => 'Bar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), ), diff --git a/tests/extension/ext/vendor2/foo/acp/a_info.php b/tests/extension/ext/vendor2/foo/acp/a_info.php index e1eaa340b7..48ab4cf8e7 100644 --- a/tests/extension/ext/vendor2/foo/acp/a_info.php +++ b/tests/extension/ext/vendor2/foo/acp/a_info.php @@ -9,7 +9,6 @@ class a_info return array( 'filename' => 'vendor2\\foo\\acp\\a_module', 'title' => 'Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')), ), diff --git a/tests/extension/ext/vendor2/foo/acp/fail_info.php b/tests/extension/ext/vendor2/foo/acp/fail_info.php index d9b4353957..78479fee70 100644 --- a/tests/extension/ext/vendor2/foo/acp/fail_info.php +++ b/tests/extension/ext/vendor2/foo/acp/fail_info.php @@ -13,7 +13,6 @@ class foo_info return array( 'filename' => 'vendor2\foo\acp\fail_module', 'title' => 'Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), ), diff --git a/tests/extension/ext/vendor2/foo/mcp/a_info.php b/tests/extension/ext/vendor2/foo/mcp/a_info.php index b5599fde65..2532e44b12 100644 --- a/tests/extension/ext/vendor2/foo/mcp/a_info.php +++ b/tests/extension/ext/vendor2/foo/mcp/a_info.php @@ -9,7 +9,6 @@ class a_info return array( 'filename' => 'vendor2\\foo\\mcp\\a_module', 'title' => 'Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), ), diff --git a/tests/extension/includes/acp/info/acp_foobar.php b/tests/extension/includes/acp/info/acp_foobar.php index b89cfb9574..bb648e6ee1 100644 --- a/tests/extension/includes/acp/info/acp_foobar.php +++ b/tests/extension/includes/acp/info/acp_foobar.php @@ -17,7 +17,6 @@ class acp_foobar_info return array( 'filename' => 'acp_foobar', 'title' => 'ACP Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), ), diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index e396b7b73e..0559a7e8a0 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -58,7 +58,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'vendor2\\foo\\acp\\a_module' => array( 'filename' => 'vendor2\\foo\\acp\\a_module', 'title' => 'Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')), ), @@ -66,7 +65,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'acp_foobar' => array( 'filename' => 'acp_foobar', 'title' => 'ACP Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), ), @@ -80,7 +78,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'vendor2\\foo\\mcp\\a_module' => array( 'filename' => 'vendor2\\foo\\mcp\\a_module', 'title' => 'Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), ), @@ -94,7 +91,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'vendor2\\foo\\mcp\\a_module' => array( 'filename' => 'vendor2\\foo\\mcp\\a_module', 'title' => 'Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), ), @@ -108,7 +104,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'vendor2\\foo\\mcp\\a_module' => array( 'filename' => 'vendor2\\foo\\mcp\\a_module', 'title' => 'Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), ), @@ -132,7 +127,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'vendor2\\foo\\acp\\a_module' => array ( 'filename' => 'vendor2\\foo\\acp\\a_module', 'title' => 'Foobar', - 'version' => '3.1.0-dev', 'modes' => array ( 'config' => array ('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array ('ACP_MODS')), ), @@ -156,7 +150,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'vendor2\\foo\\acp\\a_module' => array( 'filename' => 'vendor2\\foo\\acp\\a_module', 'title' => 'Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')), ), @@ -164,7 +157,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'acp_foobar' => array( 'filename' => 'acp_foobar', 'title' => 'ACP Foobar', - 'version' => '3.1.0-dev', 'modes' => array( 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), ), @@ -172,7 +164,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'vendor2\\bar\\acp\\a_module' => array( 'filename' => 'vendor2\\bar\\acp\\a_module', 'title' => 'Bar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), ), @@ -185,7 +176,6 @@ class phpbb_extension_modules_test extends phpbb_test_case 'vendor2\\bar\\acp\\a_module' => array( 'filename' => 'vendor2\\bar\\acp\\a_module', 'title' => 'Bar', - 'version' => '3.1.0-dev', 'modes' => array( 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), ), diff --git a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php index 2ad6d08503..c6d801881f 100644 --- a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php +++ b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php @@ -25,7 +25,6 @@ class main_info return array( 'filename' => 'foo\bar\acp\main_module', 'title' => 'ACP_FOOBAR_TITLE', - 'version' => '1.0.0', 'modes' => array( 'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')), ), diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php index 2ba37f3050..fdf9cc3241 100644 --- a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php +++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php @@ -17,7 +17,6 @@ class main_info return array( 'filename' => '\foo\bar\ucp\main_module', 'title' => 'ACP_FOOBAR_TITLE', - 'version' => '1.0.0', 'modes' => array( 'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')), ), -- cgit v1.2.1 From 192b8e2568f499aa2ead98a24d8dd5541b1f315a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 2 Aug 2014 19:09:42 +0200 Subject: [ticket/11649] Expose Twig through the container PHPBB3-11649 --- tests/controller/helper_route_test.php | 23 ++++++++++++++- tests/extension/metadata_manager_test.php | 38 +++++++++++++++++-------- tests/template/template_events_test.php | 23 ++++++++++++++- tests/template/template_test_case.php | 22 +++++++++++++- tests/template/template_test_case_with_tree.php | 22 +++++++++++++- 5 files changed, 112 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/controller/helper_route_test.php b/tests/controller/helper_route_test.php index 206c3a4f0b..8113bd0018 100644 --- a/tests/controller/helper_route_test.php +++ b/tests/controller/helper_route_test.php @@ -31,7 +31,28 @@ class phpbb_controller_helper_route_test extends phpbb_test_case $phpEx ); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, new \phpbb\template\context()); + + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $this->config, + $phpbb_path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', array( diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 535e4fe0d5..fdb9deda53 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -47,20 +47,35 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->user = new \phpbb\user(); $this->table_prefix = 'phpbb_'; - $this->template = new \phpbb\template\twig\twig( - new \phpbb\path_helper( - new \phpbb\symfony_request( - new phpbb_mock_request() - ), - new \phpbb\filesystem(), - $this->getMock('\phpbb\request\request'), - $this->phpbb_root_path, - $this->phpEx + $container = new phpbb_mock_container_builder(); + $cache_path = $this->phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $phpbb_path_helper =new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() ), + new \phpbb\filesystem(), + $this->getMock('\phpbb\request\request'), + $this->phpbb_root_path, + $this->phpEx + ); + $twig = new \phpbb\template\twig\environment( $this->config, - $this->user, - new \phpbb\template\context() + $phpbb_path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) ); + $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->migrator = new \phpbb\db\migrator( $this->config, @@ -73,7 +88,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case array(), new \phpbb\db\migration\helper() ); - $container = new phpbb_mock_container_builder(); $container->set('migrator', $this->migrator); $this->extension_manager = new \phpbb\extension\manager( diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index c415c969fe..e8ffea8d11 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -147,7 +147,28 @@ Zeta test event in all', $phpbb_root_path, $phpEx ); - $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, new \phpbb\template\context, $this->extension_manager); + + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $config, + $path_helper, + $container, + $cache_path, + $this->extension_manager, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path)); } } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 83446b5352..1f46d6ff71 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -78,7 +78,27 @@ class phpbb_template_template_test_case extends phpbb_test_case ); $this->template_path = $this->test_path . '/templates'; - $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context()); + + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $config, + $path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', $this->template_path); } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index 68ecc4b706..c634e2051a 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -34,7 +34,27 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $this->template_path = $this->test_path . '/templates'; $this->parent_template_path = $this->test_path . '/parent_templates'; - $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, new phpbb\template\context()); + + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $config, + $this->phpbb_path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } } -- cgit v1.2.1 From 59780bbd091c9e162eaf5f399f9bb2440605c4f7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 10 Aug 2014 12:17:03 +0200 Subject: [ticket/12958] Remove more references of subsilver2 PHPBB3-12958 --- tests/event/md_exporter_test.php | 1 - tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php index 0f9d855caa..28649e4f21 100644 --- a/tests/event/md_exporter_test.php +++ b/tests/event/md_exporter_test.php @@ -41,7 +41,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case $styles = array( 'adm/style/' => 'adm', 'styles/prosilver/template/' => 'styles', - 'styles/subsilver2/template/' => 'styles', ); foreach ($styles as $path => $filter) { diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 80e6293ff9..6a33fd7711 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -474,7 +474,7 @@ class phpbb_functional_test_case extends phpbb_test_case )); $db->sql_query($sql); - if ($style_path != 'prosilver' && $style_path != 'subsilver2') + if ($style_path != 'prosilver') { @mkdir($phpbb_root_path . 'styles/' . $style_path, 0777); @mkdir($phpbb_root_path . 'styles/' . $style_path . '/template', 0777); @@ -513,7 +513,7 @@ class phpbb_functional_test_case extends phpbb_test_case $db->sql_query('DELETE FROM ' . STYLES_TEMPLATE_TABLE . ' WHERE template_id = ' . $style_id); $db->sql_query('DELETE FROM ' . STYLES_THEME_TABLE . ' WHERE theme_id = ' . $style_id); - if ($style_path != 'prosilver' && $style_path != 'subsilver2') + if ($style_path != 'prosilver') { @rmdir($phpbb_root_path . 'styles/' . $style_path . '/template'); @rmdir($phpbb_root_path . 'styles/' . $style_path); -- cgit v1.2.1 From 55a3c96fb008a96e43572329ed5127ce7d6f5f6f Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 2 Sep 2014 22:12:11 +0200 Subject: [ticket/12661] Fix unit tests PHPBB3-12661 --- tests/template/template_allfolder_test.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php index b4ad84e9c3..e87688a57c 100644 --- a/tests/template/template_allfolder_test.php +++ b/tests/template/template_allfolder_test.php @@ -51,9 +51,29 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case ) ); + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $config, + $path_helper, + $container, + $cache_path, + $this->extension_manager, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $this->template_path = $this->test_path . '/templates'; $this->ext_template_path = 'tests/extension/ext/vendor4/bar/styles/all/template'; - $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context(), $this->extension_manager); $this->template->set_custom_style('all', array($this->template_path, $this->ext_template_path)); } } -- cgit v1.2.1 From a712d8a3b39025fde4652bbba0b9f466392c2d17 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 4 Oct 2014 23:25:40 +0200 Subject: [ticket/13130] Fix tests PHPBB3-13130 --- tests/test_framework/phpbb_functional_test_case.php | 3 +-- 1 file changed, 1 insertion(+), 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 8927c4dbf9..c47ae2cab6 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -934,8 +934,7 @@ class phpbb_functional_test_case extends phpbb_test_case */ public function assert_checkbox_is_unchecked($crawler, $name, $message = '') { - $this->assertSame( - '', + $this->assertNull( $this->assert_find_one_checkbox($crawler, $name)->attr('checked'), $message ?: "Failed asserting that checkbox $name is unchecked." ); -- cgit v1.2.1 From 5a7caf65084369422fdbe4aaaae46e5de69cc594 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 Nov 2013 13:47:31 +0100 Subject: [feature/patchwork-utf8] Normalize with intl, use patchwork/utf8 as fallback --- tests/RUNNING_TESTS.md | 5 +- tests/utf/normalizer_test.php | 327 ------------------------------------------ 2 files changed, 3 insertions(+), 329 deletions(-) delete mode 100644 tests/utf/normalizer_test.php (limited to 'tests') diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md index afd7caa709..b082197166 100644 --- a/tests/RUNNING_TESTS.md +++ b/tests/RUNNING_TESTS.md @@ -120,8 +120,9 @@ directory (above phpBB): Slow tests -------------- -Certain tests, such as the UTF-8 normalizer or the DNS tests tend to be slow. -Thus these tests are in the `slow` group, which is excluded by default. If you +Certain tests, such as the DNS tests tend to be slow. +Thus these tests are in the `slow` group, which is excluded by default. You can +enable slow tests by copying the phpunit.xml.all file to phpunit.xml. If you only want the slow tests, run: $ phpBB/vendor/bin/phpunit --group slow diff --git a/tests/utf/normalizer_test.php b/tests/utf/normalizer_test.php deleted file mode 100644 index 50eafda859..0000000000 --- a/tests/utf/normalizer_test.php +++ /dev/null @@ -1,327 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_normalizer.php'; - -/** -* @group slow -*/ -class phpbb_utf_normalizer_test extends phpbb_test_case -{ - static private $data_dir; - - static public function setUpBeforeClass() - { - self::$data_dir = dirname(__file__) . '/../tmp'; - self::download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt', self::$data_dir); - self::download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt', self::$data_dir); - } - - public function test_normalizer() - { - $test_suite = array( - /** - * NFC - * c2 == NFC(c1) == NFC(c2) == NFC(c3) - * c4 == NFC(c4) == NFC(c5) - */ - 'NFC' => array( - 'c2' => array('c1', 'c2', 'c3'), - 'c4' => array('c4', 'c5') - ), - - /** - * NFD - * c3 == NFD(c1) == NFD(c2) == NFD(c3) - * c5 == NFD(c4) == NFD(c5) - */ - 'NFD' => array( - 'c3' => array('c1', 'c2', 'c3'), - 'c5' => array('c4', 'c5') - ), - - /** - * NFKC - * c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5) - */ - 'NFKC' => array( - 'c4' => array('c1', 'c2', 'c3', 'c4', 'c5') - ), - - /** - * NFKD - * c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5) - */ - 'NFKD' => array( - 'c5' => array('c1', 'c2', 'c3', 'c4', 'c5') - ) - ); - - $tested_chars = array(); - - $fp = fopen(self::$data_dir . '/NormalizationTest.txt', 'rb'); - while (!feof($fp)) - { - $line = fgets($fp); - - if ($line[0] == '@') - { - continue; - } - - if (!strpos(' 0123456789ABCDEF', $line[0])) - { - continue; - } - - list($c1, $c2, $c3, $c4, $c5) = explode(';', $line); - - if (!strpos($c1, ' ')) - { - /** - * We are currently testing a single character, we add it to the list of - * characters we have processed so that we can exclude it when testing - * for invariants - */ - $tested_chars[$c1] = 1; - } - - foreach ($test_suite as $form => $serie) - { - foreach ($serie as $expected => $tests) - { - $hex_expected = ${$expected}; - $utf_expected = $this->hexseq_to_utf($hex_expected); - - foreach ($tests as $test) - { - $utf_result = $utf_expected; - call_user_func_array(array('utf_normalizer', $form), array(&$utf_result)); - - $hex_result = $this->utf_to_hexseq($utf_result); - $this->assertEquals($utf_expected, $utf_result, "$expected == $form($test) ($hex_expected != $hex_result)"); - } - } - } - } - fclose($fp); - - return $tested_chars; - } - - /** - * @depends test_normalizer - */ - public function test_invariants(array $tested_chars) - { - $fp = fopen(self::$data_dir . '/UnicodeData.txt', 'rb'); - - while (!feof($fp)) - { - $line = fgets($fp, 1024); - - if (!$pos = strpos($line, ';')) - { - continue; - } - - $hex_tested = $hex_expected = substr($line, 0, $pos); - - if (isset($tested_chars[$hex_tested])) - { - continue; - } - - $utf_expected = $this->hex_to_utf($hex_expected); - - if ($utf_expected >= UTF8_SURROGATE_FIRST - && $utf_expected <= UTF8_SURROGATE_LAST) - { - /** - * Surrogates are illegal on their own, we expect the normalizer - * to return a replacement char - */ - $utf_expected = UTF8_REPLACEMENT; - $hex_expected = $this->utf_to_hexseq($utf_expected); - } - - foreach (array('nfc', 'nfkc', 'nfd', 'nfkd') as $form) - { - $utf_result = $utf_expected; - call_user_func_array(array('utf_normalizer', $form), array(&$utf_result)); - $hex_result = $this->utf_to_hexseq($utf_result); - - $this->assertEquals($utf_expected, $utf_result, "$hex_expected == $form($hex_tested) ($hex_expected != $hex_result)"); - } - } - fclose($fp); - } - - /** - * Convert a UTF string to a sequence of codepoints in hexadecimal - * - * @param string $utf UTF string - * @return integer Unicode codepoints in hex - */ - protected function utf_to_hexseq($str) - { - $pos = 0; - $len = strlen($str); - $ret = array(); - - while ($pos < $len) - { - $c = $str[$pos]; - switch ($c & "\xF0") - { - case "\xC0": - case "\xD0": - $utf_char = substr($str, $pos, 2); - $pos += 2; - break; - - case "\xE0": - $utf_char = substr($str, $pos, 3); - $pos += 3; - break; - - case "\xF0": - $utf_char = substr($str, $pos, 4); - $pos += 4; - break; - - default: - $utf_char = $c; - ++$pos; - } - - $hex = dechex($this->utf_to_cp($utf_char)); - - if (!isset($hex[3])) - { - $hex = substr('000' . $hex, -4); - } - - $ret[] = $hex; - } - - return strtr(implode(' ', $ret), 'abcdef', 'ABCDEF'); - } - - /** - * Convert a UTF-8 char to its codepoint - * - * @param string $utf_char UTF-8 char - * @return integer Unicode codepoint - */ - protected function utf_to_cp($utf_char) - { - switch (strlen($utf_char)) - { - case 1: - return ord($utf_char); - - case 2: - return ((ord($utf_char[0]) & 0x1F) << 6) | (ord($utf_char[1]) & 0x3F); - - case 3: - return ((ord($utf_char[0]) & 0x0F) << 12) | ((ord($utf_char[1]) & 0x3F) << 6) | (ord($utf_char[2]) & 0x3F); - - case 4: - return ((ord($utf_char[0]) & 0x07) << 18) | ((ord($utf_char[1]) & 0x3F) << 12) | ((ord($utf_char[2]) & 0x3F) << 6) | (ord($utf_char[3]) & 0x3F); - - default: - throw new RuntimeException('UTF-8 chars can only be 1-4 bytes long'); - } - } - - /** - * Return a UTF string formed from a sequence of codepoints in hexadecimal - * - * @param string $seq Sequence of codepoints, separated with a space - * @return string UTF-8 string - */ - protected function hexseq_to_utf($seq) - { - return implode('', array_map(array($this, 'hex_to_utf'), explode(' ', $seq))); - } - - /** - * Convert a codepoint in hexadecimal to a UTF-8 char - * - * @param string $hex Codepoint, in hexadecimal - * @return string UTF-8 char - */ - protected function hex_to_utf($hex) - { - return $this->cp_to_utf(hexdec($hex)); - } - - /** - * Convert a codepoint to a UTF-8 char - * - * @param integer $cp Unicode codepoint - * @return string UTF-8 string - */ - protected function cp_to_utf($cp) - { - if ($cp > 0xFFFF) - { - return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F)); - } - else if ($cp > 0x7FF) - { - return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F)); - } - else if ($cp > 0x7F) - { - return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F)); - } - else - { - return chr($cp); - } - } - - // chunked download helper - static protected function download($url, $to) - { - $target = $to . '/' . basename($url); - - if (file_exists($target)) - { - return; - } - - if (!$fpr = fopen($url, 'rb')) - { - echo "Failed to download $url\n"; - return; - } - - if (!$fpw = fopen($target, 'wb')) - { - echo "Failed to open $target for writing\n"; - return; - } - - $chunk = 32768; - - while (!feof($fpr)) - { - fwrite($fpw, fread($fpr, $chunk)); - } - fclose($fpr); - fclose($fpw); - } -} -- cgit v1.2.1 From a5bfc76a73a213a388126d0f697ba64f27a4b00d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 14 Sep 2014 21:18:20 +0200 Subject: [ticket/13063] Introduces a new \phpbb\routing\router class PHPBB3-13063 --- tests/controller/common_helper_route.php | 23 ++++++++++++----------- tests/controller/controller_test.php | 8 ++++---- tests/mock/controller_helper.php | 5 ++--- tests/mock/router.php | 27 +++++++++++++++++++++++++++ tests/pagination/pagination_test.php | 8 ++++---- 5 files changed, 49 insertions(+), 22 deletions(-) create mode 100644 tests/mock/router.php (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 5e15eb3ee1..1234c372fe 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -119,9 +119,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case new phpbb_mock_cache() ); $finder->set_extensions(array_keys($this->extension_manager->all_enabled())); - $this->provider = new \phpbb\controller\provider(); - $this->provider->find_routing_files($finder); - $this->provider->find(dirname(__FILE__) . '/'); + $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php'); + $this->router->find_routing_files($finder); + $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); } @@ -161,7 +161,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case */ public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); } @@ -201,7 +202,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); } @@ -241,7 +242,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL)); } @@ -281,7 +282,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH)); } @@ -321,7 +322,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH)); } //TODO @@ -361,7 +362,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL)); } @@ -401,7 +402,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH)); } @@ -441,7 +442,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH)); } } diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 62feee3fed..cd90dda751 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -33,11 +33,11 @@ class phpbb_controller_controller_test extends phpbb_test_case )); } - public function test_provider() + public function test_router_find_files() { - $provider = new \phpbb\controller\provider(); - $provider->find_routing_files($this->extension_manager->get_finder()); - $routes = $provider->find(__DIR__)->get_routes(); + $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php'); + $router->find_routing_files($this->extension_manager->get_finder()); + $routes = $router->find(__DIR__)->get_routes(); // This will need to be updated if any new routes are defined $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('core_controller')); diff --git a/tests/mock/controller_helper.php b/tests/mock/controller_helper.php index ae3e7bf432..7e4a808906 100644 --- a/tests/mock/controller_helper.php +++ b/tests/mock/controller_helper.php @@ -13,7 +13,7 @@ class phpbb_mock_controller_helper extends \phpbb\controller\helper { - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext) { $this->template = $template; $this->user = $user; @@ -23,8 +23,7 @@ class phpbb_mock_controller_helper extends \phpbb\controller\helper $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; - $provider->find_routing_files($manager->get_finder()); - $this->route_collection = $provider->find($phpbb_root_path_ext)->get_routes(); + $this->router = $router; } public function get_current_url() diff --git a/tests/mock/router.php b/tests/mock/router.php new file mode 100644 index 0000000000..01faa338c5 --- /dev/null +++ b/tests/mock/router.php @@ -0,0 +1,27 @@ + +* @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_mock_router extends \phpbb\routing\router +{ + public function get_matcher() + { + $this->create_new_url_matcher(); + return parent::get_matcher(); + } + + public function get_generator() + { + $this->create_new_url_generator(); + return parent::get_generator(); + } +} diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 494c667198..de939e280d 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -44,9 +44,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $finder->set_extensions(array_keys($manager->all_enabled())); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $provider = new \phpbb\controller\provider(); - $provider->find_routing_files($finder); - $provider->find(dirname(__FILE__) . '/'); + $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php'); + $router->find_routing_files($finder); + $router->find(dirname(__FILE__) . '/'); $request = new phpbb_mock_request(); $request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER); @@ -57,7 +57,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $request ); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $router, $manager, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/'); $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher); } -- cgit v1.2.1 From fdcd6e81cd4ae530036fd18ad184c0d2423c6949 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 20 Nov 2014 16:37:45 +0100 Subject: [ticket/13063] Fix tests after rebase PHPBB3-13063 --- tests/controller/common_helper_route.php | 32 ++++++++++++++++---------------- tests/pagination/pagination_test.php | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 1234c372fe..028a73d70d 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -162,8 +162,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); } public function helper_url_data_with_rewrite() @@ -202,8 +202,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); } public function helper_url_data_absolute() @@ -242,8 +242,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); } public function helper_url_data_relative_path() @@ -282,8 +282,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); } public function helper_url_data_network() @@ -322,8 +322,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); } //TODO public function helper_url_data_absolute_with_rewrite() @@ -362,8 +362,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); } public function helper_url_data_relative_path_with_rewrite() @@ -402,8 +402,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); } public function helper_url_data_network_with_rewrite() @@ -442,7 +442,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); } } diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index de939e280d..04f7b807a7 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -57,7 +57,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $request ); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $router, $manager, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $router, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/'); $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher); } -- cgit v1.2.1 From 1a6e1ecf6f96acb7eb3fc0cc6233773ecb5125a8 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 15:18:11 +0200 Subject: [ticket/12620] Fix tests PHPBB3-12620 --- tests/di/create_container_test.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 4ae6017989..c98d3ff6bc 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -13,6 +13,8 @@ namespace { + define('ENVIRONMENT', 'productive'); + require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_di_container_test extends \phpbb_test_case -- cgit v1.2.1 From 943e27dffa1ecea1c34e9ae5b11c49186f30e046 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 22:55:27 +0200 Subject: [ticket/12620] Fix functional tests PHPBB3-12620 --- tests/di/create_container_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index c98d3ff6bc..2ddbf68f39 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -13,7 +13,7 @@ namespace { - define('ENVIRONMENT', 'productive'); + define('ENVIRONMENT', 'production'); require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -- cgit v1.2.1 From 3f678af5f34d9fd9a635d6ce82bd41285ff71be1 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 10 Aug 2014 12:06:50 +0200 Subject: [ticket/12620] Update tests PHPBB3-12620 --- tests/di/fixtures/config/production/environment.yml | 14 ++++++++++++++ tests/di/fixtures/config/services.yml | 14 -------------- tests/di/fixtures/other_config/production/environment.yml | 14 ++++++++++++++ tests/di/fixtures/other_config/services.yml | 14 -------------- 4 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 tests/di/fixtures/config/production/environment.yml delete mode 100644 tests/di/fixtures/config/services.yml create mode 100644 tests/di/fixtures/other_config/production/environment.yml delete mode 100644 tests/di/fixtures/other_config/services.yml (limited to 'tests') diff --git a/tests/di/fixtures/config/production/environment.yml b/tests/di/fixtures/config/production/environment.yml new file mode 100644 index 0000000000..f2a22ae109 --- /dev/null +++ b/tests/di/fixtures/config/production/environment.yml @@ -0,0 +1,14 @@ +parameters: + core: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/config/services.yml b/tests/di/fixtures/config/services.yml deleted file mode 100644 index f2a22ae109..0000000000 --- a/tests/di/fixtures/config/services.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - core: true - -services: - config.php: - synthetic: true - - dbal.conn: - class: phpbb\db\driver\factory - arguments: - - @service_container - - dispatcher: - class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/production/environment.yml b/tests/di/fixtures/other_config/production/environment.yml new file mode 100644 index 0000000000..c299bfc648 --- /dev/null +++ b/tests/di/fixtures/other_config/production/environment.yml @@ -0,0 +1,14 @@ +parameters: + other_config: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/services.yml b/tests/di/fixtures/other_config/services.yml deleted file mode 100644 index c299bfc648..0000000000 --- a/tests/di/fixtures/other_config/services.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - other_config: true - -services: - config.php: - synthetic: true - - dbal.conn: - class: phpbb\db\driver\factory - arguments: - - @service_container - - dispatcher: - class: phpbb\db\driver\container_mock -- cgit v1.2.1 From b697273aaa53d9f9f4a3d4a53cc6267e906953cd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 4 Sep 2014 17:06:39 +0200 Subject: [ticket/12620] Use PHPBB_ENVIRONMENT PHPBB3-12620 --- tests/di/create_container_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 2ddbf68f39..ecfe504775 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -13,7 +13,7 @@ namespace { - define('ENVIRONMENT', 'production'); + define('PHPBB_ENVIRONMENT', 'production'); require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -- cgit v1.2.1 From 0bf3d2d962c33ffa606d38e91d04665b78fbd8bc Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 5 Sep 2014 02:29:15 +0200 Subject: [ticket/12620] Add the support of the environments for the ext services We look for an environment.yml file in the config/PHPBB_ENVIRONMENT/ directory of the extensionss. If the directory does not exist we look for the environment.yml file in the 'default' environment and finally for the services.yml file in the config/ directory. PHPBB3-12620 --- tests/di/create_container_test.php | 4 ++++ .../di/fixtures/ext/vendor/disabled/config/production/environment.yml | 2 ++ tests/di/fixtures/ext/vendor/disabled/config/services.yml | 2 -- .../fixtures/ext/vendor/enabled-2/config/production/environment.yml | 2 ++ tests/di/fixtures/ext/vendor/enabled-3/config/services.yml | 2 ++ tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml | 2 ++ tests/di/fixtures/ext/vendor/enabled/config/services.yml | 2 -- 7 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml delete mode 100644 tests/di/fixtures/ext/vendor/disabled/config/services.yml create mode 100644 tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml create mode 100644 tests/di/fixtures/ext/vendor/enabled-3/config/services.yml create mode 100644 tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml delete mode 100644 tests/di/fixtures/ext/vendor/enabled/config/services.yml (limited to 'tests') diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index ecfe504775..ec9828debb 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -59,6 +59,8 @@ namespace // Checks use_extensions $this->assertTrue($container->hasParameter('enabled')); + $this->assertTrue($container->hasParameter('enabled_2')); + $this->assertTrue($container->hasParameter('enabled_3')); $this->assertFalse($container->hasParameter('disabled')); $this->assertFalse($container->hasParameter('available')); @@ -201,6 +203,8 @@ namespace phpbb\db\driver { return array( array('ext_name' => 'vendor/enabled'), + array('ext_name' => 'vendor/enabled-2'), + array('ext_name' => 'vendor/enabled-3'), ); } } diff --git a/tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml new file mode 100644 index 0000000000..31ada384bf --- /dev/null +++ b/tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml @@ -0,0 +1,2 @@ +parameters: + disabled: true diff --git a/tests/di/fixtures/ext/vendor/disabled/config/services.yml b/tests/di/fixtures/ext/vendor/disabled/config/services.yml deleted file mode 100644 index 31ada384bf..0000000000 --- a/tests/di/fixtures/ext/vendor/disabled/config/services.yml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - disabled: true diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml new file mode 100644 index 0000000000..feeb5a7a2d --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml @@ -0,0 +1,2 @@ +parameters: + enabled_2: true diff --git a/tests/di/fixtures/ext/vendor/enabled-3/config/services.yml b/tests/di/fixtures/ext/vendor/enabled-3/config/services.yml new file mode 100644 index 0000000000..0dae35d2bd --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled-3/config/services.yml @@ -0,0 +1,2 @@ +parameters: + enabled_3: true diff --git a/tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml b/tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml new file mode 100644 index 0000000000..88a7919ed1 --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml @@ -0,0 +1,2 @@ +parameters: + enabled: true diff --git a/tests/di/fixtures/ext/vendor/enabled/config/services.yml b/tests/di/fixtures/ext/vendor/enabled/config/services.yml deleted file mode 100644 index 88a7919ed1..0000000000 --- a/tests/di/fixtures/ext/vendor/enabled/config/services.yml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - enabled: true -- cgit v1.2.1 From 7cd0fd83b8047f40edfb69a427b14997801ef25b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 5 Sep 2014 03:03:20 +0200 Subject: [ticket/12620] Fix tests PHPBB3-12620 --- tests/bootstrap.php | 2 ++ tests/controller/config/production/routing.yml | 3 +++ tests/controller/config/routing.yml | 3 --- tests/pagination/config/production/routing.yml | 6 ++++++ tests/pagination/config/routing.yml | 6 ------ 5 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 tests/controller/config/production/routing.yml delete mode 100644 tests/controller/config/routing.yml create mode 100644 tests/pagination/config/production/routing.yml delete mode 100644 tests/pagination/config/routing.yml (limited to 'tests') diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 0e81f4372a..229a6ee82b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,6 +12,8 @@ */ define('IN_PHPBB', true); +define('PHPBB_ENVIRONMENT', 'production'); + $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; require_once $phpbb_root_path . 'includes/startup.php'; diff --git a/tests/controller/config/production/routing.yml b/tests/controller/config/production/routing.yml new file mode 100644 index 0000000000..175b11f130 --- /dev/null +++ b/tests/controller/config/production/routing.yml @@ -0,0 +1,3 @@ +core_controller: + pattern: /core_foo + defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/config/routing.yml b/tests/controller/config/routing.yml deleted file mode 100644 index 175b11f130..0000000000 --- a/tests/controller/config/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -core_controller: - pattern: /core_foo - defaults: { _controller: core_foo.controller:bar } diff --git a/tests/pagination/config/production/routing.yml b/tests/pagination/config/production/routing.yml new file mode 100644 index 0000000000..dd667274cd --- /dev/null +++ b/tests/pagination/config/production/routing.yml @@ -0,0 +1,6 @@ +core_controller: + pattern: /test + defaults: { _controller: core_foo.controller:bar, page: 1} +core_page_controller: + pattern: /test/page/{page} + defaults: { _controller: core_foo.controller:bar} diff --git a/tests/pagination/config/routing.yml b/tests/pagination/config/routing.yml deleted file mode 100644 index dd667274cd..0000000000 --- a/tests/pagination/config/routing.yml +++ /dev/null @@ -1,6 +0,0 @@ -core_controller: - pattern: /test - defaults: { _controller: core_foo.controller:bar, page: 1} -core_page_controller: - pattern: /test/page/{page} - defaults: { _controller: core_foo.controller:bar} -- cgit v1.2.1 From 014eed385bf761d9e3f0992835f44f58bf055afd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 5 Sep 2014 16:33:57 +0200 Subject: [ticket/12620] Add support of the environments for the ext routing files PHPBB3-12620 --- tests/controller/common_helper_route.php | 6 ------ tests/controller/controller_test.php | 8 ++++++++ .../ext/vendor2/bar/config/production/routing.yml | 3 +++ tests/controller/ext/vendor2/bar/config/services.yml | 3 +++ tests/controller/ext/vendor2/bar/controller.php | 18 ++++++++++++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 tests/controller/ext/vendor2/bar/config/production/routing.yml create mode 100644 tests/controller/ext/vendor2/bar/config/services.yml create mode 100644 tests/controller/ext/vendor2/bar/controller.php (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 028a73d70d..5baa846ec3 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -113,12 +113,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $finder = new \phpbb\finder( - new \phpbb\filesystem(), - dirname(__FILE__) . '/', - new phpbb_mock_cache() - ); - $finder->set_extensions(array_keys($this->extension_manager->all_enabled())); $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php'); $this->router->find_routing_files($finder); $this->router->find(dirname(__FILE__) . '/'); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index cd90dda751..637e9685e6 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -30,6 +30,11 @@ class phpbb_controller_controller_test extends phpbb_test_case 'ext_active' => '1', 'ext_path' => 'ext/vendor2/foo/', ), + 'vendor2/bar' => array( + 'ext_name' => 'vendor2/bar', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor2/bar/', + ), )); } @@ -49,6 +54,9 @@ class phpbb_controller_controller_test extends phpbb_test_case $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller2')); $this->assertEquals('/foo/bar', $routes->get('controller2')->getPath()); + $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller3')); + $this->assertEquals('/bar', $routes->get('controller3')->getPath()); + $this->assertNull($routes->get('controller_noroute')); } diff --git a/tests/controller/ext/vendor2/bar/config/production/routing.yml b/tests/controller/ext/vendor2/bar/config/production/routing.yml new file mode 100644 index 0000000000..85c93b453f --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/production/routing.yml @@ -0,0 +1,3 @@ +controller3: + pattern: /bar + defaults: { _controller: bar.controller:handle } diff --git a/tests/controller/ext/vendor2/bar/config/services.yml b/tests/controller/ext/vendor2/bar/config/services.yml new file mode 100644 index 0000000000..05a8a1994d --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/services.yml @@ -0,0 +1,3 @@ +services: + bar.controller: + class: bar\controller diff --git a/tests/controller/ext/vendor2/bar/controller.php b/tests/controller/ext/vendor2/bar/controller.php new file mode 100644 index 0000000000..ad35f5a051 --- /dev/null +++ b/tests/controller/ext/vendor2/bar/controller.php @@ -0,0 +1,18 @@ + Date: Thu, 2 Oct 2014 00:45:22 +0200 Subject: [ticket/12620] Updates test environment (production => development) PHPBB3-12620 --- tests/bootstrap.php | 2 +- tests/controller/config/development/routing.yml | 3 +++ tests/controller/config/production/routing.yml | 3 --- .../ext/vendor2/bar/config/development/routing.yml | 3 +++ .../ext/vendor2/bar/config/production/routing.yml | 3 --- tests/di/fixtures/config/development/environment.yml | 14 ++++++++++++++ tests/di/fixtures/config/production/environment.yml | 14 -------------- .../ext/vendor/disabled/config/development/environment.yml | 2 ++ .../ext/vendor/disabled/config/production/environment.yml | 2 -- .../vendor/enabled-2/config/development/environment.yml | 2 ++ .../ext/vendor/enabled-2/config/production/environment.yml | 2 -- tests/di/fixtures/other_config/development/environment.yml | 14 ++++++++++++++ tests/di/fixtures/other_config/production/environment.yml | 14 -------------- tests/pagination/config/development/routing.yml | 6 ++++++ tests/pagination/config/production/routing.yml | 6 ------ 15 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 tests/controller/config/development/routing.yml delete mode 100644 tests/controller/config/production/routing.yml create mode 100644 tests/controller/ext/vendor2/bar/config/development/routing.yml delete mode 100644 tests/controller/ext/vendor2/bar/config/production/routing.yml create mode 100644 tests/di/fixtures/config/development/environment.yml delete mode 100644 tests/di/fixtures/config/production/environment.yml create mode 100644 tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml delete mode 100644 tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml create mode 100644 tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml delete mode 100644 tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml create mode 100644 tests/di/fixtures/other_config/development/environment.yml delete mode 100644 tests/di/fixtures/other_config/production/environment.yml create mode 100644 tests/pagination/config/development/routing.yml delete mode 100644 tests/pagination/config/production/routing.yml (limited to 'tests') diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 229a6ee82b..2fc8858585 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,7 +12,7 @@ */ define('IN_PHPBB', true); -define('PHPBB_ENVIRONMENT', 'production'); +define('PHPBB_ENVIRONMENT', 'development'); $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; diff --git a/tests/controller/config/development/routing.yml b/tests/controller/config/development/routing.yml new file mode 100644 index 0000000000..175b11f130 --- /dev/null +++ b/tests/controller/config/development/routing.yml @@ -0,0 +1,3 @@ +core_controller: + pattern: /core_foo + defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/config/production/routing.yml b/tests/controller/config/production/routing.yml deleted file mode 100644 index 175b11f130..0000000000 --- a/tests/controller/config/production/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -core_controller: - pattern: /core_foo - defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/ext/vendor2/bar/config/development/routing.yml b/tests/controller/ext/vendor2/bar/config/development/routing.yml new file mode 100644 index 0000000000..85c93b453f --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/development/routing.yml @@ -0,0 +1,3 @@ +controller3: + pattern: /bar + defaults: { _controller: bar.controller:handle } diff --git a/tests/controller/ext/vendor2/bar/config/production/routing.yml b/tests/controller/ext/vendor2/bar/config/production/routing.yml deleted file mode 100644 index 85c93b453f..0000000000 --- a/tests/controller/ext/vendor2/bar/config/production/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -controller3: - pattern: /bar - defaults: { _controller: bar.controller:handle } diff --git a/tests/di/fixtures/config/development/environment.yml b/tests/di/fixtures/config/development/environment.yml new file mode 100644 index 0000000000..f2a22ae109 --- /dev/null +++ b/tests/di/fixtures/config/development/environment.yml @@ -0,0 +1,14 @@ +parameters: + core: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/config/production/environment.yml b/tests/di/fixtures/config/production/environment.yml deleted file mode 100644 index f2a22ae109..0000000000 --- a/tests/di/fixtures/config/production/environment.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - core: true - -services: - config.php: - synthetic: true - - dbal.conn: - class: phpbb\db\driver\factory - arguments: - - @service_container - - dispatcher: - class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml new file mode 100644 index 0000000000..31ada384bf --- /dev/null +++ b/tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml @@ -0,0 +1,2 @@ +parameters: + disabled: true diff --git a/tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml deleted file mode 100644 index 31ada384bf..0000000000 --- a/tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - disabled: true diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml new file mode 100644 index 0000000000..feeb5a7a2d --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml @@ -0,0 +1,2 @@ +parameters: + enabled_2: true diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml deleted file mode 100644 index feeb5a7a2d..0000000000 --- a/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - enabled_2: true diff --git a/tests/di/fixtures/other_config/development/environment.yml b/tests/di/fixtures/other_config/development/environment.yml new file mode 100644 index 0000000000..c299bfc648 --- /dev/null +++ b/tests/di/fixtures/other_config/development/environment.yml @@ -0,0 +1,14 @@ +parameters: + other_config: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/production/environment.yml b/tests/di/fixtures/other_config/production/environment.yml deleted file mode 100644 index c299bfc648..0000000000 --- a/tests/di/fixtures/other_config/production/environment.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - other_config: true - -services: - config.php: - synthetic: true - - dbal.conn: - class: phpbb\db\driver\factory - arguments: - - @service_container - - dispatcher: - class: phpbb\db\driver\container_mock diff --git a/tests/pagination/config/development/routing.yml b/tests/pagination/config/development/routing.yml new file mode 100644 index 0000000000..dd667274cd --- /dev/null +++ b/tests/pagination/config/development/routing.yml @@ -0,0 +1,6 @@ +core_controller: + pattern: /test + defaults: { _controller: core_foo.controller:bar, page: 1} +core_page_controller: + pattern: /test/page/{page} + defaults: { _controller: core_foo.controller:bar} diff --git a/tests/pagination/config/production/routing.yml b/tests/pagination/config/production/routing.yml deleted file mode 100644 index dd667274cd..0000000000 --- a/tests/pagination/config/production/routing.yml +++ /dev/null @@ -1,6 +0,0 @@ -core_controller: - pattern: /test - defaults: { _controller: core_foo.controller:bar, page: 1} -core_page_controller: - pattern: /test/page/{page} - defaults: { _controller: core_foo.controller:bar} -- cgit v1.2.1 From 6cbb60d13f75da6d9b6c6d60555ea119df79b5c0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 4 Oct 2014 16:30:34 +0200 Subject: [ticket/12620] Adds a yaml config file PHPBB3-12620 --- .../fixtures/config/development/container/environment.yml | 14 ++++++++++++++ tests/di/fixtures/config/development/environment.yml | 14 -------------- .../disabled/config/development/container/environment.yml | 2 ++ .../ext/vendor/disabled/config/development/environment.yml | 2 -- .../enabled-2/config/development/container/environment.yml | 2 ++ .../vendor/enabled-2/config/development/environment.yml | 2 -- .../enabled/config/default/container/environment.yml | 2 ++ .../ext/vendor/enabled/config/default/environment.yml | 2 -- .../other_config/development/container/environment.yml | 14 ++++++++++++++ tests/di/fixtures/other_config/development/environment.yml | 14 -------------- 10 files changed, 34 insertions(+), 34 deletions(-) create mode 100644 tests/di/fixtures/config/development/container/environment.yml delete mode 100644 tests/di/fixtures/config/development/environment.yml create mode 100644 tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml delete mode 100644 tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml create mode 100644 tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml delete mode 100644 tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml create mode 100644 tests/di/fixtures/ext/vendor/enabled/config/default/container/environment.yml delete mode 100644 tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml create mode 100644 tests/di/fixtures/other_config/development/container/environment.yml delete mode 100644 tests/di/fixtures/other_config/development/environment.yml (limited to 'tests') diff --git a/tests/di/fixtures/config/development/container/environment.yml b/tests/di/fixtures/config/development/container/environment.yml new file mode 100644 index 0000000000..f2a22ae109 --- /dev/null +++ b/tests/di/fixtures/config/development/container/environment.yml @@ -0,0 +1,14 @@ +parameters: + core: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/config/development/environment.yml b/tests/di/fixtures/config/development/environment.yml deleted file mode 100644 index f2a22ae109..0000000000 --- a/tests/di/fixtures/config/development/environment.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - core: true - -services: - config.php: - synthetic: true - - dbal.conn: - class: phpbb\db\driver\factory - arguments: - - @service_container - - dispatcher: - class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml new file mode 100644 index 0000000000..31ada384bf --- /dev/null +++ b/tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml @@ -0,0 +1,2 @@ +parameters: + disabled: true diff --git a/tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml deleted file mode 100644 index 31ada384bf..0000000000 --- a/tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - disabled: true diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml new file mode 100644 index 0000000000..feeb5a7a2d --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml @@ -0,0 +1,2 @@ +parameters: + enabled_2: true diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml deleted file mode 100644 index feeb5a7a2d..0000000000 --- a/tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - enabled_2: true diff --git a/tests/di/fixtures/ext/vendor/enabled/config/default/container/environment.yml b/tests/di/fixtures/ext/vendor/enabled/config/default/container/environment.yml new file mode 100644 index 0000000000..88a7919ed1 --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled/config/default/container/environment.yml @@ -0,0 +1,2 @@ +parameters: + enabled: true diff --git a/tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml b/tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml deleted file mode 100644 index 88a7919ed1..0000000000 --- a/tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - enabled: true diff --git a/tests/di/fixtures/other_config/development/container/environment.yml b/tests/di/fixtures/other_config/development/container/environment.yml new file mode 100644 index 0000000000..c299bfc648 --- /dev/null +++ b/tests/di/fixtures/other_config/development/container/environment.yml @@ -0,0 +1,14 @@ +parameters: + other_config: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/development/environment.yml b/tests/di/fixtures/other_config/development/environment.yml deleted file mode 100644 index c299bfc648..0000000000 --- a/tests/di/fixtures/other_config/development/environment.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - other_config: true - -services: - config.php: - synthetic: true - - dbal.conn: - class: phpbb\db\driver\factory - arguments: - - @service_container - - dispatcher: - class: phpbb\db\driver\container_mock -- cgit v1.2.1 From 3a167aa0c3eaec6c4b9d322460480786234e0419 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 4 Oct 2014 17:30:10 +0200 Subject: [ticket/12620] Creates one di extension per phpBB extension PHPBB3-12620 --- tests/di/fixtures/config/development/config.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/di/fixtures/config/development/config.yml (limited to 'tests') diff --git a/tests/di/fixtures/config/development/config.yml b/tests/di/fixtures/config/development/config.yml new file mode 100644 index 0000000000..fcfa84f68b --- /dev/null +++ b/tests/di/fixtures/config/development/config.yml @@ -0,0 +1,2 @@ +core: + require_dev_dependencies: true -- cgit v1.2.1 From 0b61e3540de353f2bf0a6904a87727e4efe9c5fa Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 4 Oct 2014 17:47:36 +0200 Subject: [ticket/12620] Fix tests PHPBB3-12620 --- tests/di/create_container_test.php | 1 - tests/di/fixtures/other_config/development/config.yml | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 tests/di/fixtures/other_config/development/config.yml (limited to 'tests') diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index ec9828debb..4e47751999 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -146,7 +146,6 @@ namespace $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); $this->assertTrue($container->hasParameter('my_parameter')); - $this->assertFalse($container->hasParameter('core.root_path')); } } } diff --git a/tests/di/fixtures/other_config/development/config.yml b/tests/di/fixtures/other_config/development/config.yml new file mode 100644 index 0000000000..fcfa84f68b --- /dev/null +++ b/tests/di/fixtures/other_config/development/config.yml @@ -0,0 +1,2 @@ +core: + require_dev_dependencies: true -- cgit v1.2.1 From 0a1db77ea85116adf24f9d3f0b92a44f818a107f Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 11 Nov 2014 19:10:43 +0100 Subject: [ticket/12620] Add a test using a custom DI extension in an extension PHPBB3-12620 --- tests/di/create_container_test.php | 3 +++ .../fixtures/ext/vendor/enabled_4/di/extension.php | 31 ++++++++++++++++++++++ .../fixtures/ext/vendor/enabled_4/environment.yml | 2 ++ 3 files changed, 36 insertions(+) create mode 100644 tests/di/fixtures/ext/vendor/enabled_4/di/extension.php create mode 100644 tests/di/fixtures/ext/vendor/enabled_4/environment.yml (limited to 'tests') diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 4e47751999..9cc714db40 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -16,6 +16,7 @@ namespace define('PHPBB_ENVIRONMENT', 'production'); require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + require_once dirname(__FILE__) . '/fixtures/ext/vendor/enabled_4/di/extension.php'; class phpbb_di_container_test extends \phpbb_test_case { @@ -61,6 +62,7 @@ namespace $this->assertTrue($container->hasParameter('enabled')); $this->assertTrue($container->hasParameter('enabled_2')); $this->assertTrue($container->hasParameter('enabled_3')); + $this->assertTrue($container->hasParameter('enabled_4')); $this->assertFalse($container->hasParameter('disabled')); $this->assertFalse($container->hasParameter('available')); @@ -204,6 +206,7 @@ namespace phpbb\db\driver array('ext_name' => 'vendor/enabled'), array('ext_name' => 'vendor/enabled-2'), array('ext_name' => 'vendor/enabled-3'), + array('ext_name' => 'vendor/enabled_4'), ); } } diff --git a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php new file mode 100644 index 0000000000..8342625687 --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php @@ -0,0 +1,31 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace vendor\enabled_4\di; + +use phpbb\extension\di\extension_base; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + +/** +* Container core extension +*/ +class extension extends extension_base +{ + protected function load_services(ContainerBuilder $container) + { + $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->ext_path))); + $loader->load('environment.yml'); + } +} diff --git a/tests/di/fixtures/ext/vendor/enabled_4/environment.yml b/tests/di/fixtures/ext/vendor/enabled_4/environment.yml new file mode 100644 index 0000000000..d0affe4fd6 --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled_4/environment.yml @@ -0,0 +1,2 @@ +parameters: + enabled_4: true -- cgit v1.2.1 From 91daa736639fca67b2d330d0f20aabbd55eec2cf Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 18:08:31 +0100 Subject: [ticket/12620] Fix session tests PHPBB3-12620 --- tests/session/testable_factory.php | 1 + tests/test_framework/phpbb_functional_test_case.php | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 3e25286480..505eb7006f 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -96,6 +96,7 @@ class phpbb_session_testable_factory 'auth.provider.db', new phpbb_mock_auth_provider() ); + $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); $provider_collection->add('auth.provider.db'); $phpbb_container->set( diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index cdb3d01524..9391795e32 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -204,6 +204,11 @@ class phpbb_functional_test_case extends phpbb_test_case { if (!$this->cache) { + global $phpbb_container; + + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); + $this->cache = new \phpbb\cache\driver\file; } -- cgit v1.2.1 From dd4f2387fd2f4df0e1513c251c9044f5bef60618 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 19:50:07 +0100 Subject: [ticket/12620] Use the test environment for the tests PHPBB3-12620 --- tests/bootstrap.php | 2 +- tests/controller/config/development/routing.yml | 3 --- tests/controller/config/test/routing.yml | 3 +++ .../ext/vendor2/bar/config/development/routing.yml | 3 --- tests/controller/ext/vendor2/bar/config/test/routing.yml | 3 +++ tests/di/create_container_test.php | 2 -- tests/di/fixtures/config/development/config.yml | 2 -- .../fixtures/config/development/container/environment.yml | 14 -------------- tests/di/fixtures/config/test/config.yml | 2 ++ tests/di/fixtures/config/test/container/environment.yml | 14 ++++++++++++++ .../disabled/config/development/container/environment.yml | 2 -- .../vendor/disabled/config/test/container/environment.yml | 2 ++ .../enabled-2/config/development/container/environment.yml | 2 -- .../vendor/enabled-2/config/test/container/environment.yml | 2 ++ tests/di/fixtures/other_config/development/config.yml | 2 -- .../other_config/development/container/environment.yml | 14 -------------- tests/di/fixtures/other_config/test/config.yml | 2 ++ .../fixtures/other_config/test/container/environment.yml | 14 ++++++++++++++ tests/pagination/config/development/routing.yml | 6 ------ tests/pagination/config/test/routing.yml | 6 ++++++ 20 files changed, 49 insertions(+), 51 deletions(-) delete mode 100644 tests/controller/config/development/routing.yml create mode 100644 tests/controller/config/test/routing.yml delete mode 100644 tests/controller/ext/vendor2/bar/config/development/routing.yml create mode 100644 tests/controller/ext/vendor2/bar/config/test/routing.yml delete mode 100644 tests/di/fixtures/config/development/config.yml delete mode 100644 tests/di/fixtures/config/development/container/environment.yml create mode 100644 tests/di/fixtures/config/test/config.yml create mode 100644 tests/di/fixtures/config/test/container/environment.yml delete mode 100644 tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml create mode 100644 tests/di/fixtures/ext/vendor/disabled/config/test/container/environment.yml delete mode 100644 tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml create mode 100644 tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml delete mode 100644 tests/di/fixtures/other_config/development/config.yml delete mode 100644 tests/di/fixtures/other_config/development/container/environment.yml create mode 100644 tests/di/fixtures/other_config/test/config.yml create mode 100644 tests/di/fixtures/other_config/test/container/environment.yml delete mode 100644 tests/pagination/config/development/routing.yml create mode 100644 tests/pagination/config/test/routing.yml (limited to 'tests') diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2fc8858585..ace48ea035 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,7 +12,7 @@ */ define('IN_PHPBB', true); -define('PHPBB_ENVIRONMENT', 'development'); +define('PHPBB_ENVIRONMENT', 'test'); $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; diff --git a/tests/controller/config/development/routing.yml b/tests/controller/config/development/routing.yml deleted file mode 100644 index 175b11f130..0000000000 --- a/tests/controller/config/development/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -core_controller: - pattern: /core_foo - defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/config/test/routing.yml b/tests/controller/config/test/routing.yml new file mode 100644 index 0000000000..175b11f130 --- /dev/null +++ b/tests/controller/config/test/routing.yml @@ -0,0 +1,3 @@ +core_controller: + pattern: /core_foo + defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/ext/vendor2/bar/config/development/routing.yml b/tests/controller/ext/vendor2/bar/config/development/routing.yml deleted file mode 100644 index 85c93b453f..0000000000 --- a/tests/controller/ext/vendor2/bar/config/development/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -controller3: - pattern: /bar - defaults: { _controller: bar.controller:handle } diff --git a/tests/controller/ext/vendor2/bar/config/test/routing.yml b/tests/controller/ext/vendor2/bar/config/test/routing.yml new file mode 100644 index 0000000000..85c93b453f --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/test/routing.yml @@ -0,0 +1,3 @@ +controller3: + pattern: /bar + defaults: { _controller: bar.controller:handle } diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 9cc714db40..d52fb6b085 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -13,8 +13,6 @@ namespace { - define('PHPBB_ENVIRONMENT', 'production'); - require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/fixtures/ext/vendor/enabled_4/di/extension.php'; diff --git a/tests/di/fixtures/config/development/config.yml b/tests/di/fixtures/config/development/config.yml deleted file mode 100644 index fcfa84f68b..0000000000 --- a/tests/di/fixtures/config/development/config.yml +++ /dev/null @@ -1,2 +0,0 @@ -core: - require_dev_dependencies: true diff --git a/tests/di/fixtures/config/development/container/environment.yml b/tests/di/fixtures/config/development/container/environment.yml deleted file mode 100644 index f2a22ae109..0000000000 --- a/tests/di/fixtures/config/development/container/environment.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - core: true - -services: - config.php: - synthetic: true - - dbal.conn: - class: phpbb\db\driver\factory - arguments: - - @service_container - - dispatcher: - class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/config/test/config.yml b/tests/di/fixtures/config/test/config.yml new file mode 100644 index 0000000000..fcfa84f68b --- /dev/null +++ b/tests/di/fixtures/config/test/config.yml @@ -0,0 +1,2 @@ +core: + require_dev_dependencies: true diff --git a/tests/di/fixtures/config/test/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml new file mode 100644 index 0000000000..f2a22ae109 --- /dev/null +++ b/tests/di/fixtures/config/test/container/environment.yml @@ -0,0 +1,14 @@ +parameters: + core: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml deleted file mode 100644 index 31ada384bf..0000000000 --- a/tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - disabled: true diff --git a/tests/di/fixtures/ext/vendor/disabled/config/test/container/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/test/container/environment.yml new file mode 100644 index 0000000000..31ada384bf --- /dev/null +++ b/tests/di/fixtures/ext/vendor/disabled/config/test/container/environment.yml @@ -0,0 +1,2 @@ +parameters: + disabled: true diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml deleted file mode 100644 index feeb5a7a2d..0000000000 --- a/tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - enabled_2: true diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml new file mode 100644 index 0000000000..feeb5a7a2d --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml @@ -0,0 +1,2 @@ +parameters: + enabled_2: true diff --git a/tests/di/fixtures/other_config/development/config.yml b/tests/di/fixtures/other_config/development/config.yml deleted file mode 100644 index fcfa84f68b..0000000000 --- a/tests/di/fixtures/other_config/development/config.yml +++ /dev/null @@ -1,2 +0,0 @@ -core: - require_dev_dependencies: true diff --git a/tests/di/fixtures/other_config/development/container/environment.yml b/tests/di/fixtures/other_config/development/container/environment.yml deleted file mode 100644 index c299bfc648..0000000000 --- a/tests/di/fixtures/other_config/development/container/environment.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - other_config: true - -services: - config.php: - synthetic: true - - dbal.conn: - class: phpbb\db\driver\factory - arguments: - - @service_container - - dispatcher: - class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/test/config.yml b/tests/di/fixtures/other_config/test/config.yml new file mode 100644 index 0000000000..fcfa84f68b --- /dev/null +++ b/tests/di/fixtures/other_config/test/config.yml @@ -0,0 +1,2 @@ +core: + require_dev_dependencies: true diff --git a/tests/di/fixtures/other_config/test/container/environment.yml b/tests/di/fixtures/other_config/test/container/environment.yml new file mode 100644 index 0000000000..c299bfc648 --- /dev/null +++ b/tests/di/fixtures/other_config/test/container/environment.yml @@ -0,0 +1,14 @@ +parameters: + other_config: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock diff --git a/tests/pagination/config/development/routing.yml b/tests/pagination/config/development/routing.yml deleted file mode 100644 index dd667274cd..0000000000 --- a/tests/pagination/config/development/routing.yml +++ /dev/null @@ -1,6 +0,0 @@ -core_controller: - pattern: /test - defaults: { _controller: core_foo.controller:bar, page: 1} -core_page_controller: - pattern: /test/page/{page} - defaults: { _controller: core_foo.controller:bar} diff --git a/tests/pagination/config/test/routing.yml b/tests/pagination/config/test/routing.yml new file mode 100644 index 0000000000..dd667274cd --- /dev/null +++ b/tests/pagination/config/test/routing.yml @@ -0,0 +1,6 @@ +core_controller: + pattern: /test + defaults: { _controller: core_foo.controller:bar, page: 1} +core_page_controller: + pattern: /test/page/{page} + defaults: { _controller: core_foo.controller:bar} -- cgit v1.2.1 From ac0ff219c61bd187dd3fbde5b6808624bd8ef077 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 20:04:00 +0100 Subject: [ticket/12620] Move the routing.yml file to routing/environment.yml PHPBB3-12620 --- tests/controller/config/test/routing.yml | 3 --- tests/controller/config/test/routing/environment.yml | 3 +++ tests/controller/ext/vendor2/bar/config/test/routing.yml | 3 --- .../controller/ext/vendor2/bar/config/test/routing/environment.yml | 3 +++ tests/pagination/config/test/routing.yml | 6 ------ tests/pagination/config/test/routing/environment.yml | 6 ++++++ 6 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 tests/controller/config/test/routing.yml create mode 100644 tests/controller/config/test/routing/environment.yml delete mode 100644 tests/controller/ext/vendor2/bar/config/test/routing.yml create mode 100644 tests/controller/ext/vendor2/bar/config/test/routing/environment.yml delete mode 100644 tests/pagination/config/test/routing.yml create mode 100644 tests/pagination/config/test/routing/environment.yml (limited to 'tests') diff --git a/tests/controller/config/test/routing.yml b/tests/controller/config/test/routing.yml deleted file mode 100644 index 175b11f130..0000000000 --- a/tests/controller/config/test/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -core_controller: - pattern: /core_foo - defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/config/test/routing/environment.yml b/tests/controller/config/test/routing/environment.yml new file mode 100644 index 0000000000..175b11f130 --- /dev/null +++ b/tests/controller/config/test/routing/environment.yml @@ -0,0 +1,3 @@ +core_controller: + pattern: /core_foo + defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/ext/vendor2/bar/config/test/routing.yml b/tests/controller/ext/vendor2/bar/config/test/routing.yml deleted file mode 100644 index 85c93b453f..0000000000 --- a/tests/controller/ext/vendor2/bar/config/test/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -controller3: - pattern: /bar - defaults: { _controller: bar.controller:handle } diff --git a/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml new file mode 100644 index 0000000000..85c93b453f --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml @@ -0,0 +1,3 @@ +controller3: + pattern: /bar + defaults: { _controller: bar.controller:handle } diff --git a/tests/pagination/config/test/routing.yml b/tests/pagination/config/test/routing.yml deleted file mode 100644 index dd667274cd..0000000000 --- a/tests/pagination/config/test/routing.yml +++ /dev/null @@ -1,6 +0,0 @@ -core_controller: - pattern: /test - defaults: { _controller: core_foo.controller:bar, page: 1} -core_page_controller: - pattern: /test/page/{page} - defaults: { _controller: core_foo.controller:bar} diff --git a/tests/pagination/config/test/routing/environment.yml b/tests/pagination/config/test/routing/environment.yml new file mode 100644 index 0000000000..dd667274cd --- /dev/null +++ b/tests/pagination/config/test/routing/environment.yml @@ -0,0 +1,6 @@ +core_controller: + pattern: /test + defaults: { _controller: core_foo.controller:bar, page: 1} +core_page_controller: + pattern: /test/page/{page} + defaults: { _controller: core_foo.controller:bar} -- cgit v1.2.1 From 677b5b2cd4937ee6c777728082084c661223dee8 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 20 Nov 2014 22:40:37 +0100 Subject: [ticket/12620] Fix rebase PHPBB3-12620 --- tests/avatar/driver/barfoo.php | 52 ++++++++++++++++---------------- tests/avatar/driver/foobar.php | 52 ++++++++++++++++---------------- tests/controller/common_helper_route.php | 6 ++-- tests/controller/controller_test.php | 4 +-- tests/pagination/pagination_test.php | 10 ++---- 5 files changed, 59 insertions(+), 65 deletions(-) (limited to 'tests') diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php index 0bf30b8a91..067bb3ef97 100644 --- a/tests/avatar/driver/barfoo.php +++ b/tests/avatar/driver/barfoo.php @@ -1,26 +1,26 @@ -router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php'); - $this->router->find_routing_files($finder); + $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router->find_routing_files($this->extension_manager->all_enabled()); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); @@ -319,7 +319,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); } -//TODO + public function helper_url_data_absolute_with_rewrite() { return array( diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 637e9685e6..354a902831 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,8 +40,8 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php'); - $router->find_routing_files($this->extension_manager->get_finder()); + $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router->find_routing_files($this->extension_manager->all_enabled()); $routes = $router->find(__DIR__)->get_routes(); // This will need to be updated if any new routes are defined diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 04f7b807a7..1b9e8c751c 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -36,16 +36,10 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $filesystem = new \phpbb\filesystem(); $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); - $finder = new \phpbb\finder( - $filesystem, - dirname(__FILE__) . '/', - new phpbb_mock_cache() - ); - $finder->set_extensions(array_keys($manager->all_enabled())); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php'); - $router->find_routing_files($finder); + $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router->find_routing_files($manager->all_enabled()); $router->find(dirname(__FILE__) . '/'); $request = new phpbb_mock_request(); -- cgit v1.2.1 From 5d3f0a9abbfe9678a9b5b480d1bbdfae69384018 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 22 Nov 2014 00:13:13 +0100 Subject: [ticket/13359] Add phpbb\template\twig\environment to template constructor PHPBB3-13359 --- tests/template/template_includecss_test.php | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index 49bd9dec8b..a8db74c3f1 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -15,6 +15,12 @@ require_once dirname(__FILE__) . '/template_test_case_with_tree.php'; class phpbb_template_template_includecss_test extends phpbb_template_template_test_case_with_tree { + /** @var \phpbb\path_helper */ + protected $phpbb_path_helper; + + /** @var string */ + protected $parent_template_path; + protected function setup_engine(array $new_config = array()) { global $phpbb_root_path, $phpEx, $user; @@ -34,11 +40,32 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te $this->template_path = $this->test_path . '/templates'; $this->parent_template_path = $this->test_path . '/parent_templates'; + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $config, + $this->phpbb_path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); $this->template = new phpbb\template\twig\twig( $this->phpbb_path_helper, $config, $user, - new phpbb\template\context(), + $context, + $twig, + $cache_path, + array(new \phpbb\template\twig\extension($context, $this->user)), new phpbb_mock_extension_manager( dirname(__FILE__) . '/', array( @@ -50,6 +77,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te ) ) ); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } -- cgit v1.2.1 From d78bb2865b27aa753b165fdc8aaa73ed82eaeac8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 22 Nov 2014 02:15:06 +0100 Subject: [ticket/13421] Always require the interface when possible PHPBB3-13421 --- tests/dbal/db_tools_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 51f9daacfb..d34a2249ef 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -17,7 +17,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case { /** @var \phpbb\db\driver\driver_interface */ protected $db; - /** @var \phpbb\db\tools */ + /** @var \phpbb\db\tools_interface */ protected $tools; protected $table_exists; protected $table_data; -- cgit v1.2.1 From ec90f2b380a598a3dbf7ada0e95878d9d1b85cbe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Dec 2014 16:34:02 +0100 Subject: [ticket/13421] Move tools to subdirectory PHPBB3-13421 --- tests/dbal/auto_increment_test.php | 2 +- tests/dbal/db_tools_test.php | 8 ++++---- tests/dbal/migrator_test.php | 2 +- tests/extension/manager_test.php | 2 +- tests/extension/metadata_manager_test.php | 2 +- tests/migrator/convert_timezones_test.php | 6 +++--- tests/migrator/schema_generator_test.php | 2 +- tests/notification/convert_test.php | 2 +- tests/test_framework/phpbb_database_test_case.php | 2 +- tests/test_framework/phpbb_database_test_connection_manager.php | 4 ++-- tests/test_framework/phpbb_functional_test_case.php | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php index 1ed8ea29e3..057bcb5bac 100644 --- a/tests/dbal/auto_increment_test.php +++ b/tests/dbal/auto_increment_test.php @@ -30,7 +30,7 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->tools = new \phpbb\db\tools($this->db); + $this->tools = new \phpbb\db\tools\tools($this->db); $this->table_data = array( 'COLUMNS' => array( diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index d34a2249ef..7d01376062 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -17,7 +17,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case { /** @var \phpbb\db\driver\driver_interface */ protected $db; - /** @var \phpbb\db\tools_interface */ + /** @var \phpbb\db\tools\tools_interface */ protected $tools; protected $table_exists; protected $table_data; @@ -32,7 +32,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->tools = new \phpbb\db\tools($this->db); + $this->tools = new \phpbb\db\tools\tools($this->db); $this->table_data = array( 'COLUMNS' => array( @@ -340,7 +340,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case public function test_perform_schema_changes_drop_tables() { - $db_tools = $this->getMock('\phpbb\db\tools', array( + $db_tools = $this->getMock('\phpbb\db\tools\tools', array( 'sql_table_exists', 'sql_table_drop', ), array(&$this->db)); @@ -366,7 +366,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case public function test_perform_schema_changes_drop_columns() { - $db_tools = $this->getMock('\phpbb\db\tools', array( + $db_tools = $this->getMock('\phpbb\db\tools\tools', array( 'sql_column_exists', 'sql_column_remove', ), array(&$this->db)); diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 10a9444d63..e4fb442818 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -38,7 +38,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->db_tools = new \phpbb\db\tools($this->db); + $this->db_tools = new \phpbb\db\tools\tools($this->db); $this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache, 'phpbb_config'); diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 5c7cad89f6..ab93edd939 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -150,7 +150,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $config = new \phpbb\config\config(array('version' => PHPBB_VERSION)); $db = $this->new_dbal(); - $db_tools = new \phpbb\db\tools($db); + $db_tools = new \phpbb\db\tools\tools($db); $phpbb_root_path = __DIR__ . './../../phpBB/'; $php_ext = 'php'; $table_prefix = 'phpbb_'; diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index b7a6cd3c5b..2d6df3a3f3 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -41,7 +41,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case 'version' => '3.1.0', )); $this->db = $this->new_dbal(); - $this->db_tools = new \phpbb\db\tools($this->db); + $this->db_tools = new \phpbb\db\tools\tools($this->db); $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->phpEx = 'php'; $this->user = new \phpbb\user('\phpbb\datetime'); diff --git a/tests/migrator/convert_timezones_test.php b/tests/migrator/convert_timezones_test.php index 7501ed2ed0..80a43b4035 100644 --- a/tests/migrator/convert_timezones_test.php +++ b/tests/migrator/convert_timezones_test.php @@ -18,7 +18,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case public function getDataSet() { $this->db = $this->new_dbal(); - $db_tools = new \phpbb\db\tools($this->db); + $db_tools = new \phpbb\db\tools\tools($this->db); // user_dst doesn't exist anymore, must re-add it to test this $db_tools->sql_column_add('phpbb_users', 'user_dst', array('BOOL', 1)); @@ -59,7 +59,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case $this->migration = new \phpbb\db\migration\data\v310\timezone( new \phpbb\config\config(array()), $this->db, - new \phpbb\db\tools($this->db), + new \phpbb\db\tools\tools($this->db), $phpbb_root_path, $phpEx, 'phpbb_' @@ -90,7 +90,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case } $this->db->sql_freeresult($result); - $db_tools = new \phpbb\db\tools($this->db); + $db_tools = new \phpbb\db\tools\tools($this->db); // Remove the user_dst field again $db_tools->sql_column_remove('phpbb_users', 'user_dst'); diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php index 9adf518a5d..1e3b489426 100644 --- a/tests/migrator/schema_generator_test.php +++ b/tests/migrator/schema_generator_test.php @@ -30,7 +30,7 @@ class schema_generator_test extends phpbb_test_case $this->config = new \phpbb\config\config(array()); $this->db = new \phpbb\db\driver\sqlite(); - $this->db_tools = new \phpbb\db\tools($this->db); + $this->db_tools = new \phpbb\db\tools\tools($this->db); $this->table_prefix = 'phpbb_'; } diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index 32ab34c9bc..ad6e5849d3 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -32,7 +32,7 @@ class phpbb_notification_convert_test extends phpbb_database_test_case $this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert( new \phpbb\config\config(array()), $this->db, - new \phpbb\db\tools($this->db), + new \phpbb\db\tools\tools($this->db), $phpbb_root_path, $phpEx, 'phpbb_' diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index fc1a3632f4..f630f4ab52 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -77,7 +77,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test global $table_prefix; $db = new \phpbb\db\driver\sqlite(); - $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix); + $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix); file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema())); } diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 5d643e43e2..ba641c6fb7 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -370,11 +370,11 @@ class phpbb_database_test_connection_manager ->get_classes(); $db = new \phpbb\db\driver\sqlite(); - $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix); + $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix); $db_table_schema = $schema_generator->get_schema(); } - $db_tools = new \phpbb\db\tools($db, true); + $db_tools = new \phpbb\db\tools\tools($db, true); foreach ($db_table_schema as $table_name => $table_data) { $queries = $db_tools->sql_create_table( diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 9391795e32..0ea6c5b7cb 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -230,7 +230,7 @@ class phpbb_functional_test_case extends phpbb_test_case $config = new \phpbb\config\config(array()); $db = $this->get_db(); - $db_tools = new \phpbb\db\tools($db); + $db_tools = new \phpbb\db\tools\tools($db); $migrator = new \phpbb\db\migrator( $config, -- cgit v1.2.1 From 17daaaf441c4972932a4fa3632eaa20132a8763e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Mon, 12 Jan 2015 22:43:03 +0100 Subject: [ticket/13499] Move `get_remote_file()` to `functions_compatibility.php` PHPBB3-13499 --- tests/functions/get_remote_file_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php index d412dce164..8e9ad1105a 100644 --- a/tests/functions/get_remote_file_test.php +++ b/tests/functions/get_remote_file_test.php @@ -12,7 +12,7 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; /** * @group slow -- cgit v1.2.1 From 6842831d6baa59425ec83cc2ebbae377942824ce Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 17 Jan 2015 11:05:18 +0100 Subject: [ticket/13513] Use paths relative to the phpBB root in the router PHPBB3-13513 --- tests/controller/common_helper_route.php | 2 +- tests/controller/controller_test.php | 2 +- tests/pagination/pagination_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 19d40cf071..3f98d51f16 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -114,7 +114,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ); $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); - $this->router->find_routing_files($this->extension_manager->all_enabled()); + $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 354a902831..86615fe4dc 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -41,7 +41,7 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); - $router->find_routing_files($this->extension_manager->all_enabled()); + $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); // This will need to be updated if any new routes are defined diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 1b9e8c751c..7d928d8820 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -39,7 +39,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); - $router->find_routing_files($manager->all_enabled()); + $router->find_routing_files($manager->all_enabled(false)); $router->find(dirname(__FILE__) . '/'); $request = new phpbb_mock_request(); -- cgit v1.2.1 From 7fc586080bf5e7b6e90dcf44526200d7c9356d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Mon, 5 Jan 2015 22:21:31 +0100 Subject: [ticket/13468] Update calls to `add_log()` PHPBB3-13468 --- tests/dbal/migrator_tool_module_test.php | 2 +- tests/log/function_add_log_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 08c3e979b8..fa2a8c33df 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -27,7 +27,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case parent::setup(); - // Force add_log function to not be used + // Disable the logs $skip_add_log = true; $db = $this->db = $this->new_dbal(); diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php index 63e468498e..78949734a9 100644 --- a/tests/log/function_add_log_test.php +++ b/tests/log/function_add_log_test.php @@ -11,7 +11,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; class phpbb_log_function_add_log_test extends phpbb_database_test_case { -- cgit v1.2.1 From 26713063045117b2221ad9373d09267dcae8637f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 29 Jan 2015 01:41:52 -0800 Subject: [ticket/10388] Update tests PHPBB3-10388 --- tests/template/template_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 0bbfe3848d..bb6b7300cb 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -286,7 +286,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array(), array(), - "Value'\n1 O'Clock\nValue\'\n1 O\'Clock", + "Value'\n1 O'Clock\nValue\\x27\n1\\x20O\\x27Clock", array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"), ), array( -- cgit v1.2.1 From 79d4ff553844fa80be4da9286239f62a45489072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 11 Jan 2015 17:32:31 +0100 Subject: [ticket/13494] Update calls to `set_config()` PHPBB3-13494 --- tests/console/cron/run_test.php | 1 - tests/functions_user/delete_user_test.php | 1 - tests/lock/db_test.php | 1 - tests/notification/group_request_test.php | 2 -- tests/notification/submit_post_base.php | 1 - tests/notification/user_list_trim_test.php | 1 - tests/session/testable_factory.php | 1 - tests/test_framework/phpbb_functional_test_case.php | 2 +- tests/tree/nestedset_forum_base.php | 1 - 9 files changed, 1 insertion(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index f76e967484..8638648898 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -39,7 +39,6 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $db = $this->db = $this->new_dbal(); $config = $this->config = new \phpbb\config\config(array('cron_lock' => '0')); - set_config(null, null, null, $this->config); $this->lock = new \phpbb\lock\db('cron_lock', $this->config, $this->db); $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index d5c78c64ad..272fc751c6 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -32,7 +32,6 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case 'load_online_time' => 5, 'search_type' => '\phpbb\search\fulltext_mysql', )); - set_config(false, false, false, $config); set_config_count(false, false, false, $config); $cache = new phpbb_mock_null_cache(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php index 6fc813cb38..389eab4152 100644 --- a/tests/lock/db_test.php +++ b/tests/lock/db_test.php @@ -30,7 +30,6 @@ class phpbb_lock_db_test extends phpbb_database_test_case $db = $this->db = $this->new_dbal(); $config = $this->config = new \phpbb\config\config(array('rand_seed' => '', 'rand_seed_last_update' => '0')); - set_config(null, null, null, $this->config); $this->lock = new \phpbb\lock\db('test_lock', $this->config, $this->db); } diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 0d1bda95ce..0d532882c6 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -40,8 +40,6 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_content.' . $phpEx); - set_config(false, false, false, $this->config); - $this->container->set('groupposition.legend', new \phpbb\groupposition\legend( $this->db, $this->user diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 5e770f71c9..fd5f33466b 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -70,7 +70,6 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Config $config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,)); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index c43eff729c..2d24950275 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -33,7 +33,6 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $db = $this->new_dbal(); $config = new \phpbb\config\config(array()); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 505eb7006f..99e7d27bea 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -84,7 +84,6 @@ class phpbb_session_testable_factory request_var(null, null, null, null, $request); $config = $this->config = new \phpbb\config\config($this->get_config_data()); - set_config(null, null, null, $config); $db = $dbal; diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 8f6d85fe14..984c0dcdcf 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -577,7 +577,7 @@ class phpbb_functional_test_case extends phpbb_test_case { require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); } - set_config(null, null, null, $config); + set_config_count(null, null, null, $config); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $passwords_manager = $this->get_passwords_manager(); diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php index c56be1f81e..647fcef2af 100644 --- a/tests/tree/nestedset_forum_base.php +++ b/tests/tree/nestedset_forum_base.php @@ -59,7 +59,6 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case global $config; $config = $this->config = new \phpbb\config\config(array('nestedset_forum_lock' => 0)); - set_config(null, null, null, $this->config); $this->lock = new \phpbb\lock\db('nestedset_forum_lock', $this->config, $this->db); $this->set = new \phpbb\tree\nestedset_forum($this->db, $this->lock, 'phpbb_forums'); -- cgit v1.2.1 From a633f3484c63fe4bd70df548b3ae4bd569bdef46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 11 Jan 2015 18:01:52 +0100 Subject: [ticket/13496] Update calls to `set_config_count()` PHPBB3-13496 --- tests/content_visibility/delete_post_test.php | 10 ++++++---- tests/functions_user/delete_user_test.php | 1 - tests/notification/submit_post_base.php | 1 - tests/notification/user_list_trim_test.php | 1 - tests/test_framework/phpbb_functional_test_case.php | 1 - 5 files changed, 6 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 6ad6351a0c..dc966c37ae 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -292,12 +292,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case { global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx; - $config['search_type'] = 'phpbb_mock_search'; + $config = new \phpbb\config\config(array( + 'num_posts' => 3, + 'num_topics' => 1, + 'search_type' => 'phpbb_mock_search', + )); $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $phpbb_config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1)); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - set_config_count(null, null, null, $phpbb_config); // Create auth mock $auth = $this->getMock('\phpbb\auth\auth'); @@ -313,7 +315,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $phpbb_config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); + $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 272fc751c6..0cb171c885 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -32,7 +32,6 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case 'load_online_time' => 5, 'search_type' => '\phpbb\search\fulltext_mysql', )); - set_config_count(false, false, false, $config); $cache = new phpbb_mock_null_cache(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index fd5f33466b..2d621f82d3 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -70,7 +70,6 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Config $config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,)); - set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( new \phpbb\cache\driver\null(), diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index 2d24950275..5886c49512 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -33,7 +33,6 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $db = $this->new_dbal(); $config = new \phpbb\config\config(array()); - set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( new \phpbb\cache\driver\null(), diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 984c0dcdcf..93876479d5 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -578,7 +578,6 @@ class phpbb_functional_test_case extends phpbb_test_case require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); } - set_config_count(null, null, null, $config); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $passwords_manager = $this->get_passwords_manager(); -- cgit v1.2.1 From f4b42c961f5729b0bbadca8a897410f890228364 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Tue, 3 Feb 2015 12:41:31 +0100 Subject: [ticket/13139] Fix tests PHPBB3-13139 --- tests/template/template_includecss_test.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index a8db74c3f1..96980e17c6 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -83,13 +83,6 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te public function template_data() { - $url_base = explode('/', dirname(__FILE__)); - foreach ($url_base as &$dir) - { - $dir = rawurlencode($dir); - } - $url_base = implode('/', $url_base); - return array( /* array( @@ -107,11 +100,11 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te ), array( array('TEST' => 3), - '', + '', ), array( array('TEST' => 4), - '', + '', ), ); } -- cgit v1.2.1 From f6e06da4c68917dafb057bf7fe19f884a3e148c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 4 Jan 2015 20:41:04 +0100 Subject: [ticket/13455] Update calls to `request_var()` PHPBB3-13455 --- tests/request/request_var_test.php | 2 +- tests/session/testable_factory.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php index 67712eb6c8..b409e5ef25 100644 --- a/tests/request/request_var_test.php +++ b/tests/request/request_var_test.php @@ -11,7 +11,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_request_var_test extends phpbb_test_case diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 99e7d27bea..7819063505 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -81,7 +81,6 @@ class phpbb_session_testable_factory $this->cookies, $this->server_data ); - request_var(null, null, null, null, $request); $config = $this->config = new \phpbb\config\config($this->get_config_data()); -- cgit v1.2.1 From 216fb13c2ad119e3a7f1b3aea497fdb825c80136 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Tue, 3 Feb 2015 16:30:41 +0100 Subject: [ticket/13407] Remove the last occurence of pattern in routing files PHPBB3-13407 --- tests/controller/ext/vendor2/bar/config/test/routing/environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml index 85c93b453f..5696ecb180 100644 --- a/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml +++ b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml @@ -1,3 +1,3 @@ controller3: - pattern: /bar + path: /bar defaults: { _controller: bar.controller:handle } -- cgit v1.2.1 From 37ae99c75d388221489aa1069078d92eca413741 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Jan 2015 12:06:45 +0100 Subject: [ticket/10748] Replace direct creations of tools(); PHPBB3-10748 --- tests/dbal/auto_increment_test.php | 3 ++- tests/dbal/db_tools_test.php | 3 ++- tests/dbal/migrator_test.php | 3 ++- tests/extension/manager_test.php | 3 ++- tests/extension/metadata_manager_test.php | 3 ++- tests/migrator/convert_timezones_test.php | 9 ++++++--- tests/migrator/schema_generator_test.php | 3 ++- tests/notification/convert_test.php | 3 ++- tests/test_framework/phpbb_database_test_case.php | 5 ++++- tests/test_framework/phpbb_database_test_connection_manager.php | 8 ++++++-- tests/test_framework/phpbb_functional_test_case.php | 3 ++- 11 files changed, 32 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php index 057bcb5bac..39eb6835ff 100644 --- a/tests/dbal/auto_increment_test.php +++ b/tests/dbal/auto_increment_test.php @@ -30,7 +30,8 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->tools = new \phpbb\db\tools\tools($this->db); + $factory = new \phpbb\db\tools\factory(); + $this->tools = $factory->get($this->db); $this->table_data = array( 'COLUMNS' => array( diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index c09b34f55c..aa0b6ccf48 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -32,7 +32,8 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->tools = new \phpbb\db\tools\tools($this->db); + $factory = new \phpbb\db\tools\factory(); + $this->tools = $factory->get($this->db); $this->table_data = array( 'COLUMNS' => array( diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 9b8383fc88..6416a2fcf7 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -38,7 +38,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->db_tools = new \phpbb\db\tools\tools($this->db); + $factory = new \phpbb\db\tools\factory(); + $this->db_tools = $factory->get($this->db); $this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache, 'phpbb_config'); diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index c737d33f95..0126216701 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -150,7 +150,8 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $config = new \phpbb\config\config(array('version' => PHPBB_VERSION)); $db = $this->new_dbal(); - $db_tools = new \phpbb\db\tools\tools($db); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($db); $phpbb_root_path = __DIR__ . './../../phpBB/'; $php_ext = 'php'; $table_prefix = 'phpbb_'; diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index bd7acf12f9..8514ed3dbd 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -41,7 +41,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case 'version' => '3.1.0', )); $this->db = $this->new_dbal(); - $this->db_tools = new \phpbb\db\tools\tools($this->db); + $factory = new \phpbb\db\tools\factory(); + $this->db_tools = $factory->get($this->db); $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->phpEx = 'php'; $this->user = new \phpbb\user('\phpbb\datetime'); diff --git a/tests/migrator/convert_timezones_test.php b/tests/migrator/convert_timezones_test.php index 80a43b4035..f8d780da0c 100644 --- a/tests/migrator/convert_timezones_test.php +++ b/tests/migrator/convert_timezones_test.php @@ -18,7 +18,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case public function getDataSet() { $this->db = $this->new_dbal(); - $db_tools = new \phpbb\db\tools\tools($this->db); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($this->db); // user_dst doesn't exist anymore, must re-add it to test this $db_tools->sql_column_add('phpbb_users', 'user_dst', array('BOOL', 1)); @@ -55,11 +56,12 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case global $phpbb_root_path, $phpEx; $this->db = $this->new_dbal(); + $factory = new \phpbb\db\tools\factory(); $this->migration = new \phpbb\db\migration\data\v310\timezone( new \phpbb\config\config(array()), $this->db, - new \phpbb\db\tools\tools($this->db), + $factory->get($this->db), $phpbb_root_path, $phpEx, 'phpbb_' @@ -90,7 +92,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case } $this->db->sql_freeresult($result); - $db_tools = new \phpbb\db\tools\tools($this->db); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($this->db); // Remove the user_dst field again $db_tools->sql_column_remove('phpbb_users', 'user_dst'); diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php index 1e3b489426..40a8343e22 100644 --- a/tests/migrator/schema_generator_test.php +++ b/tests/migrator/schema_generator_test.php @@ -30,7 +30,8 @@ class schema_generator_test extends phpbb_test_case $this->config = new \phpbb\config\config(array()); $this->db = new \phpbb\db\driver\sqlite(); - $this->db_tools = new \phpbb\db\tools\tools($this->db); + $factory = new \phpbb\db\tools\factory(); + $this->db_tools = $factory->get($this->db); $this->table_prefix = 'phpbb_'; } diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index ad6e5849d3..4a7fd89409 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -28,11 +28,12 @@ class phpbb_notification_convert_test extends phpbb_database_test_case global $phpbb_root_path, $phpEx; $this->db = $this->new_dbal(); + $factory = new \phpbb\db\tools\factory(); $this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert( new \phpbb\config\config(array()), $this->db, - new \phpbb\db\tools\tools($this->db), + $factory->get($this->db), $phpbb_root_path, $phpEx, 'phpbb_' diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index f630f4ab52..903158d3c6 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -77,7 +77,10 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test global $table_prefix; $db = new \phpbb\db\driver\sqlite(); - $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($db, true); + + $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix); file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema())); } diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index ba641c6fb7..4f38ccc0d8 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -370,11 +370,15 @@ class phpbb_database_test_connection_manager ->get_classes(); $db = new \phpbb\db\driver\sqlite(); - $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($db, true); + + $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix); $db_table_schema = $schema_generator->get_schema(); } - $db_tools = new \phpbb\db\tools\tools($db, true); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($db, true); foreach ($db_table_schema as $table_name => $table_data) { $queries = $db_tools->sql_create_table( diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 93876479d5..de18fb2cf2 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -230,7 +230,8 @@ class phpbb_functional_test_case extends phpbb_test_case $config = new \phpbb\config\config(array()); $db = $this->get_db(); - $db_tools = new \phpbb\db\tools\tools($db); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($db); $container = new phpbb_mock_container_builder(); $migrator = new \phpbb\db\migrator( -- cgit v1.2.1 From 291143fe6a821a07f8097e26e38f69efa3c84848 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 25 Jan 2015 00:33:26 +0100 Subject: [ticket/9109] Properly document and calculate the group settings with value 0 PHPBB3-9109 --- .../fixtures/get_max_setting_from_group.xml | 62 ++++++++++++++++++++++ .../get_max_setting_from_group_test.php | 60 +++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml create mode 100644 tests/functions_privmsgs/get_max_setting_from_group_test.php (limited to 'tests') diff --git a/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml b/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml new file mode 100644 index 0000000000..b10bf782ec --- /dev/null +++ b/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml @@ -0,0 +1,62 @@ + + + + group_id + group_desc + group_message_limit + group_max_recipients + + 1 + + 1 + 3 + + + 2 + + 2 + 4 + + + 3 + + 0 + 0 + +
+ + user_id + group_id + user_pending + + 1 + 1 + 0 + + + 1 + 2 + 0 + + + 1 + 3 + 0 + + + 2 + 1 + 0 + + + 2 + 2 + 0 + + + 3 + 3 + 0 + +
+
diff --git a/tests/functions_privmsgs/get_max_setting_from_group_test.php b/tests/functions_privmsgs/get_max_setting_from_group_test.php new file mode 100644 index 0000000000..48d42ec48a --- /dev/null +++ b/tests/functions_privmsgs/get_max_setting_from_group_test.php @@ -0,0 +1,60 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_privmsgs.php'; + +class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/get_max_setting_from_group.xml'); + } + + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + + protected function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + } + + static public function get_max_setting_from_group_data() + { + return array( + array(1, 0, 'message_limit'), + array(2, 2, 'message_limit'), + array(3, 0, 'message_limit'), + array(1, 0, 'max_recipients'), + array(2, 4, 'max_recipients'), + array(3, 0, 'max_recipients'), + ); + } + + /** + * @dataProvider get_max_setting_from_group_data + */ + public function test_get_max_setting_from_group($user_id, $expected, $setting) + { + $this->assertEquals($expected, phpbb_get_max_setting_from_group($this->db, $user_id, $setting)); + } + + /** + * @expectedException InvalidArgumentException + */ + public function test_get_max_setting_from_group_throws() + { + phpbb_get_max_setting_from_group($this->db, ANONYMOUS, 'not_a_setting'); + } +} -- cgit v1.2.1 From 5cc0488f74633a9f28011ed935a3b7e902ba4497 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 3 Feb 2015 23:13:37 +0100 Subject: [ticket/9109] Only query database once in phpbb_get_max_setting_from_group More test cases have been added, too. PHPBB3-9109 --- .../fixtures/get_max_setting_from_group.xml | 21 +++++++++++++++++++++ .../get_max_setting_from_group_test.php | 4 ++++ 2 files changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml b/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml index b10bf782ec..c78d63f7cb 100644 --- a/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml +++ b/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml @@ -23,6 +23,12 @@ 0 0 + + 4 + + 0 + 5 + user_id @@ -58,5 +64,20 @@ 30 + + 4 + 4 + 0 + + + 5 + 3 + 1 + + + 5 + 2 + 0 +
diff --git a/tests/functions_privmsgs/get_max_setting_from_group_test.php b/tests/functions_privmsgs/get_max_setting_from_group_test.php index 48d42ec48a..3eb7866802 100644 --- a/tests/functions_privmsgs/get_max_setting_from_group_test.php +++ b/tests/functions_privmsgs/get_max_setting_from_group_test.php @@ -36,9 +36,13 @@ class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_dat array(1, 0, 'message_limit'), array(2, 2, 'message_limit'), array(3, 0, 'message_limit'), + array(4, 0, 'message_limit'), + array(5, 2, 'message_limit'), array(1, 0, 'max_recipients'), array(2, 4, 'max_recipients'), array(3, 0, 'max_recipients'), + array(4, 5, 'max_recipients'), + array(5, 4, 'max_recipients'), ); } -- cgit v1.2.1 From cf39cfc5939f9407082f8f5c1f876ea0ee607a45 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 7 Oct 2014 20:51:08 +0200 Subject: [ticket/13132] Twig: Add loops content to the root context PHPBB3-13132 --- tests/template/template_test.php | 149 ++++++++++++++++++++- tests/template/templates/loop_advanced_twig.html | 19 +++ tests/template/templates/loop_expressions.html | 4 +- .../template/templates/loop_expressions_twig.html | 11 ++ tests/template/templates/loop_include1_twig.html | 1 + tests/template/templates/loop_include_twig.html | 4 + tests/template/templates/loop_nested2_twig.html | 6 + .../loop_nested_deep_multilevel_ref_twig.html | 13 ++ .../templates/loop_nested_include1_twig.html | 5 + .../templates/loop_nested_include_twig.html | 4 + .../templates/loop_nested_multilevel_ref_twig.html | 10 ++ tests/template/templates/loop_nested_twig.html | 6 + tests/template/templates/loop_reuse_twig.html | 6 + tests/template/templates/loop_size_twig.html | 39 ++++++ tests/template/templates/loop_twig.html | 21 +++ tests/template/templates/loop_underscore_twig.html | 21 +++ tests/template/templates/loop_vars_twig.html | 13 ++ 17 files changed, 329 insertions(+), 3 deletions(-) create mode 100644 tests/template/templates/loop_advanced_twig.html create mode 100644 tests/template/templates/loop_expressions_twig.html create mode 100644 tests/template/templates/loop_include1_twig.html create mode 100644 tests/template/templates/loop_include_twig.html create mode 100644 tests/template/templates/loop_nested2_twig.html create mode 100644 tests/template/templates/loop_nested_deep_multilevel_ref_twig.html create mode 100644 tests/template/templates/loop_nested_include1_twig.html create mode 100644 tests/template/templates/loop_nested_include_twig.html create mode 100644 tests/template/templates/loop_nested_multilevel_ref_twig.html create mode 100644 tests/template/templates/loop_nested_twig.html create mode 100644 tests/template/templates/loop_reuse_twig.html create mode 100644 tests/template/templates/loop_size_twig.html create mode 100644 tests/template/templates/loop_twig.html create mode 100644 tests/template/templates/loop_underscore_twig.html create mode 100644 tests/template/templates/loop_vars_twig.html (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index bb6b7300cb..b67b49bd35 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -129,6 +129,34 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1", ), + array( + 'loop_twig.html', + array(), + array(), + array(), + "noloop\nnoloop", + ), + array( + 'loop_twig.html', + array(), + array('test_loop' => array(array())), + array(), + "loop\nloop", + ), + array( + 'loop_twig.html', + array(), + array('test_loop' => array(array(), array()), 'test_loop.block' => array(array())), + array(), + "loop\nloop\nloop\nloop", + ), + array( + 'loop_twig.html', + array(), + array('test_loop' => array(array(), array()), 'test_loop.block' => array(array()), 'block' => array(array(), array())), + array(), + "loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1", + ), array( 'loop_vars.html', array(), @@ -150,6 +178,27 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner", ), + array( + 'loop_vars_twig.html', + array(), + array('test_loop' => array(array('VARIABLE' => 'x'))), + array(), + "first\n0 - a\nx - b\nset\nlast", + ), + array( + 'loop_vars_twig.html', + array(), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y'))), + array(), + "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast", + ), + array( + 'loop_vars_twig.html', + array(), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())), + array(), + "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner", + ), array( 'loop_advanced.html', array(), @@ -157,6 +206,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561", ), + array( + 'loop_advanced_twig.html', + array(), + array('test_loop' => array(array(), array(), array(), array(), array(), array(), array())), + array(), + "101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561", + ), array( 'loop_nested2.html', array(), @@ -164,6 +220,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "o0o1m01m11", ), + array( + 'loop_nested2_twig.html', + array(), + array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())), + array(), + "o0o1m01m11", + ), array( 'define.html', array(), @@ -243,6 +306,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array('test_loop'), '', ), + array( + 'loop_vars_twig.html', + array(), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())), + array('test_loop'), + '', + ), array( 'include_define_variable.html', array('VARIABLE' => 'variable.html'), @@ -274,6 +344,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "noloop\nnoloop", ), + array( + // Just like a regular loop but the name begins + // with an underscore + 'loop_underscore_twig.html', + array(), + array(), + array(), + "noloop\nnoloop", + ), array( 'lang.html', array(), @@ -296,6 +375,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "top-level content", ), + array( + 'loop_nested_multilevel_ref_twig.html', + array(), + array(), + array(), + "top-level content", + ), array( 'loop_nested_multilevel_ref.html', array(), @@ -303,6 +389,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz", ), + array( + 'loop_nested_multilevel_ref_twig.html', + array(), + array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))), + array(), + "top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz", + ), array( 'loop_nested_deep_multilevel_ref.html', array(), @@ -310,6 +403,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz", ), + array( + 'loop_nested_deep_multilevel_ref_twig.html', + array(), + array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))), + array(), + "top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz", + ), array( 'loop_size.html', array(), @@ -317,6 +417,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop", ), + array( + 'loop_size_twig.html', + array(), + array('test_loop' => array(array()), 'empty_loop' => array()), + array(), + "nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop", + ), array( 'loop_include.html', array(), @@ -324,6 +431,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "barbarbar1bar1", ), + array( + 'loop_include_twig.html', + array(), + array('test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1'))), + array(), + "barbarbar1bar1", + ), array( 'loop_nested_include.html', array(), @@ -335,6 +449,17 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "[bar|[bar|]][bar1|[bar1|[bar1|works]]]", array(), ), + array( + 'loop_nested_include_twig.html', + array(), + array( + 'test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1')), + 'test_loop.inner' => array(array('myinner' => 'works')), + ), + array(), + "[bar|[bar|]][bar1|[bar1|[bar1|works]]]", + array(), + ), /* Does not pass with the current implementation. array( 'loop_reuse.html', @@ -343,8 +468,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), // Not entirely sure what should be outputted but the current output of "a" is most certainly wrong "a\nb\nc\nd", + ),*/ + array( + 'loop_reuse_twig.html', + array(), + array('one' => array(array('VAR' => 'a'), array('VAR' => 'b')), 'one.one' => array(array('VAR' => 'c'), array('VAR' => 'd'))), + array(), + // Not entirely sure what should be outputted but the current output of "a" is most certainly wrong + "a\nb\nc\nd", ), - */ array( 'twig.html', array('VARIABLE' => 'FOObar',), @@ -359,6 +491,21 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), 'inner_value', ), + // Disable: needs Twig 1.14.2 + /*array( + 'loop_expressions.html', + array('loop' => array(array(),array(),array(),array(),array(),array()),), + array(), + array(), + 'yesnonoyesnonoyesnoyesnonoyes', + ), + array( + 'loop_expressions_twig.html', + array('loop' => array(array(),array(),array(),array(),array(),array()),), + array(), + array(), + 'yesnonoyesnonoyesnoyesnonoyes', + ),*/ ); } diff --git a/tests/template/templates/loop_advanced_twig.html b/tests/template/templates/loop_advanced_twig.html new file mode 100644 index 0000000000..fd9fcae045 --- /dev/null +++ b/tests/template/templates/loop_advanced_twig.html @@ -0,0 +1,19 @@ +{% for test_loop_inner in test_loop %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(0) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(0,-1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(1,1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(0,1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(2,4) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(0,-7) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(-2,6) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} +x +{% for test_loop_inner in test_loop|subset(-2,-1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %} diff --git a/tests/template/templates/loop_expressions.html b/tests/template/templates/loop_expressions.html index 6bff53f388..278bce1eca 100644 --- a/tests/template/templates/loop_expressions.html +++ b/tests/template/templates/loop_expressions.html @@ -1,11 +1,11 @@ -onoff +onoff -onoff +onoff diff --git a/tests/template/templates/loop_expressions_twig.html b/tests/template/templates/loop_expressions_twig.html new file mode 100644 index 0000000000..61a36c51e4 --- /dev/null +++ b/tests/template/templates/loop_expressions_twig.html @@ -0,0 +1,11 @@ +{% for loop_inner in loop %} + +{% if loop_inner.S_ROW_NUM is divisible by 4 %}on{% else %}off{% endif %} + +{% endfor %} + +{% for loop_inner in loop %} + +{% if loop_inner.S_ROW_NUM is divisible by 3 %}on{% else %}off{% endif %} + +{% endfor %} diff --git a/tests/template/templates/loop_include1_twig.html b/tests/template/templates/loop_include1_twig.html new file mode 100644 index 0000000000..2ff9f61b02 --- /dev/null +++ b/tests/template/templates/loop_include1_twig.html @@ -0,0 +1 @@ +{{ test_loop_inner.foo }} diff --git a/tests/template/templates/loop_include_twig.html b/tests/template/templates/loop_include_twig.html new file mode 100644 index 0000000000..1a534e2dbc --- /dev/null +++ b/tests/template/templates/loop_include_twig.html @@ -0,0 +1,4 @@ +{% for test_loop_inner in test_loop %} + {{ test_loop_inner.foo }} + {% INCLUDE 'loop_include1_twig.html' %} +{% endfor %} diff --git a/tests/template/templates/loop_nested2_twig.html b/tests/template/templates/loop_nested2_twig.html new file mode 100644 index 0000000000..cf802dc69f --- /dev/null +++ b/tests/template/templates/loop_nested2_twig.html @@ -0,0 +1,6 @@ +{% for outer_inner in outer %} + o{{ outer_inner.S_ROW_COUNT }} + {% for middle in outer_inner.middle %} + m{{ middle.S_ROW_COUNT }}{{ outer_inner.S_ROW_COUNT }} + {% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_nested_deep_multilevel_ref_twig.html b/tests/template/templates/loop_nested_deep_multilevel_ref_twig.html new file mode 100644 index 0000000000..9bc68e6e2e --- /dev/null +++ b/tests/template/templates/loop_nested_deep_multilevel_ref_twig.html @@ -0,0 +1,13 @@ +top-level content +{% for outer_inner in outer %} + outer + {% for middle in outer_inner.middle %} + {{ middle.S_BLOCK_NAME }} + {% for inner in middle.inner %} + inner {{ inner.VARIABLE }} + {% if inner.S_FIRST_ROW %} + first row of {{ inner.S_NUM_ROWS }} in {{ inner.S_BLOCK_NAME }} + {% endif %} + {% endfor %} + {% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_nested_include1_twig.html b/tests/template/templates/loop_nested_include1_twig.html new file mode 100644 index 0000000000..4c2ebb5f15 --- /dev/null +++ b/tests/template/templates/loop_nested_include1_twig.html @@ -0,0 +1,5 @@ +[{{ test_loop_inner.foo }}| +{% for inner in test_loop_inner.inner %} + [{{ test_loop_inner.foo }}| + {{ inner.myinner }}] +{% endfor %}] diff --git a/tests/template/templates/loop_nested_include_twig.html b/tests/template/templates/loop_nested_include_twig.html new file mode 100644 index 0000000000..c92ac922d1 --- /dev/null +++ b/tests/template/templates/loop_nested_include_twig.html @@ -0,0 +1,4 @@ +{% for test_loop_inner in test_loop %} + [{{ test_loop_inner.foo }} + |{% INCLUDE 'loop_nested_include1_twig.html' %}] +{% endfor %} diff --git a/tests/template/templates/loop_nested_multilevel_ref_twig.html b/tests/template/templates/loop_nested_multilevel_ref_twig.html new file mode 100644 index 0000000000..336a57d0bc --- /dev/null +++ b/tests/template/templates/loop_nested_multilevel_ref_twig.html @@ -0,0 +1,10 @@ +top-level content +{% for outer_inner in outer %} + outer {{ outer_inner.VARIABLE }} + {% for inner in outer_inner.inner %} + inner {{ inner.VARIABLE }} + {% if inner.S_FIRST_ROW %} + first row + {% endif %} + {% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_nested_twig.html b/tests/template/templates/loop_nested_twig.html new file mode 100644 index 0000000000..b294226b3a --- /dev/null +++ b/tests/template/templates/loop_nested_twig.html @@ -0,0 +1,6 @@ +{% for outer_inner in outer %} +outer - {{ outer_inner.S_ROW_COUNT }}{% if outer_inner.VARIABLE %} - {{ outer_inner.VARIABLE }}{% endif %}{% if TEST_MORE %}[{{ outer_inner.S_BLOCK_NAME }}|{{ outer_inner.S_NUM_ROWS }}]{% endif %} +{% for middle in outer_inner.middle %} +middle - {{ middle.S_ROW_COUNT }}{% if middle.VARIABLE %} - {{ middle.VARIABLE }}{% endif %}{% if TEST_MORE %}[{{ middle.S_BLOCK_NAME }}|{{ middle.S_NUM_ROWS }}]{% endif %} +{% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_reuse_twig.html b/tests/template/templates/loop_reuse_twig.html new file mode 100644 index 0000000000..67452a737f --- /dev/null +++ b/tests/template/templates/loop_reuse_twig.html @@ -0,0 +1,6 @@ +{% for one_inner in one %} + {{ one_inner.VAR }} + {% for one_one_inner in one_inner.one %} + {{ one_one_inner.VAR }} + {% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_size_twig.html b/tests/template/templates/loop_size_twig.html new file mode 100644 index 0000000000..f6d2571e11 --- /dev/null +++ b/tests/template/templates/loop_size_twig.html @@ -0,0 +1,39 @@ +{% if nonexistent_loop|length %} +nonexistent +{% endif %} + +{% if nonexistent_loop|length == 0 %} +nonexistent = 0 +{% endif %} + +{% if ! nonexistent_loop|length %} +! nonexistent +{% endif %} + +{% if empty_loop|length %} +empty +{% endif %} + +{% if empty_loop|length == 0 %} +empty = 0 +{% endif %} + +{% if ! empty_loop|length %} +! empty +{% endif %} + +{% if test_loop|length %} +loop +{% endif %} + +{% if test_loop|length == 0 %} +loop = 0 +{% endif %} + +{% if ! test_loop|length %} +! loop +{% endif %} + +{% for test_loop_inner in test_loop %} +in loop +{% endfor %} diff --git a/tests/template/templates/loop_twig.html b/tests/template/templates/loop_twig.html new file mode 100644 index 0000000000..fb24f331b3 --- /dev/null +++ b/tests/template/templates/loop_twig.html @@ -0,0 +1,21 @@ +{% for test_loop_inner in test_loop %} +loop +{% else %} +noloop +{% endfor %} + +{% if test_loop|length %} +loop +{% else %} +noloop +{% endif %} + +{% if test_loop|length == 2 %} +loop +{% endif %} + +{% for test_loop_inner in test_loop %} +{% for block_inner in block %} +loop#{{ test_loop_inner.S_ROW_COUNT }}-block#{{ block_inner.S_ROW_COUNT }} +{% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_underscore_twig.html b/tests/template/templates/loop_underscore_twig.html new file mode 100644 index 0000000000..44b095c882 --- /dev/null +++ b/tests/template/templates/loop_underscore_twig.html @@ -0,0 +1,21 @@ +{% for _underscore_loop_inner in _underscore_loop %} +loop +{% else %} +noloop +{% endfor %} + +{% if _underscore_loop|length %} +loop +{% else %} +noloop +{% endif %} + +{% if _underscore_loop|length == 2 %} +loop +{% endif %} + +{% for _underscore_loop_inner in _underscore_loop %} +{% for block_inner in block %} +loop#{{ loop.S_ROW_COUNT }}-block#{{ block_inner.S_ROW_COUNT }} +{% endfor %} +{% endfor %} diff --git a/tests/template/templates/loop_vars_twig.html b/tests/template/templates/loop_vars_twig.html new file mode 100644 index 0000000000..af6c63d8e3 --- /dev/null +++ b/tests/template/templates/loop_vars_twig.html @@ -0,0 +1,13 @@ +{% for test_loop_inner in test_loop %} +{% if test_loop_inner.S_FIRST_ROW %}first{% endif %} +{{ test_loop_inner.S_ROW_NUM }} - a +{{ test_loop_inner.VARIABLE }} - b +{% if test_loop_inner.VARIABLE %}set{% endif %} +{% if test_loop_inner.S_LAST_ROW %} +last +{% endif %} +{% for inner_inner in test_loop_inner.inner %} +{{ inner_inner.S_ROW_NUM }} - c +{% if inner_inner.S_LAST_ROW and inner_inner.S_ROW_COUNT and inner_inner.S_NUM_ROWS %}last inner{% endif %} +{% endfor %} +{% endfor %} -- cgit v1.2.1 From 54753e926df28b686937394bc675130647893639 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Thu, 5 Mar 2015 21:53:48 +0100 Subject: [ticket/13132] Enable twig expressions tests PHPBB3-13132 --- tests/template/template_test.php | 18 ++++++++++++------ tests/template/templates/loop_expressions.html | 4 ++-- tests/template/templates/loop_expressions_twig.html | 4 ++-- tests/template/templates/loop_expressions_twig2.html | 11 +++++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 tests/template/templates/loop_expressions_twig2.html (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index b67b49bd35..33dc4ca551 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -491,21 +491,27 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), 'inner_value', ), - // Disable: needs Twig 1.14.2 - /*array( + array( 'loop_expressions.html', - array('loop' => array(array(),array(),array(),array(),array(),array()),), array(), + array('loop' => array(array(),array(),array(),array(),array(),array()),), array(), - 'yesnonoyesnonoyesnoyesnonoyes', + 'yesnononoyesnoyesnonoyesnono', ), array( 'loop_expressions_twig.html', + array(), + array('loop' => array(array(),array(),array(),array(),array(),array()),), + array(), + 'yesnononoyesnoyesnonoyesnono', + ), + array( + 'loop_expressions_twig2.html', array('loop' => array(array(),array(),array(),array(),array(),array()),), array(), array(), - 'yesnonoyesnonoyesnoyesnonoyes', - ),*/ + 'yesnononoyesnoyesnonoyesnono', + ), ); } diff --git a/tests/template/templates/loop_expressions.html b/tests/template/templates/loop_expressions.html index 278bce1eca..ddb9fd52fa 100644 --- a/tests/template/templates/loop_expressions.html +++ b/tests/template/templates/loop_expressions.html @@ -1,11 +1,11 @@ -onoff +yesno -onoff +yesno diff --git a/tests/template/templates/loop_expressions_twig.html b/tests/template/templates/loop_expressions_twig.html index 61a36c51e4..5ca8cc3601 100644 --- a/tests/template/templates/loop_expressions_twig.html +++ b/tests/template/templates/loop_expressions_twig.html @@ -1,11 +1,11 @@ {% for loop_inner in loop %} -{% if loop_inner.S_ROW_NUM is divisible by 4 %}on{% else %}off{% endif %} +{% if loop_inner.S_ROW_NUM is divisible by(4) %}yes{% else %}no{% endif %} {% endfor %} {% for loop_inner in loop %} -{% if loop_inner.S_ROW_NUM is divisible by 3 %}on{% else %}off{% endif %} +{% if loop_inner.S_ROW_NUM is divisible by(3) %}yes{% else %}no{% endif %} {% endfor %} diff --git a/tests/template/templates/loop_expressions_twig2.html b/tests/template/templates/loop_expressions_twig2.html new file mode 100644 index 0000000000..16159ead4c --- /dev/null +++ b/tests/template/templates/loop_expressions_twig2.html @@ -0,0 +1,11 @@ +{% for loop_inner in loop %} + +{% if loop.index0 is divisible by(4) %}yes{% else %}no{% endif %} + +{% endfor %} + +{% for loop_inner in loop %} + +{% if loop.index0 is divisible by(3) %}yes{% else %}no{% endif %} + +{% endfor %} -- cgit v1.2.1 From 5bc03c961023e01dfb74eff296b12b6169d705e4 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 17:16:53 +0000 Subject: [feature/sql-bool-builder] Prepare testing class PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 24 +++++++++ tests/dbal/fixtures/boolean_processor.xml | 84 +++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 tests/dbal/boolean_processor_test.php create mode 100644 tests/dbal/fixtures/boolean_processor.xml (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php new file mode 100644 index 0000000000..f80e12ad4f --- /dev/null +++ b/tests/dbal/boolean_processor_test.php @@ -0,0 +1,24 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; + +class phpbb_boolean_processor_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/boolean_processor.xml'); + } + +} diff --git a/tests/dbal/fixtures/boolean_processor.xml b/tests/dbal/fixtures/boolean_processor.xml new file mode 100644 index 0000000000..c5da677116 --- /dev/null +++ b/tests/dbal/fixtures/boolean_processor.xml @@ -0,0 +1,84 @@ + + + + ban_id + ban_userid + + 1 + 2 + +
+ + user_id + username + username_clean + user_permissions + user_sig + + 1 + mass email + mass email + + + + + 2 + banned + banned + + + + + 3 + helper + helper + + + + + 4 + GroupBPal + groupbpal + + + + + 5 + GroupBPal2 + groupBPal2 + + + + + 6 + not in group + not in group + + + +
+ + user_id + group_id + + 1 + 1 + + + 2 + 1 + + + 3 + 1 + + + 4 + 2 + + + 5 + 2 + +
+
-- cgit v1.2.1 From d10a0ca1ca48d8d348922a806f14f63360179d50 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 20:25:55 +0000 Subject: [feature/sql-bool-builder] test_triple_and_with_is_null PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index f80e12ad4f..652cb1164b 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -21,4 +21,41 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/boolean_processor.xml'); } + public function test_triple_and_with_is_null() + { + $db = $this->new_dbal(); + + $db->sql_return_on_error(true); + + $sql_ary = array( + 'SELECT' => 'u.username', + 'FROM' => array( + 'phpbb_users' => 'u', + 'phpbb_user_group' => 'ug', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array( + 'phpbb_banlist' => 'b', + ), + 'ON' => 'u.user_id = b.ban_userid', + ), + ), + 'WHERE' => array('AND', + array('ug.group_id', '=', 1), + array('u.user_id', '=', 'ug.user_id'), + array('b.ban_id', 'IS', NULL), + ), + 'ORDER_BY' => 'u.username', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); + $result = $db->sql_query($sql); + + $db->sql_return_on_error(false); + + $this->assertEquals(array( + array('username' => 'helper'), + array('username' => 'mass email'), + ), $db->sql_fetchrowset($result)); + } } -- cgit v1.2.1 From 5d3b22c21e2c31dce80d3a4c84fd5a0a326f944f Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 20:26:24 +0000 Subject: [feature/sql-bool-builder] test_double_and_with_not_of_and PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 652cb1164b..40efbe8d5a 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -21,6 +21,37 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/boolean_processor.xml'); } + public function test_double_and_with_not_of_or() + { + $db = $this->new_dbal(); + + $db->sql_return_on_error(true); + + $sql_ary = array( + 'SELECT' => 'u.user_id', + 'FROM' => array( + 'phpbb_users' => 'u', + 'phpbb_user_group' => 'ug', + ), + 'WHERE' => array('AND', + array('NOT', + array('OR', + array('ug.group_id', '=', 1), + array('ug.group_id', '=', 2), + ), + ), + array('u.user_id', '=', 'ug.user_id'), + ), + 'ORDER_BY' => 'u.user_id', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); + $result = $db->sql_query($sql); + + $db->sql_return_on_error(false); + + $this->assertEquals(array(), $db->sql_fetchrowset($result)); + } + public function test_triple_and_with_is_null() { $db = $this->new_dbal(); -- cgit v1.2.1 From e6eab35a641b8795f8a277e28d3eab0937d64b6d Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 20:29:48 +0000 Subject: [feature/sql-bool-builder] test_triple_and_with_in PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 40efbe8d5a..081a5ac64d 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -21,6 +21,37 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/boolean_processor.xml'); } + public function test_triple_and_with_in() + { + $db = $this->new_dbal(); + + $db->sql_return_on_error(true); + + $sql_ary = array( + 'SELECT' => 'u.user_id', + 'FROM' => array( + 'phpbb_users' => 'u', + 'phpbb_user_group' => 'ug', + ), + 'WHERE' => array('AND', + array('ug.user_id', 'IN', array(1, 2, 3, 4)), + array('ug.group_id', '=', 1), + array('u.user_id', '=', 'ug.user_id'), + ), + 'ORDER_BY' => 'u.user_id', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); + $result = $db->sql_query($sql); + + $db->sql_return_on_error(false); + + $this->assertEquals(array( + array('user_id' => '1'), + array('user_id' => '2'), + array('user_id' => '3'), + ), $db->sql_fetchrowset($result), + } + public function test_double_and_with_not_of_or() { $db = $this->new_dbal(); -- cgit v1.2.1 From 5f63d685f6b0235badd7723e477754833595d045 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 20:30:04 +0000 Subject: [feature/sql-bool-builder] test_and_of_or_of_and PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 081a5ac64d..716e524e9b 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -21,6 +21,52 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/boolean_processor.xml'); } + public function test_and_of_or_of_and() + { + $db = $this->new_dbal(); + + $db->sql_return_on_error(true); + + $sql_ary = array( + 'SELECT' => 'u.user_id', + 'FROM' => array( + 'phpbb_users' => 'u', + 'phpbb_user_group' => 'ug', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array( + 'phpbb_banlist' => 'b', + ), + 'ON' => 'u.user_id = b.ban_userid', + ), + ), + 'WHERE' => array('AND', + array('OR', + array('AND', + array('ug.user_id', 'IN', array(1, 2, 3, 4)), + array('ug.group_id', '=', 2), + ), + array('AND', + array('ug.group_id', '=', 1), + array('b.ban_id', 'IS NOT', NULL), + ), + ), + array('u.user_id', '=', 'ug.user_id'), + ), + 'ORDER_BY' => 'u.user_id', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); + $result = $db->sql_query($sql); + + $db->sql_return_on_error(false); + + $this->assertEquals(array( + array('user_id' => '2'), + array('user_id' => '4'), + ), $db->sql_fetchrowset($result)); + } + public function test_triple_and_with_in() { $db = $this->new_dbal(); -- cgit v1.2.1 From 1754f1832d563074e767f236cbc315eb41c7b7b9 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 20:30:35 +0000 Subject: [feature/sql-bool-builder] test_single_in PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 716e524e9b..e615edbdcd 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -21,6 +21,32 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/boolean_processor.xml'); } + public function test_single_in() + { + $db = $this->new_dbal(); + + $db->sql_return_on_error(true); + + $sql_ary = array( + 'SELECT' => 'u.user_id', + 'FROM' => array( + 'phpbb_users' => 'u', + ), + 'WHERE' => array('u.user_id', 'IN', array(3,4,5)), + 'ORDER_BY' => 'u.user_id', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); + $result = $db->sql_query($sql); + + $db->sql_return_on_error(false); + + $this->assertEquals(array( + array('user_id' => '3'), + array('user_id' => '4'), + array('user_id' => '5'), + ), $db->sql_fetchrowset($result)); + } + public function test_and_of_or_of_and() { $db = $this->new_dbal(); -- cgit v1.2.1 From d60d596f25b0c31526f469cf56c4cdb1e3698bda Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 20:31:19 +0000 Subject: [feature/sql-bool-builder] test_single_not_in PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index e615edbdcd..a94085b77d 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -21,6 +21,32 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/boolean_processor.xml'); } + public function test_single_not_in() + { + $db = $this->new_dbal(); + + $db->sql_return_on_error(true); + + $sql_ary = array( + 'SELECT' => 'u.user_id', + 'FROM' => array( + 'phpbb_users' => 'u', + ), + 'WHERE' => array('u.user_id', 'NOT_IN', array(3,4,5)), + 'ORDER_BY' => 'u.user_id', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); + $result = $db->sql_query($sql); + + $db->sql_return_on_error(false); + + $this->assertEquals(array( + array('user_id' => '1'), + array('user_id' => '2'), + array('user_id' => '6'), + ), $db->sql_fetchrowset($result)); + } + public function test_single_in() { $db = $this->new_dbal(); -- cgit v1.2.1 From c342531872938797f52f3e6bdfa966d81e3253ce Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 20:31:32 +0000 Subject: [feature/sql-bool-builder] test_single_like PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index a94085b77d..8f57a8e452 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -21,6 +21,31 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/boolean_processor.xml'); } + public function test_single_like() + { + $db = $this->new_dbal(); + + $db->sql_return_on_error(true); + + $sql_ary = array( + 'SELECT' => 'u.user_id', + 'FROM' => array( + 'phpbb_users' => 'u', + ), + 'WHERE' => array('u.username_clean', 'LIKE', 'gr' . $db->get_any_char()), + 'ORDER_BY' => 'u.user_id', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); + $result = $db->sql_query($sql); + + $db->sql_return_on_error(false); + + $this->assertEquals(array( + array('user_id' => '4'), + array('user_id' => '5'), + ), $db->sql_fetchrowset($result)); + } + public function test_single_not_in() { $db = $this->new_dbal(); -- cgit v1.2.1 From bc6ea5796dcdabd57ff9e6f7640d724df67254c5 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 20:31:46 +0000 Subject: [feature/sql-bool-builder] test_single_not_like PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 8f57a8e452..2ba3f6ff22 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -21,6 +21,33 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/boolean_processor.xml'); } + public function test_single_not_like() + { + $db = $this->new_dbal(); + + $db->sql_return_on_error(true); + + $sql_ary = array( + 'SELECT' => 'u.user_id', + 'FROM' => array( + 'phpbb_users' => 'u', + ), + 'WHERE' => array('u.username_clean', 'NOT_LIKE', 'gr' . $db->get_any_char()), + 'ORDER_BY' => 'u.user_id', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); + $result = $db->sql_query($sql); + + $db->sql_return_on_error(false); + + $this->assertEquals(array( + array('user_id' => '1'), + array('user_id' => '2'), + array('user_id' => '3'), + array('user_id' => '6'), + ), $db->sql_fetchrowset($result)); + } + public function test_single_like() { $db = $this->new_dbal(); -- cgit v1.2.1 From 576eaa0cff7a5e051aa672034e596e90f65fc1a9 Mon Sep 17 00:00:00 2001 From: brunoais Date: Mon, 16 Mar 2015 11:31:51 +0000 Subject: [feature/sql-bool-builder] Adding the IS operator to predicted operators PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 2ba3f6ff22..5e044797f8 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -153,7 +153,7 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case ), array('AND', array('ug.group_id', '=', 1), - array('b.ban_id', 'IS NOT', NULL), + array('b.ban_id', 'IS_NOT', NULL), ), ), array('u.user_id', '=', 'ug.user_id'), -- cgit v1.2.1 From fe132f19e8d5c821fff936d208fbb981aa6ac92d Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Mar 2015 21:01:00 +0000 Subject: [feature/sql-bool-builder] Improved tests output to show the SQL error. PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 47 +++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 5e044797f8..8662485ac8 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -45,7 +45,11 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case array('user_id' => '2'), array('user_id' => '3'), array('user_id' => '6'), - ), $db->sql_fetchrowset($result)); + ), $db->sql_fetchrowset($result), + ($result === false) ? + "SQL ERROR:
" . var_export($sql, true) . "
" . $db->sql_error() : + var_export($sql, true) . ' ' . var_export($result, true) + ); } public function test_single_like() @@ -70,7 +74,11 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case $this->assertEquals(array( array('user_id' => '4'), array('user_id' => '5'), - ), $db->sql_fetchrowset($result)); + ), $db->sql_fetchrowset($result), + ($result === false) ? + "SQL ERROR:
" . var_export($sql, true) . "
" . $db->sql_error() : + var_export($sql, true) . ' ' . var_export($result, true) + ); } public function test_single_not_in() @@ -96,7 +104,11 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case array('user_id' => '1'), array('user_id' => '2'), array('user_id' => '6'), - ), $db->sql_fetchrowset($result)); + ), $db->sql_fetchrowset($result), + ($result === false) ? + "SQL ERROR:
" . var_export($sql, true) . "
" . $db->sql_error() : + var_export($sql, true) . ' ' . var_export($result, true) + ); } public function test_single_in() @@ -122,7 +134,11 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case array('user_id' => '3'), array('user_id' => '4'), array('user_id' => '5'), - ), $db->sql_fetchrowset($result)); + ), $db->sql_fetchrowset($result), + ($result === false) ? + "SQL ERROR:
" . var_export($sql, true) . "
" . $db->sql_error() : + var_export($sql, true) . ' ' . var_export($result, true) + ); } public function test_and_of_or_of_and() @@ -168,7 +184,11 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case $this->assertEquals(array( array('user_id' => '2'), array('user_id' => '4'), - ), $db->sql_fetchrowset($result)); + ), $db->sql_fetchrowset($result), + ($result === false) ? + "SQL ERROR:
" . var_export($sql, true) . "
" . $db->sql_error() : + var_export($sql, true) . ' ' . var_export($result, true) + ); } public function test_triple_and_with_in() @@ -200,6 +220,11 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case array('user_id' => '2'), array('user_id' => '3'), ), $db->sql_fetchrowset($result), + ($result === false) ? + "SQL ERROR:
" . var_export($sql, true) . "
" . $db->sql_error() : + var_export($sql, true) . ' ' . var_export($result, true) + ); + } public function test_double_and_with_not_of_or() @@ -230,7 +255,11 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case $db->sql_return_on_error(false); - $this->assertEquals(array(), $db->sql_fetchrowset($result)); + $this->assertEquals(array(), $db->sql_fetchrowset($result), + ($result === false) ? + "SQL ERROR:
" . var_export($sql, true) . "
" . $db->sql_error() : + var_export($sql, true) . ' ' . var_export($result, true) + ); } public function test_triple_and_with_is_null() @@ -268,6 +297,10 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case $this->assertEquals(array( array('username' => 'helper'), array('username' => 'mass email'), - ), $db->sql_fetchrowset($result)); + ), $db->sql_fetchrowset($result), + ($result === false) ? + "SQL ERROR:
" . var_export($sql, true) . "
" . $db->sql_error() : + var_export($sql, true) . ' ' . var_export($result, true) + ); } } -- cgit v1.2.1 From 147a713cc066d493b50b82a9d475aa9af940e2b4 Mon Sep 17 00:00:00 2001 From: s9e Date: Sat, 22 Nov 2014 20:00:58 +0100 Subject: [ticket/11768] This commit integrates s9e\TextFormatter This commit integrates s9e\TextFormatter as outlined in http://area51.phpbb.com/phpBB/viewtopic.php?f=108&t=44467 PHPBB3-11768 --- tests/notification/group_request_test.php | 1 + tests/test_framework/phpbb_test_case_helpers.php | 210 ++++++++ .../text_formatter/s9e/default_formatting_test.php | 200 ++++++++ tests/text_formatter/s9e/factory_test.php | 182 +++++++ .../s9e/fixtures/default_formatting.xml | 466 ++++++++++++++++++ tests/text_formatter/s9e/fixtures/default_lang.xml | 20 + tests/text_formatter/s9e/fixtures/factory.xml | 115 +++++ .../text_formatter/s9e/fixtures/inttext_token.xml | 27 ++ tests/text_formatter/s9e/fixtures/local_url.xml | 28 ++ .../s9e/fixtures/smilies_special_chars.xml | 23 + .../s9e/fixtures/style_inheritance.xml | 66 +++ tests/text_formatter/s9e/fixtures/styles.xml | 36 ++ .../s9e/fixtures/styles/bar/template/bbcode.html | 40 ++ .../fixtures/styles/barplus/template/bbcode.html | 40 ++ .../s9e/fixtures/styles/foo/template/bbcode.html | 40 ++ tests/text_formatter/s9e/parser_test.php | 162 +++++++ tests/text_formatter/s9e/renderer_test.php | 355 ++++++++++++++ tests/text_formatter/s9e/utils_test.php | 157 ++++++ tests/text_processing/decode_message_test.php | 87 ++++ tests/text_processing/fixtures/empty.xml | 3 + tests/text_processing/fixtures/smilies.xml | 443 +++++++++++++++++ .../generate_text_for_display_test.php | 172 ++++++- .../generate_text_for_edit_test.php | 90 ++++ .../generate_text_for_storage_test.php | 70 +++ tests/text_processing/message_parser_test.php | 532 +++++++++++++++++++++ tests/text_processing/smilies_test.php | 48 ++ tests/text_processing/strip_bbcode_test.php | 38 ++ .../text_processing/tickets_data/PHPBB3-10002.html | 2 + .../text_processing/tickets_data/PHPBB3-10002.txt | 2 + .../text_processing/tickets_data/PHPBB3-10425.html | 3 + .../text_processing/tickets_data/PHPBB3-10425.txt | 3 + .../text_processing/tickets_data/PHPBB3-10587.html | 2 + .../text_processing/tickets_data/PHPBB3-10587.txt | 2 + .../text_processing/tickets_data/PHPBB3-10922.html | 1 + .../text_processing/tickets_data/PHPBB3-10922.txt | 1 + .../text_processing/tickets_data/PHPBB3-10989.html | 8 + .../text_processing/tickets_data/PHPBB3-10989.txt | 8 + .../text_processing/tickets_data/PHPBB3-11153.html | 1 + .../text_processing/tickets_data/PHPBB3-11153.txt | 1 + .../text_processing/tickets_data/PHPBB3-11153.xml | 28 ++ .../text_processing/tickets_data/PHPBB3-12195.html | 1 + .../text_processing/tickets_data/PHPBB3-12195.txt | 1 + .../tickets_data/PHPBB3-3981.before.php | 17 + .../text_processing/tickets_data/PHPBB3-3981.html | 1 + tests/text_processing/tickets_data/PHPBB3-3981.txt | 1 + .../text_processing/tickets_data/PHPBB3-7187.html | 1 + tests/text_processing/tickets_data/PHPBB3-7187.txt | 1 + tests/text_processing/tickets_data/PHPBB3-7187.xml | 33 ++ .../tickets_data/PHPBB3-7275.after.php | 15 + .../text_processing/tickets_data/PHPBB3-7275.html | 1 + tests/text_processing/tickets_data/PHPBB3-7275.txt | 1 + tests/text_processing/tickets_data/PHPBB3-7275.xml | 49 ++ .../text_processing/tickets_data/PHPBB3-9377.html | 1 + tests/text_processing/tickets_data/PHPBB3-9377.txt | 1 + tests/text_processing/tickets_data/PHPBB3-9377.xml | 41 ++ tests/text_processing/tickets_test.php | 91 ++++ 56 files changed, 3959 insertions(+), 10 deletions(-) create mode 100644 tests/text_formatter/s9e/default_formatting_test.php create mode 100644 tests/text_formatter/s9e/factory_test.php create mode 100644 tests/text_formatter/s9e/fixtures/default_formatting.xml create mode 100644 tests/text_formatter/s9e/fixtures/default_lang.xml create mode 100644 tests/text_formatter/s9e/fixtures/factory.xml create mode 100644 tests/text_formatter/s9e/fixtures/inttext_token.xml create mode 100644 tests/text_formatter/s9e/fixtures/local_url.xml create mode 100644 tests/text_formatter/s9e/fixtures/smilies_special_chars.xml create mode 100644 tests/text_formatter/s9e/fixtures/style_inheritance.xml create mode 100644 tests/text_formatter/s9e/fixtures/styles.xml create mode 100644 tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html create mode 100644 tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html create mode 100644 tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html create mode 100644 tests/text_formatter/s9e/parser_test.php create mode 100644 tests/text_formatter/s9e/renderer_test.php create mode 100644 tests/text_formatter/s9e/utils_test.php create mode 100644 tests/text_processing/decode_message_test.php create mode 100644 tests/text_processing/fixtures/empty.xml create mode 100644 tests/text_processing/fixtures/smilies.xml create mode 100644 tests/text_processing/generate_text_for_edit_test.php create mode 100644 tests/text_processing/generate_text_for_storage_test.php create mode 100644 tests/text_processing/message_parser_test.php create mode 100644 tests/text_processing/smilies_test.php create mode 100644 tests/text_processing/strip_bbcode_test.php create mode 100644 tests/text_processing/tickets_data/PHPBB3-10002.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-10002.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-10425.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-10425.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-10587.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-10587.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-10922.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-10922.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-10989.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-10989.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-11153.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-11153.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-11153.xml create mode 100644 tests/text_processing/tickets_data/PHPBB3-12195.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-12195.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-3981.before.php create mode 100644 tests/text_processing/tickets_data/PHPBB3-3981.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-3981.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-7187.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-7187.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-7187.xml create mode 100644 tests/text_processing/tickets_data/PHPBB3-7275.after.php create mode 100644 tests/text_processing/tickets_data/PHPBB3-7275.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-7275.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-7275.xml create mode 100644 tests/text_processing/tickets_data/PHPBB3-9377.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-9377.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-9377.xml create mode 100644 tests/text_processing/tickets_test.php (limited to 'tests') diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 0d532882c6..6a56a38c45 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -51,6 +51,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher; $phpbb_log = new \phpbb\log\null(); + $this->get_test_case_helpers()->set_s9e_services(); // Now on to the actual test diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index dee70ad016..d0b1573e61 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -11,6 +11,8 @@ * */ +use Symfony\Component\DependencyInjection\ContainerInterface; + class phpbb_test_case_helpers { protected $expectedTriggerError = false; @@ -298,4 +300,212 @@ class phpbb_test_case_helpers } } } + + /** + * Set working instances of the text_formatter.* services + * + * If no container is passed, the global $phpbb_container will be used and/or + * created if applicable + * + * @param ContainerInterface $container Service container + * @param string $fixture Path to the XML fixture + * @param string $styles_path Path to the styles dir + * @return ContainerInterface + */ + public function set_s9e_services(ContainerInterface $container = null, $fixture = null, $styles_path = null) + { + static $first_run; + global $phpbb_container, $phpbb_root_path, $phpEx; + + $cache_dir = __DIR__ . '/../tmp/'; + + // Remove old cache files on first run + if (!isset($first_run)) + { + $first_run = 1; + + array_map('unlink', array_merge( + glob($cache_dir . 'data_s9e_*'), + glob($cache_dir . 's9e_*') + )); + } + + if (!isset($container)) + { + if (!isset($phpbb_container)) + { + $phpbb_container = new phpbb_mock_container_builder; + } + + $container = $phpbb_container; + } + + if (!isset($fixture)) + { + $fixture = __DIR__ . '/../text_formatter/s9e/fixtures/default_formatting.xml'; + } + + if (!isset($styles_path)) + { + $styles_path = $phpbb_root_path . 'styles/'; + } + + $dataset = new DOMDocument; + $dataset->load($fixture); + + $tables = array( + 'phpbb_bbcodes' => array(), + 'phpbb_smilies' => array(), + 'phpbb_styles' => array(), + 'phpbb_words' => array() + ); + foreach ($dataset->getElementsByTagName('table') as $table) + { + $name = $table->getAttribute('name'); + $columns = array(); + + foreach ($table->getElementsByTagName('column') as $column) + { + $columns[] = $column->textContent; + } + + foreach ($table->getElementsByTagName('row') as $row) + { + $values = array(); + + foreach ($row->getElementsByTagName('value') as $value) + { + $values[] = $value->textContent; + } + + $tables[$name][] = array_combine($columns, $values); + } + } + + // Set up a default style if there's none set + if (empty($tables['phpbb_styles'])) + { + $tables['phpbb_styles'][] = array( + 'style_id' => 1, + 'style_path' => 'prosilver', + 'bbcode_bitfield' => 'kNg=' + ); + } + + // Mock the DAL, make it return data from the fixture + $mb = $this->test_case->getMockBuilder('phpbb\\textformatter\\data_access'); + $mb->setMethods(array('get_bbcodes', 'get_smilies', 'get_styles', 'get_words')); + $mb->setConstructorArgs(array( + $this->test_case->getMock('phpbb\\db\\driver\\driver'), + 'phpbb_bbcodes', + 'phpbb_smilies', + 'phpbb_styles', + 'phpbb_words', + $styles_path + )); + + $dal = $mb->getMock(); + $container->set('text_formatter.data_access', $dal); + + $dal->expects($this->test_case->any()) + ->method('get_bbcodes') + ->will($this->test_case->returnValue($tables['phpbb_bbcodes'])); + $dal->expects($this->test_case->any()) + ->method('get_smilies') + ->will($this->test_case->returnValue($tables['phpbb_smilies'])); + $dal->expects($this->test_case->any()) + ->method('get_styles') + ->will($this->test_case->returnValue($tables['phpbb_styles'])); + $dal->expects($this->test_case->any()) + ->method('get_words') + ->will($this->test_case->returnValue($tables['phpbb_words'])); + + // Cache the parser and renderer with a key based on this method's arguments + $cache = new \phpbb\cache\driver\file($cache_dir); + $prefix = '_s9e_' . md5(serialize(func_get_args())); + $cache_key_parser = $prefix . '_parser'; + $cache_key_renderer = $prefix . '_renderer'; + + // Create a path_helper + if (!$container->has('path_helper')) + { + $container->set( + 'path_helper', + new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem(), + $this->test_case->getMock('\phpbb\request\request'), + $phpbb_root_path, + $phpEx + ) + ); + } + + // Create and register the text_formatter.s9e.factory service + $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $cache_dir, $cache_key_parser, $cache_key_renderer); + $container->set('text_formatter.s9e.factory', $factory); + + // Create a user if none was provided, and add the common lang strings + if ($container->has('user')) + { + $user = $container->get('user'); + } + else + { + $user = new \phpbb\user('\phpbb\datetime'); + $user->optionset('viewcensors', true); + $user->optionset('viewflash', true); + $user->optionset('viewimg', true); + $user->optionset('viewsmilies', true); + } + $user->add_lang('common'); + + if (!isset($user->style)) + { + $user->style = array('style_id' => 1); + } + + // Create and register the text_formatter.s9e.parser service and its alias + $parser = new \phpbb\textformatter\s9e\parser( + $cache, + $cache_key_parser, + $user, + $container + ); + + $container->set('text_formatter.parser', $parser); + $container->set('text_formatter.s9e.parser', $parser); + + // Create and register the text_formatter.s9e.renderer service and its alias + $renderer = new \phpbb\textformatter\s9e\renderer( + $cache, + $cache_dir, + $cache_key_renderer, + $container + ); + + $root_path = ($container->hasParameter('core.root_path')) + ? $container->getParameter('core.root_path') + : './'; + $config = ($container->has('config')) + ? $container->get('config') + : new \phpbb\config\config(array('smilies_path' => 'images/smilies', 'allow_nocensors' => false)); + $auth = ($container->has('auth')) ? $container->get('auth') : new \phpbb\auth\auth; + + // Calls configured in services.yml + $renderer->configure_smilies_path($config, $container->get('path_helper')); + $renderer->configure_user($user, $config, $auth); + + $container->set('text_formatter.renderer', $renderer); + $container->set('text_formatter.s9e.renderer', $renderer); + + // Create and register the text_formatter.s9e.utils service and its alias + $utils = new \phpbb\textformatter\s9e\utils; + $container->set('text_formatter.utils', $utils); + $container->set('text_formatter.s9e.utils', $utils); + + return $container; + } } diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php new file mode 100644 index 0000000000..be258868dd --- /dev/null +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -0,0 +1,200 @@ +get_test_case_helpers()->set_s9e_services(null, $fixture); + + $parser = $container->get('text_formatter.parser'); + $renderer = $container->get('text_formatter.renderer'); + + $parsed_text = $parser->parse($original); + + $this->assertSame($expected, $renderer->render($parsed_text)); + } + + public function get_default_formatting_tests() + { + return array( + array( + '[b]bold[/b]', + 'bold' + ), + array( + '[u]underlined[/u]', + 'underlined' + ), + array( + '[i]italic[/i]', + 'italic' + ), + array( + '[color=#FF0000]colored[/color]', + 'colored' + ), + array( + '[color=red]colored[/color]', + 'colored' + ), + array( + '[size=75]smaller[/size]', + 'smaller' + ), + array( + '[quote]quoted[/quote]', + '
quoted
' + ), + array( + '[quote="username"]quoted[/quote]', + '
username wrote:quoted
' + ), + array( + '[code]unparsed code[/code]', + '

CODE: Select all

unparsed code
' + ), + array( + '[list]no item[/list]', + '
    ' + ), + array( + '[*]unparsed', + '[*]unparsed' + ), + array( + '[list][*]item[/list]', + '
    • item
    ' + ), + array( + '[list][*]item[/*][/list]', + '
    • item
    ' + ), + array( + '[list=1][*]item[/list]', + '
    1. item
    ' + ), + array( + '[list=a][*]item[/list]', + '
    1. item
    ' + ), + array( + '[list=i][*]item[/list]', + '
    1. item
    ' + ), + array( + '[list=I][*]item[/list]', + '
    1. item
    ' + ), + array( + '[list=disc][*]item[/list]', + '
    • item
    ' + ), + array( + '[list=circle][*]item[/list]', + '
    • item
    ' + ), + array( + '[list=square][*]item[/list]', + '
    • item
    ' + ), + array( + '[img]https://area51.phpbb.com/images/area51.png[/img]', + 'Image' + ), + array( + '[url]https://area51.phpbb.com/[/url]', + 'https://area51.phpbb.com/' + ), + array( + '[url=https://area51.phpbb.com/]Area51[/url]', + 'Area51' + ), + array( + '[email]bbcode-test@phpbb.com[/email]', + 'bbcode-test@phpbb.com' + ), + array( + '[email=bbcode-test@phpbb.com]Email[/email]', + 'Email' + ), + array( + '[attachment=0]filename[/attachment]', + '
    filename
    ' + ), + array( + // PHPBB3-1401 - correct: parsed + '[quote="[test]test"]test [ test[/quote]', + '
    [test]test wrote:test [ test
    ' + ), + array( + // PHPBB3-6117 - correct: parsed + '[quote]test[/quote] test ] and [ test [quote]test[/quote]', + '
    test
    test ] and [ test
    test
    ' + ), + array( + // PHPBB3-6200 - correct: parsed + '[quote="["]test[/quote]', + '
    [ wrote:test
    ' + ), + array( + // PHPBB3-9364 - quoted: "test[/[/b]quote] test" / non-quoted: "[/quote] test" - also failed if layout distorted + '[quote]test[/[/b]quote] test [/quote][/quote] test', + '
    test[/[/b]quote] test
    [/quote] test' + ), + array( + // PHPBB3-8096 - first quote tag parsed, second quote tag unparsed + '[quote="a"]a[/quote][quote="a]a[/quote]', + '
    a wrote:a
    [quote="a]a[/quote]' + ), + array( + // Allow textual bbcodes in textual bbcodes + '[b]bold [i]bold + italic[/i][/b]', + 'bold bold + italic' + ), + array( + // Allow textual bbcodes in url with description + '[url=https://area51.phpbb.com/]Area51 [i]italic[/i][/url]', + 'Area51 italic' + ), + array( + // Allow url with description in textual bbcodes + '[i]italic [url=https://area51.phpbb.com/]Area51[/url][/i]', + 'italic Area51' + ), + array( + // Do not parse textual bbcodes in code + '[code]unparsed code [b]bold [i]bold + italic[/i][/b][/code]', + '

    CODE: Select all

    unparsed code [b]bold [i]bold + italic[/i][/b]
    ' + ), + array( + // Do not parse quote bbcodes in code + '[code]unparsed code [quote="username"]quoted[/quote][/code]', + '

    CODE: Select all

    unparsed code [quote="username"]quoted[/quote]
    ' + ), +/* + array( + // Textual bbcode nesting into textual bbcode + '[b]bold [i]bold + italic[/b] italic[/i]', + 'bold bold + italic italic' + ), +*/ + array( + "[code]\tline1\n line2[/code]", + '

    CODE: Select all

       line1
    ' . "\n" . '  line2
    ' + ), + ); + } +} diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php new file mode 100644 index 0000000000..2ea4b3031b --- /dev/null +++ b/tests/text_formatter/s9e/factory_test.php @@ -0,0 +1,182 @@ +createXMLDataSet(__DIR__ . '/fixtures/factory.xml'); + } + + public function get_cache_dir() + { + return __DIR__ . '/../../tmp/'; + } + + public function get_factory() + { + global $phpbb_root_path; + + $this->cache = new phpbb_mock_cache; + + $dal = new \phpbb\textformatter\data_access( + $this->new_dbal(), + 'phpbb_bbcodes', + 'phpbb_smilies', + 'phpbb_styles', + 'phpbb_words', + $phpbb_root_path . 'styles/' + ); + + $factory = new \phpbb\textformatter\s9e\factory( + $dal, + $this->cache, + $this->get_cache_dir(), + '_foo_parser', + '_foo_renderer' + ); + + return $factory; + } + + public function test_get_configurator() + { + $configurator = $this->get_factory()->get_configurator(); + + $this->assertInstanceOf('s9e\\TextFormatter\\Configurator', $configurator); + + $this->assertTrue(isset($configurator->plugins['Autoemail'])); + $this->assertTrue(isset($configurator->plugins['Autolink'])); + + $this->assertTrue(isset($configurator->BBCodes['B'])); + $this->assertTrue(isset($configurator->BBCodes['CODE'])); + $this->assertTrue(isset($configurator->BBCodes['COLOR'])); + $this->assertTrue(isset($configurator->BBCodes['EMAIL'])); + $this->assertTrue(isset($configurator->BBCodes['FLASH'])); + $this->assertTrue(isset($configurator->BBCodes['I'])); + $this->assertTrue(isset($configurator->BBCodes['IMG'])); + $this->assertTrue(isset($configurator->BBCodes['LIST'])); + $this->assertTrue(isset($configurator->BBCodes['*'])); + $this->assertTrue(isset($configurator->BBCodes['QUOTE'])); + $this->assertTrue(isset($configurator->BBCodes['SIZE'])); + $this->assertTrue(isset($configurator->BBCodes['U'])); + $this->assertTrue(isset($configurator->BBCodes['URL'])); + + // This custom BBCode should be set + $this->assertTrue(isset($configurator->BBCodes['CUSTOM'])); + + // This unsafe custom BBCode will trigger an exception and should be ignored + $this->assertFalse(isset($configurator->BBCodes['UNSAFE'])); + + $this->assertTrue(isset($configurator->Emoticons[':D'])); + } + + public function test_regenerate() + { + list($parser, $renderer) = $this->get_factory()->regenerate(); + + $this->assertInstanceOf('s9e\\TextFormatter\\Parser', $parser); + $this->assertInstanceOf('s9e\\TextFormatter\\Renderer', $renderer); + + $this->assertEquals($parser, $this->cache->get('_foo_parser'), 'The parser was not cached'); + $this->assertEquals( + array( + 'class' => get_class($renderer), + 'renderer' => serialize($renderer) + ), + $this->cache->get('_foo_renderer'), + 'The renderer was not cached' + ); + + $file = $this->get_cache_dir() . get_class($renderer) . '.php'; + $this->assertFileExists($file); + unlink($file); + } + + public function test_tidy() + { + $factory = $this->get_factory(); + + // Create a fake "old" cache file + $old_file = $this->get_cache_dir() . 's9e_foo.php'; + touch($old_file); + + // Create a current renderer + list($parser, $renderer) = $factory->regenerate(); + $new_file = $this->get_cache_dir() . get_class($renderer) . '.php'; + + // Tidy the cache + $factory->tidy(); + + $this->assertFileExists($new_file, 'The current renderer has been deleted'); + $this->assertFileNotExists($old_file, 'The old renderer has not been deleted'); + + unlink($new_file); + } + + public function test_local_url() + { + global $config, $user, $request; + + $config = array( + 'force_server_vars' => true, + 'server_protocol' => 'http://', + 'server_name' => 'path', + 'server_port' => 80, + 'script_path' => '/to', + 'cookie_secure' => false + ); + $user = new phpbb_mock_user; + $request = new phpbb_mock_request; + + $fixture = __DIR__ . '/fixtures/local_url.xml'; + $renderer = $this->get_test_case_helpers()->set_s9e_services(null, $fixture)->get('text_formatter.renderer'); + + $this->assertSame( + 'http://path/to/foo', + $renderer->render('[local]foo[/local]') + ); + } + + public function test_smilies_special_chars() + { + // Use a smiley that contains every special chars in every field + $fixture = __DIR__ . '/fixtures/smilies_special_chars.xml'; + $renderer = $this->get_test_case_helpers()->set_s9e_services(null, $fixture)->get('text_formatter.renderer'); + + $this->assertSame( + '"\'<&>', + $renderer->render('"\'<&>') + ); + } + + /** + * @testdox {INTTEXT} is supported in custom BBCodes + */ + public function test_inttext_token() + { + $fixture = __DIR__ . '/fixtures/inttext_token.xml'; + $container = $this->get_test_case_helpers()->set_s9e_services(null, $fixture); + $parser = $container->get('text_formatter.parser'); + $renderer = $container->get('text_formatter.renderer'); + + $original = '[spoiler=ɎɆS]text[/spoiler]'; + $expected = '
    ɎɆS
    text
    '; + $this->assertSame($expected, $renderer->render($parser->parse($original))); + + $original = '[spoiler=N:O:P:E]text[/spoiler]'; + $expected = $original; + $this->assertSame($expected, $renderer->render($parser->parse($original))); + } +} diff --git a/tests/text_formatter/s9e/fixtures/default_formatting.xml b/tests/text_formatter/s9e/fixtures/default_formatting.xml new file mode 100644 index 0000000000..2b7236fb30 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/default_formatting.xml @@ -0,0 +1,466 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 1 + :D + Very Happy + icon_e_biggrin.gif + 15 + 17 + 1 + 1 + + + 2 + :-D + Very Happy + icon_e_biggrin.gif + 15 + 17 + 2 + 1 + + + 3 + :grin: + Very Happy + icon_e_biggrin.gif + 15 + 17 + 3 + 1 + + + 4 + :) + Smile + icon_e_smile.gif + 15 + 17 + 4 + 1 + + + 5 + :-) + Smile + icon_e_smile.gif + 15 + 17 + 5 + 1 + + + 6 + :smile: + Smile + icon_e_smile.gif + 15 + 17 + 6 + 1 + + + 7 + ;) + Wink + icon_e_wink.gif + 15 + 17 + 7 + 1 + + + 8 + ;-) + Wink + icon_e_wink.gif + 15 + 17 + 8 + 1 + + + 9 + :wink: + Wink + icon_e_wink.gif + 15 + 17 + 9 + 1 + + + 10 + :( + Sad + icon_e_sad.gif + 15 + 17 + 10 + 1 + + + 11 + :-( + Sad + icon_e_sad.gif + 15 + 17 + 11 + 1 + + + 12 + :sad: + Sad + icon_e_sad.gif + 15 + 17 + 12 + 1 + + + 13 + :o + Surprised + icon_e_surprised.gif + 15 + 17 + 13 + 1 + + + 14 + :-o + Surprised + icon_e_surprised.gif + 15 + 17 + 14 + 1 + + + 15 + :eek: + Surprised + icon_e_surprised.gif + 15 + 17 + 15 + 1 + + + 16 + :shock: + Shocked + icon_eek.gif + 15 + 17 + 16 + 1 + + + 17 + :? + Confused + icon_e_confused.gif + 15 + 17 + 17 + 1 + + + 18 + :-? + Confused + icon_e_confused.gif + 15 + 17 + 18 + 1 + + + 19 + :???: + Confused + icon_e_confused.gif + 15 + 17 + 19 + 1 + + + 20 + 8-) + Cool + icon_cool.gif + 15 + 17 + 20 + 1 + + + 21 + :cool: + Cool + icon_cool.gif + 15 + 17 + 21 + 1 + + + 22 + :lol: + Laughing + icon_lol.gif + 15 + 17 + 22 + 1 + + + 23 + :x + Mad + icon_mad.gif + 15 + 17 + 23 + 1 + + + 24 + :-x + Mad + icon_mad.gif + 15 + 17 + 24 + 1 + + + 25 + :mad: + Mad + icon_mad.gif + 15 + 17 + 25 + 1 + + + 26 + :P + Razz + icon_razz.gif + 15 + 17 + 26 + 1 + + + 27 + :-P + Razz + icon_razz.gif + 15 + 17 + 27 + 1 + + + 28 + :razz: + Razz + icon_razz.gif + 15 + 17 + 28 + 1 + + + 29 + :oops: + Embarrassed + icon_redface.gif + 15 + 17 + 29 + 1 + + + 30 + :cry: + Crying or Very Sad + icon_cry.gif + 15 + 17 + 30 + 1 + + + 31 + :evil: + Evil or Very Mad + icon_evil.gif + 15 + 17 + 31 + 1 + + + 32 + :twisted: + Twisted Evil + icon_twisted.gif + 15 + 17 + 32 + 1 + + + 33 + :roll: + Rolling Eyes + icon_rolleyes.gif + 15 + 17 + 33 + 1 + + + 34 + :!: + Exclamation + icon_exclaim.gif + 15 + 17 + 34 + 1 + + + 35 + :?: + Question + icon_question.gif + 15 + 17 + 35 + 1 + + + 36 + :idea: + Idea + icon_idea.gif + 15 + 17 + 36 + 1 + + + 37 + :arrow: + Arrow + icon_arrow.gif + 15 + 17 + 37 + 1 + + + 38 + :| + Neutral + icon_neutral.gif + 15 + 17 + 38 + 1 + + + 39 + :-| + Neutral + icon_neutral.gif + 15 + 17 + 39 + 1 + + + 40 + :mrgreen: + Mr. Green + icon_mrgreen.gif + 15 + 17 + 40 + 1 + + + 41 + :geek: + Geek + icon_e_geek.gif + 17 + 17 + 41 + 1 + + + 42 + :ugeek: + Uber Geek + icon_e_ugeek.gif + 17 + 18 + 42 + 1 + +
    + + + style_id + style_name + style_copyright + style_active + style_path + bbcode_bitfield + style_parent_id + style_parent_tree + + 1 + prosilver + &copy; phpBB Group + 1 + prosilver + kNg= + 0 + + +
    + + + word_id + word + replacement + + + 1 + apple + banana + +
    +
    diff --git a/tests/text_formatter/s9e/fixtures/default_lang.xml b/tests/text_formatter/s9e/fixtures/default_lang.xml new file mode 100644 index 0000000000..2cfde4aab2 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/default_lang.xml @@ -0,0 +1,20 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + + + 13 + foo + + 1 + [foo]{TEXT}[/foo] + {L_FOO_BAR} + +
    +
    diff --git a/tests/text_formatter/s9e/fixtures/factory.xml b/tests/text_formatter/s9e/fixtures/factory.xml new file mode 100644 index 0000000000..9ae52e9747 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/factory.xml @@ -0,0 +1,115 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + custom + + 1 + [custom]{TEXT}[/custom] + <span style="color:red">{TEXT}</span> + !\[custom\](.*?)\[/custom\]!ies + '[custom:$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', '&#39;', '&#40;', '&#41;'), trim('${1}')).'[/custom:$uid]' + !\[custom:$uid\](.*?)\[/custom:$uid\]!s + <span style="color:red">${1}</span> + + + 14 + unsafe + + 1 + [unsafe]{TEXT}[/unsafe] + <script>{TEXT}</script> + !\[unsafe\](.*?)\[/unsafe\]!ies + '[unsafe:$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', '&#39;', '&#40;', '&#41;'), trim('${1}')).'[/unsafe:$uid]' + !\[unsafe:$uid\](.*?)\[/unsafe:$uid\]!s + <script>${1}</script> + +
    + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 1 + :D + Very Happy + icon_e_biggrin.gif + 15 + 17 + 2 + 1 + + + 4 + :) + Smile + icon_e_smile.gif + 15 + 17 + 4 + 1 + + + 10 + :( + Sad + icon_e_sad.gif + 15 + 17 + 10 + 1 + +
    + + + style_id + style_name + style_copyright + style_active + style_path + bbcode_bitfield + style_parent_id + style_parent_tree + + + 1 + prosilver + &copy; phpBB Group + 1 + prosilver + kNg= + 0 + + +
    + + + word_id + word + replacement + + + 1 + apple + banana + +
    +
    diff --git a/tests/text_formatter/s9e/fixtures/inttext_token.xml b/tests/text_formatter/s9e/fixtures/inttext_token.xml new file mode 100644 index 0000000000..30b971f315 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/inttext_token.xml @@ -0,0 +1,27 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + spoiler= + + 1 + [spoiler={INTTEXT}]{TEXT}[/spoiler] +
    {INTTEXT}
    {TEXT}
    ]]>
    + + +
    ${1}
    ${2}
    ]]>
    +
    +
    +
    diff --git a/tests/text_formatter/s9e/fixtures/local_url.xml b/tests/text_formatter/s9e/fixtures/local_url.xml new file mode 100644 index 0000000000..9db2bf4710 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/local_url.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + local + + 1 + [local]{LOCAL_URL}[/local] + {LOCAL_URL}]]> + + bbcode_specialchars('${1}').'[/local:$uid]']]> + + http://path/to/phpBB/${1}]]> + +
    +
    diff --git a/tests/text_formatter/s9e/fixtures/smilies_special_chars.xml b/tests/text_formatter/s9e/fixtures/smilies_special_chars.xml new file mode 100644 index 0000000000..d3a7cfa4f7 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/smilies_special_chars.xml @@ -0,0 +1,23 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 1 + "'<&> + "'<&> + "'<&>.png + 15 + 17 + 2 + 1 + +
    +
    diff --git a/tests/text_formatter/s9e/fixtures/style_inheritance.xml b/tests/text_formatter/s9e/fixtures/style_inheritance.xml new file mode 100644 index 0000000000..a692d0ef2d --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/style_inheritance.xml @@ -0,0 +1,66 @@ + + + + style_id + style_name + style_copyright + style_active + style_path + bbcode_bitfield + style_parent_id + style_parent_tree + + + 1 + foo + + 1 + foo + + QA== + 0 + + + + 2 + fooplus + + 1 + fooplus + QA== + 1 + + + + 3 + fooplusplus + + 1 + fooplusplus + QA== + 2 + + + + 4 + bar + + 1 + bar + + QA== + 0 + + + + 5 + barplus + + 1 + barplus + QA== + 4 + + +
    +
    diff --git a/tests/text_formatter/s9e/fixtures/styles.xml b/tests/text_formatter/s9e/fixtures/styles.xml new file mode 100644 index 0000000000..8004412aea --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/styles.xml @@ -0,0 +1,36 @@ + + + + style_id + style_name + style_copyright + style_active + style_path + bbcode_bitfield + style_parent_id + style_parent_tree + + + 1 + foo + + 1 + foo + + QA== + 0 + + + + 2 + bar + + 1 + bar + + QA== + 0 + + +
    +
    diff --git a/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html new file mode 100644 index 0000000000..a17446581a --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html @@ -0,0 +1,40 @@ +
      +
        +
      + +
        +
      + +
    • +
    • + +
      {USERNAME} {L_WROTE}{L_COLON} +
      +
      + +

      {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}

      +
      + +
      +
      + + + + + + + + + + +{TEXT} + +{TEXT} + +{L_IMAGE} + +{DESCRIPTION} + +{DESCRIPTION} + + diff --git a/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html new file mode 100644 index 0000000000..cd2f0acae3 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html @@ -0,0 +1,40 @@ +
        +
          +
        + +
          +
        + +
      • +
      • + +
        {USERNAME} {L_WROTE}{L_COLON} +
        +
        + +

        {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}

        +
        + +
        +
        + + + + + + + + + + +{TEXT} + +{TEXT} + +{L_IMAGE} + +{DESCRIPTION} + +{DESCRIPTION} + + diff --git a/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html new file mode 100644 index 0000000000..909c09df5a --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html @@ -0,0 +1,40 @@ +
          +
            +
          + +
            +
          + +
        • +
        • + +
          {USERNAME} {L_WROTE}{L_COLON} +
          +
          + +

          {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}

          +
          + +
          +
          + + + + + + + + + + +{TEXT} + +{TEXT} + +{L_IMAGE} + +{DESCRIPTION} + +{DESCRIPTION} + + diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php new file mode 100644 index 0000000000..528305a11c --- /dev/null +++ b/tests/text_formatter/s9e/parser_test.php @@ -0,0 +1,162 @@ +getMockBuilder('s9e\\TextFormatter\\Parser') + ->disableOriginalConstructor() + ->getMock(); + + $cache = $this->getMock('phpbb_mock_cache'); + $cache->expects($this->once()) + ->method('get') + ->with('_foo_parser') + ->will($this->returnValue($mock)); + + $parser = new \phpbb\textformatter\s9e\parser( + $cache, + '_foo_parser', + $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), + new phpbb_mock_container_builder + ); + } + + public function test_use_from_cache() + { + $mock = $this->getMockBuilder('s9e\\TextFormatter\\Parser') + ->disableOriginalConstructor() + ->getMock(); + + $mock->expects($this->once()) + ->method('parse') + ->with('test') + ->will($this->returnValue('test')); + + $cache = new phpbb_mock_cache; + $cache->put('_foo_parser', $mock); + + $parser = new \phpbb\textformatter\s9e\parser( + $cache, + '_foo_parser', + $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), + new phpbb_mock_container_builder + ); + + $this->assertSame('test', $parser->parse('test')); + } + + public function test_regenerate_on_cache_miss() + { + $mock = $this->getMockBuilder('s9e\\TextFormatter\\Parser') + ->disableOriginalConstructor() + ->getMock(); + + $mock->expects($this->once()) + ->method('parse') + ->with('test') + ->will($this->returnValue('test')); + + $factory = $this->getMock('stdClass', array('regenerate')); + $factory->expects($this->once()) + ->method('regenerate') + ->will($this->returnValue(array($mock, false))); + + $container = new phpbb_mock_container_builder; + $container->set('text_formatter.s9e.factory', $factory); + + $parser = new \phpbb\textformatter\s9e\parser( + new phpbb_mock_cache, + '_foo_parser', + $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), + $container + ); + + $this->assertSame('test', $parser->parse('test')); + } + + /** + * @dataProvider get_options_tests() + */ + public function test_options($adapter_method, $adapter_arg, $concrete_method, $concrete_arg) + { + $mock = $this->getMockBuilder('s9e\\TextFormatter\\Parser') + ->setMethods(array($concrete_method)) + ->disableOriginalConstructor() + ->getMock(); + foreach ((array) $concrete_arg as $i => $concrete_arg) + { + $mock->expects($this->at($i)) + ->method($concrete_method) + ->with($concrete_arg); + } + + $cache = new phpbb_mock_cache; + $cache->put('_foo_parser', $mock); + + $parser = new \phpbb\textformatter\s9e\parser( + $cache, + '_foo_parser', + $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), + new phpbb_mock_container_builder + ); + + call_user_func_array(array($parser, $adapter_method), (array) $adapter_arg); + } + + public function get_options_tests() + { + return array( + array( + 'disable_bbcode', 'url', + 'disableTag', 'URL' + ), + array( + 'disable_bbcodes', null, + 'disablePlugin', 'BBCodes' + ), + array( + 'disable_censor', null, + 'disablePlugin', 'Censor' + ), + array( + 'disable_magic_url', null, + 'disablePlugin', array('Autoemail', 'Autolink') + ), + array( + 'disable_smilies', null, + 'disablePlugin', 'Emoticons' + ), + array( + 'enable_bbcode', 'url', + 'enableTag', 'URL' + ), + array( + 'enable_bbcodes', null, + 'enablePlugin', 'BBCodes' + ), + array( + 'enable_censor', null, + 'enablePlugin', 'Censor' + ), + array( + 'enable_magic_url', null, + 'enablePlugin', array('Autoemail', 'Autolink') + ), + array( + 'enable_smilies', null, + 'enablePlugin', 'Emoticons' + ) + ); + } +} diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php new file mode 100644 index 0000000000..76babbfdf3 --- /dev/null +++ b/tests/text_formatter/s9e/renderer_test.php @@ -0,0 +1,355 @@ +get_cache_dir() . 'renderer_foo.php', + 'getMockForAbstractClass('s9e\\TextFormatter\\Renderer'); + + $cache = $this->getMock('phpbb_mock_cache'); + $cache->expects($this->once()) + ->method('get') + ->with('_foo_renderer') + ->will($this->returnValue(array('class' => 'renderer_foo', 'renderer' => serialize($mock)))); + + $container = new phpbb_mock_container_builder; + $container->set('text_formatter.s9e.factory', $factory); + + $renderer = new \phpbb\textformatter\s9e\renderer( + $cache, + $this->get_cache_dir(), + '_foo_renderer', + $container + ); + } + + public function test_regenerate_on_cache_miss() + { + $mock = $this->getMockForAbstractClass('s9e\\TextFormatter\\Renderer'); + + $cache = $this->getMock('phpbb_mock_cache'); + $cache->expects($this->once()) + ->method('get') + ->with('_foo_renderer') + ->will($this->returnValue(false)); + + $factory = $this->getMock('stdClass', array('regenerate')); + $factory->expects($this->once()) + ->method('regenerate') + ->will($this->returnValue(array($mock, false))); + + $container = new phpbb_mock_container_builder; + $container->set('text_formatter.s9e.factory', $factory); + + $renderer = new \phpbb\textformatter\s9e\renderer( + $cache, + $this->get_cache_dir(), + '_foo_renderer', + $container + ); + } + + /** + * @dataProvider get_options_cases + */ + public function test_options($original, $expected, $calls) + { + $container = new phpbb_mock_container_builder; + $this->get_test_case_helpers()->set_s9e_services($container); + + $renderer = $container->get('text_formatter.renderer'); + + foreach ($calls as $method => $arg) + { + $renderer->$method($arg); + } + + $this->assertSame($expected, $renderer->render($original)); + } + + public function get_options_cases() + { + return array( + array( + 'apple', + 'banana', + array('set_viewcensors' => true) + ), + array( + 'apple', + 'apple', + array('set_viewcensors' => false) + ), + array( + '[flash=123,456]http://example.org/foo.swf[/flash]', + '', + array('set_viewflash' => true) + ), + array( + '[img]http://example.org/foo.png[/img]', + 'Image', + array('set_viewimg' => true) + ), + array( + ':)', + ':)', + array('set_viewsmilies' => true) + ), + array( + ':)', + ':)', + array('set_viewsmilies' => false) + ), + ); + } + + /** + * @dataProvider get_default_options_cases + */ + public function test_default_options($original, $expected, $setup = null) + { + $container = new phpbb_mock_container_builder; + + if (isset($setup)) + { + $setup($container, $this); + } + + $this->get_test_case_helpers()->set_s9e_services($container); + + $this->assertSame($expected, $container->get('text_formatter.renderer')->render($original)); + } + + public function get_default_options_cases() + { + return array( + array( + 'apple', + 'banana' + ), + array( + 'apple', + 'banana', + function ($phpbb_container) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('viewcensors', false); + + $phpbb_container->set('user', $user); + } + ), + array( + 'apple', + 'banana', + function ($phpbb_container) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('viewcensors', false); + + $config = new \phpbb\config\config(array('allow_nocensors' => true)); + + $phpbb_container->set('user', $user); + $phpbb_container->set('config', $config); + } + ), + array( + 'apple', + 'apple', + function ($phpbb_container, $test) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('viewcensors', false); + + $config = new \phpbb\config\config(array('allow_nocensors' => true)); + + $auth = $test->getMock('phpbb\\auth\\auth'); + $auth->expects($test->any()) + ->method('acl_get') + ->with('u_chgcensors') + ->will($test->returnValue(true)); + + $phpbb_container->set('user', $user); + $phpbb_container->set('config', $config); + $phpbb_container->set('auth', $auth); + } + ), + array( + '[flash=123,456]http://localhost/foo.swf[/flash]', + '' + ), + array( + '[flash=123,456]http://localhost/foo.swf[/flash]', + 'http://localhost/foo.swf', + function ($phpbb_container) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('viewflash', false); + + $phpbb_container->set('user', $user); + } + ), + array( + '[img]http://localhost/mrgreen.gif[/img]', + 'Image' + ), + array( + '[img]http://localhost/mrgreen.gif[/img]', + 'http://localhost/mrgreen.gif', + function ($phpbb_container) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('viewimg', false); + + $phpbb_container->set('user', $user); + } + ), + array( + ':)', + ':)' + ), + array( + ':)', + ':)', + function ($phpbb_container) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('smilies', false); + + $phpbb_container->set('user', $user); + } + ), + ); + } + + public function test_default_lang() + { + global $phpbb_container; + $this->get_test_case_helpers()->set_s9e_services($phpbb_container, __DIR__ . '/fixtures/default_lang.xml'); + + $renderer = $phpbb_container->get('text_formatter.renderer'); + + $this->assertSame('FOO_BAR', $renderer->render('')); + } + + /** + * @dataProvider get_option_names + */ + public function test_get_option($option_name) + { + global $phpbb_container; + $this->get_test_case_helpers()->set_s9e_services(); + + $renderer = $phpbb_container->get('text_formatter.renderer'); + + $renderer->{'set_' . $option_name}(false); + $this->assertFalse($renderer->{'get_' . $option_name}()); + $renderer->{'set_' . $option_name}(true); + $this->assertTrue($renderer->{'get_' . $option_name}()); + } + + public function get_option_names() + { + return array( + array('viewcensors'), + array('viewflash'), + array('viewimg'), + array('viewsmilies') + ); + } + + public function test_styles() + { + global $phpbb_container; + + $tests = array( + 1 => 'bold', + 2 => 'bold' + ); + + foreach ($tests as $style_id => $expected) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->style = array('style_id' => $style_id); + + $phpbb_container = new phpbb_mock_container_builder; + $phpbb_container->set('user', $user); + + $this->get_test_case_helpers()->set_s9e_services($phpbb_container, __DIR__ . '/fixtures/styles.xml', __DIR__ . '/fixtures/styles/'); + + $renderer = $phpbb_container->get('text_formatter.renderer'); + $this->assertSame( + $expected, + $renderer->render('[b]bold[/b]') + ); + } + } + + public function test_style_inheritance1() + { + global $phpbb_container; + + // Style 3 inherits from 2 which inherits from 1. Only style 1 has a bbcode.html + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->style = array('style_id' => 3); + + $phpbb_container = new phpbb_mock_container_builder; + $phpbb_container->set('user', $user); + + $this->get_test_case_helpers()->set_s9e_services($phpbb_container, __DIR__ . '/fixtures/style_inheritance.xml', __DIR__ . '/fixtures/styles/'); + + $renderer = $phpbb_container->get('text_formatter.renderer'); + $this->assertSame( + 'bold', + $renderer->render('[b]bold[/b]') + ); + } + + public function test_style_inheritance2() + { + global $phpbb_container; + + // Style 5 inherits from 4, but both have a bbcode.html + $tests = array( + 4 => 'bold', + 5 => 'bold' + ); + + foreach ($tests as $style_id => $expected) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->style = array('style_id' => $style_id); + + $phpbb_container = new phpbb_mock_container_builder; + $phpbb_container->set('user', $user); + + $this->get_test_case_helpers()->set_s9e_services($phpbb_container, __DIR__ . '/fixtures/style_inheritance.xml', __DIR__ . '/fixtures/styles/'); + + $renderer = $phpbb_container->get('text_formatter.renderer'); + $this->assertSame( + $expected, + $renderer->render('[b]bold[/b]') + ); + } + } +} diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php new file mode 100644 index 0000000000..510beba817 --- /dev/null +++ b/tests/text_formatter/s9e/utils_test.php @@ -0,0 +1,157 @@ +get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->unparse($original)); + } + + public function get_unparse_tests() + { + return array( + array( + 'Plain text', + 'Plain text' + ), + array( + "Multi
          \nline
          ", + "Multi\nline" + ), + array( + '[b]bold[/b]', + '[b]bold[/b]' + ) + ); + } + + /** + * @dataProvider get_remove_formatting_tests + */ + public function test_remove_formatting($original, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->remove_formatting($original)); + } + + public function get_remove_formatting_tests() + { + return array( + array( + 'Plain text', + 'Plain text' + ), + array( + "Multi
          \nline
          ", + "Multi\nline" + ), + array( + '[b]bold[/b]', + 'bold' + ) + ); + } + + /** + * @dataProvider get_clean_formatting_tests + */ + public function test_clean_formatting($original, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->clean_formatting($original)); + } + + public function get_clean_formatting_tests() + { + return array( + array( + 'Plain text', + 'Plain text' + ), + array( + "Multi
          \nline
          ", + "Multi\nline" + ), + array( + '[b]bold[/b]', + ' bold ' + ) + ); + } + + /** + * @dataProvider get_remove_bbcode_tests + */ + public function test_remove_bbcode($original, $name, $depth, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->remove_bbcode($original, $name, $depth)); + } + + public function get_remove_bbcode_tests() + { + return array( + array( + 'Plain text', + 'b', + 1, + 'Plain text' + ), + array( + '[quote="u0"][quote="u1"][quote="u2"]q2[/quote] +q1[/quote] +q0[/quote] +[b]bold[/b]', + 'quote', + 0, + ' +[b]bold[/b]' + ), + array( + '[quote="u0"][quote="u1"][quote="u2"]q2[/quote] +q1[/quote] +q0[/quote] +[b]bold[/b]', + 'quote', + 1, + '[quote="u0"] +q0[/quote] +[b]bold[/b]' + ), + array( + '[quote="u0"][quote="u1"][quote="u2"]q2[/quote] +q1[/quote] +q0[/quote] +[b]bold[/b]', + 'quote', + 2, + '[quote="u0"][quote="u1"] +q1[/quote] +q0[/quote] +[b]bold[/b]' + ), + ); + } +} diff --git a/tests/text_processing/decode_message_test.php b/tests/text_processing/decode_message_test.php new file mode 100644 index 0000000000..855b3c6c57 --- /dev/null +++ b/tests/text_processing/decode_message_test.php @@ -0,0 +1,87 @@ +assertSame($expected, $actual); + } + + public function get_legacy_tests() + { + return array( + array( + "&<>"'", + "&<>"'" + ), + array( + ':)', + ':)' + ), + /** + * Fails as per PHPBB3-8420 + * @link http://tracker.phpbb.com/browse/PHPBB3-8420 + * + array( + '[url=http://example.com:2cpxwbdy]:arrow: here[/url:2cpxwbdy]', + '[url=http://example.com] :arrow: here[/url]', + '2cpxwbdy' + ), + */ + ); + } + + /** + * @dataProvider get_text_formatter_tests + */ + public function test_text_formatter($original, $expected) + { + $this->get_test_case_helpers()->set_s9e_services(); + + $actual = $original; + decode_message($actual); + + $this->assertSame($expected, $actual); + } + + public function get_text_formatter_tests() + { + return array( + array( + "&<>\"'", + "&<>"'" + ), + array( + ':)', + ':)' + ), + array( + "a
          \nb
          ", + "a\nb" + ), + /** + * @link http://tracker.phpbb.com/browse/PHPBB3-8420 + */ + array( + '[url=http://example.com] :arrow: here[/url]', + '[url=http://example.com] :arrow: here[/url]' + ), + ); + } +} diff --git a/tests/text_processing/fixtures/empty.xml b/tests/text_processing/fixtures/empty.xml new file mode 100644 index 0000000000..d8206ad124 --- /dev/null +++ b/tests/text_processing/fixtures/empty.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/text_processing/fixtures/smilies.xml b/tests/text_processing/fixtures/smilies.xml new file mode 100644 index 0000000000..25b2e60836 --- /dev/null +++ b/tests/text_processing/fixtures/smilies.xml @@ -0,0 +1,443 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 1 + :D + Very Happy + icon_e_biggrin.gif + 15 + 17 + 1 + 1 + + + 2 + :-D + Very Happy + icon_e_biggrin.gif + 15 + 17 + 2 + 1 + + + 3 + :grin: + Very Happy + icon_e_biggrin.gif + 15 + 17 + 3 + 1 + + + 4 + :) + Smile + icon_e_smile.gif + 15 + 17 + 4 + 1 + + + 5 + :-) + Smile + icon_e_smile.gif + 15 + 17 + 5 + 1 + + + 6 + :smile: + Smile + icon_e_smile.gif + 15 + 17 + 6 + 1 + + + 7 + ;) + Wink + icon_e_wink.gif + 15 + 17 + 7 + 1 + + + 8 + ;-) + Wink + icon_e_wink.gif + 15 + 17 + 8 + 1 + + + 9 + :wink: + Wink + icon_e_wink.gif + 15 + 17 + 9 + 1 + + + 10 + :( + Sad + icon_e_sad.gif + 15 + 17 + 10 + 1 + + + 11 + :-( + Sad + icon_e_sad.gif + 15 + 17 + 11 + 1 + + + 12 + :sad: + Sad + icon_e_sad.gif + 15 + 17 + 12 + 1 + + + 13 + :o + Surprised + icon_e_surprised.gif + 15 + 17 + 13 + 1 + + + 14 + :-o + Surprised + icon_e_surprised.gif + 15 + 17 + 14 + 1 + + + 15 + :eek: + Surprised + icon_e_surprised.gif + 15 + 17 + 15 + 1 + + + 16 + :shock: + Shocked + icon_eek.gif + 15 + 17 + 16 + 1 + + + 17 + :? + Confused + icon_e_confused.gif + 15 + 17 + 17 + 1 + + + 18 + :-? + Confused + icon_e_confused.gif + 15 + 17 + 18 + 1 + + + 19 + :???: + Confused + icon_e_confused.gif + 15 + 17 + 19 + 1 + + + 20 + 8-) + Cool + icon_cool.gif + 15 + 17 + 20 + 1 + + + 21 + :cool: + Cool + icon_cool.gif + 15 + 17 + 21 + 1 + + + 22 + :lol: + Laughing + icon_lol.gif + 15 + 17 + 22 + 1 + + + 23 + :x + Mad + icon_mad.gif + 15 + 17 + 23 + 1 + + + 24 + :-x + Mad + icon_mad.gif + 15 + 17 + 24 + 1 + + + 25 + :mad: + Mad + icon_mad.gif + 15 + 17 + 25 + 1 + + + 26 + :P + Razz + icon_razz.gif + 15 + 17 + 26 + 1 + + + 27 + :-P + Razz + icon_razz.gif + 15 + 17 + 27 + 1 + + + 28 + :razz: + Razz + icon_razz.gif + 15 + 17 + 28 + 1 + + + 29 + :oops: + Embarrassed + icon_redface.gif + 15 + 17 + 29 + 1 + + + 30 + :cry: + Crying or Very Sad + icon_cry.gif + 15 + 17 + 30 + 1 + + + 31 + :evil: + Evil or Very Mad + icon_evil.gif + 15 + 17 + 31 + 1 + + + 32 + :twisted: + Twisted Evil + icon_twisted.gif + 15 + 17 + 32 + 1 + + + 33 + :roll: + Rolling Eyes + icon_rolleyes.gif + 15 + 17 + 33 + 1 + + + 34 + :!: + Exclamation + icon_exclaim.gif + 15 + 17 + 34 + 1 + + + 35 + :?: + Question + icon_question.gif + 15 + 17 + 35 + 1 + + + 36 + :idea: + Idea + icon_idea.gif + 15 + 17 + 36 + 1 + + + 37 + :arrow: + Arrow + icon_arrow.gif + 15 + 17 + 37 + 1 + + + 38 + :| + Neutral + icon_neutral.gif + 15 + 17 + 38 + 1 + + + 39 + :-| + Neutral + icon_neutral.gif + 15 + 17 + 39 + 1 + + + 40 + :mrgreen: + Mr. Green + icon_mrgreen.gif + 15 + 17 + 40 + 1 + + + 41 + :geek: + Geek + icon_e_geek.gif + 17 + 17 + 41 + 1 + + + 42 + :ugeek: + Uber Geek + icon_e_ugeek.gif + 17 + 18 + 42 + 1 + + + 43 + 8) + 8) + custom.gif + 17 + 18 + 42 + 1 + +
          +
          diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index 057416da33..fe83938c0b 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -11,10 +11,8 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; -require_once dirname(__FILE__) . '/../mock/user.php'; -require_once dirname(__FILE__) . '/../mock/cache.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_case { @@ -24,21 +22,175 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca parent::setUp(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; + $config = new \phpbb\config\config(array()); + set_config(null, null, null, $config); + } + + /** + * @dataProvider get_legacy_tests + */ + public function test_legacy($original, $expected, $uid = '', $bitfield = '', $flags = 0, $censor_text = true) + { + global $cache, $user; + $cache = new phpbb_mock_cache; + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('viewcensors', true); + $user->optionset('viewflash', true); + $user->optionset('viewimg', true); + $user->optionset('viewsmilies', true); + + $actual = generate_text_for_display($original, $uid, $bitfield, $flags, $censor_text); + + $this->assertSame($expected, $actual); + } + + public function get_legacy_tests() + { + return array( + array( + '', + '' + ), + array( + '0', + '0' + ), + ); + } + + public function test_censor_is_restored() + { + global $phpbb_container; + + $phpbb_container = new phpbb_mock_container_builder; - $user = new phpbb_mock_user; + $user = new \phpbb\user('\\phpbb\\datetime'); $user->optionset('viewcensors', false); - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $config = new \phpbb\config\config(array('allow_nocensors' => true)); + + $auth = $this->getMock('phpbb\\auth\\auth'); + $auth->expects($this->any()) + ->method('acl_get') + ->with('u_chgcensors') + ->will($this->returnValue(true)); + + $phpbb_container->set('user', $user); + $phpbb_container->set('config', $config); + $phpbb_container->set('auth', $auth); + + $this->get_test_case_helpers()->set_s9e_services($phpbb_container); + $renderer = $phpbb_container->get('text_formatter.renderer'); + + $original = 'apple'; + + $renderer->set_viewcensors(false); + $this->assertSame('apple', $renderer->render($original)); + $renderer->set_viewcensors(true); + $this->assertSame('banana', $renderer->render($original)); + $this->assertSame('apple', generate_text_for_display($original, '', '', 0, false)); + $this->assertSame('banana', $renderer->render($original), 'The original setting was not restored'); + + $renderer->set_viewcensors(false); + $this->assertSame('apple', $renderer->render($original)); + $this->assertSame('banana', generate_text_for_display($original, '', '', 0, truee)); + $this->assertSame('apple', $renderer->render($original), 'The original setting was not restored'); } - public function test_empty_string() + /** + * @dataProvider get_text_formatter_tests + */ + public function test_text_formatter($original, $expected, $censor_text = true, $setup = null) { - $this->assertSame('', generate_text_for_display('', '', '', 0)); + global $phpbb_container; + + $phpbb_container = new phpbb_mock_container_builder; + + if (isset($setup)) + { + $setup($phpbb_container, $this); + } + + $this->get_test_case_helpers()->set_s9e_services($phpbb_container); + + $this->assertSame($expected, generate_text_for_display($original, '', '', 0, $censor_text)); } - public function test_zero_string() + public function get_text_formatter_tests() { - $this->assertSame('0', generate_text_for_display('0', '', '', 0)); + return array( + array( + 'Plain text', + 'Plain text' + ), + array( + 'Hello [url=http://example.org]world[/url]', + 'Hello world' + ), + array( + '&<>"\'', + '&<>"\'' + ), + array( + 'apple', + 'banana', + true + ), + array( + 'apple', + 'apple', + false + ), + array( + '[flash=123,456]http://localhost/foo.swf[/flash]', + '' + ), + array( + '[flash=123,456]http://localhost/foo.swf[/flash]', + 'http://localhost/foo.swf', + true, + function ($phpbb_container) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('viewflash', false); + + $phpbb_container->set('user', $user); + } + ), + array( + '[img]http://localhost/mrgreen.gif[/img]', + 'Image' + ), + array( + '[img]http://localhost/mrgreen.gif[/img]', + 'http://localhost/mrgreen.gif', + true, + function ($phpbb_container) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('viewimg', false); + + $phpbb_container->set('user', $user); + } + ), + array( + ':)', + ':)' + ), + array( + ':)', + ':)', + true, + function ($phpbb_container) + { + $user = new \phpbb\user('\\phpbb\\datetime'); + $user->optionset('smilies', false); + + $phpbb_container->set('user', $user); + } + ), + ); } } diff --git a/tests/text_processing/generate_text_for_edit_test.php b/tests/text_processing/generate_text_for_edit_test.php new file mode 100644 index 0000000000..85b3a6a0ab --- /dev/null +++ b/tests/text_processing/generate_text_for_edit_test.php @@ -0,0 +1,90 @@ +optionset('viewcensors', false); + + $return = generate_text_for_edit($original, $uid, $flags); + + $this->assertSame($expected, $return['text']); + } + + public function get_legacy_tests() + { + return array( + array( + '', + '' + ), + array( + '0', + '0' + ), + array( + 'Hello [url=http://example.org:1f4coh9x]world[/url:1f4coh9x] :)', + 'Hello [url=http://example.org]world[/url] :)', + '1f4coh9x', + 0 + ), + array( + "&<>"'", + "&<>"'" + ) + ); + } + + /** + * @dataProvider get_text_formatter_tests + */ + public function test_text_formatter($original, $expected) + { + global $phpbb_dispatcher; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; + $this->get_test_case_helpers()->set_s9e_services(); + + $return = generate_text_for_edit($original, '', 0); + + $this->assertSame($expected, $return['text']); + } + + public function get_text_formatter_tests() + { + return array( + array( + 'Plain text', + 'Plain text' + ), + array( + 'Hello [url=http://example.org]world[/url] :)', + 'Hello [url=http://example.org]world[/url] :)' + ), + array( + '&<>"\'', + "&<>"'" + ) + ); + } +} diff --git a/tests/text_processing/generate_text_for_storage_test.php b/tests/text_processing/generate_text_for_storage_test.php new file mode 100644 index 0000000000..0bacaacfb8 --- /dev/null +++ b/tests/text_processing/generate_text_for_storage_test.php @@ -0,0 +1,70 @@ +set('config', $config); + $this->get_test_case_helpers()->set_s9e_services($phpbb_container); + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; + } + + /** + * @dataProvider get_text_formatter_tests + */ + public function test_text_formatter($original, $expected, $allow_bbcode = true, $allow_urls = true, $allow_smilies = true, $setup = null) + { + $actual = $original; + $uid = ''; + $bitfield = ''; + $flags = 0; + + if (isset($setup)) + { + $setup(); + } + + generate_text_for_storage($actual, $uid, $bitfield, $flags, $allow_bbcode, $allow_urls, $allow_smilies); + + $this->assertSame($expected, $actual); + } + + public function get_text_formatter_tests() + { + return array( + array( + 'Hello world', + 'Hello world' + ), + array( + 'Hello [url=http://example.org]world[/url] :)', + 'Hello [url=http://example.org]world[/url] :)' + ), + array( + '&<>"\'', + '&<>"\'' + ), + ); + } +} diff --git a/tests/text_processing/message_parser_test.php b/tests/text_processing/message_parser_test.php new file mode 100644 index 0000000000..59af2553f8 --- /dev/null +++ b/tests/text_processing/message_parser_test.php @@ -0,0 +1,532 @@ + 999)); + + $map = array( + array('MAX_FLASH_HEIGHT_EXCEEDED', 123, 'Your flash files may only be up to 123 pixels high.'), + array('MAX_FLASH_WIDTH_EXCEEDED', 456, 'Your flash files may only be up to 456 pixels wide.'), + array('MAX_FONT_SIZE_EXCEEDED', 120, 'You may only use fonts up to size 120.'), + array('MAX_FONT_SIZE_EXCEEDED', 200, 'You may only use fonts up to size 200.'), + array('MAX_IMG_HEIGHT_EXCEEDED', 12, 'Your images may only be up to 12 pixels high.'), + array('MAX_IMG_WIDTH_EXCEEDED', 34, 'Your images may only be up to 34 pixels wide.'), + array('TOO_MANY_SMILIES', 3, 'Your message contains too many smilies. The maximum number of smilies allowed is 3.'), + array('TOO_MANY_URLS', 2, 'Your message contains too many URLs. The maximum number of URLs allowed is 2.'), + array('UNAUTHORISED_BBCODE', '[flash]', 'You cannot use certain BBCodes: [flash].'), + array('UNAUTHORISED_BBCODE', '[img]', 'You cannot use certain BBCodes: [img].'), + array('UNAUTHORISED_BBCODE', '[quote]', 'You cannot use certain BBCodes: [quote].'), + array('UNAUTHORISED_BBCODE', '[url]', 'You cannot use certain BBCodes: [url].'), + ); + + $user = $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(); + $user->expects($this->any()) + ->method('lang') + ->will($this->returnValueMap($map)); + + $user->lang = array( + 'NO_POLL_TITLE' => 'You have to enter a poll title.', + 'POLL_TITLE_TOO_LONG' => 'The poll title must contain fewer than 100 characters.', + 'POLL_TITLE_COMP_TOO_LONG' => 'The parsed size of your poll title is too large, consider removing BBCodes or smilies.', + 'TOO_FEW_POLL_OPTIONS' => 'You must enter at least two poll options.', + 'TOO_MANY_POLL_OPTIONS' => 'You have tried to enter too many poll options.', + 'TOO_MANY_USER_OPTIONS' => 'You cannot specify more options per user than existing poll options.', + 'UNABLE_GET_IMAGE_SIZE' => 'It was not possible to determine the dimensions of the image.' + ); + + $phpbb_container = new phpbb_mock_container_builder; + $phpbb_container->set('user', $user); + $phpbb_container->set('config', $config); + + if (isset($setup)) + { + $setup($parser, $phpbb_container, $this); + } + + $this->get_test_case_helpers()->set_s9e_services($phpbb_container); + } + + /** + * @dataProvider get_test_polls + */ + public function test_parse_poll($poll, $expected, $warn_msg = array()) + { + $this->prepare_s9e_services(); + + $message_parser = new parse_message('Me[i]s[/i]sage'); + + // Add some default values + $poll += array( + 'poll_length' => 123, + 'poll_start' => 123, + 'poll_last_vote' => 123, + 'poll_vote_change' => true, + 'enable_bbcode' => true, + 'enable_urls' => true, + 'enable_smilies' => true, + 'img_status' => true + ); + + $message_parser->parse_poll($poll); + $this->assertSame($expected, array_intersect_key($poll, $expected)); + + $this->assertSame( + 'Me[i]s[/i]sage', + $message_parser->parse(true, true, true, true, true, true, true, false) + ); + + $this->assertSame($warn_msg, $message_parser->warn_msg); + } + + public function get_test_polls() + { + return array( + array( + array( + 'poll_title' => 'foo [b]bar[/b] baz', + 'poll_option_text' => "[i]foo[/i]\nbar\n[i]baz[/i]", + 'poll_max_options' => 3, + 'poll_options_size' => 3 + ), + array( + 'poll_title' => 'foo [b]bar[/b] baz', + 'poll_option_text' => "[i]foo[/i]\nbar\n[i]baz[/i]", + 'poll_options' => array( + '[i]foo[/i]', + 'bar', + '[i]baz[/i]' + ) + ) + ), + array( + array( + 'poll_title' => 'xxx', + 'poll_option_text' => "[quote]quote[/quote]\n:)", + 'poll_max_options' => 2, + 'poll_options_size' => 2 + ), + array( + 'poll_title' => 'xxx', + 'poll_option_text' => "[quote]quote[/quote]\n:)", + 'poll_options' => array( + '[quote]quote[/quote]', + ':)' + ) + ), + array('You cannot use certain BBCodes: [quote].') + ), + array( + array( + 'poll_title' => 'xxx', + 'poll_option_text' => "[flash=12,34]http://example.org/x.swf[/flash]\n:)", + 'poll_max_options' => 2, + 'poll_options_size' => 2 + ), + array( + 'poll_title' => 'xxx', + 'poll_option_text' => "[flash=12,34]http://example.org/x.swf[/flash]\n:)", + 'poll_options' => array( + '[flash=12,34]http://example.org/x.swf[/flash]', + ':)' + ) + ), + array('You cannot use certain BBCodes: [flash].') + ), + array( + array( + 'poll_title' => 'xxx', + 'poll_option_text' => "[b]x\ny[/b]", + 'poll_max_options' => 2, + 'poll_options_size' => 2 + ), + array( + 'poll_title' => 'xxx', + 'poll_option_text' => "[b]x\ny[/b]", + 'poll_options' => array( + '[b]x', + 'y[/b]', + ) + ) + ), + ); + } + + /** + * @dataProvider get_test_cases + */ + public function test_options($original, $expected, array $args, $setup = null, $warn_msg = array()) + { + $this->prepare_s9e_services($setup); + + $message_parser = new parse_message($original); + call_user_func_array(array($message_parser, 'parse'), $args); + + $this->assertSame($expected, $message_parser->message); + $this->assertSame($warn_msg, $message_parser->warn_msg); + } + + public function get_test_cases() + { + return array( + array( + '[b]bold[/b]', + '[b]bold[/b]', + array(true, true, true, true, true, true, true) + ), + array( + '[b]bold[/b]', + '[b]bold[/b]', + array(false, true, true, true, true, true, true) + ), + array( + 'http://example.org', + 'http://example.org', + array(true, true, true, true, true, true, true) + ), + array( + 'http://example.org', + 'http://example.org', + array(true, false, true, true, true, true, true) + ), + array( + ':)', + ':)', + array(true, true, true, true, true, true, true) + ), + array( + ':)', + ':)', + array(true, true, false, true, true, true, true) + ), + array( + '[url=http://example.org][img]http://example.org/img.png[/img][/url]', + '[url=http://example.org][img]http://example.org/img.png[/img][/url]', + array(true, true, true, true, true, true, true) + ), + array( + '[url=http://example.org][img]http://example.org/img.png[/img][/url]', + '[url=http://example.org][img]http://example.org/img.png[/img][/url]', + array(true, true, true, false, true, true, true), + null, + array('You cannot use certain BBCodes: [img].') + ), + array( + '[flash=12,34]http://example.org/foo.swf[/flash]', + '[flash=12,34]http://example.org/foo.swf[/flash]', + array(true, true, true, true, true, true, true) + ), + array( + '[flash=12,34]http://example.org/foo.swf[/flash]', + '[flash=12,34]http://example.org/foo.swf[/flash]', + array(true, true, true, true, false, true, true), + null, + array('You cannot use certain BBCodes: [flash].') + ), + array( + '[quote="foo"]bar :)[/quote]', + '[quote="foo"]bar :)[/quote]', + array(true, true, true, true, true, true, true) + ), + array( + '[quote="foo"]bar :)[/quote]', + '[quote="foo"]bar :)[/quote]', + array(true, true, true, true, true, false, true), + null, + array('You cannot use certain BBCodes: [quote].') + ), + array( + '[url=http://example.org][img]http://example.org/img.png[/img][/url]', + '[url=http://example.org][img]http://example.org/img.png[/img][/url]', + array(true, true, true, true, true, true, true) + ), + array( + '[url=http://example.org][img]http://example.org/img.png[/img][/url]', + '[url=http://example.org][img]http://example.org/img.png[/img][/url]', + array(true, true, true, true, true, true, false), + null, + array('You cannot use certain BBCodes: [url].') + ), + array( + '[size=200]200[/size]', + '[size=200]200[/size]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_font_size', 200); + } + ), + array( + '[size=200]200[/size]', + '[size=200]200[/size]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_font_size', 0); + } + ), + array( + '[size=2000]2000[/size]', + '[size=2000]2000[/size]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_font_size', 200); + }, + array('You may only use fonts up to size 200.') + ), + array( + '[size=0]0[/size]', + '[size=0]0[/size]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_font_size', 200); + } + ), + array( + '[size=200]200[/size]', + '[size=200]200[/size]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_sig_font_size', 200); + } + ), + array( + '[size=200]200[/size]', + '[size=200]200[/size]', + array(true, true, true, true, true, true, true, true, 'sig'), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_sig_font_size', 120); + }, + array('You may only use fonts up to size 120.') + ), + array( + '[img]http://example.org/100x100.png[/img]', + '[img]http://example.org/100x100.png[/img]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_img_height', 12); + }, + array('Your images may only be up to 12 pixels high.') + ), + array( + '[img]http://example.org/100x100.png[/img]', + '[img]http://example.org/100x100.png[/img]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_img_width', 34); + }, + array('Your images may only be up to 34 pixels wide.') + ), + array( + '[img]http://example.org/100x100.png[/img]', + '[img]http://example.org/100x100.png[/img]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_img_height', 0); + $phpbb_container->get('config')->set('max_post_img_width', 0); + } + ), + array( + '[img]http://example.org/100x100.png[/img]', + '[img]http://example.org/100x100.png[/img]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_img_height', 100); + $phpbb_container->get('config')->set('max_post_img_width', 100); + } + ), + array( + '[img]http://example.org/100x100.png[/img]', + '[img]http://example.org/100x100.png[/img]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_sig_img_height', 12); + $phpbb_container->get('config')->set('max_sig_img_width', 34); + } + ), + array( + '[img]http://example.org/404.png[/img]', + '[img]http://example.org/404.png[/img]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_img_height', 12); + }, + array('It was not possible to determine the dimensions of the image.') + ), + array( + '[flash=999,999]http://example.org/foo.swf[/flash]', + '[flash=999,999]http://example.org/foo.swf[/flash]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_img_height', 123); + }, + array('Your flash files may only be up to 123 pixels high.') + ), + array( + '[flash=999,999]http://example.org/foo.swf[/flash]', + '[flash=999,999]http://example.org/foo.swf[/flash]', + array(true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_img_width', 456); + }, + array('Your flash files may only be up to 456 pixels wide.') + ), + array( + ':) :) :)', + ':) :) :)', + array(true, true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_smilies', 3); + } + ), + array( + ':) :) :) :)', + ':) :) :) :)', + array(true, true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_smilies', 3); + }, + array('Your message contains too many smilies. The maximum number of smilies allowed is 3.') + ), + array( + ':) :) :) :)', + ':) :) :) :)', + array(true, true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_smilies', 0); + } + ), + array( + ':) :) :) :)', + ':) :) :) :)', + array(true, true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_sig_smilies', 3); + } + ), + array( + ':) :) :) :)', + ':) :) :) :)', + array(true, true, true, true, true, true, true, true, 'sig'), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_sig_smilies', 3); + }, + array('Your message contains too many smilies. The maximum number of smilies allowed is 3.') + ), + array( + 'http://example.org http://example.org http://example.org', + 'http://example.org http://example.org http://example.org', + array(true, true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_urls', 2); + }, + array('Your message contains too many URLs. The maximum number of URLs allowed is 2.') + ), + array( + 'http://example.org http://example.org http://example.org', + 'http://example.org http://example.org http://example.org', + array(true, true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_post_urls', 0); + } + ), + array( + 'http://example.org http://example.org http://example.org', + 'http://example.org http://example.org http://example.org', + array(true, true, true, true, true, true, true, true), + function ($parser, $phpbb_container) + { + $phpbb_container->get('config')->set('max_sig_urls', 2); + } + ), + ); + } +} + +class phpbb_text_processing_message_parser_test_proxy +{ + protected $response; + + public function stream_open($url) + { + if (strpos($url, '100x100')) + { + // Return a 100 x 100 PNG image + $this->response = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQAAAABYmaj5AAAAE0lEQVR4AWOgKxgFo2AUjIJRAAAFeAABHs0ozQAAAABJRU5ErkJggg=='); + } + else + { + $this->response = '404 not found'; + } + + return true; + } + + public function stream_stat() + { + return false; + } + + public function stream_read($len) + { + $chunk = substr($this->response, 0, $len); + $this->response = substr($this->response, $len); + + return $chunk; + } + + public function stream_eof() + { + return ($this->response === false); + } +} diff --git a/tests/text_processing/smilies_test.php b/tests/text_processing/smilies_test.php new file mode 100644 index 0000000000..cd35c25525 --- /dev/null +++ b/tests/text_processing/smilies_test.php @@ -0,0 +1,48 @@ +get_test_case_helpers()->set_s9e_services(null, __DIR__ . '/fixtures/smilies.xml'); + $parser = $container->get('text_formatter.parser'); + $renderer = $container->get('text_formatter.renderer'); + + $this->assertSame($expected, $renderer->render($parser->parse($original))); + } + + public function get_text_formatter_tests() + { + return array( + array( + ':) beginning', + ':) beginning' + ), + array( + 'end :)', + 'end :)' + ), + array( + ':)', + ':)' + ), + array( + 'xx (18) 8) xx', + 'xx (18) 8) xx' + ), + ); + } +} diff --git a/tests/text_processing/strip_bbcode_test.php b/tests/text_processing/strip_bbcode_test.php new file mode 100644 index 0000000000..d0dda89167 --- /dev/null +++ b/tests/text_processing/strip_bbcode_test.php @@ -0,0 +1,38 @@ +assertSame($expected, $actual, '20m4ill1'); + } + + public function test_s9e() + { + $phpbb_container = $this->get_test_case_helpers()->set_s9e_services(); + + $original = '[b]bold[/b]'; + $expected = ' bold '; + + $actual = $original; + strip_bbcode($actual); + + $this->assertSame($expected, $actual); + } +} diff --git a/tests/text_processing/tickets_data/PHPBB3-10002.html b/tests/text_processing/tickets_data/PHPBB3-10002.html new file mode 100644 index 0000000000..82990b2253 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10002.html @@ -0,0 +1,2 @@ +
          • one +
            • two
          \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10002.txt b/tests/text_processing/tickets_data/PHPBB3-10002.txt new file mode 100644 index 0000000000..fe2f29073f --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10002.txt @@ -0,0 +1,2 @@ +[quote][list][*]one +[quote][list][*]two[/list][/quote] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10425.html b/tests/text_processing/tickets_data/PHPBB3-10425.html new file mode 100644 index 0000000000..522b2f8858 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10425.html @@ -0,0 +1,3 @@ +http://ar.wikipedia.org/wiki/الصفحة_الرئيسية
          +http://ar.wikipedia.org/wiki/الصفحة_الرئيسية
          +link \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10425.txt b/tests/text_processing/tickets_data/PHPBB3-10425.txt new file mode 100644 index 0000000000..d93c0446b6 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10425.txt @@ -0,0 +1,3 @@ +http://ar.wikipedia.org/wiki/الصفحة_الرئيسية +[url]http://ar.wikipedia.org/wiki/الصفحة_الرئيسية[/url] +[url=http://ar.wikipedia.org/wiki/الصفحة_الرئيسية]link[/url] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10587.html b/tests/text_processing/tickets_data/PHPBB3-10587.html new file mode 100644 index 0000000000..dd0a483244 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10587.html @@ -0,0 +1,2 @@ +http://www.tx-gaming.net/warzone/tournament.php?tourney[id]=34&action=brackets
          +link \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10587.txt b/tests/text_processing/tickets_data/PHPBB3-10587.txt new file mode 100644 index 0000000000..f81a35eb5f --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10587.txt @@ -0,0 +1,2 @@ +[url]http://www.tx-gaming.net/warzone/tournament.php?tourney[id]=34&action=brackets[/url] +[url="http://www.tx-gaming.net/warzone/tournament.php?tourney[id]=34&action=brackets"]link[/url] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.html b/tests/text_processing/tickets_data/PHPBB3-10922.html new file mode 100644 index 0000000000..cdf8316df0 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10922.html @@ -0,0 +1 @@ +user@example.org... \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.txt b/tests/text_processing/tickets_data/PHPBB3-10922.txt new file mode 100644 index 0000000000..348f8a1541 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10922.txt @@ -0,0 +1 @@ +[email]user@example.org[/email][email=user@example.org]...[/email] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10989.html b/tests/text_processing/tickets_data/PHPBB3-10989.html new file mode 100644 index 0000000000..f003ad3dfa --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10989.html @@ -0,0 +1,8 @@ +
          Lorem wrote:[quote="Lorem"
          Suspendisse iaculis porta tempor. Nulla.
          + Nullam a tortor sit amet.
          + Proin ac mi eget magna. + +
          Lorem wrote:Quisque fermentum tortor quis odio scelerisque consequat fermentum urna gravida. In semper vehicula condimentum. Donec suscipit ante imperdiet augue rhoncus.
          + +
          +Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas quis odio orci, sit amet semper. \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10989.txt b/tests/text_processing/tickets_data/PHPBB3-10989.txt new file mode 100644 index 0000000000..dc2430f210 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10989.txt @@ -0,0 +1,8 @@ +[quote="Lorem"][quote="Lorem"[quote] Suspendisse iaculis porta tempor. Nulla.[/quote] + Nullam a tortor sit amet.[/quote] + Proin ac mi eget magna. + +[quote="Lorem"]Quisque fermentum tortor quis odio scelerisque consequat fermentum urna gravida. In semper vehicula condimentum. Donec suscipit ante imperdiet augue rhoncus.[/quote] + + +Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas quis odio orci, sit amet semper. \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-11153.html b/tests/text_processing/tickets_data/PHPBB3-11153.html new file mode 100644 index 0000000000..0f67ac4bc0 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-11153.html @@ -0,0 +1 @@ +... \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-11153.txt b/tests/text_processing/tickets_data/PHPBB3-11153.txt new file mode 100644 index 0000000000..d2794978d9 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-11153.txt @@ -0,0 +1 @@ +[myemail=user@example.org]...[/myemail] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-11153.xml b/tests/text_processing/tickets_data/PHPBB3-11153.xml new file mode 100644 index 0000000000..a7fc69520b --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-11153.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + myemail + + 1 + [myemail={EMAIL}]{TEXT}[/myemail] + {TEXT}]]> + + bbcode_specialchars('${1}').':$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', ''', '(', ')'), trim('${2}')).'[/myemail:$uid]']]> + + ${2}]]> + +
          +
          diff --git a/tests/text_processing/tickets_data/PHPBB3-12195.html b/tests/text_processing/tickets_data/PHPBB3-12195.html new file mode 100644 index 0000000000..d8e0f8d523 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-12195.html @@ -0,0 +1 @@ +Image \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-12195.txt b/tests/text_processing/tickets_data/PHPBB3-12195.txt new file mode 100644 index 0000000000..b66dbd5d96 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-12195.txt @@ -0,0 +1 @@ +[url=//example.org/][img]//example.org/img.png[/img][/url] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-3981.before.php b/tests/text_processing/tickets_data/PHPBB3-3981.before.php new file mode 100644 index 0000000000..20c96d163c --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-3981.before.php @@ -0,0 +1,17 @@ +markTestSkipped('International URLs need idn_to_ascii()'); + } +} diff --git a/tests/text_processing/tickets_data/PHPBB3-3981.html b/tests/text_processing/tickets_data/PHPBB3-3981.html new file mode 100644 index 0000000000..e5f1b4561d --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-3981.html @@ -0,0 +1 @@ +http://www.ööö.com \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-3981.txt b/tests/text_processing/tickets_data/PHPBB3-3981.txt new file mode 100644 index 0000000000..976823f1d1 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-3981.txt @@ -0,0 +1 @@ +[url]http://www.ööö.com[/url] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-7187.html b/tests/text_processing/tickets_data/PHPBB3-7187.html new file mode 100644 index 0000000000..9138779d29 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-7187.html @@ -0,0 +1 @@ +
          :geek: :ugeek:
          \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-7187.txt b/tests/text_processing/tickets_data/PHPBB3-7187.txt new file mode 100644 index 0000000000..584151a083 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-7187.txt @@ -0,0 +1 @@ +[quote]:geek: :ugeek:[/quote] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-7187.xml b/tests/text_processing/tickets_data/PHPBB3-7187.xml new file mode 100644 index 0000000000..d270b12619 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-7187.xml @@ -0,0 +1,33 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 41 + :geek: + Geek + icon_e_geek.gif + 17 + 17 + 41 + 1 + + + 42 + :ugeek: + Uber Geek + icon_e_ugeek.gif + 17 + 18 + 42 + 1 + +
          +
          diff --git a/tests/text_processing/tickets_data/PHPBB3-7275.after.php b/tests/text_processing/tickets_data/PHPBB3-7275.after.php new file mode 100644 index 0000000000..a824cb9b84 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-7275.after.php @@ -0,0 +1,15 @@ +assertSame($original, $parsed_text); +} diff --git a/tests/text_processing/tickets_data/PHPBB3-7275.html b/tests/text_processing/tickets_data/PHPBB3-7275.html new file mode 100644 index 0000000000..12502833fd --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-7275.html @@ -0,0 +1 @@ +
          :)
          \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-7275.txt b/tests/text_processing/tickets_data/PHPBB3-7275.txt new file mode 100644 index 0000000000..8de97d67e0 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-7275.txt @@ -0,0 +1 @@ +[center]:)[/center] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-7275.xml b/tests/text_processing/tickets_data/PHPBB3-7275.xml new file mode 100644 index 0000000000..9e979afffb --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-7275.xml @@ -0,0 +1,49 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + center + + 1 + [center]{TEXT}[/center] + {TEXT}]]> + !\[center\](.*?)\[/center\]!ies + + !\[center:$uid\](.*?)\[/center:$uid\]!s + ${1}]]> + +
          + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 4 + :) + Smile + icon_e_smile.gif + 15 + 17 + 4 + 1 + +
          +
          diff --git a/tests/text_processing/tickets_data/PHPBB3-9377.html b/tests/text_processing/tickets_data/PHPBB3-9377.html new file mode 100644 index 0000000000..dcfb79c173 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-9377.html @@ -0,0 +1 @@ +red blue red \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-9377.txt b/tests/text_processing/tickets_data/PHPBB3-9377.txt new file mode 100644 index 0000000000..dfd71492c5 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-9377.txt @@ -0,0 +1 @@ +[red]red [blue]blue[/blue] red[/red] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-9377.xml b/tests/text_processing/tickets_data/PHPBB3-9377.xml new file mode 100644 index 0000000000..1d8ee3d53f --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-9377.xml @@ -0,0 +1,41 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + red + + 1 + [red]{TEXT}[/red] + <span style="color:red">{TEXT}</span> + !\[red\](.*?)\[/red\]!ies + '[red:$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', '&#39;', '&#40;', '&#41;'), trim('${1}')).'[/red:$uid]' + !\[red:$uid\](.*?)\[/red:$uid\]!s + <span style="color:red">${1}</span> + + + + 14 + blue + + 1 + [blue]{TEXT}[/blue] + <span style="color:blue">{TEXT}</span> + !\[blue\](.*?)\[/blue\]!ies + '[blue:$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', '&#39;', '&#40;', '&#41;'), trim('${1}')).'[/blue:$uid]' + !\[blue:$uid\](.*?)\[/blue:$uid\]!s + <span style="color:blue">${1}</span> + +
          +
          diff --git a/tests/text_processing/tickets_test.php b/tests/text_processing/tickets_test.php new file mode 100644 index 0000000000..d2072a10f5 --- /dev/null +++ b/tests/text_processing/tickets_test.php @@ -0,0 +1,91 @@ +get_test_case_helpers()->set_s9e_services($phpbb_container, $fixture); + + $parser = $phpbb_container->get('text_formatter.parser'); + $renderer = $phpbb_container->get('text_formatter.renderer'); + + if (isset($before_assert)) + { + $test = $this; + $before_assert(get_defined_vars()); + } + + $parsed_text = $parser->parse($original); + + $this->assertSame($expected, $renderer->render($parsed_text)); + + if (isset($after_assert)) + { + $test = $this; + $after_assert(get_defined_vars()); + } + } + + public function get_tickets_data() + { + $tests = array(); + + foreach (glob(__DIR__ . '/tickets_data/*.txt') as $txt_filename) + { + $ticket_id = basename($txt_filename, '.txt'); + $html_filename = substr($txt_filename, 0, -3) . 'html'; + $xml_filename = substr($txt_filename, 0, -3) . 'xml'; + $before_filename = substr($txt_filename, 0, -3) . 'before.php'; + $after_filename = substr($txt_filename, 0, -3) . 'after.php'; + + if (!file_exists($xml_filename)) + { + $xml_filename = __DIR__ . '/../fixtures/empty.xml'; + } + + $before_assert = null; + if (file_exists($before_filename)) + { + include($before_filename); + $before_assert = 'before_assert_' . strtolower(str_replace('-', '_', $ticket_id)); + } + + $after_assert = null; + if (file_exists($after_filename)) + { + include($after_filename); + $after_assert = 'after_assert_' . strtolower(str_replace('-', '_', $ticket_id)); + } + + $tests[] = array( + $ticket_id, + file_get_contents($txt_filename), + file_get_contents($html_filename), + $xml_filename, + $before_assert, + $after_assert + ); + } + + return $tests; + } +} -- cgit v1.2.1 From c4a58bce890869f3d44d145cd43cb036ad99ac74 Mon Sep 17 00:00:00 2001 From: s9e Date: Wed, 4 Feb 2015 23:27:04 +0100 Subject: [ticket/11768] Updated test case helper with new signature PHPBB3-11768 --- tests/test_framework/phpbb_test_case_helpers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index d0b1573e61..3423d83bb1 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -472,7 +472,7 @@ class phpbb_test_case_helpers $cache, $cache_key_parser, $user, - $container + $factory ); $container->set('text_formatter.parser', $parser); @@ -483,7 +483,7 @@ class phpbb_test_case_helpers $cache, $cache_dir, $cache_key_renderer, - $container + $factory ); $root_path = ($container->hasParameter('core.root_path')) -- cgit v1.2.1 From 90d1a431bde5aaed1e925c3124d081576c759376 Mon Sep 17 00:00:00 2001 From: s9e Date: Thu, 5 Feb 2015 00:01:10 +0100 Subject: [ticket/11768] Updated tests to use the new constructor signature PHPBB3-11768 --- tests/text_formatter/s9e/parser_test.php | 29 +++++++++++++++++++++-------- tests/text_formatter/s9e/renderer_test.php | 17 +++++++++-------- 2 files changed, 30 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 528305a11c..aee906e213 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -24,11 +24,16 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case ->with('_foo_parser') ->will($this->returnValue($mock)); + $factory = $this->getMockBuilder('phpbb\\textformatter\\s9e\\factory') + ->disableOriginalConstructor() + ->getMock(); + $factory->expects($this->never())->method('regenerate'); + $parser = new \phpbb\textformatter\s9e\parser( $cache, '_foo_parser', $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), - new phpbb_mock_container_builder + $factory ); } @@ -46,11 +51,16 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $cache = new phpbb_mock_cache; $cache->put('_foo_parser', $mock); + $factory = $this->getMockBuilder('phpbb\\textformatter\\s9e\\factory') + ->disableOriginalConstructor() + ->getMock(); + $factory->expects($this->never())->method('regenerate'); + $parser = new \phpbb\textformatter\s9e\parser( $cache, '_foo_parser', $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), - new phpbb_mock_container_builder + $factory ); $this->assertSame('test', $parser->parse('test')); @@ -67,19 +77,18 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case ->with('test') ->will($this->returnValue('test')); - $factory = $this->getMock('stdClass', array('regenerate')); + $factory = $this->getMockBuilder('phpbb\\textformatter\\s9e\\factory') + ->disableOriginalConstructor() + ->getMock(); $factory->expects($this->once()) ->method('regenerate') ->will($this->returnValue(array($mock, false))); - $container = new phpbb_mock_container_builder; - $container->set('text_formatter.s9e.factory', $factory); - $parser = new \phpbb\textformatter\s9e\parser( new phpbb_mock_cache, '_foo_parser', $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), - $container + $factory ); $this->assertSame('test', $parser->parse('test')); @@ -104,11 +113,15 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $cache = new phpbb_mock_cache; $cache->put('_foo_parser', $mock); + $factory = $this->getMockBuilder('phpbb\\textformatter\\s9e\\factory') + ->disableOriginalConstructor() + ->getMock(); + $parser = new \phpbb\textformatter\s9e\parser( $cache, '_foo_parser', $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), - new phpbb_mock_container_builder + $factory ); call_user_func_array(array($parser, $adapter_method), (array) $adapter_arg); diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 76babbfdf3..977c165177 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -33,14 +33,16 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ->with('_foo_renderer') ->will($this->returnValue(array('class' => 'renderer_foo', 'renderer' => serialize($mock)))); - $container = new phpbb_mock_container_builder; - $container->set('text_formatter.s9e.factory', $factory); + $factory = $this->getMockBuilder('phpbb\\textformatter\\s9e\\factory') + ->disableOriginalConstructor() + ->getMock(); + $factory->expects($this->never())->method('regenerate'); $renderer = new \phpbb\textformatter\s9e\renderer( $cache, $this->get_cache_dir(), '_foo_renderer', - $container + $factory ); } @@ -54,19 +56,18 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ->with('_foo_renderer') ->will($this->returnValue(false)); - $factory = $this->getMock('stdClass', array('regenerate')); + $factory = $this->getMockBuilder('phpbb\\textformatter\\s9e\\factory') + ->disableOriginalConstructor() + ->getMock(); $factory->expects($this->once()) ->method('regenerate') ->will($this->returnValue(array($mock, false))); - $container = new phpbb_mock_container_builder; - $container->set('text_formatter.s9e.factory', $factory); - $renderer = new \phpbb\textformatter\s9e\renderer( $cache, $this->get_cache_dir(), '_foo_renderer', - $container + $factory ); } -- cgit v1.2.1 From 6540918ffa3d7203da1f55dc2d08674b378663f3 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 10 Feb 2015 02:24:06 +0100 Subject: [ticket/11768] Added test files PHPBB3-11768 --- tests/text_processing/tickets_data/PHPBB3-10122.html | 1 + tests/text_processing/tickets_data/PHPBB3-10122.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-10122.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-10122.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-10122.html b/tests/text_processing/tickets_data/PHPBB3-10122.html new file mode 100644 index 0000000000..f0fb6115b2 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10122.html @@ -0,0 +1 @@ +
          • This is my indented text
          \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10122.txt b/tests/text_processing/tickets_data/PHPBB3-10122.txt new file mode 100644 index 0000000000..a5e059df66 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10122.txt @@ -0,0 +1 @@ +[list=none][*]This is my indented text[/list] \ No newline at end of file -- cgit v1.2.1 From 63753bbf1a7a695938c7196fb7c1d9318d7a7375 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 13 Feb 2015 11:17:44 +0100 Subject: [ticket/11768] Uncommented disabled test PHPBB3-11768 --- tests/text_formatter/s9e/default_formatting_test.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index be258868dd..a7d3235c12 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -184,13 +184,11 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '[code]unparsed code [quote="username"]quoted[/quote][/code]', '

          CODE: Select all

          unparsed code [quote="username"]quoted[/quote]
          ' ), -/* array( // Textual bbcode nesting into textual bbcode '[b]bold [i]bold + italic[/b] italic[/i]', 'bold bold + italic italic' ), -*/ array( "[code]\tline1\n line2[/code]", '

          CODE: Select all

             line1
          ' . "\n" . '  line2
          ' -- cgit v1.2.1 From f6e3e41717e71fb43ea63785cfe7980e33be3fbf Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 13 Feb 2015 11:28:51 +0100 Subject: [ticket/11768] Added support for magic links that start with "www." PHPBB3-11768 --- tests/text_formatter/s9e/default_formatting_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index a7d3235c12..99a89a8d2e 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -193,6 +193,14 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case "[code]\tline1\n line2[/code]", '

          CODE: Select all

             line1
          ' . "\n" . '  line2
          ' ), + array( + '... http://example.org ...', + '... http://example.org ...' + ), + array( + '... www.example.org ...', + '... www.example.org ...' + ), ); } } -- cgit v1.2.1 From 6bd86a8e8a7c8e2ccf90d02343132c085978cd44 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 15 Feb 2015 03:08:36 +0100 Subject: [ticket/11768] Updated phpbb\textformatter\s9e\factory::regenerate() Returns an associative array rather than a numerically-indexed array. Feels cleaner and more extensible. PHPBB3-11768 --- tests/text_formatter/s9e/factory_test.php | 4 ++-- tests/text_formatter/s9e/parser_test.php | 2 +- tests/text_formatter/s9e/renderer_test.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 2ea4b3031b..9542da8d9a 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -84,7 +84,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case public function test_regenerate() { - list($parser, $renderer) = $this->get_factory()->regenerate(); + extract($this->get_factory()->regenerate()); $this->assertInstanceOf('s9e\\TextFormatter\\Parser', $parser); $this->assertInstanceOf('s9e\\TextFormatter\\Renderer', $renderer); @@ -113,7 +113,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case touch($old_file); // Create a current renderer - list($parser, $renderer) = $factory->regenerate(); + extract($factory->regenerate()); $new_file = $this->get_cache_dir() . get_class($renderer) . '.php'; // Tidy the cache diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index aee906e213..f422e5425a 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -82,7 +82,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case ->getMock(); $factory->expects($this->once()) ->method('regenerate') - ->will($this->returnValue(array($mock, false))); + ->will($this->returnValue(array('parser' => $mock))); $parser = new \phpbb\textformatter\s9e\parser( new phpbb_mock_cache, diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 977c165177..464bcf8eed 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -61,7 +61,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ->getMock(); $factory->expects($this->once()) ->method('regenerate') - ->will($this->returnValue(array($mock, false))); + ->will($this->returnValue(array('parser' => $mock))); $renderer = new \phpbb\textformatter\s9e\renderer( $cache, -- cgit v1.2.1 From 6578e1c6ec7172016fbfa375dd2fce5cb20f3ce1 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 17 Feb 2015 09:18:31 +0100 Subject: [ticket/11768] Added limited support for [url] in [quote] author PHPBB3-11768 --- tests/text_formatter/s9e/default_formatting_test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 99a89a8d2e..b28c8b157e 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -201,6 +201,18 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '... www.example.org ...', '... www.example.org ...' ), + array( + '[quote="[url=http://example.org]xxx[/url]"]...[/quote]', + '
          xxx wrote:...
          ' + ), + array( + '[quote="[url]http://example.org[/url]"]...[/quote]', + '
          ' + ), + array( + '[quote="http://example.org"]...[/quote]', + '
          ' + ), ); } } -- cgit v1.2.1 From f721b85a7835c18459b310e4db74cc0f654b05ec Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 19 Feb 2015 06:05:39 +0100 Subject: [ticket/11768] Replaced the Censor plugin ...with something that is run at rendering time. PHPBB3-11768 --- tests/text_formatter/s9e/parser_test.php | 8 -------- tests/text_formatter/s9e/renderer_test.php | 12 ++++++------ 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index f422e5425a..09af6c22ad 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -138,10 +138,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case 'disable_bbcodes', null, 'disablePlugin', 'BBCodes' ), - array( - 'disable_censor', null, - 'disablePlugin', 'Censor' - ), array( 'disable_magic_url', null, 'disablePlugin', array('Autoemail', 'Autolink') @@ -158,10 +154,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case 'enable_bbcodes', null, 'enablePlugin', 'BBCodes' ), - array( - 'enable_censor', null, - 'enablePlugin', 'Censor' - ), array( 'enable_magic_url', null, 'enablePlugin', array('Autoemail', 'Autolink') diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 464bcf8eed..fbf17c8f68 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -93,12 +93,12 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case { return array( array( - 'apple', + 'apple', 'banana', array('set_viewcensors' => true) ), array( - 'apple', + 'apple', 'apple', array('set_viewcensors' => false) ), @@ -146,11 +146,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case { return array( array( - 'apple', + 'apple', 'banana' ), array( - 'apple', + 'apple', 'banana', function ($phpbb_container) { @@ -161,7 +161,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case } ), array( - 'apple', + 'apple', 'banana', function ($phpbb_container) { @@ -175,7 +175,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case } ), array( - 'apple', + 'apple', 'apple', function ($phpbb_container, $test) { -- cgit v1.2.1 From 93c53ed52da7ec2e26bf97b3cc5bba1f1ca403bb Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 19 Feb 2015 06:31:56 +0100 Subject: [ticket/11768] Fixed test PHPBB3-11768 --- tests/text_formatter/s9e/factory_test.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 9542da8d9a..7c26443579 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -89,15 +89,11 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $this->assertInstanceOf('s9e\\TextFormatter\\Parser', $parser); $this->assertInstanceOf('s9e\\TextFormatter\\Renderer', $renderer); + $renderer_data = $this->cache->get('_foo_renderer'); $this->assertEquals($parser, $this->cache->get('_foo_parser'), 'The parser was not cached'); - $this->assertEquals( - array( - 'class' => get_class($renderer), - 'renderer' => serialize($renderer) - ), - $this->cache->get('_foo_renderer'), - 'The renderer was not cached' - ); + $this->assertEquals(get_class($renderer), $renderer_data['class']); + $this->assertEquals(serialize($renderer), $renderer_data['renderer']); + $this->assertInstanceOf('s9e\\TextFormatter\\Plugins\\Censor\\Helper', $renderer_data['censor']); $file = $this->get_cache_dir() . get_class($renderer) . '.php'; $this->assertFileExists($file); -- cgit v1.2.1 From 3e5ee87b15c70fbfc246b6d8f6d18a186d11d83a Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 20 Feb 2015 06:03:05 +0100 Subject: [ticket/11768] Allowed text in places where text is not valid HTML PHPBB3-11768 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index b28c8b157e..94d46a58b7 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -68,7 +68,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( '[list]no item[/list]', - '
            ' + '
              no item
            ' ), array( '[*]unparsed', -- cgit v1.2.1 From c1ba3a678d5a565b74d893c57eb5133623702350 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 23 Feb 2015 19:03:41 +0100 Subject: [ticket/11768] Added methods to access the library's parser/renderer PHPBB3-11768 --- tests/text_formatter/s9e/parser_test.php | 8 ++++++++ tests/text_formatter/s9e/renderer_test.php | 7 +++++++ 2 files changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 09af6c22ad..a3c86e8350 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -7,6 +7,7 @@ * */ require_once __DIR__ . '/../../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; require_once __DIR__ . '/../../mock/user.php'; require_once __DIR__ . '/../../mock/cache.php'; @@ -164,4 +165,11 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case ) ); } + + public function test_get_parser() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $parser = $container->get('text_formatter.parser'); + $this->assertInstanceOf('s9e\\TextFormatter\\Parser', $parser->get_parser()); + } } diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index fbf17c8f68..486b17d03f 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -353,4 +353,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ); } } + + public function test_get_renderer() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $renderer = $container->get('text_formatter.renderer'); + $this->assertInstanceOf('s9e\\TextFormatter\\Renderer', $renderer->get_renderer()); + } } -- cgit v1.2.1 From b12043d4b076b1e214fd85da28358ba829d47a76 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 3 Mar 2015 00:43:46 +0100 Subject: [ticket/11768] Renamed get_words() to get_censored_words() PHPBB3-11768 --- tests/test_framework/phpbb_test_case_helpers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 3423d83bb1..8e49dca40c 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -394,7 +394,7 @@ class phpbb_test_case_helpers // Mock the DAL, make it return data from the fixture $mb = $this->test_case->getMockBuilder('phpbb\\textformatter\\data_access'); - $mb->setMethods(array('get_bbcodes', 'get_smilies', 'get_styles', 'get_words')); + $mb->setMethods(array('get_bbcodes', 'get_censored_words', 'get_smilies', 'get_styles')); $mb->setConstructorArgs(array( $this->test_case->getMock('phpbb\\db\\driver\\driver'), 'phpbb_bbcodes', @@ -417,7 +417,7 @@ class phpbb_test_case_helpers ->method('get_styles') ->will($this->test_case->returnValue($tables['phpbb_styles'])); $dal->expects($this->test_case->any()) - ->method('get_words') + ->method('get_censored_words') ->will($this->test_case->returnValue($tables['phpbb_words'])); // Cache the parser and renderer with a key based on this method's arguments -- cgit v1.2.1 From 0dd5e62382047f9e256eb148ab199c04a05914b2 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 3 Mar 2015 01:10:58 +0100 Subject: [ticket/11768] Replaced headers in test files PHPBB3-11768 --- tests/text_formatter/s9e/default_formatting_test.php | 10 +++++++--- tests/text_formatter/s9e/factory_test.php | 10 +++++++--- tests/text_formatter/s9e/parser_test.php | 10 +++++++--- tests/text_formatter/s9e/renderer_test.php | 10 +++++++--- tests/text_formatter/s9e/utils_test.php | 10 +++++++--- tests/text_processing/generate_text_for_edit_test.php | 10 +++++++--- tests/text_processing/generate_text_for_storage_test.php | 10 +++++++--- tests/text_processing/smilies_test.php | 10 +++++++--- tests/text_processing/tickets_data/PHPBB3-3981.before.php | 10 +++++++--- tests/text_processing/tickets_data/PHPBB3-7275.after.php | 10 +++++++--- tests/text_processing/tickets_test.php | 10 +++++++--- 11 files changed, 77 insertions(+), 33 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 94d46a58b7..79232562cf 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ require_once __DIR__ . '/../../../phpBB/includes/functions.php'; diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 7c26443579..2930826a78 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ require_once __DIR__ . '/../../../phpBB/includes/functions.php'; diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index a3c86e8350..4b1a23e254 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ require_once __DIR__ . '/../../../phpBB/includes/functions.php'; diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 486b17d03f..aa0b036c87 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ require_once __DIR__ . '/../../../phpBB/includes/functions.php'; diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 510beba817..3de9b707c5 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/text_processing/generate_text_for_edit_test.php b/tests/text_processing/generate_text_for_edit_test.php index 85b3a6a0ab..d1db1c6ce1 100644 --- a/tests/text_processing/generate_text_for_edit_test.php +++ b/tests/text_processing/generate_text_for_edit_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/text_processing/generate_text_for_storage_test.php b/tests/text_processing/generate_text_for_storage_test.php index 0bacaacfb8..2a33e2e7be 100644 --- a/tests/text_processing/generate_text_for_storage_test.php +++ b/tests/text_processing/generate_text_for_storage_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/text_processing/smilies_test.php b/tests/text_processing/smilies_test.php index cd35c25525..3bbe065d36 100644 --- a/tests/text_processing/smilies_test.php +++ b/tests/text_processing/smilies_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/text_processing/tickets_data/PHPBB3-3981.before.php b/tests/text_processing/tickets_data/PHPBB3-3981.before.php index 20c96d163c..1c326b52af 100644 --- a/tests/text_processing/tickets_data/PHPBB3-3981.before.php +++ b/tests/text_processing/tickets_data/PHPBB3-3981.before.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/text_processing/tickets_data/PHPBB3-7275.after.php b/tests/text_processing/tickets_data/PHPBB3-7275.after.php index a824cb9b84..99f41d7839 100644 --- a/tests/text_processing/tickets_data/PHPBB3-7275.after.php +++ b/tests/text_processing/tickets_data/PHPBB3-7275.after.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/text_processing/tickets_test.php b/tests/text_processing/tickets_test.php index d2072a10f5..1f7aa58ebb 100644 --- a/tests/text_processing/tickets_test.php +++ b/tests/text_processing/tickets_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1 From ed29972e76d4dfd9a670582421c8dff0f470411e Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 3 Mar 2015 01:28:48 +0100 Subject: [ticket/11768] Removed require_once calls that target mock classes PHPBB3-11768 --- tests/text_formatter/s9e/factory_test.php | 2 -- tests/text_formatter/s9e/parser_test.php | 2 -- tests/text_formatter/s9e/renderer_test.php | 1 - tests/text_processing/generate_text_for_edit_test.php | 2 -- tests/text_processing/generate_text_for_storage_test.php | 1 - tests/text_processing/tickets_test.php | 1 - 6 files changed, 9 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 2930826a78..d78765b7d5 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -12,8 +12,6 @@ */ require_once __DIR__ . '/../../../phpBB/includes/functions.php'; require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../../mock/user.php'; -require_once __DIR__ . '/../../mock/cache.php'; require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 4b1a23e254..725ff42bfd 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -12,8 +12,6 @@ */ require_once __DIR__ . '/../../../phpBB/includes/functions.php'; require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../../mock/user.php'; -require_once __DIR__ . '/../../mock/cache.php'; class phpbb_textformatter_s9e_parser_test extends phpbb_test_case { diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index aa0b036c87..17d358c3ce 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -12,7 +12,6 @@ */ require_once __DIR__ . '/../../../phpBB/includes/functions.php'; require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../../mock/cache.php'; class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case { diff --git a/tests/text_processing/generate_text_for_edit_test.php b/tests/text_processing/generate_text_for_edit_test.php index d1db1c6ce1..105e8da86b 100644 --- a/tests/text_processing/generate_text_for_edit_test.php +++ b/tests/text_processing/generate_text_for_edit_test.php @@ -13,8 +13,6 @@ require_once __DIR__ . '/../../phpBB/includes/functions.php'; require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../mock/user.php'; -require_once __DIR__ . '/../mock/cache.php'; class phpbb_text_processing_generate_text_for_edit_test extends phpbb_test_case { diff --git a/tests/text_processing/generate_text_for_storage_test.php b/tests/text_processing/generate_text_for_storage_test.php index 2a33e2e7be..ffa06e4e02 100644 --- a/tests/text_processing/generate_text_for_storage_test.php +++ b/tests/text_processing/generate_text_for_storage_test.php @@ -14,7 +14,6 @@ require_once __DIR__ . '/../../phpBB/includes/functions.php'; require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; -require_once __DIR__ . '/../mock/container_builder.php'; class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_case { diff --git a/tests/text_processing/tickets_test.php b/tests/text_processing/tickets_test.php index 1f7aa58ebb..8c48a3f4a9 100644 --- a/tests/text_processing/tickets_test.php +++ b/tests/text_processing/tickets_test.php @@ -14,7 +14,6 @@ require_once __DIR__ . '/../../phpBB/includes/functions.php'; require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; -require_once __DIR__ . '/../mock/container_builder.php'; class phpbb_text_processing_tickets_test extends phpbb_test_case { -- cgit v1.2.1 From 462696aa4787112b67b2ea8febf6a9f40a461baa Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 3 Mar 2015 01:42:54 +0100 Subject: [ticket/11768] Replaced headers in test files PHPBB3-11768 --- tests/text_processing/decode_message_test.php | 10 +++++++--- tests/text_processing/message_parser_test.php | 10 +++++++--- tests/text_processing/strip_bbcode_test.php | 10 +++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/text_processing/decode_message_test.php b/tests/text_processing/decode_message_test.php index 855b3c6c57..c9c1da52d5 100644 --- a/tests/text_processing/decode_message_test.php +++ b/tests/text_processing/decode_message_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/text_processing/message_parser_test.php b/tests/text_processing/message_parser_test.php index 59af2553f8..cdbd6c0ca7 100644 --- a/tests/text_processing/message_parser_test.php +++ b/tests/text_processing/message_parser_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/text_processing/strip_bbcode_test.php b/tests/text_processing/strip_bbcode_test.php index d0dda89167..827d8d4a52 100644 --- a/tests/text_processing/strip_bbcode_test.php +++ b/tests/text_processing/strip_bbcode_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1 From d37f2d10f02b6a7a2b12e4b21284df310f39d3e6 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 3 Mar 2015 02:14:09 +0100 Subject: [ticket/11768] Removed the cached renderer We don't need to cache an instance of the renderer, we can just instantiate it every time we need one. PHPBB3-11768 --- tests/text_formatter/s9e/factory_test.php | 1 - tests/text_formatter/s9e/renderer_test.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index d78765b7d5..a1378514b4 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -94,7 +94,6 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $renderer_data = $this->cache->get('_foo_renderer'); $this->assertEquals($parser, $this->cache->get('_foo_parser'), 'The parser was not cached'); $this->assertEquals(get_class($renderer), $renderer_data['class']); - $this->assertEquals(serialize($renderer), $renderer_data['renderer']); $this->assertInstanceOf('s9e\\TextFormatter\\Plugins\\Censor\\Helper', $renderer_data['censor']); $file = $this->get_cache_dir() . get_class($renderer) . '.php'; diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 17d358c3ce..248b38206a 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -34,7 +34,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $cache->expects($this->once()) ->method('get') ->with('_foo_renderer') - ->will($this->returnValue(array('class' => 'renderer_foo', 'renderer' => serialize($mock)))); + ->will($this->returnValue(array('class' => 'renderer_foo'))); $factory = $this->getMockBuilder('phpbb\\textformatter\\s9e\\factory') ->disableOriginalConstructor() -- cgit v1.2.1 From 5fe8c6b6f5080c7e174882d279beb2b84ddd01ab Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 3 Mar 2015 02:24:51 +0100 Subject: [ticket/11768] Removed unused var PHPBB3-11768 --- tests/text_formatter/s9e/renderer_test.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 248b38206a..b93fd8bbe6 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -28,8 +28,6 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case 'getMockForAbstractClass('s9e\\TextFormatter\\Renderer'); - $cache = $this->getMock('phpbb_mock_cache'); $cache->expects($this->once()) ->method('get') -- cgit v1.2.1 From 78b544920c0d3984dd814cfe59f43c46feac6f12 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 3 Mar 2015 04:18:17 +0100 Subject: [ticket/11768] Added support for creating unsafe BBCodes PHPBB3-11768 --- tests/text_formatter/s9e/factory_test.php | 18 +++++++++++--- .../text_formatter/s9e/fixtures/unsafe_bbcode.xml | 28 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 tests/text_formatter/s9e/fixtures/unsafe_bbcode.xml (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index a1378514b4..8df841605d 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -78,9 +78,6 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case // This custom BBCode should be set $this->assertTrue(isset($configurator->BBCodes['CUSTOM'])); - // This unsafe custom BBCode will trigger an exception and should be ignored - $this->assertFalse(isset($configurator->BBCodes['UNSAFE'])); - $this->assertTrue(isset($configurator->Emoticons[':D'])); } @@ -176,4 +173,19 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $expected = $original; $this->assertSame($expected, $renderer->render($parser->parse($original))); } + + /** + * @testdox Accepts unsafe custom BBCodes + */ + public function test_unsafe_bbcode() + { + $fixture = __DIR__ . '/fixtures/unsafe_bbcode.xml'; + $container = $this->get_test_case_helpers()->set_s9e_services(null, $fixture); + $parser = $container->get('text_formatter.parser'); + $renderer = $container->get('text_formatter.renderer'); + + $original = '[xss=javascript:alert(1)]text[/xss]'; + $expected = 'text'; + $this->assertSame($expected, $renderer->render($parser->parse($original))); + } } diff --git a/tests/text_formatter/s9e/fixtures/unsafe_bbcode.xml b/tests/text_formatter/s9e/fixtures/unsafe_bbcode.xml new file mode 100644 index 0000000000..55a2e689b6 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/unsafe_bbcode.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + xss= + + 1 + [xss={TEXT1}]{TEXT2}[/xss] + {TEXT2}]]> + + + + ${2}]]> + +
            +
            -- cgit v1.2.1 From 1b4bdff3b3d01cd422f7a49a1de14b3edbd76804 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 6 Mar 2015 13:00:03 +0100 Subject: [ticket/11768] Fixed test double PHPBB3-11768 --- tests/text_processing/message_parser_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_processing/message_parser_test.php b/tests/text_processing/message_parser_test.php index cdbd6c0ca7..691c0d5b8a 100644 --- a/tests/text_processing/message_parser_test.php +++ b/tests/text_processing/message_parser_test.php @@ -53,6 +53,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case array('UNAUTHORISED_BBCODE', '[img]', 'You cannot use certain BBCodes: [img].'), array('UNAUTHORISED_BBCODE', '[quote]', 'You cannot use certain BBCodes: [quote].'), array('UNAUTHORISED_BBCODE', '[url]', 'You cannot use certain BBCodes: [url].'), + array('UNABLE_GET_IMAGE_SIZE', 'It was not possible to determine the dimensions of the image.'), ); $user = $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(); @@ -67,7 +68,6 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case 'TOO_FEW_POLL_OPTIONS' => 'You must enter at least two poll options.', 'TOO_MANY_POLL_OPTIONS' => 'You have tried to enter too many poll options.', 'TOO_MANY_USER_OPTIONS' => 'You cannot specify more options per user than existing poll options.', - 'UNABLE_GET_IMAGE_SIZE' => 'It was not possible to determine the dimensions of the image.' ); $phpbb_container = new phpbb_mock_container_builder; -- cgit v1.2.1 From b021225148d8ba14e106dd24a25128e3be36992a Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 6 Mar 2015 13:11:33 +0100 Subject: [ticket/11768] Removed unused var PHPBB3-11768 --- tests/test_framework/phpbb_test_case_helpers.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 8e49dca40c..e584c238a2 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -486,9 +486,6 @@ class phpbb_test_case_helpers $factory ); - $root_path = ($container->hasParameter('core.root_path')) - ? $container->getParameter('core.root_path') - : './'; $config = ($container->has('config')) ? $container->get('config') : new \phpbb\config\config(array('smilies_path' => 'images/smilies', 'allow_nocensors' => false)); -- cgit v1.2.1 From f4f5bdbaee48d0ed341ec9b720579a4f751916fc Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 19 Mar 2015 11:38:44 +0100 Subject: [ticket/11768] Removed whitespace No functional change intended PHPBB3-11768 --- tests/text_formatter/s9e/factory_test.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 8df841605d..7dfa512b28 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -29,9 +29,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case public function get_factory() { global $phpbb_root_path; - $this->cache = new phpbb_mock_cache; - $dal = new \phpbb\textformatter\data_access( $this->new_dbal(), 'phpbb_bbcodes', @@ -40,7 +38,6 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case 'phpbb_words', $phpbb_root_path . 'styles/' ); - $factory = new \phpbb\textformatter\s9e\factory( $dal, $this->cache, @@ -122,7 +119,6 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case public function test_local_url() { global $config, $user, $request; - $config = array( 'force_server_vars' => true, 'server_protocol' => 'http://', -- cgit v1.2.1 From 49b9e8e4eafff93f25a99bf263982fe79b7f0549 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 19 Mar 2015 12:45:12 +0100 Subject: [ticket/11768] Added configurator events PHPBB3-11768 --- tests/test_framework/phpbb_test_case_helpers.php | 18 +++++++++-- tests/text_formatter/s9e/factory_test.php | 39 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index e584c238a2..5c6da94014 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -315,7 +315,7 @@ class phpbb_test_case_helpers public function set_s9e_services(ContainerInterface $container = null, $fixture = null, $styles_path = null) { static $first_run; - global $phpbb_container, $phpbb_root_path, $phpEx; + global $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx; $cache_dir = __DIR__ . '/../tmp/'; @@ -443,8 +443,22 @@ class phpbb_test_case_helpers ); } + // Create an event dispatcher + if ($container->has('dispatcher')) + { + $dispatcher = $container->get('dispatcher'); + } + else if (isset($phpbb_dispatcher)) + { + $dispatcher = $phpbb_dispatcher; + } + else + { + $dispatcher = new phpbb_mock_event_dispatcher; + } + // Create and register the text_formatter.s9e.factory service - $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $cache_dir, $cache_key_parser, $cache_key_renderer); + $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $cache_dir, $cache_key_parser, $cache_key_renderer); $container->set('text_formatter.s9e.factory', $factory); // Create a user if none was provided, and add the common lang strings diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 7dfa512b28..9f7551ef14 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -16,6 +16,13 @@ require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case { + public function setUp() + { + $this->cache = new phpbb_mock_cache; + $this->dispatcher = new phpbb_mock_event_dispatcher; + parent::setUp(); + } + public function getDataSet() { return $this->createXMLDataSet(__DIR__ . '/fixtures/factory.xml'); @@ -41,6 +48,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $factory = new \phpbb\textformatter\s9e\factory( $dal, $this->cache, + $this->dispatcher, $this->get_cache_dir(), '_foo_parser', '_foo_renderer' @@ -184,4 +192,35 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $expected = 'text'; $this->assertSame($expected, $renderer->render($parser->parse($original))); } + + /** + * @testdox get_configurator() triggers events before and after configuration + */ + public function test_configure_events() + { + $this->dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface'); + $this->dispatcher + ->expects($this->at(0)) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_configure_before', + $this->callback(array($this, 'configure_event_callback')) + ) + ->will($this->returnArgument(1)); + $this->dispatcher + ->expects($this->at(1)) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_configure_after', + $this->callback(array($this, 'configure_event_callback')) + ) + ->will($this->returnArgument(1)); + + $this->get_factory()->get_configurator(); + } + + public function configure_event_callback($vars) + { + return isset($vars['configurator']) && $vars['configurator'] instanceof \s9e\TextFormatter\Configurator; + } } -- cgit v1.2.1 From 69dae16ba79a82714b3fa24955c5cbc6e372a388 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 21 Mar 2015 12:32:17 +0100 Subject: [ticket/11768] Preserve comments in custom BBCodes PHPBB3-11768 --- tests/text_formatter/s9e/factory_test.php | 15 ++++++++++++ .../s9e/fixtures/preserve_comments.xml | 28 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/text_formatter/s9e/fixtures/preserve_comments.xml (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 9f7551ef14..8382097544 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -178,6 +178,21 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $this->assertSame($expected, $renderer->render($parser->parse($original))); } + /** + * @testdox Preserves comments in custom BBCodes + */ + public function test_preserve_comments() + { + $fixture = __DIR__ . '/fixtures/preserve_comments.xml'; + $container = $this->get_test_case_helpers()->set_s9e_services(null, $fixture); + $parser = $container->get('text_formatter.parser'); + $renderer = $container->get('text_formatter.renderer'); + + $original = '[X]'; + $expected = ''; + $this->assertSame($expected, $renderer->render($parser->parse($original))); + } + /** * @testdox Accepts unsafe custom BBCodes */ diff --git a/tests/text_formatter/s9e/fixtures/preserve_comments.xml b/tests/text_formatter/s9e/fixtures/preserve_comments.xml new file mode 100644 index 0000000000..f81d366aad --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/preserve_comments.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + X + + 1 + [X][/X] + ]]> + + + + + +
            +
            -- cgit v1.2.1 From 37fedc656fbdeb36b098375201042eed4c7e7229 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 23 Mar 2015 21:34:49 +0100 Subject: [ticket/11768] Updated the text_formatter.s9e.utils service Made it use s9e\TextFormatter\Utils. Refactored some tests to make them more readable. PHPBB3-11768 --- tests/text_formatter/s9e/utils_test.php | 37 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 3de9b707c5..6f0ef54182 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -109,52 +109,41 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case public function test_remove_bbcode($original, $name, $depth, $expected) { $container = $this->get_test_case_helpers()->set_s9e_services(); + $parser = $container->get('text_formatter.parser'); $utils = $container->get('text_formatter.utils'); - $this->assertSame($expected, $utils->remove_bbcode($original, $name, $depth)); + $parsed = $parser->parse($original); + $actual = $utils->unparse($utils->remove_bbcode($parsed, $name, $depth)); + + $this->assertSame($expected, $actual); } public function get_remove_bbcode_tests() { return array( array( - 'Plain text', + 'Plain text', 'b', 1, - 'Plain text' + 'Plain text' ), array( - '[quote="u0"][quote="u1"][quote="u2"]q2[/quote] -q1[/quote] -q0[/quote] -[b]bold[/b]', + '[quote="u0"][quote="u1"][quote="u2"]q2[/quote]q1[/quote]q0[/quote][b]bold[/b]', 'quote', 0, - ' -[b]bold[/b]' + '[b]bold[/b]', ), array( - '[quote="u0"][quote="u1"][quote="u2"]q2[/quote] -q1[/quote] -q0[/quote] -[b]bold[/b]', + '[quote="u0"][quote="u1"][quote="u2"]q2[/quote]q1[/quote]q0[/quote][b]bold[/b]', 'quote', 1, - '[quote="u0"] -q0[/quote] -[b]bold[/b]' + '[quote="u0"]q0[/quote][b]bold[/b]', ), array( - '[quote="u0"][quote="u1"][quote="u2"]q2[/quote] -q1[/quote] -q0[/quote] -[b]bold[/b]', + '[quote="u0"][quote="u1"][quote="u2"]q2[/quote]q1[/quote]q0[/quote][b]bold[/b]', 'quote', 2, - '[quote="u0"][quote="u1"] -q1[/quote] -q0[/quote] -[b]bold[/b]' + '[quote="u0"][quote="u1"]q1[/quote]q0[/quote][b]bold[/b]', ), ); } -- cgit v1.2.1 From 2a462bb7e43b848d0277bd27e14ca4d645230eeb Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 25 Mar 2015 01:13:31 +0100 Subject: [ticket/11768] Removed get_parser() / get_renderer() accessors There's no need to access the s9e\TextFormatter objects outside of events. PHPBB3-11768 --- tests/text_formatter/s9e/parser_test.php | 7 ------- tests/text_formatter/s9e/renderer_test.php | 7 ------- 2 files changed, 14 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 725ff42bfd..71433e209f 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -167,11 +167,4 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case ) ); } - - public function test_get_parser() - { - $container = $this->get_test_case_helpers()->set_s9e_services(); - $parser = $container->get('text_formatter.parser'); - $this->assertInstanceOf('s9e\\TextFormatter\\Parser', $parser->get_parser()); - } } diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index b93fd8bbe6..ce2fccd9b7 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -354,11 +354,4 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ); } } - - public function test_get_renderer() - { - $container = $this->get_test_case_helpers()->set_s9e_services(); - $renderer = $container->get('text_formatter.renderer'); - $this->assertInstanceOf('s9e\\TextFormatter\\Renderer', $renderer->get_renderer()); - } } -- cgit v1.2.1 From a7a53d5a30d4736f8114721c0d7019d64d24cda2 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 25 Mar 2015 01:39:19 +0100 Subject: [ticket/11768] Added core.text_formatter_s9e_parser_setup event PHPBB3-11768 --- tests/test_framework/phpbb_test_case_helpers.php | 5 ++- tests/text_formatter/s9e/parser_test.php | 47 ++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 5c6da94014..d43138d780 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -425,6 +425,7 @@ class phpbb_test_case_helpers $prefix = '_s9e_' . md5(serialize(func_get_args())); $cache_key_parser = $prefix . '_parser'; $cache_key_renderer = $prefix . '_renderer'; + $container->set('cache.driver', $cache); // Create a path_helper if (!$container->has('path_helper')) @@ -473,6 +474,7 @@ class phpbb_test_case_helpers $user->optionset('viewflash', true); $user->optionset('viewimg', true); $user->optionset('viewsmilies', true); + $container->set('user', $user); } $user->add_lang('common'); @@ -486,7 +488,8 @@ class phpbb_test_case_helpers $cache, $cache_key_parser, $user, - $factory + $factory, + $dispatcher ); $container->set('text_formatter.parser', $parser); diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 71433e209f..03b29bef12 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -36,7 +36,8 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $cache, '_foo_parser', $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), - $factory + $factory, + new phpbb_mock_event_dispatcher ); } @@ -63,7 +64,8 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $cache, '_foo_parser', $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), - $factory + $factory, + new phpbb_mock_event_dispatcher ); $this->assertSame('test', $parser->parse('test')); @@ -91,7 +93,8 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case new phpbb_mock_cache, '_foo_parser', $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), - $factory + $factory, + new phpbb_mock_event_dispatcher ); $this->assertSame('test', $parser->parse('test')); @@ -124,7 +127,8 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $cache, '_foo_parser', $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), - $factory + $factory, + new phpbb_mock_event_dispatcher ); call_user_func_array(array($parser, $adapter_method), (array) $adapter_arg); @@ -167,4 +171,39 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case ) ); } + + /** + * @testdox The constructor triggers a core.text_formatter_s9e_parser_setup event + */ + public function test_setup_event() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface'); + $dispatcher + ->expects($this->once()) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_parser_setup', + $this->callback(array($this, 'setup_event_callback')) + ) + ->will($this->returnArgument(1)); + + new \phpbb\textformatter\s9e\parser( + $container->get('cache.driver'), + '_foo_parser', + $container->get('user'), + $container->get('text_formatter.s9e.factory'), + $dispatcher + ); + } + + public function setup_event_callback($vars) + { + return isset($vars['parser']) + && $vars['parser'] instanceof \s9e\TextFormatter\Parser + && isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\parser + && isset($vars['user']) + && $vars['user'] instanceof \phpbb\user; + } } -- cgit v1.2.1 From af4f9b860f50a562a03f55efad1da7e0854bdfda Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 26 Mar 2015 04:39:36 +0100 Subject: [ticket/11768] Added core.text_formatter_s9e_renderer_setup event PHPBB3-11768 --- tests/test_framework/phpbb_test_case_helpers.php | 4 ++- tests/text_formatter/s9e/renderer_test.php | 39 ++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index d43138d780..09fec38013 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -426,6 +426,7 @@ class phpbb_test_case_helpers $cache_key_parser = $prefix . '_parser'; $cache_key_renderer = $prefix . '_renderer'; $container->set('cache.driver', $cache); + $container->setParameter('cache.dir', $cache_dir); // Create a path_helper if (!$container->has('path_helper')) @@ -500,7 +501,8 @@ class phpbb_test_case_helpers $cache, $cache_dir, $cache_key_renderer, - $factory + $factory, + $dispatcher ); $config = ($container->has('config')) diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index ce2fccd9b7..ab89d42620 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -43,7 +43,8 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $cache, $this->get_cache_dir(), '_foo_renderer', - $factory + $factory, + new phpbb_mock_event_dispatcher ); } @@ -68,7 +69,8 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $cache, $this->get_cache_dir(), '_foo_renderer', - $factory + $factory, + new phpbb_mock_event_dispatcher ); } @@ -354,4 +356,37 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ); } } + + /** + * @testdox The constructor triggers a core.text_formatter_s9e_renderer_setup event + */ + public function test_setup_event() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface'); + $dispatcher + ->expects($this->once()) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_renderer_setup', + $this->callback(array($this, 'setup_event_callback')) + ) + ->will($this->returnArgument(1)); + + new \phpbb\textformatter\s9e\renderer( + $container->get('cache.driver'), + $container->getParameter('cache.dir'), + '_foo_renderer', + $container->get('text_formatter.s9e.factory'), + $dispatcher + ); + } + + public function setup_event_callback($vars) + { + return isset($vars['renderer']) + && $vars['renderer'] instanceof \s9e\TextFormatter\Renderer + && isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer; + } } -- cgit v1.2.1 From a04fca86ee4fec3cb615f358f3dc914564d9a9b1 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 26 Mar 2015 05:10:25 +0100 Subject: [ticket/11768] Added renderer events Added core.text_formatter_s9e_render_before and core.text_formatter_s9e_render_after PHPBB3-11768 --- tests/text_formatter/s9e/renderer_test.php | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index ab89d42620..c69a93dbc1 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -389,4 +389,58 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case && isset($vars['self']) && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer; } + + /** + * @testdox render() triggers a core.text_formatter_s9e_render_before and core.text_formatter_s9e_render_after events + */ + public function test_render_event() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface'); + $dispatcher + ->expects($this->any()) + ->method('trigger_event') + ->will($this->returnArgument(1)); + $dispatcher + ->expects($this->at(1)) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_render_before', + $this->callback(array($this, 'render_before_event_callback')) + ) + ->will($this->returnArgument(1)); + $dispatcher + ->expects($this->at(2)) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_render_after', + $this->callback(array($this, 'render_after_event_callback')) + ) + ->will($this->returnArgument(1)); + + $renderer = new \phpbb\textformatter\s9e\renderer( + $container->get('cache.driver'), + $container->getParameter('cache.dir'), + '_foo_renderer', + $container->get('text_formatter.s9e.factory'), + $dispatcher + ); + $renderer->render('...'); + } + + public function render_before_event_callback($vars) + { + return isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer + && isset($vars['xml']) + && $vars['xml'] === '...'; + } + + public function render_after_event_callback($vars) + { + return isset($vars['html']) + && $vars['html'] === '...' + && isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer; + } } -- cgit v1.2.1 From f75f63b264b2005faedb699dd867bd1d9c429a09 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 26 Mar 2015 05:20:23 +0100 Subject: [ticket/11768] Added parser events Added core.text_formatter_s9e_parse_before and core.text_formatter_s9e_parse_after PHPBB3-11768 --- tests/text_formatter/s9e/parser_test.php | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 03b29bef12..74182bda47 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -206,4 +206,58 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case && isset($vars['user']) && $vars['user'] instanceof \phpbb\user; } + + /** + * @testdox parse() triggers a core.text_formatter_s9e_parse_before and core.text_formatter_s9e_parse_after events + */ + public function test_parse_event() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface'); + $dispatcher + ->expects($this->any()) + ->method('trigger_event') + ->will($this->returnArgument(1)); + $dispatcher + ->expects($this->at(1)) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_parse_before', + $this->callback(array($this, 'parse_before_event_callback')) + ) + ->will($this->returnArgument(1)); + $dispatcher + ->expects($this->at(2)) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_parse_after', + $this->callback(array($this, 'parse_after_event_callback')) + ) + ->will($this->returnArgument(1)); + + $parser = new \phpbb\textformatter\s9e\parser( + $container->get('cache.driver'), + '_foo_parser', + $container->get('user'), + $container->get('text_formatter.s9e.factory'), + $dispatcher + ); + $parser->parse('...'); + } + + public function parse_before_event_callback($vars) + { + return isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\parser + && isset($vars['text']) + && $vars['text'] === '...'; + } + + public function parse_after_event_callback($vars) + { + return isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\parser + && isset($vars['xml']) + && $vars['xml'] === '...'; + } } -- cgit v1.2.1 From 55c3fc02cfe1ce151bfb65c31ec72fc75f9d7872 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 26 Mar 2015 15:28:04 +0100 Subject: [ticket/11768] Updated utils service Updated docblocks. Removed remove_formatting() because it overlaps with clean_formatting() PHPBB3-11768 --- tests/text_formatter/s9e/utils_test.php | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 6f0ef54182..69f8682cac 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -45,35 +45,6 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case ); } - /** - * @dataProvider get_remove_formatting_tests - */ - public function test_remove_formatting($original, $expected) - { - $container = $this->get_test_case_helpers()->set_s9e_services(); - $utils = $container->get('text_formatter.utils'); - - $this->assertSame($expected, $utils->remove_formatting($original)); - } - - public function get_remove_formatting_tests() - { - return array( - array( - 'Plain text', - 'Plain text' - ), - array( - "Multi
            \nline
            ", - "Multi\nline" - ), - array( - '[b]bold[/b]', - 'bold' - ) - ); - } - /** * @dataProvider get_clean_formatting_tests */ -- cgit v1.2.1 From 3e04e643df4ca5463450df5d94f3caca3e5596c0 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 27 Mar 2015 01:12:57 +0100 Subject: [ticket/11768] Restored get_parser() / get_renderer() PHPBB3-11768 --- tests/text_formatter/s9e/parser_test.php | 7 +++++++ tests/text_formatter/s9e/renderer_test.php | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 74182bda47..2904df25b4 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -260,4 +260,11 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case && isset($vars['xml']) && $vars['xml'] === '...'; } + + public function test_get_parser() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $parser = $container->get('text_formatter.parser'); + $this->assertInstanceOf('s9e\\TextFormatter\\Parser', $parser->get_parser()); + } } diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index c69a93dbc1..8835a80d9d 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -443,4 +443,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case && isset($vars['self']) && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer; } + + public function test_get_renderer() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $renderer = $container->get('text_formatter.renderer'); + $this->assertInstanceOf('s9e\\TextFormatter\\Renderer', $renderer->get_renderer()); + } } -- cgit v1.2.1 From d8e7e11ee3a5c49e80a4ec3e0bdf2011ba5e9ce7 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 27 Mar 2015 01:29:09 +0100 Subject: [ticket/11768] Renamed service vars The name of the variable that holds the service instance is now consistent across events. PHPBB3-11768 --- tests/text_formatter/s9e/parser_test.php | 12 +++++------- tests/text_formatter/s9e/renderer_test.php | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 2904df25b4..71966f9d36 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -200,9 +200,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case public function setup_event_callback($vars) { return isset($vars['parser']) - && $vars['parser'] instanceof \s9e\TextFormatter\Parser - && isset($vars['self']) - && $vars['self'] instanceof \phpbb\textformatter\s9e\parser + && $vars['parser'] instanceof \phpbb\textformatter\s9e\parser && isset($vars['user']) && $vars['user'] instanceof \phpbb\user; } @@ -247,16 +245,16 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case public function parse_before_event_callback($vars) { - return isset($vars['self']) - && $vars['self'] instanceof \phpbb\textformatter\s9e\parser + return isset($vars['parser']) + && $vars['parser'] instanceof \phpbb\textformatter\s9e\parser && isset($vars['text']) && $vars['text'] === '...'; } public function parse_after_event_callback($vars) { - return isset($vars['self']) - && $vars['self'] instanceof \phpbb\textformatter\s9e\parser + return isset($vars['parser']) + && $vars['parser'] instanceof \phpbb\textformatter\s9e\parser && isset($vars['xml']) && $vars['xml'] === '...'; } diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 8835a80d9d..91458541d3 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -385,9 +385,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case public function setup_event_callback($vars) { return isset($vars['renderer']) - && $vars['renderer'] instanceof \s9e\TextFormatter\Renderer - && isset($vars['self']) - && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer; + && $vars['renderer'] instanceof \phpbb\textformatter\s9e\renderer; } /** @@ -430,8 +428,8 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case public function render_before_event_callback($vars) { - return isset($vars['self']) - && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer + return isset($vars['renderer']) + && $vars['renderer'] instanceof \phpbb\textformatter\s9e\renderer && isset($vars['xml']) && $vars['xml'] === '...'; } @@ -440,8 +438,8 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case { return isset($vars['html']) && $vars['html'] === '...' - && isset($vars['self']) - && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer; + && isset($vars['renderer']) + && $vars['renderer'] instanceof \phpbb\textformatter\s9e\renderer; } public function test_get_renderer() -- cgit v1.2.1 From 477f7823e5f51b083c13881d221835ae34c15b8f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Apr 2015 12:08:55 +0200 Subject: [ticket/13522] Fix globals for 3.2 in Q&A tests PHPBB3-13522 --- tests/captcha/qa_test.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/captcha/qa_test.php b/tests/captcha/qa_test.php index 1f2f9f3070..4aa5e714f5 100644 --- a/tests/captcha/qa_test.php +++ b/tests/captcha/qa_test.php @@ -27,14 +27,16 @@ class phpbb_captcha_qa_test extends \phpbb_database_test_case public function setUp() { - global $db; + global $db, $request, $phpbb_container; $db = $this->new_dbal(); parent::setUp(); - $this->request = new \phpbb_mock_request(); - request_var(false, false, false, false, $this->request); + $request = new \phpbb_mock_request(); + $phpbb_container = new \phpbb_mock_container_builder(); + $factory = new \phpbb\db\tools\factory(); + $phpbb_container->set('dbal.tools', $factory->get($db)); $this->qa = new \phpbb\captcha\plugins\qa('phpbb_captcha_questions', 'phpbb_captcha_answers', 'phpbb_qa_confirm'); } @@ -87,7 +89,8 @@ class phpbb_captcha_qa_test extends \phpbb_database_test_case */ public function test_acp_get_question_input($value, $expected) { - $this->request->overwrite('answers', $value); + global $request; + $request->overwrite('answers', $value); $this->assertEquals($expected, $this->qa->acp_get_question_input()); } -- cgit v1.2.1 From a089ff5eb0dcdab83c6c2e64cb0e7cb618aec41f Mon Sep 17 00:00:00 2001 From: MateBartus Date: Wed, 25 Feb 2015 21:13:20 +0100 Subject: [ticket/13654] Moving reporting into controller Moving report.php's content into different services and controllers to better comply with the MVC model. Also implementing: * Replacement for reasons_display() * Adding assign_meta_refresh_var() to \controller\helper * Adding separate routes for easy configuration * Updating unit tests to expect to correct results * Add BC tests PHPBB3-13654 --- .../functional/controllers_compatibility_test.php | 43 ++++++++++++++++++++++ tests/functional/report_post_captcha_test.php | 7 ++-- 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 tests/functional/controllers_compatibility_test.php (limited to 'tests') diff --git a/tests/functional/controllers_compatibility_test.php b/tests/functional/controllers_compatibility_test.php new file mode 100644 index 0000000000..7ba0b0d991 --- /dev/null +++ b/tests/functional/controllers_compatibility_test.php @@ -0,0 +1,43 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +/** +* @group functional +*/ + +class phpbb_functional_controllers_compatibility_test extends phpbb_functional_test_case +{ + public function test_report_compatibility() + { + $this->assert301('report.php?f=1&p=1', 'app.php/post/1/report'); + $this->assert301('report.php?p=1', 'app.php/post/1/report'); + $this->assert301('report.php?pm=1', 'app.php/pm/1/report'); + } + + protected function assert301($from, $to) + { + self::$client->followRedirects(false); + self::request('GET', $from, array(), false); + + // Fix sid issues + $location = self::$client->getResponse()->getHeader('Location'); + $location = preg_replace('#sid=[^&]+(&(amp;)?)?#', '', $location); + if (substr($location, -1) === '?') + { + $location = substr($location, 0, -1); + } + + $this->assertEquals(301, self::$client->getResponse()->getStatus()); + $this->assertStringEndsWith($to, $location); + } +} diff --git a/tests/functional/report_post_captcha_test.php b/tests/functional/report_post_captcha_test.php index 93a03bd931..36a1a9ee4d 100644 --- a/tests/functional/report_post_captcha_test.php +++ b/tests/functional/report_post_captcha_test.php @@ -18,12 +18,13 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca { public function test_guest_report_post() { - $crawler = self::request('GET', 'report.php?f=2&p=1'); + $crawler = self::request('GET', 'app.php/post/1/report', array(), false); + $this->assert_response_html(403); $this->add_lang('mcp'); $this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text()); $this->set_reporting_guest(1); - $crawler = self::request('GET', 'report.php?f=2&p=1'); + $crawler = self::request('GET', 'app.php/post/1/report'); $this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); $this->set_reporting_guest(-1); } @@ -31,7 +32,7 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca public function test_user_report_post() { $this->login(); - $crawler = self::request('GET', 'report.php?f=2&p=1'); + $crawler = self::request('GET', 'app.php/post/1/report'); $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); $this->add_lang('mcp'); -- cgit v1.2.1 From 4bdef6fd21a5dcab455b0cd1ee2652de606929c3 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Thu, 12 Mar 2015 00:25:00 +0100 Subject: [ticket/13697] Moving filesystem related functions to filesystem service * Moving filesystem service to \phpbb\filesystem namespace * Wraping Symfony's Filesystem component * Moving filesystem related functions from includes/functions.php into \phpbb\filesystem\filesystem Functions moved (and deprecated): - phpbb_chmod - phpbb_is_writable - phpbb_is_absolute - phpbb_own_realpath - phpbb_realpath * Adding interface for filesystem service PHPBB3-13697 --- tests/avatar/manager_test.php | 6 +- tests/controller/common_helper_route.php | 6 +- tests/controller/controller_test.php | 2 +- tests/dbal/connect_test.php | 4 +- tests/dbal/migrator_test.php | 2 +- .../fixtures/ext/vendor/enabled_4/di/extension.php | 3 +- tests/error_collector_test.php | 9 +++ tests/extension/finder_test.php | 4 +- tests/extension/manager_test.php | 2 +- tests/extension/metadata_manager_test.php | 6 +- tests/filesystem/clean_path_test.php | 2 +- tests/filesystem/is_absolute_test.php | 68 ++++++++++++++++ tests/filesystem/realpath_test.php | 90 ++++++++++++++++++++++ tests/functional/fileupload_remote_test.php | 11 ++- tests/functions/build_url_test.php | 2 +- tests/functions/is_absolute_test.php | 60 --------------- tests/mock/controller_helper.php | 2 +- tests/mock/extension_manager.php | 2 +- tests/pagination/pagination_test.php | 4 +- tests/path_helper/path_helper_test.php | 10 +-- tests/security/base.php | 2 +- tests/security/redirect_test.php | 2 +- tests/session/check_ban_test.php | 5 +- tests/session/extract_page_test.php | 2 +- tests/template/includephp_test.php | 3 +- tests/template/template_allfolder_test.php | 4 +- tests/template/template_events_test.php | 4 +- tests/template/template_includecss_test.php | 4 +- tests/template/template_test_case.php | 8 +- tests/template/template_test_case_with_tree.php | 4 +- tests/test_framework/phpbb_database_test_case.php | 2 +- .../phpbb_database_test_connection_manager.php | 2 +- .../test_framework/phpbb_functional_test_case.php | 2 +- tests/test_framework/phpbb_session_test_case.php | 2 +- tests/upload/filespec_test.php | 9 ++- tests/upload/fileupload_test.php | 22 +++--- tests/viewonline/helper_test.php | 2 +- 37 files changed, 252 insertions(+), 122 deletions(-) create mode 100644 tests/filesystem/is_absolute_test.php create mode 100644 tests/filesystem/realpath_test.php delete mode 100644 tests/functions/is_absolute_test.php (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index a109a7b5de..4befbfc1fc 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -35,6 +35,8 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case ->method('get') ->will($this->returnArgument(0)); + $filesystem = new \phpbb\filesystem\filesystem(); + // Prepare dependencies for avatar manager and driver $this->config = new \phpbb\config\config(array()); $cache = $this->getMock('\phpbb\cache\driver\driver_interface'); @@ -42,7 +44,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + $filesystem, $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -76,7 +78,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case } else { - $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $path_helper, $guesser, $cache)); + $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $filesystem, $path_helper, $guesser, $cache)); } $cur_avatar->expects($this->any()) ->method('get_name') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 3f98d51f16..91b0cda68d 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -69,7 +69,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->symfony_request = new \phpbb\symfony_request( $this->request ); - $this->filesystem = new \phpbb\filesystem(); + $this->filesystem = new \phpbb\filesystem\filesystem(); $this->phpbb_path_helper = new \phpbb\path_helper( $this->symfony_request, $this->filesystem, @@ -84,7 +84,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader(''); + $loader = new \phpbb\template\twig\loader($this->filesystem, ''); $twig = new \phpbb\template\twig\environment( $this->config, $this->phpbb_path_helper, @@ -113,7 +113,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router = new phpbb_mock_router($this->filesystem, $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 86615fe4dc..a837e25f66 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,7 +40,7 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); diff --git a/tests/dbal/connect_test.php b/tests/dbal/connect_test.php index 1ae34bd2b6..edf57189cb 100644 --- a/tests/dbal/connect_test.php +++ b/tests/dbal/connect_test.php @@ -22,7 +22,9 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case public function test_failing_connect() { - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $phpbb_filesystem; + + $phpbb_filesystem = new phpbb\filesystem\filesystem(); $config = $this->get_database_config(); diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 6416a2fcf7..d550ca55a2 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -69,7 +69,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $container, $this->db, $this->config, - new phpbb\filesystem(), + new phpbb\filesystem\filesystem(), $user, 'phpbb_ext', dirname(__FILE__) . '/../../phpBB/', diff --git a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php index 8342625687..8e5ed6c52c 100644 --- a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php +++ b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php @@ -25,7 +25,8 @@ class extension extends extension_base { protected function load_services(ContainerBuilder $container) { - $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->ext_path))); + $filesystem = new \phpbb\filesystem\filesystem(); + $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->ext_path))); $loader->load('environment.yml'); } } diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php index b92c4fa6bb..ddbe2e3af1 100644 --- a/tests/error_collector_test.php +++ b/tests/error_collector_test.php @@ -15,6 +15,15 @@ require_once dirname(__FILE__) . '/../phpBB/includes/functions.php'; class phpbb_error_collector_test extends phpbb_test_case { + public function setUp() + { + parent::setUp(); + + global $phpbb_filesystem; + + $phpbb_filesystem = new \phpbb\filesystem\filesystem(); + } + public function test_collection() { $collector = new \phpbb\error_collector(E_ALL | E_STRICT); // php set_error_handler() default diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 2116cc057b..463b69e9a9 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -244,7 +244,7 @@ class phpbb_extension_finder_test extends phpbb_test_case public function test_get_classes_create_cache() { $cache = new phpbb_mock_cache; - $finder = new \phpbb\finder(new \phpbb\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name'); + $finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name'); $finder->set_extensions(array_keys($this->extension_manager->all_enabled())); $files = $finder->suffix('_class.php')->get_files(); @@ -284,7 +284,7 @@ class phpbb_extension_finder_test extends phpbb_test_case ); $finder = new \phpbb\finder( - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', new phpbb_mock_cache(array( '_ext_finder' => array( diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 0126216701..b76203b32a 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -177,7 +177,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $container, $db, $config, - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $user, 'phpbb_ext', dirname(__FILE__) . '/', diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 8514ed3dbd..db573ae0c3 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -51,12 +51,12 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $container = new phpbb_mock_container_builder(); $cache_path = $this->phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader(''); + $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $phpbb_path_helper =new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $this->phpbb_root_path, $this->phpEx @@ -98,7 +98,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $container, $this->db, $this->config, - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->user, 'phpbb_ext', $this->phpbb_root_path, diff --git a/tests/filesystem/clean_path_test.php b/tests/filesystem/clean_path_test.php index c585b17155..d2dec424b4 100644 --- a/tests/filesystem/clean_path_test.php +++ b/tests/filesystem/clean_path_test.php @@ -18,7 +18,7 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case public function setUp() { parent::setUp(); - $this->filesystem = new \phpbb\filesystem(); + $this->filesystem = new \phpbb\filesystem\filesystem(); } public function clean_path_data() diff --git a/tests/filesystem/is_absolute_test.php b/tests/filesystem/is_absolute_test.php new file mode 100644 index 0000000000..7a50989b74 --- /dev/null +++ b/tests/filesystem/is_absolute_test.php @@ -0,0 +1,68 @@ + + * @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_filesystem_is_absolute_test extends phpbb_test_case +{ + /** @var \phpbb\filesystem\filesystem_interface */ + protected $filesystem; + + public function setUp() + { + parent::setUp(); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + } + + static public function is_absolute_data() + { + return array( + // Empty + array('', false), + + // Absolute unix style + array('/etc/phpbb', true), + // Unix does not support \ so that is not an absolute path + array('\etc\phpbb', false), + + // Absolute windows style + array('c:\windows', true), + array('C:\Windows', true), + array('c:/windows', true), + array('C:/Windows', true), + + // Executable + array('etc/phpbb', false), + array('explorer.exe', false), + + // Relative subdir + array('Windows\System32', false), + array('Windows\System32\explorer.exe', false), + array('Windows/System32', false), + array('Windows/System32/explorer.exe', false), + + // Relative updir + array('..\Windows\System32', false), + array('..\Windows\System32\explorer.exe', false), + array('../Windows/System32', false), + array('../Windows/System32/explorer.exe', false), + ); + } + + /** + * @dataProvider is_absolute_data + */ + public function test_is_absolute($path, $expected) + { + $this->assertEquals($expected, $this->filesystem->is_absolute_path($path)); + } +} diff --git a/tests/filesystem/realpath_test.php b/tests/filesystem/realpath_test.php new file mode 100644 index 0000000000..d994935f94 --- /dev/null +++ b/tests/filesystem/realpath_test.php @@ -0,0 +1,90 @@ + + * @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_filesystem_realpath_test extends phpbb_test_case +{ + static protected $filesystem_own_realpath; + + /** @var \phpbb\filesystem\filesystem_interface */ + protected $filesystem; + + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + $reflection_class = new ReflectionClass('\phpbb\filesystem\filesystem'); + self::$filesystem_own_realpath = $reflection_class->getMethod('phpbb_own_realpath'); + self::$filesystem_own_realpath->setAccessible(true); + } + + public function setUp() + { + parent::setUp(); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + } + + public function realpath_resolve_absolute_without_symlinks_data() + { + return array( + // Constant data + array(__DIR__, __DIR__), + array(__DIR__ . '/../filesystem/../filesystem', __DIR__), + array(__DIR__ . '/././', __DIR__), + array(__DIR__ . '/non_existent', false), + + array(__FILE__, __FILE__), + array(__FILE__ . '../', false), + ); + } + + public function realpath_resolve_relative_without_symlinks_data() + { + if (!function_exists('getcwd')) + { + return array(); + } + + $filesystem = new \phpbb\filesystem\filesystem(); + $relative_path = $filesystem->make_path_relative(__DIR__, getcwd()); + + return array( + array($relative_path, __DIR__), + array($relative_path . '../filesystem/../filesystem', __DIR__), + array($relative_path . '././', __DIR__), + + array($relative_path . 'realpath_test.php', __FILE__), + ); + } + + /** + * @dataProvider realpath_resolve_absolute_without_symlinks_data + */ + public function test_realpath_absolute_without_links($path, $expected) + { + $this->assertEquals($expected, self::$filesystem_own_realpath->invoke($this->filesystem, $path)); + } + + /** + * @dataProvider realpath_resolve_relative_without_symlinks_data + */ + public function test_realpath_relative_without_links($path, $expected) + { + if (!function_exists('getcwd')) + { + $this->markTestSkipped('phpbb_own_realpath() cannot be tested with relative paths: getcwd is not available.'); + } + + $this->assertEquals($expected, self::$filesystem_own_realpath->invoke($this->filesystem, $path)); + } +} diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 6ece150b23..4aa1a83b30 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -18,6 +18,8 @@ require_once __DIR__ . '/../../phpBB/includes/functions_upload.php'; */ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case { + protected $filesystem; + public function setUp() { parent::setUp(); @@ -38,6 +40,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $user = new phpbb_mock_user(); $user->lang = new phpbb_mock_lang(); + $this->filesystem = new \phpbb\filesystem\filesystem(); } public function tearDown() @@ -49,21 +52,21 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { - $upload = new fileupload('', array('jpg'), 100); + $upload = new fileupload($this->filesystem, '', array('jpg'), 100); $file = $upload->remote_upload(self::$root_url . 'develop/blank.gif'); $this->assertEquals('URL_INVALID', $file->error[0]); } public function test_empty_file() { - $upload = new fileupload('', array('jpg'), 100); + $upload = new fileupload($this->filesystem, '', array('jpg'), 100); $file = $upload->remote_upload(self::$root_url . 'develop/blank.jpg'); $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); } public function test_successful_upload() { - $upload = new fileupload('', array('gif'), 1000); + $upload = new fileupload($this->filesystem, '', array('gif'), 1000); $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->filename)); @@ -71,7 +74,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_too_large() { - $upload = new fileupload('', array('gif'), 100); + $upload = new fileupload($this->filesystem, '', array('gif'), 100); $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(1, sizeof($file->error)); $this->assertEquals('WRONG_FILESIZE', $file->error[0]); diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index a59b94c744..3e19b51f02 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -29,7 +29,7 @@ class phpbb_build_url_test extends phpbb_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $phpbb_root_path, 'php' diff --git a/tests/functions/is_absolute_test.php b/tests/functions/is_absolute_test.php deleted file mode 100644 index afa4b9b59f..0000000000 --- a/tests/functions/is_absolute_test.php +++ /dev/null @@ -1,60 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - -class phpbb_functions_is_absolute_test extends phpbb_test_case -{ - static public function is_absolute_data() - { - return array( - // Empty - array('', false), - - // Absolute unix style - array('/etc/phpbb', true), - // Unix does not support \ so that is not an absolute path - array('\etc\phpbb', false), - - // Absolute windows style - array('c:\windows', true), - array('C:\Windows', true), - array('c:/windows', true), - array('C:/Windows', true), - - // Executable - array('etc/phpbb', false), - array('explorer.exe', false), - - // Relative subdir - array('Windows\System32', false), - array('Windows\System32\explorer.exe', false), - array('Windows/System32', false), - array('Windows/System32/explorer.exe', false), - - // Relative updir - array('..\Windows\System32', false), - array('..\Windows\System32\explorer.exe', false), - array('../Windows/System32', false), - array('../Windows/System32/explorer.exe', false), - ); - } - - /** - * @dataProvider is_absolute_data - */ - public function test_is_absolute($path, $expected) - { - $this->assertEquals($expected, phpbb_is_absolute($path)); - } -} diff --git a/tests/mock/controller_helper.php b/tests/mock/controller_helper.php index 7e4a808906..1d9f5dc5bf 100644 --- a/tests/mock/controller_helper.php +++ b/tests/mock/controller_helper.php @@ -13,7 +13,7 @@ class phpbb_mock_controller_helper extends \phpbb\controller\helper { - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext) { $this->template = $template; $this->user = $user; diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php index 3b759fbbc2..2ce61c5149 100644 --- a/tests/mock/extension_manager.php +++ b/tests/mock/extension_manager.php @@ -18,7 +18,7 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = 'php'; $this->extensions = $extensions; - $this->filesystem = new \phpbb\filesystem(); + $this->filesystem = new \phpbb\filesystem\filesystem(); $this->container = $container; } } diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 6679d48c01..c705e67135 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -34,11 +34,11 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); - $filesystem = new \phpbb\filesystem(); + $filesystem = new \phpbb\filesystem\filesystem(); $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new phpbb_mock_router($filesystem, $manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $router->find_routing_files($manager->all_enabled(false)); $router->find(dirname(__FILE__) . '/'); diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index 73f0e6bafc..007441bc92 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -21,14 +21,14 @@ class phpbb_path_helper_test extends phpbb_test_case { parent::setUp(); - $filesystem = new \phpbb\filesystem(); + $filesystem = new \phpbb\filesystem\filesystem(); $this->set_phpbb_root_path($filesystem); $this->path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $this->phpbb_root_path, 'php' @@ -56,7 +56,7 @@ class phpbb_path_helper_test extends phpbb_test_case public function basic_update_web_root_path_data() { - $filesystem = new \phpbb\filesystem(); + $filesystem = new \phpbb\filesystem\filesystem(); $this->set_phpbb_root_path($filesystem); return array( @@ -90,7 +90,7 @@ class phpbb_path_helper_test extends phpbb_test_case public function update_web_root_path_data() { - $this->set_phpbb_root_path(new \phpbb\filesystem()); + $this->set_phpbb_root_path(new \phpbb\filesystem\filesystem()); return array( array( @@ -158,7 +158,7 @@ class phpbb_path_helper_test extends phpbb_test_case $path_helper = new \phpbb\path_helper( $symfony_request, - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $this->phpbb_root_path, 'php' diff --git a/tests/security/base.php b/tests/security/base.php index 330408b448..5888a2bf2a 100644 --- a/tests/security/base.php +++ b/tests/security/base.php @@ -46,7 +46,7 @@ abstract class phpbb_security_test_base extends phpbb_test_case $request = new phpbb_mock_request(array(), array(), array(), $this->server); $symfony_request = new \phpbb\symfony_request($request); - $phpbb_filesystem = new \phpbb\filesystem(); + $phpbb_filesystem = new \phpbb\filesystem\filesystem(); // Set no user and trick a bit to circumvent errors $user = new \phpbb\user('\phpbb\datetime'); diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index 21fb103ed1..3c67a1e98a 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -62,7 +62,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $this->phpbb_root_path, 'php' diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index 561b7faf49..04da5f08b9 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -42,7 +42,10 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case parent::setUp(); // Get session here so that config is mocked correctly $this->session = $this->session_factory->get_session($this->db); - global $cache, $config, $phpbb_root_path, $phpEx; + global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_filesystem; + + $phpbb_filesystem = new \phpbb\filesystem\filesystem(); + $this->backup_cache = $cache; // Change the global cache object for this test because // the mock cache object does not hit the database as is needed diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index f0d1cdb60e..96445ef9b3 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -145,7 +145,7 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case { global $symfony_request, $request, $phpbb_filesystem; - $phpbb_filesystem = new \phpbb\filesystem(); + $phpbb_filesystem = new \phpbb\filesystem\filesystem(); $server['HTTP_HOST'] = 'localhost'; $server['SERVER_NAME'] = 'localhost'; diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php index fdddbef4f2..722e10e42d 100644 --- a/tests/template/includephp_test.php +++ b/tests/template/includephp_test.php @@ -39,8 +39,9 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case { global $phpbb_root_path; + $filesystem = new \phpbb\filesystem\filesystem(); $path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc'; - $this->assertTrue(phpbb_is_absolute($path_to_php)); + $this->assertTrue($filesystem->is_absolute_path($path_to_php)); $template_text = "Path is absolute.\n"; $cache_dir = $phpbb_root_path . 'cache/'; diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php index e87688a57c..f739a78d84 100644 --- a/tests/template/template_allfolder_test.php +++ b/tests/template/template_allfolder_test.php @@ -34,7 +34,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -54,7 +54,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader(''); + $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, $path_helper, diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index e8ffea8d11..6d1b7253e3 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -142,7 +142,7 @@ Zeta test event in all', new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -151,7 +151,7 @@ Zeta test event in all', $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader(''); + $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, $path_helper, diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index 96980e17c6..7a73d1f888 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -32,7 +32,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -43,7 +43,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader(''); + $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, $this->phpbb_path_helper, diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index f9ea8cfaba..29ff669efc 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -71,7 +71,7 @@ class phpbb_template_template_test_case extends phpbb_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -82,7 +82,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader(''); + $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, $path_helper, @@ -108,6 +108,10 @@ class phpbb_template_template_test_case extends phpbb_test_case $this->setup_engine(); $this->template->clear_cache(); + + global $phpbb_filesystem; + + $phpbb_filesystem = new \phpbb\filesystem\filesystem(); } protected function tearDown() diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index c634e2051a..eab83f379a 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -26,7 +26,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem(), + new \phpbb\filesystem\filesystem(), $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -38,7 +38,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader(''); + $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, $this->phpbb_path_helper, diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 903158d3c6..4d0460ebeb 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -58,7 +58,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $setup_extensions = static::setup_extensions(); - $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx); + $finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path, null, $phpEx); $finder->core_path('phpbb/db/migration/data/'); if (!empty($setup_extensions)) { diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 4f38ccc0d8..5136af5ad1 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -365,7 +365,7 @@ class phpbb_database_test_connection_manager { global $phpbb_root_path, $phpEx, $table_prefix; - $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx); + $finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path, null, $phpEx); $classes = $finder->core_path('phpbb/db/migration/data/') ->get_classes(); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 495413593b..daa570caf6 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -254,7 +254,7 @@ class phpbb_functional_test_case extends phpbb_test_case $container, $db, $config, - new phpbb\filesystem(), + new phpbb\filesystem\filesystem(), $user, self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php index 1bf0277fe0..1c1930e88d 100644 --- a/tests/test_framework/phpbb_session_test_case.php +++ b/tests/test_framework/phpbb_session_test_case.php @@ -34,7 +34,7 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case $symfony_request = new \phpbb\symfony_request( new phpbb_mock_request() ); - $phpbb_filesystem = new \phpbb\filesystem(); + $phpbb_filesystem = new \phpbb\filesystem\filesystem(); $phpbb_path_helper = new \phpbb\path_helper( $symfony_request, $phpbb_filesystem, diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 05547dcd00..8fbb437ef0 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -23,6 +23,7 @@ class phpbb_filespec_test extends phpbb_test_case const UPLOAD_MAX_FILESIZE = 1000; private $config; + private $filesystem; public $path; protected function setUp() @@ -30,7 +31,7 @@ class phpbb_filespec_test extends phpbb_test_case // Global $config required by unique_id // Global $user required by filespec::additional_checks and // filespec::move_file - global $config, $user; + global $config, $user, $phpbb_filesystem; if (!is_array($config)) { @@ -75,6 +76,8 @@ class phpbb_filespec_test extends phpbb_test_case $guessers[2]->set_priority(-2); $guessers[3]->set_priority(-2); $this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers); + + $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem(); } private function get_filespec($override = array()) @@ -88,7 +91,7 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - return new filespec(array_merge($upload_ary, $override), null, $this->mimetype_guesser); + return new filespec(array_merge($upload_ary, $override), null, $this->filesystem, $this->mimetype_guesser); } protected function tearDown() @@ -198,7 +201,7 @@ class phpbb_filespec_test extends phpbb_test_case $filespec = $this->get_filespec(); $filespec->clean_filename('unique', self::PREFIX); $name = $filespec->realname; - + $this->assertEquals(strlen($name), 32 + strlen(self::PREFIX)); $this->assertRegExp('#^[A-Za-z0-9]+$#', substr($name, strlen(self::PREFIX))); $this->assertFalse(isset($filenames[$name])); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index fcfb84125d..9de384b64f 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -20,12 +20,14 @@ class phpbb_fileupload_test extends phpbb_test_case { private $path; + private $filesystem; + protected function setUp() { // Global $config required by unique_id // Global $user required by several functions dealing with translations // Global $request required by form_upload, local_upload and is_valid - global $config, $user, $request; + global $config, $user, $request, $phpbb_filesystem; if (!is_array($config)) { @@ -40,6 +42,8 @@ class phpbb_fileupload_test extends phpbb_test_case $request = new phpbb_mock_request(); + $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem(); + $this->path = __DIR__ . '/fixture/'; } @@ -65,7 +69,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new fileupload('', array('png'), 100); + $upload = new fileupload($this->filesystem, '', array('png'), 100); $file = $this->gen_valid_filespec(); $upload->common_checks($file); $this->assertEquals('DISALLOWED_EXTENSION', $file->error[0]); @@ -73,7 +77,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new fileupload('', array('jpg'), 100); + $upload = new fileupload($this->filesystem, '', array('jpg'), 100); $file = $this->gen_valid_filespec(); $file->realname = 'invalid?'; $upload->common_checks($file); @@ -82,7 +86,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new fileupload('', array('jpg'), 100); + $upload = new fileupload($this->filesystem, '', array('jpg'), 100); $file = $this->gen_valid_filespec(); $file->filesize = 1000; $upload->common_checks($file); @@ -91,7 +95,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new fileupload('', array('jpg'), 1000); + $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); $file = $this->gen_valid_filespec(); $upload->common_checks($file); $this->assertEquals(0, sizeof($file->error)); @@ -99,7 +103,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new fileupload('', array('jpg'), 1000); + $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); $file = $upload->local_upload($this->path . 'jpg.jpg'); @@ -109,7 +113,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new fileupload('', array('jpg'), 1000); + $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); $file = $upload->local_upload($this->path . 'jpg.jpg'); @@ -121,7 +125,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new fileupload('', array('jpg'), 1000); + $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg'); @@ -134,7 +138,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new fileupload('', false, false, 1, 1, 100, 100); + $upload = new fileupload($this->filesystem, '', false, false, 1, 1, 100, 100); $file1 = $this->gen_valid_filespec(); $file2 = $this->gen_valid_filespec(); diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php index bbbed59de7..6540d33287 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(new \phpbb\filesystem()); + $this->viewonline_helper = new \phpbb\viewonline_helper(new \phpbb\filesystem\filesystem()); } public function session_pages_data() -- cgit v1.2.1 From 2fa99602c6f6431e99468ca13f4a58344a401c24 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 8 Feb 2015 20:46:14 +0100 Subject: [ticket/8672] Add class for retrieving imagesize without download getimagesize() always downloads the complete file before checking the actual image dimensions. This class will be able to do the same without having to download possibly large files. PHPBB3-8672 --- tests/avatar/manager_test.php | 5 +- tests/upload/fixture/bmp | Bin 0 -> 64 bytes tests/upload/fixture/iff | Bin 0 -> 120 bytes tests/upload/fixture/iff_maya | Bin 0 -> 88 bytes tests/upload/fixture/jp2 | Bin 0 -> 528 bytes tests/upload/fixture/jpx | Bin 0 -> 528 bytes tests/upload/fixture/psd | Bin 0 -> 6374 bytes tests/upload/fixture/tif_compressed | Bin 0 -> 236 bytes tests/upload/fixture/tif_msb | Bin 0 -> 222 bytes tests/upload/fixture/wbmp | Bin 0 -> 5 bytes tests/upload/imagesize_test.php | 99 ++++++++++++++++++++++++++++++++++++ 11 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 tests/upload/fixture/bmp create mode 100644 tests/upload/fixture/iff create mode 100644 tests/upload/fixture/iff_maya create mode 100644 tests/upload/fixture/jp2 create mode 100644 tests/upload/fixture/jpx create mode 100644 tests/upload/fixture/psd create mode 100644 tests/upload/fixture/tif_compressed create mode 100644 tests/upload/fixture/tif_msb create mode 100644 tests/upload/fixture/wbmp create mode 100644 tests/upload/imagesize_test.php (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 4befbfc1fc..14c88c8da5 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -57,9 +57,10 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case new \phpbb\mimetype\content_guesser, ); $guesser = new \phpbb\mimetype\guesser($guessers); + $imagesize = new \phpbb\upload\imagesize(); // $this->avatar_foobar will be needed later on - $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $path_helper, $cache)); + $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache)); $this->avatar_foobar->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.foobar')); @@ -74,7 +75,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case { if ($driver !== 'upload') { - $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $path_helper, $cache)); + $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache)); } else { diff --git a/tests/upload/fixture/bmp b/tests/upload/fixture/bmp new file mode 100644 index 0000000000..04bff561ab Binary files /dev/null and b/tests/upload/fixture/bmp differ diff --git a/tests/upload/fixture/iff b/tests/upload/fixture/iff new file mode 100644 index 0000000000..24eda8f593 Binary files /dev/null and b/tests/upload/fixture/iff differ diff --git a/tests/upload/fixture/iff_maya b/tests/upload/fixture/iff_maya new file mode 100644 index 0000000000..b6fb85101b Binary files /dev/null and b/tests/upload/fixture/iff_maya differ diff --git a/tests/upload/fixture/jp2 b/tests/upload/fixture/jp2 new file mode 100644 index 0000000000..adca6ecf0e Binary files /dev/null and b/tests/upload/fixture/jp2 differ diff --git a/tests/upload/fixture/jpx b/tests/upload/fixture/jpx new file mode 100644 index 0000000000..adca6ecf0e Binary files /dev/null and b/tests/upload/fixture/jpx differ diff --git a/tests/upload/fixture/psd b/tests/upload/fixture/psd new file mode 100644 index 0000000000..d1bc9a6a70 Binary files /dev/null and b/tests/upload/fixture/psd differ diff --git a/tests/upload/fixture/tif_compressed b/tests/upload/fixture/tif_compressed new file mode 100644 index 0000000000..133b50c4f0 Binary files /dev/null and b/tests/upload/fixture/tif_compressed differ diff --git a/tests/upload/fixture/tif_msb b/tests/upload/fixture/tif_msb new file mode 100644 index 0000000000..32eb8abfbb Binary files /dev/null and b/tests/upload/fixture/tif_msb differ diff --git a/tests/upload/fixture/wbmp b/tests/upload/fixture/wbmp new file mode 100644 index 0000000000..708c86ccee Binary files /dev/null and b/tests/upload/fixture/wbmp differ diff --git a/tests/upload/imagesize_test.php b/tests/upload/imagesize_test.php new file mode 100644 index 0000000000..2ce712e5c1 --- /dev/null +++ b/tests/upload/imagesize_test.php @@ -0,0 +1,99 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once(__DIR__ . '/../../phpBB/includes/functions.php'); + +class phpbb_upload_imagesize_test extends \phpbb_test_case +{ + /** @var \phpbb\upload\imagesize */ + protected $imagesize; + + /** @var string Path to fixtures */ + protected $path; + + public function setUp() + { + parent::setUp(); + $this->imagesize = new \phpbb\upload\imagesize(); + $this->path = __DIR__ . '/fixture/'; + } + + public function data_get_imagesize() + { + return array( + array('foobar', 'image/bmp', false), + array('png', 'image/png', array('width' => 1, 'height' => 1, 'type' => IMAGETYPE_PNG)), + array('gif', 'image/png', false), + array('png', '', array('width' => 1, 'height' => 1, 'type' => IMAGETYPE_PNG)), + array('gif', 'image/gif', array('width' => 1, 'height' => 1, 'type' => IMAGETYPE_GIF)), + array('jpg', 'image/gif', false), + array('gif', '', array('width' => 1, 'height' => 1, 'type' => IMAGETYPE_GIF)), + array('jpg', 'image/jpg', array('width' => 1, 'height' => 1, 'type' => IMAGETYPE_JPEG)), + array('jpg', 'image/jpeg', array('width' => 1, 'height' => 1, 'type' => IMAGETYPE_JPEG)), + array('png', 'image/jpg', false), + array('jpg', '', array('width' => 1, 'height' => 1, 'type' => IMAGETYPE_JPEG)), + array('psd', 'image/psd', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_PSD)), + array('psd', 'image/photoshop', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_PSD)), + array('jpg', 'image/psd', false), + array('psd', '', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_PSD)), + array('bmp', 'image/bmp', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_BMP)), + array('png', 'image/bmp', false), + array('bmp', '', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_BMP)), + array('tif', 'image/tif', array('width' => 1, 'height' => 1, 'type' => IMAGETYPE_TIFF_II)), + array('png', 'image/tif', false), + array('tif', '', array('width' => 1, 'height' => 1, 'type' => IMAGETYPE_TIFF_II)), + array('tif_compressed', 'image/tif', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_TIFF_II)), + array('png', 'image/tiff', false), + array('tif_compressed', '', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_TIFF_II)), + array('tif_msb', 'image/tif', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_TIFF_MM)), + array('tif_msb', '', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_TIFF_MM)), + array('wbmp', 'image/wbmp', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_WBMP)), + array('wbmp', 'image/vnd.wap.wbmp', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_WBMP)), + array('png', 'image/vnd.wap.wbmp', false), + array('wbmp', '', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_WBMP)), + array('iff', 'image/iff', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_IFF)), + array('iff', 'image/x-iff', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_IFF)), + array('iff_maya', 'iamge/iff', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_IFF)), + array('png', 'image/iff', false), + array('png', 'image/x-iff', false), + array('iff', '', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_IFF)), + array('iff_maya', '', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_IFF)), + array('jp2', 'image/jp2', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_JPEG2000)), + array('jp2', 'image/jpx', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_JPEG2000)), + array('jp2', 'image/jpm', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_JPEG2000)), + array('jpg', 'image/jp2', false), + array('jpx', 'image/jpx', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_JPEG2000)), + array('jp2', '', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_JPEG2000)), + array('jpx', '', array('width' => 2, 'height' => 1, 'type' => IMAGETYPE_JPEG2000)), + ); + } + + /** + * @dataProvider data_get_imagesize + */ + public function test_get_imagesize($file, $mime_type, $expected) + { + $this->assertEquals($expected, $this->imagesize->get_imagesize($this->path . $file, $mime_type)); + } + + public function test_get_imagesize_remote() + { + $this->assertSame(array( + 'width' => 80, + 'height' => 80, + 'type' => IMAGETYPE_JPEG, + ), + $this->imagesize->get_imagesize('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg')); + } +} -- cgit v1.2.1 From 245d042e43374e6467f447507783a68fae186ef1 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 6 Apr 2015 21:32:22 +0200 Subject: [ticket/8672] Updated the text_formatter.s9e service PHPBB3-8672 --- tests/test_framework/phpbb_test_case_helpers.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 09fec38013..0f9b049f44 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -458,6 +458,10 @@ class phpbb_test_case_helpers { $dispatcher = new phpbb_mock_event_dispatcher; } + if (!isset($phpbb_dispatcher)) + { + $phpbb_dispatcher = $dispatcher; + } // Create and register the text_formatter.s9e.factory service $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $cache_dir, $cache_key_parser, $cache_key_renderer); -- cgit v1.2.1 From 39d6180c6814996dde84cfcd8c0150bba37354ac Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 7 Apr 2015 16:19:36 +0200 Subject: [ticket/8672] Use fastImageSize in classes PHPBB3-8672 --- tests/avatar/manager_test.php | 2 +- tests/upload/imagesize_test.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 14c88c8da5..638ba0aaff 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -57,7 +57,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case new \phpbb\mimetype\content_guesser, ); $guesser = new \phpbb\mimetype\guesser($guessers); - $imagesize = new \phpbb\upload\imagesize(); + $imagesize = new \fastImageSize\fastImageSize(); // $this->avatar_foobar will be needed later on $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache)); diff --git a/tests/upload/imagesize_test.php b/tests/upload/imagesize_test.php index 2ce712e5c1..bfea4b819d 100644 --- a/tests/upload/imagesize_test.php +++ b/tests/upload/imagesize_test.php @@ -16,7 +16,7 @@ require_once(__DIR__ . '/../../phpBB/includes/functions.php'); class phpbb_upload_imagesize_test extends \phpbb_test_case { - /** @var \phpbb\upload\imagesize */ + /** @var \fastImageSize\fastImageSize */ protected $imagesize; /** @var string Path to fixtures */ @@ -25,7 +25,7 @@ class phpbb_upload_imagesize_test extends \phpbb_test_case public function setUp() { parent::setUp(); - $this->imagesize = new \phpbb\upload\imagesize(); + $this->imagesize = new \fastImageSize\fastImageSize(); $this->path = __DIR__ . '/fixture/'; } @@ -84,7 +84,7 @@ class phpbb_upload_imagesize_test extends \phpbb_test_case */ public function test_get_imagesize($file, $mime_type, $expected) { - $this->assertEquals($expected, $this->imagesize->get_imagesize($this->path . $file, $mime_type)); + $this->assertEquals($expected, $this->imagesize->getImageSize($this->path . $file, $mime_type)); } public function test_get_imagesize_remote() @@ -94,6 +94,6 @@ class phpbb_upload_imagesize_test extends \phpbb_test_case 'height' => 80, 'type' => IMAGETYPE_JPEG, ), - $this->imagesize->get_imagesize('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg')); + $this->imagesize->getImageSize('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg')); } } -- cgit v1.2.1 From 55c5bc126decffeaa74abdb853eb010cc3dcda8c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 18 Apr 2015 14:01:21 +0200 Subject: [ticket/8672] User $user->lang() instead of sprintf PHPBB3-8672 --- tests/upload/filespec_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 8fbb437ef0..f6deb242a2 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -287,7 +287,7 @@ class phpbb_filespec_test extends phpbb_test_case array('txt_copy', 'txt_as_img', 'image/jpg', 'txt', false, true), array('txt_copy_2', 'txt_moved', 'text/plain', 'txt', false, true), array('jpg_copy', 'jpg_moved', 'image/png', 'jpg', false, true), - array('png_copy', 'png_moved', 'image/png', 'jpg', 'IMAGE_FILETYPE_MISMATCH', true), + array('png_copy', 'png_moved', 'image/png', 'jpg', 'IMAGE_FILETYPE_MISMATCH png jpg', true), ); } -- cgit v1.2.1 From 25acba225961e037ea1f7e04259eee3dc4f589ee Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 24 Apr 2015 00:21:32 +0200 Subject: [ticket/12745] Added support for Unicode characters outside BMP PHPBB3-12745 --- tests/functional/posting_test.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index fd802eed45..8ac734c733 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -43,14 +43,6 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $this->add_lang('posting'); - self::create_post(2, - 1, - 'Unsupported characters', - "This is a test with these weird characters: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", - array(), - 'Your message contains the following unsupported characters' - ); - self::create_post(2, 1, "Unsupported: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", @@ -59,4 +51,14 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case 'Your subject contains the following unsupported characters' ); } + + public function test_supported_unicode_characters() + { + $this->login(); + + $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.'); + $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', "This is a test with these weird characters: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6"); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + $this->assertContains("\xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", $crawler->text()); + } } -- cgit v1.2.1 From 98bdcd0cde8155cdcf3161b5794951d1860071ba Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 25 Apr 2015 17:06:16 +0200 Subject: [ticket/12745] Added HTML entity test https://github.com/phpbb/phpbb/pull/3548#issuecomment-96219167 PHPBB3-12745 --- tests/functional/posting_test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 8ac734c733..7acf375c5d 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -61,4 +61,14 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); $this->assertContains("\xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", $crawler->text()); } + + public function test_html_entities() + { + $this->login(); + + $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.'); + $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', '😀'); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + $this->assertContains('😀', $crawler->text()); + } } -- cgit v1.2.1 From 102b6c2df377759de8b17f3fe6fa7366fb7385dd Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 28 Apr 2015 02:40:33 +0200 Subject: [ticket/10922] Added support for body and subject in email BBCode PHPBB3-10922 --- tests/text_processing/tickets_data/PHPBB3-10922.html | 4 +++- tests/text_processing/tickets_data/PHPBB3-10922.txt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.html b/tests/text_processing/tickets_data/PHPBB3-10922.html index cdf8316df0..0c74809377 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.html +++ b/tests/text_processing/tickets_data/PHPBB3-10922.html @@ -1 +1,3 @@ -user@example.org... \ No newline at end of file +user@example.org
            +...
            +user@example.org
            diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.txt b/tests/text_processing/tickets_data/PHPBB3-10922.txt index 348f8a1541..a8f09c40f2 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.txt +++ b/tests/text_processing/tickets_data/PHPBB3-10922.txt @@ -1 +1,3 @@ -[email]user@example.org[/email][email=user@example.org]...[/email] \ No newline at end of file +[email]user@example.org[/email] +[email=user@example.org]...[/email] +[email subject="Hello" body="Sent from phpBB"]user@example.org[/email] -- cgit v1.2.1 From 3f54fd49b5bf421852ceb2a54395d5ed353d2f29 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 28 Apr 2015 02:53:40 +0200 Subject: [ticket/10922] Replaced urlencode() with rawurlencode() RFC-6068 asks for percent-encoding so that seems more correct. Not sure about that one. PHPBB3-10922 --- tests/text_processing/tickets_data/PHPBB3-10922.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.html b/tests/text_processing/tickets_data/PHPBB3-10922.html index 0c74809377..6ca9eb0aa1 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.html +++ b/tests/text_processing/tickets_data/PHPBB3-10922.html @@ -1,3 +1,3 @@ user@example.org
            ...
            -user@example.org
            +user@example.org
            -- cgit v1.2.1 From 6dc14f4cf0ce968315c9deb57c97a1eabb406dad Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 28 Apr 2015 03:23:21 +0200 Subject: [ticket/10922] Added tests PHPBB3-10922 --- tests/text_processing/tickets_data/PHPBB3-10922.html | 2 ++ tests/text_processing/tickets_data/PHPBB3-10922.txt | 2 ++ 2 files changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.html b/tests/text_processing/tickets_data/PHPBB3-10922.html index 6ca9eb0aa1..7c375e79a6 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.html +++ b/tests/text_processing/tickets_data/PHPBB3-10922.html @@ -1,3 +1,5 @@ user@example.org
            ...
            user@example.org
            +user@example.org
            +user@example.org
            diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.txt b/tests/text_processing/tickets_data/PHPBB3-10922.txt index a8f09c40f2..7a0b245528 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.txt +++ b/tests/text_processing/tickets_data/PHPBB3-10922.txt @@ -1,3 +1,5 @@ [email]user@example.org[/email] [email=user@example.org]...[/email] [email subject="Hello" body="Sent from phpBB"]user@example.org[/email] +[email subject="Hi there"]user@example.org[/email] +[email body="Hi there"]user@example.org[/email] -- cgit v1.2.1 From d242610d0fa8ba1d5a462ebf084e834bb210934d Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 28 Apr 2015 15:36:51 +0200 Subject: [ticket/10922] Added test data PHPBB3-10922 --- tests/text_processing/tickets_data/PHPBB3-10922.html | 5 ++++- tests/text_processing/tickets_data/PHPBB3-10922.txt | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.html b/tests/text_processing/tickets_data/PHPBB3-10922.html index 7c375e79a6..0fa80b9960 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.html +++ b/tests/text_processing/tickets_data/PHPBB3-10922.html @@ -1,5 +1,8 @@ user@example.org
            ...
            -user@example.org
            +...
            user@example.org
            user@example.org
            +user@example.org
            +user@example.org
            +...
            diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.txt b/tests/text_processing/tickets_data/PHPBB3-10922.txt index 7a0b245528..3db0786eca 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.txt +++ b/tests/text_processing/tickets_data/PHPBB3-10922.txt @@ -1,5 +1,8 @@ [email]user@example.org[/email] -[email=user@example.org]...[/email] -[email subject="Hello" body="Sent from phpBB"]user@example.org[/email] +[email=user@example.org ]...[/email] +[email=user@example.org subject="Hello"]...[/email] [email subject="Hi there"]user@example.org[/email] [email body="Hi there"]user@example.org[/email] +[email subject="Hello" body="Sent from phpBB"]user@example.org[/email] +[email body="Sent from phpBB" subject="Hello"]user@example.org[/email] +[email body="Sent from phpBB" subject="Hello" email="user@example.org"]...[/email] -- cgit v1.2.1 From 5c78be56ec0d32a7934bdfd83a4fb0242befc1fa Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 28 Apr 2015 16:17:54 +0200 Subject: [ticket/10922] Added test PHPBB3-10922 --- tests/text_processing/tickets_data/PHPBB3-10922.html | 1 + tests/text_processing/tickets_data/PHPBB3-10922.txt | 1 + 2 files changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.html b/tests/text_processing/tickets_data/PHPBB3-10922.html index 0fa80b9960..3ff117f171 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.html +++ b/tests/text_processing/tickets_data/PHPBB3-10922.html @@ -1,5 +1,6 @@ user@example.org
            ...
            +...
            ...
            user@example.org
            user@example.org
            diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.txt b/tests/text_processing/tickets_data/PHPBB3-10922.txt index 3db0786eca..e533ce6ed5 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.txt +++ b/tests/text_processing/tickets_data/PHPBB3-10922.txt @@ -1,4 +1,5 @@ [email]user@example.org[/email] +[email=user@example.org]...[/email] [email=user@example.org ]...[/email] [email=user@example.org subject="Hello"]...[/email] [email subject="Hi there"]user@example.org[/email] -- cgit v1.2.1 From 2bbd78ec7de941344852c6f8d006f02444ed4f34 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 29 Apr 2015 23:01:19 +0200 Subject: [ticket/10268] Added regression test PHPBB3-10268 --- tests/text_processing/tickets_data/PHPBB3-10268.html | 4 ++++ tests/text_processing/tickets_data/PHPBB3-10268.txt | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-10268.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-10268.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-10268.html b/tests/text_processing/tickets_data/PHPBB3-10268.html new file mode 100644 index 0000000000..c89e63f9a3 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10268.html @@ -0,0 +1,4 @@ +
            +
            +http://phpbb.com
            + http://phpbb.com
            diff --git a/tests/text_processing/tickets_data/PHPBB3-10268.txt b/tests/text_processing/tickets_data/PHPBB3-10268.txt new file mode 100644 index 0000000000..b4e49c9454 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-10268.txt @@ -0,0 +1,4 @@ +[quote="http://phpbb.com"]...[/quote] +[quote=" http://phpbb.com"]...[/quote] +[b]http://phpbb.com[/b] +[b] http://phpbb.com[/b] -- cgit v1.2.1 From c56726e9da0cb483f8e0c88aacc4c3b3e84ee8e4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 29 Apr 2015 23:59:55 +0200 Subject: [ticket/13641] Added regression test PHPBB3-13641 --- .../text_processing/tickets_data/PHPBB3-13641.html | 1 + .../text_processing/tickets_data/PHPBB3-13641.txt | 1 + .../text_processing/tickets_data/PHPBB3-13641.xml | 28 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-13641.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-13641.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-13641.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-13641.html b/tests/text_processing/tickets_data/PHPBB3-13641.html new file mode 100644 index 0000000000..1bd1c06dbb --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13641.html @@ -0,0 +1 @@ +[color=#FF0000] - red \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13641.txt b/tests/text_processing/tickets_data/PHPBB3-13641.txt new file mode 100644 index 0000000000..58f324715e --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13641.txt @@ -0,0 +1 @@ +[c][color=#FF0000][/c] - [color=#FF0000]red[/color] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13641.xml b/tests/text_processing/tickets_data/PHPBB3-13641.xml new file mode 100644 index 0000000000..451c5c69cd --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13641.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + c + + 1 + [c]{TEXT}[/c] + {TEXT}]]> + + + + ${1}]]> + +
            +
            -- cgit v1.2.1 From 71660301d6467d2cb7a0fc08ee74e13912b6bc42 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 30 Apr 2015 00:09:35 +0200 Subject: [ticket/13425] Added regression test PHPBB3-13425 --- .../text_processing/tickets_data/PHPBB3-13425.html | 1 + .../text_processing/tickets_data/PHPBB3-13425.txt | 1 + .../text_processing/tickets_data/PHPBB3-13425.xml | 23 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-13425.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-13425.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-13425.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-13425.html b/tests/text_processing/tickets_data/PHPBB3-13425.html new file mode 100644 index 0000000000..9a042dc558 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13425.html @@ -0,0 +1 @@ +
            :lol: starts with a smiley
            \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13425.txt b/tests/text_processing/tickets_data/PHPBB3-13425.txt new file mode 100644 index 0000000000..8456410df5 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13425.txt @@ -0,0 +1 @@ +[quote]:lol: starts with a smiley[/quote] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13425.xml b/tests/text_processing/tickets_data/PHPBB3-13425.xml new file mode 100644 index 0000000000..cbdcaa7fb7 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13425.xml @@ -0,0 +1,23 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 22 + :lol: + Laughing + icon_lol.gif + 15 + 17 + 22 + 1 + +
            +
            -- cgit v1.2.1 From abb4a2f6de615f0a371925b1d99733b2d536e771 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 30 Apr 2015 00:21:43 +0200 Subject: [ticket/8419] Added regression test PHPBB3-8419 --- .../text_processing/tickets_data/PHPBB3-8419.html | 1 + tests/text_processing/tickets_data/PHPBB3-8419.txt | 1 + tests/text_processing/tickets_data/PHPBB3-8419.xml | 28 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-8419.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-8419.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-8419.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-8419.html b/tests/text_processing/tickets_data/PHPBB3-8419.html new file mode 100644 index 0000000000..38df626a94 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-8419.html @@ -0,0 +1 @@ +przykład \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-8419.txt b/tests/text_processing/tickets_data/PHPBB3-8419.txt new file mode 100644 index 0000000000..dac47823b6 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-8419.txt @@ -0,0 +1 @@ +[ort]tę [/ort]przykład \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-8419.xml b/tests/text_processing/tickets_data/PHPBB3-8419.xml new file mode 100644 index 0000000000..2f1df345f9 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-8419.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + myemail + + 1 + [ort]{TEXT}[/ort] + {TEXT}]]> + + + + ${1}]]> + +
            +
            -- cgit v1.2.1 From 66ad8051271eb0b5ea6368214ed1058b1fd3b818 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 30 Apr 2015 00:35:32 +0200 Subject: [ticket/9073] Added regression test PHPBB3-9073 --- tests/text_processing/tickets_data/PHPBB3-9073.html | 2 ++ tests/text_processing/tickets_data/PHPBB3-9073.txt | 2 ++ tests/text_processing/tickets_data/PHPBB3-9073.xml | 14 ++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-9073.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-9073.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-9073.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-9073.html b/tests/text_processing/tickets_data/PHPBB3-9073.html new file mode 100644 index 0000000000..ff1f9fd0ce --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-9073.html @@ -0,0 +1,2 @@ +http://www.xxxx-xx-xxxx.com/
            +http://www.xxxx-xx-xxxx.com/
            diff --git a/tests/text_processing/tickets_data/PHPBB3-9073.txt b/tests/text_processing/tickets_data/PHPBB3-9073.txt new file mode 100644 index 0000000000..2c271173ce --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-9073.txt @@ -0,0 +1,2 @@ +http://www.some-ad-site.com/ +[url]http://www.some-ad-site.com/[/url] diff --git a/tests/text_processing/tickets_data/PHPBB3-9073.xml b/tests/text_processing/tickets_data/PHPBB3-9073.xml new file mode 100644 index 0000000000..d635d51ed1 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-9073.xml @@ -0,0 +1,14 @@ + + + + word_id + word + replacement + + + 1 + http://www.some-ad-site.com* + http://www.xxxx-xx-xxxx.com + +
            +
            -- cgit v1.2.1 From 57072a1e28061ff51148c7d6a0c47664f0060639 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Wed, 29 Apr 2015 00:13:29 +0200 Subject: [ticket/13793] Remove translation on throwing exceptions PHPBB3-13793 --- tests/controller/controller_test.php | 2 +- tests/dbal/migrator_test.php | 2 -- tests/extension/manager_test.php | 2 -- tests/extension/metadata_manager_test.php | 23 +++++++++++++--------- .../test_framework/phpbb_functional_test_case.php | 2 -- 5 files changed, 15 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index a837e25f66..5c0290ee6f 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -82,7 +82,7 @@ class phpbb_controller_controller_test extends phpbb_test_case include(__DIR__.'/phpbb/controller/foo.php'); } - $resolver = new \phpbb\controller\resolver(new \phpbb\user('\phpbb\datetime'), $container, dirname(__FILE__) . '/'); + $resolver = new \phpbb\controller\resolver($container, dirname(__FILE__) . '/'); $symfony_request = new Request(); $symfony_request->attributes->set('_controller', 'foo.controller:handle'); diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index d550ca55a2..f52e6ea63d 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -63,14 +63,12 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case ); $container->set('migrator', $this->migrator); $container->set('dispatcher', new phpbb_mock_event_dispatcher()); - $user = new \phpbb\user('\phpbb\datetime'); $this->extension_manager = new \phpbb\extension\manager( $container, $this->db, $this->config, new phpbb\filesystem\filesystem(), - $user, 'phpbb_ext', dirname(__FILE__) . '/../../phpBB/', 'php', diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index b76203b32a..a24b0cf178 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -155,7 +155,6 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $phpbb_root_path = __DIR__ . './../../phpBB/'; $php_ext = 'php'; $table_prefix = 'phpbb_'; - $user = new \phpbb\user('\phpbb\user'); $container = new phpbb_mock_container_builder(); @@ -178,7 +177,6 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $db, $config, new \phpbb\filesystem\filesystem(), - $user, 'phpbb_ext', dirname(__FILE__) . '/', $php_ext, diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index db573ae0c3..c269eee987 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -99,7 +99,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->db, $this->config, new \phpbb\filesystem\filesystem(), - $this->user, 'phpbb_ext', $this->phpbb_root_path, $this->phpEx, @@ -120,7 +119,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case } catch (\phpbb\extension\exception $e) { - $this->assertEquals((string) $e, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json')); + $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); + $this->assertEquals($message, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json')); } } @@ -137,7 +137,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case } catch (\phpbb\extension\exception $e) { - $this->fail($e); + $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); + $this->fail($message); } $json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/vendor2/foo/composer.json'), true); @@ -169,7 +170,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case } catch(\phpbb\extension\exception $e) { - $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', $field_name)); + $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); + $this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', $field_name)); } } @@ -183,7 +185,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case } catch (\phpbb\extension\exception $e) { - $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'authors')); + $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); + $this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', 'authors')); } $manager->merge_metadata(array( @@ -199,7 +202,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case } catch (\phpbb\extension\exception $e) { - $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'author name')); + $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); + $this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', 'author name')); } } @@ -232,7 +236,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case } catch(\phpbb\extension\exception $e) { - $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', $field_name)); + $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); + $this->assertEquals($message, $this->user->lang('META_FIELD_INVALID', $field_name)); } } @@ -256,7 +261,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case } catch(\phpbb\extension\exception $e) { - $this->fail($e); + $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); + $this->fail($message); } } @@ -352,7 +358,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->config, $this->extension_manager, $this->template, - $this->user, $this->phpbb_root_path ); } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index daa570caf6..c1ec287477 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -248,14 +248,12 @@ class phpbb_functional_test_case extends phpbb_test_case ); $container->set('migrator', $migrator); $container->set('dispatcher', new phpbb_mock_event_dispatcher()); - $user = new \phpbb\user('\phpbb\datetime'); $extension_manager = new \phpbb\extension\manager( $container, $db, $config, new phpbb\filesystem\filesystem(), - $user, self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', $phpEx, -- cgit v1.2.1 From e5a167e6c2fb3159c1b8ac1587e39994ef4fb553 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 2 May 2015 01:53:11 +0200 Subject: [ticket/13805] Updated generate_text_for_storage() to match message_parser PHPBB3-13805 --- .../generate_text_for_storage_test.php | 120 ++++++++++++++++++++- 1 file changed, 115 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/text_processing/generate_text_for_storage_test.php b/tests/text_processing/generate_text_for_storage_test.php index ffa06e4e02..474f6d8f0f 100644 --- a/tests/text_processing/generate_text_for_storage_test.php +++ b/tests/text_processing/generate_text_for_storage_test.php @@ -12,6 +12,7 @@ */ require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_compatibility.php'; require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; @@ -36,7 +37,7 @@ class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_ca /** * @dataProvider get_text_formatter_tests */ - public function test_text_formatter($original, $expected, $allow_bbcode = true, $allow_urls = true, $allow_smilies = true, $setup = null) + public function test_text_formatter($original, $expected, $allow_bbcode, $allow_urls, $allow_smilies, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode, $setup = null) { $actual = $original; $uid = ''; @@ -48,7 +49,7 @@ class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_ca $setup(); } - generate_text_for_storage($actual, $uid, $bitfield, $flags, $allow_bbcode, $allow_urls, $allow_smilies); + generate_text_for_storage($actual, $uid, $bitfield, $flags, $allow_bbcode, $allow_urls, $allow_smilies, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode); $this->assertSame($expected, $actual); } @@ -58,15 +59,124 @@ class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_ca return array( array( 'Hello world', - 'Hello world' + 'Hello world', + true, + true, + true, + true, + true, + true, + true, ), array( 'Hello [url=http://example.org]world[/url] :)', - 'Hello [url=http://example.org]world[/url] :)' + 'Hello [url=http://example.org]world[/url] :)', + true, + true, + true, + true, + true, + true, + true, ), array( '&<>"\'', - '&<>"\'' + '&<>"\'', + true, + true, + true, + true, + true, + true, + true, + ), + array( + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + false, + false, + false, + false, + false, + false, + false, + ), + array( + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + true, + false, + false, + false, + false, + false, + false, + ), + array( + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + false, + true, + false, + false, + false, + false, + true, + ), + array( + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + false, + false, + true, + false, + false, + false, + false, + ), + array( + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + true, + false, + false, + true, + false, + false, + false, + ), + array( + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + true, + false, + false, + false, + true, + false, + false, + ), + array( + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + true, + false, + false, + false, + false, + true, + false, + ), + array( + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]', + true, + false, + false, + false, + false, + false, + true, ), ); } -- cgit v1.2.1 From 179a4700221aa49071b07d638c44b9326c7a14a8 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Tue, 14 Apr 2015 02:31:23 +0200 Subject: [ticket/13762] Moving language related functionality into a separate class PHPBB3-13762 --- tests/auth/provider_apache_test.php | 4 +- tests/auth/provider_db_test.php | 4 +- tests/auth/provider_oauth_token_storage_test.php | 4 +- tests/avatar/manager_test.php | 11 +- tests/console/cache/purge_test.php | 7 +- tests/console/config/config_test.php | 7 +- tests/console/cron/cron_list_test.php | 7 +- tests/console/cron/run_test.php | 5 +- tests/content_visibility/delete_post_test.php | 4 +- .../get_forums_visibility_sql_test.php | 4 +- .../get_global_visibility_sql_test.php | 4 +- .../content_visibility/get_visibility_sql_test.php | 4 +- .../set_post_visibility_test.php | 8 +- .../set_topic_visibility_test.php | 4 +- tests/controller/common_helper_route.php | 4 +- tests/datetime/from_format_test.php | 12 +- tests/dbal/migrator_tool_module_test.php | 4 +- tests/event/exception_listener_test.php | 6 +- tests/extension/metadata_manager_test.php | 20 +- tests/functions/generate_string_list.php | 9 +- tests/groupposition/legend_test.php | 42 +++-- tests/groupposition/teampage_test.php | 48 +++-- tests/language/language_test.php | 210 +++++++++++++++++++++ tests/log/add_test.php | 8 +- tests/log/delete_test.php | 4 +- tests/log/function_add_log_test.php | 5 +- tests/notification/base.php | 7 +- tests/notification/submit_post_base.php | 5 +- tests/notification/user_list_trim_test.php | 14 +- tests/pagination/pagination_test.php | 7 +- tests/plupload/plupload_test.php | 6 +- tests/profilefields/type_bool_test.php | 7 +- tests/profilefields/type_date_test.php | 7 +- tests/profilefields/type_dropdown_test.php | 7 +- tests/profilefields/type_googleplus_test.php | 6 +- tests/profilefields/type_int_test.php | 7 +- tests/profilefields/type_string_test.php | 7 +- tests/profilefields/type_url_test.php | 7 +- tests/security/base.php | 4 +- tests/template/template_allfolder_test.php | 5 +- tests/template/template_test_case.php | 22 ++- .../test_framework/phpbb_functional_test_case.php | 10 +- tests/test_framework/phpbb_test_case_helpers.php | 4 +- tests/text_formatter/s9e/renderer_test.php | 54 ++++-- .../generate_text_for_display_test.php | 30 ++- tests/user/lang_test.php | 119 ------------ tests/version/version_fetch_test.php | 4 +- tests/version/version_helper_remote_test.php | 6 +- tests/version/version_test.php | 18 +- 49 files changed, 580 insertions(+), 232 deletions(-) create mode 100644 tests/language/language_test.php delete mode 100644 tests/user/lang_test.php (limited to 'tests') diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 68ad7b2c19..60423acbc1 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -28,8 +28,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case $db = $this->new_dbal(); $config = new \phpbb\config\config(array()); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); $this->request = $this->getMock('\phpbb\request\request'); - $this->user = new \phpbb\user('\phpbb\datetime'); + $this->user = new \phpbb\user($lang, '\phpbb\datetime'); $driver_helper = new \phpbb\passwords\driver\helper($config); $passwords_drivers = array( 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php index 09ca0816bf..38dbfa1fcb 100644 --- a/tests/auth/provider_db_test.php +++ b/tests/auth/provider_db_test.php @@ -38,8 +38,10 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case 'ip_login_limit_use_forwarded' => 0, 'max_login_attempts' => 0, )); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); $request = $this->getMock('\phpbb\request\request'); - $user = new \phpbb\user('\phpbb\datetime'); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $driver_helper = new \phpbb\passwords\driver\helper($config); $passwords_drivers = array( 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php index 71b49ff439..78b936ee8e 100644 --- a/tests/auth/provider_oauth_token_storage_test.php +++ b/tests/auth/provider_oauth_token_storage_test.php @@ -31,7 +31,9 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c global $phpbb_root_path, $phpEx; $this->db = $this->new_dbal(); - $this->user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $this->user = new \phpbb\user($lang, '\phpbb\datetime'); $this->service_name = 'auth.provider.oauth.service.testing'; $this->token_storage_table = 'phpbb_oauth_tokens'; diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 638ba0aaff..71f40c0b13 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -94,7 +94,9 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case // Set up avatar manager $this->manager = new \phpbb\avatar\manager($this->config, $avatar_drivers, $phpbb_container); $this->db = $this->new_dbal(); - $this->user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $this->user = new \phpbb\user($lang, '\phpbb\datetime'); } protected function avatar_drivers() @@ -277,7 +279,12 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case public function test_localize_errors() { - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + global $phpbb_root_path, $phpEx; + + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime') + ); $lang_array = array( array('FOOBAR_OFF', 'foobar_off'), array('FOOBAR_EXPLAIN', 'FOOBAR_EXPLAIN %s'), diff --git a/tests/console/cache/purge_test.php b/tests/console/cache/purge_test.php index 96988c1028..172fb0ecf3 100644 --- a/tests/console/cache/purge_test.php +++ b/tests/console/cache/purge_test.php @@ -32,6 +32,8 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case protected function setUp() { + global $phpbb_root_path, $phpEx; + if (file_exists($this->cache_dir)) { // cache directory possibly left after aborted @@ -45,7 +47,10 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case $this->db = $this->getMock('\phpbb\db\driver\driver_interface'); $this->config = new \phpbb\config\config(array('assets_version' => 1)); - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime') + ); } public function test_purge() diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index 7c098af004..076316217d 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -22,9 +22,14 @@ class phpbb_console_command_config_test extends phpbb_test_case public function setUp() { + global $phpbb_root_path, $phpEx; + $this->config = new \phpbb\config\config(array()); - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime') + ); $this->user->method('lang')->will($this->returnArgument(0)); } diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index 22423304be..3bbe2078ba 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -32,7 +32,12 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case protected function setUp() { - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + global $phpbb_root_path, $phpEx; + + $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $this->user->method('lang')->will($this->returnArgument(0)); } diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index 8638648898..51ea49b282 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -41,7 +41,10 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $config = $this->config = new \phpbb\config\config(array('cron_lock' => '0')); $this->lock = new \phpbb\lock\db('cron_lock', $this->config, $this->db); - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $this->user->method('lang')->will($this->returnArgument(0)); $this->task = new phpbb_cron_task_simple(); diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index dc966c37ae..b59b6493d4 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -309,7 +309,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ->will($this->returnValueMap(array( array('m_approve', 1, true), ))); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 28e463ecb5..6c5066119e 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -134,7 +134,9 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $config = new phpbb\config\config(array()); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 586bae8668..9ae4182673 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -134,7 +134,9 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $config = new phpbb\config\config(array()); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 9ae2d2fdc4..aaaf64330e 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -81,7 +81,9 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $config = new phpbb\config\config(array()); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 36ebf58374..6375ce8f6d 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -124,7 +124,9 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('\phpbb\auth\auth'); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $config = new phpbb\config\config(array()); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); @@ -175,7 +177,9 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('\phpbb\auth\auth'); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $config = new phpbb\config\config(array()); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 6c34f42167..f4d65f9ce3 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -88,7 +88,9 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('\phpbb\auth\auth'); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $config = new phpbb\config\config(array()); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index f1f369cce6..3e4b5fd38d 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -84,7 +84,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $this->user = new \phpbb\user($lang, '\phpbb\datetime');; $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php index 8968619bb5..7ecb546768 100644 --- a/tests/datetime/from_format_test.php +++ b/tests/datetime/from_format_test.php @@ -37,7 +37,11 @@ class phpbb_datetime_from_format_test extends phpbb_test_case */ public function test_from_format($timezone, $format, $expected) { - $user = new \phpbb\user('\phpbb\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->timezone = new DateTimeZone($timezone); $user->lang['datetime'] = array( 'TODAY' => 'Today', @@ -107,7 +111,11 @@ class phpbb_datetime_from_format_test extends phpbb_test_case */ public function test_relative_format_date($timestamp, $forcedate, $expected) { - $user = new \phpbb\user('\phpbb\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->timezone = new DateTimeZone('UTC'); $user->lang['datetime'] = array( 'TODAY' => 'Today', diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index fa2a8c33df..a665c8c13e 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -32,7 +32,9 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $db = $this->db = $this->new_dbal(); $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); - $user = $this->user = new \phpbb\user('\phpbb\user'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = $this->user = new \phpbb\user($lang, '\phpbb\datetime'); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/event/exception_listener_test.php b/tests/event/exception_listener_test.php index 4d3453cd83..608cde4f9b 100644 --- a/tests/event/exception_listener_test.php +++ b/tests/event/exception_listener_test.php @@ -79,7 +79,11 @@ class exception_listener extends phpbb_test_case ->disableOriginalConstructor() ->getMock(); - $user = new \phpbb\user('\phpbb\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->add_lang('common'); $exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $user); diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index c269eee987..101ab8616c 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -45,7 +45,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->db_tools = $factory->get($this->db); $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->phpEx = 'php'; - $this->user = new \phpbb\user('\phpbb\datetime'); $this->table_prefix = 'phpbb_'; $container = new phpbb_mock_container_builder(); @@ -75,8 +74,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case 'autoescape' => false, ) ); - $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $container = new phpbb_mock_container_builder(); @@ -104,6 +101,16 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->phpEx, $this->cache ); + + global $phpbb_root_path; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $this->phpEx); + $lang_loader->set_extension_manager($this->extension_manager); + $lang = new \phpbb\language\language($lang_loader); + $this->user = new \phpbb\user($lang, '\phpbb\datetime'); + + $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); } // Should fail from missing composer.json @@ -168,7 +175,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $manager->validate($field_name); $this->fail('Exception not triggered'); } - catch(\phpbb\extension\exception $e) + catch (\phpbb\extension\exception $e) { $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); $this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', $field_name)); @@ -234,7 +241,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $manager->validate($field_name); $this->fail('Exception not triggered'); } - catch(\phpbb\extension\exception $e) + catch (\phpbb\extension\exception $e) { $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); $this->assertEquals($message, $this->user->lang('META_FIELD_INVALID', $field_name)); @@ -259,10 +266,9 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case { $this->assertEquals(true, $manager->validate('enable')); } - catch(\phpbb\extension\exception $e) + catch (\phpbb\extension\exception $e) { $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $this->fail($message); } } diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php index cd1e37618a..bcf0c09fe4 100644 --- a/tests/functions/generate_string_list.php +++ b/tests/functions/generate_string_list.php @@ -22,7 +22,12 @@ class phpbb_generate_string_list_test extends phpbb_test_case { parent::setUp(); - $this->user = new \phpbb\user('\phpbb\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $this->user = $user; $this->user->data = array('user_lang' => 'en'); $this->user->add_lang('common'); } @@ -36,7 +41,7 @@ class phpbb_generate_string_list_test extends phpbb_test_case ), array( array('A'), - 'A', + 'A', ), array( array(2 => 'A', 3 => 'B'), diff --git a/tests/groupposition/legend_test.php b/tests/groupposition/legend_test.php index fe003e93a7..566a8a2935 100644 --- a/tests/groupposition/legend_test.php +++ b/tests/groupposition/legend_test.php @@ -33,11 +33,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case */ public function test_get_group_value($group_id, $expected, $throws_exception) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); if ($throws_exception) @@ -51,11 +53,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case public function test_get_group_count() { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\legend($db, $user); @@ -91,11 +95,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case */ public function test_add_group($group_id, $expected_added, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\legend($db, $user); @@ -179,11 +185,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case */ public function test_delete_group($group_id, $skip_group, $expected_deleted, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\legend($db, $user); @@ -234,11 +242,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case */ public function test_move_up($group_id, $excepted_moved, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\legend($db, $user); @@ -289,11 +299,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case */ public function test_move_down($group_id, $excepted_moved, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\legend($db, $user); @@ -387,11 +399,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case */ public function test_move($group_id, $increment, $excepted_moved, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\legend($db, $user); diff --git a/tests/groupposition/teampage_test.php b/tests/groupposition/teampage_test.php index 1e61e3ebfb..dff52f7a43 100644 --- a/tests/groupposition/teampage_test.php +++ b/tests/groupposition/teampage_test.php @@ -35,11 +35,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case */ public function test_get_group_value($group_id, $expected, $throws_exception) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); if ($throws_exception) @@ -53,11 +55,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case public function test_get_group_count() { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); @@ -137,11 +141,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case */ public function test_add_group_teampage($group_id, $parent_id, $expected_added, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); @@ -180,11 +186,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case */ public function test_add_category_teampage($group_name, $expected_added, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); @@ -247,11 +255,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case */ public function test_delete_group($group_id, $expected_deleted, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); @@ -299,11 +309,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case */ public function test_delete_teampage($teampage_id, $expected_deleted, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); @@ -462,11 +474,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case */ public function test_move($group_id, $move_delta, $excepted_moved, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); @@ -625,11 +639,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case */ public function test_move_teampage($teampage_id, $move_delta, $excepted_moved, $expected) { - global $cache; + global $cache, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = array(); $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); diff --git a/tests/language/language_test.php b/tests/language/language_test.php new file mode 100644 index 0000000000..95de403bd4 --- /dev/null +++ b/tests/language/language_test.php @@ -0,0 +1,210 @@ + + * @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_language_test extends phpbb_test_case +{ + /** @var \phpbb\language\language */ + protected $lang; + + public function setUp() + { + global $phpbb_root_path, $phpEx; + + // Set up language service + $this->lang = new \phpbb\language\language( + new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx) + ); + + // Set up language data for testing + $reflection_class = new ReflectionClass('\phpbb\language\language'); + + // Set default language files loaded flag to true + $loaded_flag = $reflection_class->getProperty('common_language_files_loaded'); + $loaded_flag->setAccessible(true); + $loaded_flag->setValue($this->lang, true); + + // Set up test language data + $lang_array = $reflection_class->getProperty('lang'); + $lang_array->setAccessible(true); + $lang_array->setValue($this->lang, $this->get_test_data_set()); + } + + public function test_lang() + { + // No param + $this->assertEquals($this->lang->lang('FOO'), 'BAR'); + $this->assertEquals($this->lang->lang('EMPTY'), ''); + $this->assertEquals($this->lang->lang('ZERO'), '0'); + + // Invalid index + $this->assertEquals($this->lang->lang('VOID'), 'VOID'); + + // Unnecessary param + $this->assertEquals($this->lang->lang('FOO', 2), 'BAR'); + $this->assertEquals($this->lang->lang('FOO', 2, 3), 'BAR'); + $this->assertEquals($this->lang->lang('FOO', 2, 3, 'BARZ'), 'BAR'); + + // String + $this->assertEquals($this->lang->lang('STR', 24, 'x', 42), '24 x, 42 topics'); + $this->assertEquals($this->lang->lang('STR2', 64), '64 foos'); + + // Array + $this->assertEquals($this->lang->lang('ARRY', 0), 'No posts'); + $this->assertEquals($this->lang->lang('ARRY', 1), '1 post'); + $this->assertEquals($this->lang->lang('ARRY', 2), '2 posts'); + $this->assertEquals($this->lang->lang('ARRY', 123), '123 posts'); + + // Empty array returns the language key + $this->assertEquals($this->lang->lang('ARRY_EMPTY', 123), 'ARRY_EMPTY'); + + // No 0 key defined + $this->assertEquals($this->lang->lang('ARRY_NO_ZERO', 0), '0 posts'); + $this->assertEquals($this->lang->lang('ARRY_NO_ZERO', 1), '1 post'); + $this->assertEquals($this->lang->lang('ARRY_NO_ZERO', 2), '2 posts'); + + // Array with missing keys + $this->assertEquals($this->lang->lang('ARRY_MISSING', 2), '2 post'); + + // Floats as array key + $this->assertEquals($this->lang->lang('ARRY_FLOAT', 1.3), '1 post'); + $this->assertEquals($this->lang->lang('ARRY_FLOAT', 2.0), '2.0 posts'); + $this->assertEquals($this->lang->lang('ARRY_FLOAT', 2.51), '2.5 posts'); + + // Use sub key, if first paramenter is an array + $this->assertEquals($this->lang->lang(array('dateformat', 'AGO'), 2), '2 seconds'); + + // ticket PHPBB3-9949 - use first int to determinate the plural-form to use + $this->assertEquals($this->lang->lang('ARRY', 1, 2), '1 post'); + $this->assertEquals($this->lang->lang('ARRY', 1, 's', 2), '1 post'); + } + + public function test_lang_plural_rules() + { + $this->assertEquals($this->lang->lang('PLURAL_ARRY', 0), '0 is 0'); + $this->assertEquals($this->lang->lang('PLURAL_ARRY', 1), '1 is 1'); + $this->assertEquals($this->lang->lang('PLURAL_ARRY', 103), '103 ends with 01-10'); + $this->assertEquals($this->lang->lang('PLURAL_ARRY', 15), '15 ends with 11-19'); + $this->assertEquals($this->lang->lang('PLURAL_ARRY', 300), '300 is part of the last rule'); + } + + public function test_lang_bc() + { + $user = new \phpbb\user($this->lang, '\phpbb\datetime'); + + // Test lang array access + $this->assertEquals($user->lang['FOO'], 'BAR'); + + // No param + $this->assertEquals($user->lang('FOO'), 'BAR'); + $this->assertEquals($user->lang('EMPTY'), ''); + $this->assertEquals($user->lang('ZERO'), '0'); + + // Invalid index + $this->assertEquals($user->lang('VOID'), 'VOID'); + + // Unnecessary param + $this->assertEquals($user->lang('FOO', 2), 'BAR'); + $this->assertEquals($user->lang('FOO', 2, 3), 'BAR'); + $this->assertEquals($user->lang('FOO', 2, 3, 'BARZ'), 'BAR'); + + // String + $this->assertEquals($user->lang('STR', 24, 'x', 42), '24 x, 42 topics'); + $this->assertEquals($user->lang('STR2', 64), '64 foos'); + + // Array + $this->assertEquals($user->lang('ARRY', 0), 'No posts'); + $this->assertEquals($user->lang('ARRY', 1), '1 post'); + $this->assertEquals($user->lang('ARRY', 2), '2 posts'); + $this->assertEquals($user->lang('ARRY', 123), '123 posts'); + + // Empty array returns the language key + $this->assertEquals($user->lang('ARRY_EMPTY', 123), 'ARRY_EMPTY'); + + // No 0 key defined + $this->assertEquals($user->lang('ARRY_NO_ZERO', 0), '0 posts'); + $this->assertEquals($user->lang('ARRY_NO_ZERO', 1), '1 post'); + $this->assertEquals($user->lang('ARRY_NO_ZERO', 2), '2 posts'); + + // Array with missing keys + $this->assertEquals($user->lang('ARRY_MISSING', 2), '2 post'); + + // Floats as array key + $this->assertEquals($user->lang('ARRY_FLOAT', 1.3), '1 post'); + $this->assertEquals($user->lang('ARRY_FLOAT', 2.0), '2.0 posts'); + $this->assertEquals($user->lang('ARRY_FLOAT', 2.51), '2.5 posts'); + + // Use sub key, if first paramenter is an array + $this->assertEquals($user->lang(array('dateformat', 'AGO'), 2), '2 seconds'); + + // ticket PHPBB3-9949 - use first int to determinate the plural-form to use + $this->assertEquals($user->lang('ARRY', 1, 2), '1 post'); + $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post'); + } + + public function test_lang_plural_rules_bc() + { + $user = new \phpbb\user($this->lang, '\phpbb\datetime'); + + // ticket PHPBB3-10345 - different plural rules, not just 0/1/2+ + $this->assertEquals($user->lang('PLURAL_ARRY', 0), '0 is 0'); + $this->assertEquals($user->lang('PLURAL_ARRY', 1), '1 is 1'); + $this->assertEquals($user->lang('PLURAL_ARRY', 103), '103 ends with 01-10'); + $this->assertEquals($user->lang('PLURAL_ARRY', 15), '15 ends with 11-19'); + $this->assertEquals($user->lang('PLURAL_ARRY', 300), '300 is part of the last rule'); + } + + protected function get_test_data_set() + { + return array( + 'FOO' => 'BAR', + 'BARZ' => 'PENG', + 'EMPTY' => '', + 'ZERO' => '0', + 'STR' => '%d %s, %d topics', + 'STR2' => '%d foos', + 'ARRY' => array( + 0 => 'No posts', // 0 + 1 => '1 post', // 1 + 2 => '%d posts', // 2+ + ), + 'ARRY_NO_ZERO' => array( + 1 => '1 post', // 1 + 2 => '%d posts', // 0, 2+ + ), + 'ARRY_MISSING' => array( + 1 => '%d post', // 1 + //Missing second plural + ), + 'ARRY_FLOAT' => array( + 1 => '1 post', // 1.x + 2 => '%1$.1f posts', // 0.x, 2+.x + ), + 'ARRY_EMPTY' => array( + ), + 'dateformat' => array( + 'AGO' => array( + 1 => '%d second', + 2 => '%d seconds', + ), + ), + 'PLURAL_RULE' => 13, + 'PLURAL_ARRY' => array( + 0 => '%d is 0', // 0 + 1 => '%d is 1', // 1 + 2 => '%d ends with 01-10', // ending with 01-10 + 3 => '%d ends with 11-19', // ending with 11-19 + 4 => '%d is part of the last rule', // everything else + ), + ); + } +} diff --git a/tests/log/add_test.php b/tests/log/add_test.php index bacc0c76f7..cfc592a464 100644 --- a/tests/log/add_test.php +++ b/tests/log/add_test.php @@ -27,7 +27,9 @@ class phpbb_log_add_test extends phpbb_database_test_case $db = $this->new_dbal(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $auth = $this->getMock('\phpbb\auth\auth'); $log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); @@ -56,7 +58,9 @@ class phpbb_log_add_test extends phpbb_database_test_case $db = $this->new_dbal(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $auth = $this->getMock('\phpbb\auth\auth'); $log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); diff --git a/tests/log/delete_test.php b/tests/log/delete_test.php index ec43182a0c..fe4c3835cb 100644 --- a/tests/log/delete_test.php +++ b/tests/log/delete_test.php @@ -30,7 +30,9 @@ class phpbb_log_delete_test extends phpbb_database_test_case $db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->data['user_id'] = 1; $auth = $this->getMock('\phpbb\auth\auth'); diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php index 78949734a9..cdfeb52996 100644 --- a/tests/log/function_add_log_test.php +++ b/tests/log/function_add_log_test.php @@ -161,7 +161,10 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case $db = $this->new_dbal(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $auth = $this->getMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); diff --git a/tests/notification/base.php b/tests/notification/base.php index 162feae557..c9d57a5934 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -56,7 +56,10 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case 'allow_topic_notify' => true, 'allow_forum_notify' => true, )); - $user = $this->user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $this->user = $user; $this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $auth = $this->auth = new phpbb_mock_notifications_auth(); $cache = $this->cache = new \phpbb\cache\service( @@ -66,7 +69,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $phpbb_root_path, $phpEx ); - + $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = $this->container = new phpbb_mock_container_builder(); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 2d621f82d3..1412fb8509 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -83,7 +83,10 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); // User - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $user->ip = ''; $user->data = array( 'user_id' => 2, diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index 5886c49512..bcbdc81ef0 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -51,7 +51,9 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case array('u_viewprofile', 1, false), ))); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->data = array('user_lang' => 'en'); $user->add_lang('common'); @@ -71,7 +73,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case 'topic_title' => 'Test', 'poster_id' => 2, 'post_username' => 'A', - 'responders' => null, + 'responders' => null, ), 'Reply from A in topic:', ), @@ -82,7 +84,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case 'post_username' => 'A', 'responders' => array( array('username' => '', 'poster_id' => 3), - ), + ), ), 'Reply from A and B in topic:', ), @@ -94,7 +96,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case 'responders' => array( array('username' => '', 'poster_id' => 3), array('username' => '', 'poster_id' => 4), - ), + ), ), 'Reply from A, B, and C in topic:', ), @@ -107,7 +109,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case array('username' => '', 'poster_id' => 3), array('username' => '', 'poster_id' => 4), array('username' => '', 'poster_id' => 5), - ), + ), ), 'Reply from A, B, C, and D in topic:', ), @@ -121,7 +123,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case array('username' => '', 'poster_id' => 4), array('username' => '', 'poster_id' => 5), array('username' => '', 'poster_id' => 6), - ), + ), ), 'Reply from A, B, C, and 2 others in topic:', ), diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index c705e67135..4916665a72 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -26,10 +26,13 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case { parent::setUp(); - global $phpbb_dispatcher; + global $phpbb_dispatcher, $phpbb_root_path, $phpEx; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $this->user->expects($this->any()) ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); diff --git a/tests/plupload/plupload_test.php b/tests/plupload/plupload_test.php index 2f47bf2b39..aa7793567d 100644 --- a/tests/plupload/plupload_test.php +++ b/tests/plupload/plupload_test.php @@ -34,6 +34,10 @@ class phpbb_plupload_test extends phpbb_test_case */ public function test_generate_resize_string($config_width, $config_height, $expected) { + global $phpbb_root_path, $phpEx; + + $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $config = new \phpbb\config\config(array( 'img_max_width' => $config_width, 'img_max_height' => $config_height, @@ -43,7 +47,7 @@ class phpbb_plupload_test extends phpbb_test_case '', $config, new phpbb_mock_request, - new \phpbb\user('\phpbb\datetime'), + new \phpbb\user($lang, '\phpbb\datetime'), new \phpbb\php\ini, new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)) ); diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php index 41c40ddb4b..10239172c3 100644 --- a/tests/profilefields/type_bool_test.php +++ b/tests/profilefields/type_bool_test.php @@ -25,7 +25,12 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case */ public function setUp() { - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + global $phpbb_root_path, $phpEx; + + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $user->expects($this->any()) ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); diff --git a/tests/profilefields/type_date_test.php b/tests/profilefields/type_date_test.php index 123955198e..e0807b2f9b 100644 --- a/tests/profilefields/type_date_test.php +++ b/tests/profilefields/type_date_test.php @@ -25,7 +25,12 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case */ public function setUp() { - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + global $phpbb_root_path, $phpEx; + + $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $this->user->expects($this->any()) ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php index 3845a8e96b..ab02353fb9 100644 --- a/tests/profilefields/type_dropdown_test.php +++ b/tests/profilefields/type_dropdown_test.php @@ -25,7 +25,12 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case */ public function setUp() { - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + global $phpbb_root_path, $phpEx; + + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $user->expects($this->any()) ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); diff --git a/tests/profilefields/type_googleplus_test.php b/tests/profilefields/type_googleplus_test.php index f3db6ef01f..6faf939231 100644 --- a/tests/profilefields/type_googleplus_test.php +++ b/tests/profilefields/type_googleplus_test.php @@ -21,7 +21,11 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case { parent::setUp(); - $user = new \phpbb\user('\phpbb\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->add_lang('ucp'); $request = $this->getMock('\phpbb\request\request'); $template = $this->getMock('\phpbb\template\template'); diff --git a/tests/profilefields/type_int_test.php b/tests/profilefields/type_int_test.php index 07b22525e2..33f3f575c8 100644 --- a/tests/profilefields/type_int_test.php +++ b/tests/profilefields/type_int_test.php @@ -24,7 +24,12 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case */ public function setUp() { - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + global $phpbb_root_path, $phpEx; + + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $user->expects($this->any()) ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php index 0417afbfab..447ab32a00 100644 --- a/tests/profilefields/type_string_test.php +++ b/tests/profilefields/type_string_test.php @@ -28,9 +28,12 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case */ public function setUp() { - global $request, $user, $cache; + global $request, $user, $cache, $phpbb_root_path, $phpEx; - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $cache = new phpbb_mock_cache; $user->expects($this->any()) ->method('lang') diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php index cc37f04f30..a0f93fe1f6 100644 --- a/tests/profilefields/type_url_test.php +++ b/tests/profilefields/type_url_test.php @@ -26,7 +26,12 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case */ public function setUp() { - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + global $phpbb_root_path, $phpEx; + + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $user->expects($this->any()) ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); diff --git a/tests/security/base.php b/tests/security/base.php index 5888a2bf2a..d2abdbc362 100644 --- a/tests/security/base.php +++ b/tests/security/base.php @@ -49,7 +49,9 @@ abstract class phpbb_security_test_base extends phpbb_test_case $phpbb_filesystem = new \phpbb\filesystem\filesystem(); // Set no user and trick a bit to circumvent errors - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->lang = true; $user->browser = $this->server['HTTP_USER_AGENT']; $user->referer = ''; diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php index f739a78d84..63f35bc758 100644 --- a/tests/template/template_allfolder_test.php +++ b/tests/template/template_allfolder_test.php @@ -28,7 +28,10 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case $defaults = $this->config_defaults(); $config = new \phpbb\config\config(array_merge($defaults, $new_config)); - $this->user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $this->user = $user; $path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 29ff669efc..7e2020ba09 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -15,6 +15,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_template_template_test_case extends phpbb_test_case { + protected $lang; protected $template; protected $template_path; protected $user; @@ -24,6 +25,17 @@ class phpbb_template_template_test_case extends phpbb_test_case // Keep the contents of the cache for debugging? const PRESERVE_CACHE = true; + static protected $language_reflection_lang; + + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + $reflection = new ReflectionClass('\phpbb\language\language'); + self::$language_reflection_lang = $reflection->getProperty('lang'); + self::$language_reflection_lang->setAccessible(true); + } + protected function display($handle) { ob_start(); @@ -65,7 +77,10 @@ class phpbb_template_template_test_case extends phpbb_test_case $defaults = $this->config_defaults(); $config = new \phpbb\config\config(array_merge($defaults, $new_config)); - $this->user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $this->lang = $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $this->user = $user; $path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( @@ -145,7 +160,10 @@ class phpbb_template_template_test_case extends phpbb_test_case { foreach ($lang_vars as $name => $value) { - $this->user->lang[$name] = $value; + self::$language_reflection_lang->setValue($this->lang, array_merge( + self::$language_reflection_lang->getValue($this->lang), + array($name => $value) + )); } } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index c1ec287477..2be6c46a6d 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -614,7 +614,10 @@ class phpbb_functional_test_case extends phpbb_test_case $db = $this->get_db(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $auth = $this->getMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); @@ -653,7 +656,10 @@ class phpbb_functional_test_case extends phpbb_test_case $db = $this->get_db(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $auth = $this->getMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 0f9b049f44..685014d3e4 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -474,7 +474,9 @@ class phpbb_test_case_helpers } else { - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewcensors', true); $user->optionset('viewflash', true); $user->optionset('viewimg', true); diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 91458541d3..3c0bbb96c7 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -157,7 +157,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case 'banana', function ($phpbb_container) { - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewcensors', false); $phpbb_container->set('user', $user); @@ -168,7 +172,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case 'banana', function ($phpbb_container) { - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewcensors', false); $config = new \phpbb\config\config(array('allow_nocensors' => true)); @@ -182,7 +190,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case 'apple', function ($phpbb_container, $test) { - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewcensors', false); $config = new \phpbb\config\config(array('allow_nocensors' => true)); @@ -207,7 +219,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case 'http://localhost/foo.swf', function ($phpbb_container) { - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewflash', false); $phpbb_container->set('user', $user); @@ -222,7 +238,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case 'http://localhost/mrgreen.gif', function ($phpbb_container) { - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewimg', false); $phpbb_container->set('user', $user); @@ -237,7 +257,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ':)', function ($phpbb_container) { - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('smilies', false); $phpbb_container->set('user', $user); @@ -291,9 +315,13 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case 2 => 'bold' ); + global $phpbb_root_path, $phpEx; + foreach ($tests as $style_id => $expected) { - $user = new \phpbb\user('\\phpbb\\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->style = array('style_id' => $style_id); $phpbb_container = new phpbb_mock_container_builder; @@ -311,10 +339,12 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case public function test_style_inheritance1() { - global $phpbb_container; + global $phpbb_container, $phpbb_root_path, $phpEx; // Style 3 inherits from 2 which inherits from 1. Only style 1 has a bbcode.html - $user = new \phpbb\user('\\phpbb\\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->style = array('style_id' => 3); $phpbb_container = new phpbb_mock_container_builder; @@ -331,7 +361,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case public function test_style_inheritance2() { - global $phpbb_container; + global $phpbb_container, $phpbb_root_path, $phpEx; // Style 5 inherits from 4, but both have a bbcode.html $tests = array( @@ -341,7 +371,9 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case foreach ($tests as $style_id => $expected) { - $user = new \phpbb\user('\\phpbb\\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->style = array('style_id' => $style_id); $phpbb_container = new phpbb_mock_container_builder; diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index fe83938c0b..f2b0d6c78b 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -34,8 +34,12 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca { global $cache, $user; + global $phpbb_root_path, $phpEx; + $cache = new phpbb_mock_cache; - $user = new \phpbb\user('\\phpbb\\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewcensors', true); $user->optionset('viewflash', true); $user->optionset('viewimg', true); @@ -66,7 +70,11 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $phpbb_container = new phpbb_mock_container_builder; - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewcensors', false); $config = new \phpbb\config\config(array('allow_nocensors' => true)); @@ -153,7 +161,11 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca true, function ($phpbb_container) { - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewflash', false); $phpbb_container->set('user', $user); @@ -169,7 +181,11 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca true, function ($phpbb_container) { - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('viewimg', false); $phpbb_container->set('user', $user); @@ -185,7 +201,11 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca true, function ($phpbb_container) { - $user = new \phpbb\user('\\phpbb\\datetime'); + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->optionset('smilies', false); $phpbb_container->set('user', $user); diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php deleted file mode 100644 index bb11bb63cb..0000000000 --- a/tests/user/lang_test.php +++ /dev/null @@ -1,119 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - -class phpbb_user_lang_test extends phpbb_test_case -{ - public function test_user_lang_sprintf() - { - $user = new \phpbb\user('\phpbb\datetime'); - $user->lang = array( - 'FOO' => 'BAR', - 'BARZ' => 'PENG', - 'EMPTY' => '', - 'ZERO' => '0', - 'STR' => '%d %s, %d topics', - 'STR2' => '%d foos', - 'ARRY' => array( - 0 => 'No posts', // 0 - 1 => '1 post', // 1 - 2 => '%d posts', // 2+ - ), - 'ARRY_NO_ZERO' => array( - 1 => '1 post', // 1 - 2 => '%d posts', // 0, 2+ - ), - 'ARRY_MISSING' => array( - 1 => '%d post', // 1 - //Missing second plural - ), - 'ARRY_FLOAT' => array( - 1 => '1 post', // 1.x - 2 => '%1$.1f posts', // 0.x, 2+.x - ), - 'ARRY_EMPTY' => array( - ), - 'dateformat' => array( - 'AGO' => array( - 1 => '%d second', - 2 => '%d seconds', - ), - ), - ); - - // No param - $this->assertEquals($user->lang('FOO'), 'BAR'); - $this->assertEquals($user->lang('EMPTY'), ''); - $this->assertEquals($user->lang('ZERO'), '0'); - - // Invalid index - $this->assertEquals($user->lang('VOID'), 'VOID'); - - // Unnecessary param - $this->assertEquals($user->lang('FOO', 2), 'BAR'); - $this->assertEquals($user->lang('FOO', 2, 3), 'BAR'); - $this->assertEquals($user->lang('FOO', 2, 3, 'BARZ'), 'BAR'); - - // String - $this->assertEquals($user->lang('STR', 24, 'x', 42), '24 x, 42 topics'); - $this->assertEquals($user->lang('STR2', 64), '64 foos'); - - // Array - $this->assertEquals($user->lang('ARRY', 0), 'No posts'); - $this->assertEquals($user->lang('ARRY', 1), '1 post'); - $this->assertEquals($user->lang('ARRY', 2), '2 posts'); - $this->assertEquals($user->lang('ARRY', 123), '123 posts'); - - // Empty array returns the language key - $this->assertEquals($user->lang('ARRY_EMPTY', 123), 'ARRY_EMPTY'); - - // No 0 key defined - $this->assertEquals($user->lang('ARRY_NO_ZERO', 0), '0 posts'); - $this->assertEquals($user->lang('ARRY_NO_ZERO', 1), '1 post'); - $this->assertEquals($user->lang('ARRY_NO_ZERO', 2), '2 posts'); - - // Array with missing keys - $this->assertEquals($user->lang('ARRY_MISSING', 2), '2 post'); - - // Floats as array key - $this->assertEquals($user->lang('ARRY_FLOAT', 1.3), '1 post'); - $this->assertEquals($user->lang('ARRY_FLOAT', 2.0), '2.0 posts'); - $this->assertEquals($user->lang('ARRY_FLOAT', 2.51), '2.5 posts'); - - // Use sub key, if first paramenter is an array - $this->assertEquals($user->lang(array('dateformat', 'AGO'), 2), '2 seconds'); - - // ticket PHPBB3-9949 - use first int to determinate the plural-form to use - $this->assertEquals($user->lang('ARRY', 1, 2), '1 post'); - $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post'); - - // ticket PHPBB3-10345 - different plural rules, not just 0/1/2+ - $user = new \phpbb\user('\phpbb\datetime'); - $user->lang = array( - 'PLURAL_RULE' => 13, - 'ARRY' => array( - 0 => '%d is 0', // 0 - 1 => '%d is 1', // 1 - 2 => '%d ends with 01-10', // ending with 01-10 - 3 => '%d ends with 11-19', // ending with 11-19 - 4 => '%d is part of the last rule', // everything else - ), - ); - $this->assertEquals($user->lang('ARRY', 0), '0 is 0'); - $this->assertEquals($user->lang('ARRY', 1), '1 is 1'); - $this->assertEquals($user->lang('ARRY', 103), '103 ends with 01-10'); - $this->assertEquals($user->lang('ARRY', 15), '15 ends with 11-19'); - $this->assertEquals($user->lang('ARRY', 300), '300 is part of the last rule'); - } -} diff --git a/tests/version/version_fetch_test.php b/tests/version/version_fetch_test.php index cfc87183cf..6ecc9b7223 100644 --- a/tests/version/version_fetch_test.php +++ b/tests/version/version_fetch_test.php @@ -28,13 +28,15 @@ class phpbb_version_helper_fetch_test extends phpbb_test_case ->disableOriginalConstructor() ->getMock(); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $this->version_helper = new \phpbb\version_helper( $this->cache, new \phpbb\config\config(array( 'version' => '3.1.0', )), new \phpbb\file_downloader(), - new \phpbb\user('\phpbb\datetime') + new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime') ); } diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php index 65ae7646b9..05ae320713 100644 --- a/tests/version/version_helper_remote_test.php +++ b/tests/version/version_helper_remote_test.php @@ -37,13 +37,15 @@ class version_helper_remote_test extends \phpbb_test_case ->will($this->returnValue(false)); $this->file_downloader = new phpbb_mock_file_downloader(); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $this->version_helper = new \phpbb\version_helper( $this->cache, $config, $this->file_downloader, - new \phpbb\user('\phpbb\datetime') + new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime') ); - $this->user = new \phpbb\user('\phpbb\datetime'); + $this->user = new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime'); $this->user->add_lang('acp/common'); } diff --git a/tests/version/version_test.php b/tests/version/version_test.php index 528f1602d6..05577f6a18 100644 --- a/tests/version/version_test.php +++ b/tests/version/version_test.php @@ -25,13 +25,15 @@ class phpbb_version_helper_test extends phpbb_test_case ->disableOriginalConstructor() ->getMock(); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $this->version_helper = new \phpbb\version_helper( $this->cache, new \phpbb\config\config(array( 'version' => '3.1.0', )), new \phpbb\file_downloader(), - new \phpbb\user('\phpbb\datetime') + new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime') ); } @@ -199,6 +201,11 @@ class phpbb_version_helper_test extends phpbb_test_case */ public function test_get_suggested_updates($current_version, $versions, $expected) { + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $version_helper = $this ->getMockBuilder('\phpbb\version_helper') ->setMethods(array( @@ -210,7 +217,7 @@ class phpbb_version_helper_test extends phpbb_test_case 'version' => $current_version, )), new \phpbb\file_downloader(), - new \phpbb\user('\phpbb\datetime'), + new \phpbb\user($lang, '\phpbb\datetime'), )) ->getMock() ; @@ -310,6 +317,11 @@ class phpbb_version_helper_test extends phpbb_test_case */ public function test_get_latest_on_current_branch($current_version, $versions, $expected) { + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $version_helper = $this ->getMockBuilder('\phpbb\version_helper') ->setMethods(array( @@ -321,7 +333,7 @@ class phpbb_version_helper_test extends phpbb_test_case 'version' => $current_version, )), new \phpbb\file_downloader(), - new \phpbb\user('\phpbb\datetime'), + new \phpbb\user($lang, '\phpbb\datetime'), )) ->getMock() ; -- cgit v1.2.1 From 74dbaac0394f45955553ff46515404fe5b06bfba Mon Sep 17 00:00:00 2001 From: MateBartus Date: Thu, 30 Apr 2015 22:40:17 +0200 Subject: [ticket/13800] Make router's extension manager dependency optional PHPBB3-13800 --- tests/controller/common_helper_route.php | 2 +- tests/controller/controller_test.php | 2 +- tests/pagination/pagination_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 3e4b5fd38d..6910530279 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -120,7 +120,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($this->filesystem, $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router = new phpbb_mock_router($this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 5c0290ee6f..5781d3ebc1 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,7 +40,7 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 4916665a72..67c3d0a30f 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -41,7 +41,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $router = new phpbb_mock_router($filesystem, $manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new phpbb_mock_router($filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $manager); $router->find_routing_files($manager->all_enabled(false)); $router->find(dirname(__FILE__) . '/'); -- cgit v1.2.1 From b3cc20a575da12e7b66f3883dcc7f0eb6ca82ad8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 May 2015 10:09:37 +0200 Subject: [ticket/13782] Rename null driver to dummy for PHP7 compatibility PHPBB3-13782 --- tests/cache/null_driver_test.php | 2 +- tests/dbal/migrator_tool_module_test.php | 2 +- tests/dbal/migrator_tool_permission_test.php | 2 +- tests/functions_user/group_user_attributes_test.php | 2 +- tests/notification/base.php | 2 +- tests/notification/submit_post_base.php | 2 +- tests/notification/user_list_trim_test.php | 2 +- tests/test_framework/phpbb_functional_test_case.php | 6 +++--- tests/version/version_helper_remote_test.php | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php index b9f96732f5..d5af57b009 100644 --- a/tests/cache/null_driver_test.php +++ b/tests/cache/null_driver_test.php @@ -24,7 +24,7 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case { parent::setUp(); - $this->driver = new \phpbb\cache\driver\null; + $this->driver = new \phpbb\cache\driver\dummy; } public function test_get_put() diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index a665c8c13e..695a7e7a7f 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -31,7 +31,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $skip_add_log = true; $db = $this->db = $this->new_dbal(); - $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); + $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = $this->user = new \phpbb\user($lang, '\phpbb\datetime'); diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php index 4453fbf123..3d190e7a11 100644 --- a/tests/dbal/migrator_tool_permission_test.php +++ b/tests/dbal/migrator_tool_permission_test.php @@ -28,7 +28,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case parent::setup(); $db = $this->db = $this->new_dbal(); - $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); + $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); $this->auth = new \phpbb\auth\auth(); $this->tool = new \phpbb\db\migration\tool\permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx); diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index 99a15b32bf..6ccada44f8 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -139,7 +139,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_clear_prefetch'); - $cache_driver = new \phpbb\cache\driver\null(); + $cache_driver = new \phpbb\cache\driver\dummy(); $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container ->expects($this->any()) diff --git a/tests/notification/base.php b/tests/notification/base.php index c9d57a5934..a1ebecd6f9 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -63,7 +63,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $auth = $this->auth = new phpbb_mock_notifications_auth(); $cache = $this->cache = new \phpbb\cache\service( - new \phpbb\cache\driver\null(), + new \phpbb\cache\driver\dummy(), $this->config, $this->db, $phpbb_root_path, diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 1412fb8509..d7a711e007 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -72,7 +72,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,)); $cache = new \phpbb\cache\service( - new \phpbb\cache\driver\null(), + new \phpbb\cache\driver\dummy(), $config, $db, $phpbb_root_path, diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index bcbdc81ef0..f7b4fcb215 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -35,7 +35,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $config = new \phpbb\config\config(array()); $cache = new \phpbb\cache\service( - new \phpbb\cache\driver\null(), + new \phpbb\cache\driver\dummy(), $config, $db, $phpbb_root_path, diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 2be6c46a6d..0fec3c2dff 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -574,7 +574,7 @@ class phpbb_functional_test_case extends phpbb_test_case } $cache = new phpbb_mock_null_cache; - $cache_driver = new \phpbb\cache\driver\null(); + $cache_driver = new \phpbb\cache\driver\dummy(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('cache.driver', $cache_driver); $phpbb_notifications = new phpbb_mock_notification_manager(); @@ -623,7 +623,7 @@ class phpbb_functional_test_case extends phpbb_test_case $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $cache = new phpbb_mock_null_cache; - $cache_driver = new \phpbb\cache\driver\null(); + $cache_driver = new \phpbb\cache\driver\dummy(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('cache.driver', $cache_driver); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); @@ -665,7 +665,7 @@ class phpbb_functional_test_case extends phpbb_test_case $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $cache = new phpbb_mock_null_cache; - $cache_driver = new \phpbb\cache\driver\null(); + $cache_driver = new \phpbb\cache\driver\dummy(); $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container ->expects($this->any()) diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php index 05ae320713..724c4c970c 100644 --- a/tests/version/version_helper_remote_test.php +++ b/tests/version/version_helper_remote_test.php @@ -30,7 +30,7 @@ class version_helper_remote_test extends \phpbb_test_case )); $container = new \phpbb_mock_container_builder(); $db = new \phpbb\db\driver\factory($container); - $this->cache = $this->getMock('\phpbb\cache\service', array('get'), array(new \phpbb\cache\driver\null(), $config, $db, '../../', 'php')); + $this->cache = $this->getMock('\phpbb\cache\service', array('get'), array(new \phpbb\cache\driver\dummy(), $config, $db, '../../', 'php')); $this->cache->expects($this->any()) ->method('get') ->with($this->anything()) -- cgit v1.2.1 From 232f71dae43df9794184961431aca81d0e4652da Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 May 2015 10:11:28 +0200 Subject: [ticket/13782] Rename null log to dummy for PHP7 compatibility PHPBB3-13782 --- tests/console/cache/purge_test.php | 2 +- tests/notification/group_request_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/console/cache/purge_test.php b/tests/console/cache/purge_test.php index 172fb0ecf3..6c92660580 100644 --- a/tests/console/cache/purge_test.php +++ b/tests/console/cache/purge_test.php @@ -91,7 +91,7 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case public function get_command_tester() { $application = new Application(); - $application->add(new purge($this->user, $this->cache, $this->db, $this->getMock('\phpbb\auth\auth'), new \phpbb\log\null(), $this->config)); + $application->add(new purge($this->user, $this->cache, $this->db, $this->getMock('\phpbb\auth\auth'), new \phpbb\log\dummy(), $this->config)); $command = $application->find('cache:purge'); $this->command_name = $command->getName(); diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 6a56a38c45..a24808fbbd 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -50,7 +50,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas $this->cache->get_driver() )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $phpbb_log = new \phpbb\log\null(); + $phpbb_log = new \phpbb\log\dummy(); $this->get_test_case_helpers()->set_s9e_services(); // Now on to the actual test -- cgit v1.2.1 From 292d0ab382563143082bd8809ec189d646a31e0e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 May 2015 10:12:41 +0200 Subject: [ticket/13782] Rename null driver test to dummy driver test PHPBB3-13782 --- tests/cache/dummy_driver_test.php | 77 +++++++++++++++++++++++++++++++++++++++ tests/cache/null_driver_test.php | 77 --------------------------------------- 2 files changed, 77 insertions(+), 77 deletions(-) create mode 100644 tests/cache/dummy_driver_test.php delete mode 100644 tests/cache/null_driver_test.php (limited to 'tests') diff --git a/tests/cache/dummy_driver_test.php b/tests/cache/dummy_driver_test.php new file mode 100644 index 0000000000..6cb6b73729 --- /dev/null +++ b/tests/cache/dummy_driver_test.php @@ -0,0 +1,77 @@ + +* @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_cache_dummy_driver_test extends phpbb_database_test_case +{ + protected $driver; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + protected function setUp() + { + parent::setUp(); + + $this->driver = new \phpbb\cache\driver\dummy; + } + + public function test_get_put() + { + $this->assertSame(false, $this->driver->get('key')); + + $this->driver->put('key', 'value'); + + // null driver does not cache + $this->assertSame(false, $this->driver->get('key')); + } + + public function test_purge() + { + $this->assertNull($this->driver->purge()); + } + + public function test_destroy() + { + $this->assertNull($this->driver->destroy('foo')); + } + + public function test_cache_sql() + { + global $db, $cache, $phpbb_root_path, $phpEx; + $config = new phpbb\config\config(array()); + $db = $this->new_dbal(); + $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_root_path, $phpEx); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); + + $sql = 'DELETE FROM phpbb_config'; + $result = $db->sql_query($sql); + + // As null cache driver does not actually cache, + // this should return no results + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + + $this->assertSame(false, $db->sql_fetchrow($result)); + + $db->sql_close(); + } +} diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php deleted file mode 100644 index d5af57b009..0000000000 --- a/tests/cache/null_driver_test.php +++ /dev/null @@ -1,77 +0,0 @@ - -* @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_cache_null_driver_test extends phpbb_database_test_case -{ - protected $driver; - - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); - } - - protected function setUp() - { - parent::setUp(); - - $this->driver = new \phpbb\cache\driver\dummy; - } - - public function test_get_put() - { - $this->assertSame(false, $this->driver->get('key')); - - $this->driver->put('key', 'value'); - - // null driver does not cache - $this->assertSame(false, $this->driver->get('key')); - } - - public function test_purge() - { - $this->assertNull($this->driver->purge()); - } - - public function test_destroy() - { - $this->assertNull($this->driver->destroy('foo')); - } - - public function test_cache_sql() - { - global $db, $cache, $phpbb_root_path, $phpEx; - $config = new phpbb\config\config(array()); - $db = $this->new_dbal(); - $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_root_path, $phpEx); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql, 300); - $first_result = $db->sql_fetchrow($result); - $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); - $this->assertEquals($expected, $first_result); - - $sql = 'DELETE FROM phpbb_config'; - $result = $db->sql_query($sql); - - // As null cache driver does not actually cache, - // this should return no results - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql, 300); - - $this->assertSame(false, $db->sql_fetchrow($result)); - - $db->sql_close(); - } -} -- cgit v1.2.1 From f821130c3a4a22efd491aaad962cc84a82dde56a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 25 Nov 2014 17:04:15 +0100 Subject: [ticket/12632] Add twig.debug and twig.auto_reload in config.yml PHPBB3-13206 PHPBB3-12632 --- tests/di/fixtures/config/test/container/environment.yml | 11 +++++++++++ tests/di/fixtures/other_config/test/container/environment.yml | 11 +++++++++++ 2 files changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/di/fixtures/config/test/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml index f2a22ae109..0873078844 100644 --- a/tests/di/fixtures/config/test/container/environment.yml +++ b/tests/di/fixtures/config/test/container/environment.yml @@ -12,3 +12,14 @@ services: dispatcher: class: phpbb\db\driver\container_mock + + template.twig.environment: + class: Exception + arguments: + - ~ + - ~ + - ~ + - ~ + - ~ + - ~ + - [] diff --git a/tests/di/fixtures/other_config/test/container/environment.yml b/tests/di/fixtures/other_config/test/container/environment.yml index c299bfc648..2aa29db2eb 100644 --- a/tests/di/fixtures/other_config/test/container/environment.yml +++ b/tests/di/fixtures/other_config/test/container/environment.yml @@ -12,3 +12,14 @@ services: dispatcher: class: phpbb\db\driver\container_mock + + template.twig.environment: + class: Exception + arguments: + - ~ + - ~ + - ~ + - ~ + - ~ + - ~ + - [] -- cgit v1.2.1 From 321ed2a3dd10231a09dec18a85a783a73ba12ddf Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Sun, 22 Feb 2015 22:43:53 +0100 Subject: [ticket/13638] Add tests PHPBB3-13638 --- tests/template/asset_test.php | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/template/asset_test.php (limited to 'tests') diff --git a/tests/template/asset_test.php b/tests/template/asset_test.php new file mode 100644 index 0000000000..f84ea2e3ee --- /dev/null +++ b/tests/template/asset_test.php @@ -0,0 +1,49 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +use phpbb\template\asset; + +class phpbb_template_asset_test extends phpbb_test_case +{ + public function set_path_data() + { + return array( + // array(phpbb_root_path, given path, expected path), + array('.', 'foo/bar', 'foo/bar'), + array('../', 'foo/bar', 'foo/bar'), + array('./phpBB/', 'foo/bar', 'foo/bar'), + array('../', __DIR__ . '/foo/bar', '../phpbb/tests/template/foo/bar'), + array('./', __DIR__ . '/foo/bar', './tests/template/foo/bar'), + array('./phpBB/', __DIR__ . '/foo/bar', 'tests/template/foo/bar'), + ); + } + + /** + * @dataProvider set_path_data + */ + public function test_set_path($phpbb_root_path, $path, $expected) + { + $path_helper = $this->getMockBuilder('\phpbb\path_helper') + ->disableOriginalConstructor() + ->setMethods(array()) + ->getMock(); + + $path_helper->method('get_phpbb_root_path') + ->willReturn($phpbb_root_path); + + $asset = new asset('', $path_helper); + + $asset->set_path($path, true); + $this->assertEquals($expected, $asset->get_path()); + } +} -- cgit v1.2.1 From 51376a43919cba7a5037edb7cc31f18b5950437b Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Mon, 4 May 2015 23:50:16 +0200 Subject: [ticket/13638] Inject $filesystem in \phpbb\template\asset PHPBB3-13638 --- tests/controller/common_helper_route.php | 1 + tests/extension/metadata_manager_test.php | 6 ++++-- tests/template/asset_test.php | 2 +- tests/template/template_allfolder_test.php | 5 ++++- tests/template/template_events_test.php | 3 +++ tests/template/template_includecss_test.php | 5 ++++- tests/template/template_test_case.php | 5 ++++- tests/template/template_test_case_with_tree.php | 5 ++++- 8 files changed, 25 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 3e4b5fd38d..b01241e105 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -94,6 +94,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $loader = new \phpbb\template\twig\loader($this->filesystem, ''); $twig = new \phpbb\template\twig\environment( $this->config, + $this->filesystem, $this->phpbb_path_helper, $container, $cache_path, diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 101ab8616c..aaaee3b2e5 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -51,17 +51,19 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $cache_path = $this->phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); - $phpbb_path_helper =new \phpbb\path_helper( + $filesystem = new \phpbb\filesystem\filesystem(); + $phpbb_path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), + $filesystem, $this->getMock('\phpbb\request\request'), $this->phpbb_root_path, $this->phpEx ); $twig = new \phpbb\template\twig\environment( $this->config, + $filesystem, $phpbb_path_helper, $container, $cache_path, diff --git a/tests/template/asset_test.php b/tests/template/asset_test.php index f84ea2e3ee..f6ce0fe241 100644 --- a/tests/template/asset_test.php +++ b/tests/template/asset_test.php @@ -41,7 +41,7 @@ class phpbb_template_asset_test extends phpbb_test_case $path_helper->method('get_phpbb_root_path') ->willReturn($phpbb_root_path); - $asset = new asset('', $path_helper); + $asset = new asset('', $path_helper, new phpbb\filesystem\filesystem()); $asset->set_path($path, true); $this->assertEquals($expected, $asset->get_path()); diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php index 63f35bc758..14a8e9d463 100644 --- a/tests/template/template_allfolder_test.php +++ b/tests/template/template_allfolder_test.php @@ -33,11 +33,13 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case $user = new \phpbb\user($lang, '\phpbb\datetime'); $this->user = $user; + $filesystem = new \phpbb\filesystem\filesystem(); + $path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), + $filesystem, $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -60,6 +62,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, + $filesystem, $path_helper, $container, $cache_path, diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index 6d1b7253e3..285e82188b 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -138,6 +138,8 @@ Zeta test event in all', $this->extension_manager = new phpbb_mock_filesystem_extension_manager( dirname(__FILE__) . "/datasets/$dataset/" ); + + $filesystem = new \phpbb\filesystem\filesystem(); $path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() @@ -154,6 +156,7 @@ Zeta test event in all', $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, + $filesystem, $path_helper, $container, $cache_path, diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index 7a73d1f888..8c398d992b 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -28,11 +28,13 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te $defaults = $this->config_defaults(); $config = new \phpbb\config\config(array_merge($defaults, $new_config)); + $filesystem = new \phpbb\filesystem\filesystem(); + $this->phpbb_path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), + $filesystem, $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -46,6 +48,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, + $filesystem, $this->phpbb_path_helper, $container, $cache_path, diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 7e2020ba09..b1826571af 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -82,11 +82,13 @@ class phpbb_template_template_test_case extends phpbb_test_case $user = new \phpbb\user($lang, '\phpbb\datetime'); $this->user = $user; + $filesystem = new \phpbb\filesystem\filesystem(); + $path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), + $filesystem, $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -100,6 +102,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, + $filesystem, $path_helper, $container, $cache_path, diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index eab83f379a..d0c49006fd 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -22,11 +22,13 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $defaults = $this->config_defaults(); $config = new \phpbb\config\config(array_merge($defaults, $new_config)); + $filesystem = new \phpbb\filesystem\filesystem(); + $this->phpbb_path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), + $filesystem, $this->getMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -41,6 +43,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment( $config, + $filesystem, $this->phpbb_path_helper, $container, $cache_path, -- cgit v1.2.1 From 7b301e22f32e9209bb4e3ea17a5637a84a4ef908 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Fri, 1 May 2015 19:04:21 +0200 Subject: [ticket/13804] Make template's user dependency optional PHPBB3-13804 --- tests/controller/common_helper_route.php | 2 +- tests/extension/metadata_manager_test.php | 2 +- tests/template/template_allfolder_test.php | 2 +- tests/template/template_events_test.php | 2 +- tests/template/template_includecss_test.php | 2 +- tests/template/template_test_case.php | 2 +- tests/template/template_test_case_with_tree.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index b01241e105..e2f15d85fa 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -107,7 +107,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 'autoescape' => false, ) ); - $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->extension_manager = new phpbb_mock_extension_manager( diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index aaaee3b2e5..53bd3d109b 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -111,7 +111,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $lang = new \phpbb\language\language($lang_loader); $this->user = new \phpbb\user($lang, '\phpbb\datetime'); - $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); } diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php index 14a8e9d463..9a0f1f512e 100644 --- a/tests/template/template_allfolder_test.php +++ b/tests/template/template_allfolder_test.php @@ -75,7 +75,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case 'autoescape' => false, ) ); - $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); + $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->template_path = $this->test_path . '/templates'; diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index 285e82188b..54e08652a1 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -169,7 +169,7 @@ Zeta test event in all', 'autoescape' => false, ) ); - $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); + $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path)); diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index 8c398d992b..062fc9493b 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -64,10 +64,10 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te $this->template = new phpbb\template\twig\twig( $this->phpbb_path_helper, $config, - $user, $context, $twig, $cache_path, + $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), new phpbb_mock_extension_manager( dirname(__FILE__) . '/', diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index b1826571af..62eea0d361 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -115,7 +115,7 @@ class phpbb_template_template_test_case extends phpbb_test_case 'autoescape' => false, ) ); - $this->template = new phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', $this->template_path); } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index d0c49006fd..bf5de6b85e 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -56,7 +56,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat 'autoescape' => false, ) ); - $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } -- cgit v1.2.1 From e2bc6c8024eed988ba833ec062b9e856a77ff661 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 10 May 2015 03:04:12 +0200 Subject: [ticket/13828] Renamed testing doubles to avoid PHP7 keywords PHPBB3-13828 --- tests/di/fixtures/config.php | 2 +- tests/notification/submit_post_type_topic_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/di/fixtures/config.php b/tests/di/fixtures/config.php index 04e20f63d8..f2e1145efa 100644 --- a/tests/di/fixtures/config.php +++ b/tests/di/fixtures/config.php @@ -8,4 +8,4 @@ $dbname = 'phpbb'; $dbuser = 'root'; $dbpasswd = ''; $table_prefix = 'phpbb_'; -$acm_type = '\phpbb\cache\driver\null'; +$acm_type = '\phpbb\cache\driver\dummy'; diff --git a/tests/notification/submit_post_type_topic_test.php b/tests/notification/submit_post_type_topic_test.php index c095fbc4ba..f14f305517 100644 --- a/tests/notification/submit_post_type_topic_test.php +++ b/tests/notification/submit_post_type_topic_test.php @@ -42,7 +42,7 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_ ), ))); - $phpbb_log = $this->getMock('\phpbb\log\null'); + $phpbb_log = $this->getMock('\phpbb\log\dummy'); } /** -- cgit v1.2.1 From 8b7a42f338ca7315aae11d25e7adb89aaefe7849 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 7 May 2015 16:01:42 +0200 Subject: [ticket/13614] Removed code that relies on phpbb_pcre_utf8_support() Removed all calls to phpbb_pcre_utf8_support() as well as unreachable code. PHPBB3-13614 --- tests/regex/censor_test.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php index 50c6778c8c..5625b0020b 100644 --- a/tests/regex/censor_test.php +++ b/tests/regex/censor_test.php @@ -37,17 +37,7 @@ class phpbb_regex_censor_test extends phpbb_test_case */ public function test_censor_unicode($pattern, $subject) { - $regex = get_censor_preg_expression($pattern, true); - - $this->assertRegExp($regex, $subject); - } - - /** - * @dataProvider censor_test_data - */ - public function test_censor_no_unicode($pattern, $subject) - { - $regex = get_censor_preg_expression($pattern, false); + $regex = get_censor_preg_expression($pattern); $this->assertRegExp($regex, $subject); } -- cgit v1.2.1 From 737affcbb2f2e4f7ee5d8182a4e8cac599265ef4 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Thu, 14 May 2015 16:33:39 +0200 Subject: [ticket/13839] Don't be dependent on the phpBB root directory name in tests PHPBB3-13839 --- tests/template/asset_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/template/asset_test.php b/tests/template/asset_test.php index f6ce0fe241..3d2fdd8959 100644 --- a/tests/template/asset_test.php +++ b/tests/template/asset_test.php @@ -22,7 +22,7 @@ class phpbb_template_asset_test extends phpbb_test_case array('.', 'foo/bar', 'foo/bar'), array('../', 'foo/bar', 'foo/bar'), array('./phpBB/', 'foo/bar', 'foo/bar'), - array('../', __DIR__ . '/foo/bar', '../phpbb/tests/template/foo/bar'), + array('../', __DIR__ . '/foo/bar', '../' . basename(dirname(dirname(__DIR__))) . '/tests/template/foo/bar'), array('./', __DIR__ . '/foo/bar', './tests/template/foo/bar'), array('./phpBB/', __DIR__ . '/foo/bar', 'tests/template/foo/bar'), ); -- cgit v1.2.1 From 549fe66d90eed1d6a4fee6f5f706c73455d73596 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 26 Apr 2015 21:30:50 +0200 Subject: [ticket/13770] Update tests PHPBB3-13770 --- tests/di/create_container_test.php | 89 +++++----------------- tests/di/fixtures/config.php | 2 +- tests/di/fixtures/config/production/config.yml | 2 + .../config/production/container/environment.yml | 17 +++++ 4 files changed, 40 insertions(+), 70 deletions(-) create mode 100644 tests/di/fixtures/config/production/config.yml create mode 100644 tests/di/fixtures/config/production/container/environment.yml (limited to 'tests') diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index d52fb6b085..2d94f1d778 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -31,7 +31,8 @@ namespace { $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->config_php = new \phpbb\config_php_file($this->phpbb_root_path . 'fixtures/', 'php'); - $this->builder = new phpbb_mock_phpbb_di_container_builder($this->config_php, $this->phpbb_root_path . 'fixtures/', 'php'); + $this->builder = new phpbb_mock_phpbb_di_container_builder($this->phpbb_root_path . 'fixtures/', 'php'); + $this->builder->with_config($this->config_php); $this->filename = $this->phpbb_root_path . '../tmp/container.php'; if (is_file($this->filename)) @@ -78,9 +79,9 @@ namespace $this->assertTrue($container->isFrozen()); } - public function test_dump_container() + public function test_without_cache() { - $this->builder->set_dump_container(false); + $this->builder->without_cache(); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -94,9 +95,9 @@ namespace $this->assertTrue($container->isFrozen()); } - public function test_use_extensions() + public function test_without_extensions() { - $this->builder->set_use_extensions(false); + $this->builder->without_extensions(); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -109,9 +110,9 @@ namespace $this->assertFalse($container->hasParameter('available')); } - public function test_compile_container() + public function test_without_compiled_container() { - $this->builder->set_compile_container(false); + $this->builder->without_compiled_container(); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -119,19 +120,9 @@ namespace $this->assertFalse($container->isFrozen()); } - public function test_inject_config() + public function test_with_config_path() { - $this->builder->set_inject_config(false); - $container = $this->builder->get_container(); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); - - // Checks inject_config - $this->assertFalse($container->hasParameter('dbal.dbhost')); - } - - public function test_set_config_path() - { - $this->builder->set_config_path($this->phpbb_root_path . 'fixtures/other_config/'); + $this->builder->with_config_path($this->phpbb_root_path . 'fixtures/other_config/'); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -139,9 +130,9 @@ namespace $this->assertFalse($container->hasParameter('core')); } - public function test_set_custom_parameters() + public function test_with_custom_parameters() { - $this->builder->set_custom_parameters(array('my_parameter' => true)); + $this->builder->with_custom_parameters(array('my_parameter' => true)); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -150,61 +141,21 @@ namespace } } -namespace phpbb\db\driver +namespace phpbb\extension { - class container_mock extends \phpbb\db\driver\driver + class manager_mock extends \phpbb\extension\manager { - public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - } - - public function sql_query($query = '', $cache_ttl = 0) - { - } - - public function sql_fetchrow($query_id = false) - { - } - - public function sql_freeresult($query_id = false) - { - } - - function sql_server_info($raw = false, $use_cache = true) - { - } - - function sql_affectedrows() - { - } - - function sql_rowseek($rownum, &$query_id) - { - } - - function sql_nextid() - { - } - - function sql_escape($msg) - { - } - - function sql_like_expression($expression) - { - } - - function sql_not_like_expression($expression) + public function __construct() { } - function sql_fetchrowset($query_id = false) + public function all_enabled($phpbb_relative = true) { return array( - array('ext_name' => 'vendor/enabled'), - array('ext_name' => 'vendor/enabled-2'), - array('ext_name' => 'vendor/enabled-3'), - array('ext_name' => 'vendor/enabled_4'), + 'vendor/enabled' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled/', + 'vendor/enabled-2' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled-2/', + 'vendor/enabled-3' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled-3/', + 'vendor/enabled_4' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled_4/', ); } } diff --git a/tests/di/fixtures/config.php b/tests/di/fixtures/config.php index f2e1145efa..1e9207d924 100644 --- a/tests/di/fixtures/config.php +++ b/tests/di/fixtures/config.php @@ -1,7 +1,7 @@ Date: Sun, 3 May 2015 16:06:42 +0200 Subject: [ticket/13680] Updated quote notifications Added get_quote_authors() to text_formatter.utils service to retrieve the names used in first-level quotes PHPBB3-13680 --- tests/notification/base.php | 9 ++++- tests/notification/manager_helper.php | 5 +++ tests/notification/submit_post_base.php | 5 +++ tests/notification/submit_post_type_quote_test.php | 38 ++++++++++++---------- tests/text_formatter/s9e/utils_test.php | 34 +++++++++++++++++++ 5 files changed, 72 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/notification/base.php b/tests/notification/base.php index a1ebecd6f9..45b0b6f179 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -116,7 +116,14 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case { global $phpbb_root_path, $phpEx; - return new $type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); + $instance = new $type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); + + if ($type === 'phpbb\\notification\\type\\quote') + { + $instance->set_utils(new \phpbb\textformatter\s9e\utils); + } + + return $instance; } protected function assert_notifications($expected, $options = array()) diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 75b7275d3a..48bf5b177b 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -48,6 +48,11 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager $item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); + if ($item_type === 'phpbb\\notification\\type\\quote') + { + $item->set_utils(new \phpbb\textformatter\s9e\utils); + } + $item->set_notification_manager($this); $item->set_initial_data($data); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index d7a711e007..04fb6658c3 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -117,6 +117,11 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); + if ($type === 'quote') + { + $class->set_utils(new \phpbb\textformatter\s9e\utils); + } + $phpbb_container->set('notification.type.' . $type, $class); $notification_types_array['notification.type.' . $type] = $class; diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php index 61e3840773..8ad6a62b09 100644 --- a/tests/notification/submit_post_type_quote_test.php +++ b/tests/notification/submit_post_type_quote_test.php @@ -51,6 +51,8 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ */ public function submit_post_data() { + $parser = $this->get_test_case_helpers()->set_s9e_services()->get('text_formatter.parser'); + return array( /** * Normal post @@ -65,15 +67,15 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ */ array( array( - 'message' => implode(' ', array( - '[quote="poster":uid]poster should not be notified[/quote:uid]', - '[quote="test":uid]test should be notified[/quote:uid]', - '[quote="unauthorized":uid]unauthorized to read, should not receive a notification[/quote:uid]', - '[quote="notified":uid]already notified, should not receive a new notification[/quote:uid]', - '[quote="disabled":uid]option disabled, should not receive a notification[/quote:uid]', - '[quote="default":uid]option set to default, should receive a notification[/quote:uid]', - '[quote="doesn\'t exist":uid]user does not exist, should not receive a notification[/quote:uid]', - )), + 'message' => $parser->parse(implode(' ', array( + '[quote="poster"]poster should not be notified[/quote]', + '[quote="test"]test should be notified[/quote]', + '[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]', + '[quote="notified"]already notified, should not receive a new notification[/quote]', + '[quote="disabled"]option disabled, should not receive a notification[/quote]', + '[quote="default"]option set to default, should receive a notification[/quote]', + '[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]', + ))), 'bbcode_uid' => 'uid', ), array( @@ -94,15 +96,15 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ */ array( array( - 'message' => implode(' ', array( - '[quote="poster":uid]poster should not be notified[/quote:uid]', - '[quote="test":uid]test should be notified[/quote:uid]', - '[quote="unauthorized":uid]unauthorized to read, should not receive a notification[/quote:uid]', - '[quote="notified":uid]already notified, should not receive a new notification[/quote:uid]', - '[quote="disabled":uid]option disabled, should not receive a notification[/quote:uid]', - '[quote="default":uid]option set to default, should receive a notification[/quote:uid]', - '[quote="doesn\'t exist":uid]user does not exist, should not receive a notification[/quote:uid]', - )), + 'message' => $parser->parse(implode(' ', array( + '[quote="poster"]poster should not be notified[/quote]', + '[quote="test"]test should be notified[/quote]', + '[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]', + '[quote="notified"]already notified, should not receive a new notification[/quote]', + '[quote="disabled"]option disabled, should not receive a notification[/quote]', + '[quote="default"]option set to default, should receive a notification[/quote]', + '[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]', + ))), 'bbcode_uid' => 'uid', 'force_approved_state' => false, ), diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 69f8682cac..78e5869af1 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -74,6 +74,40 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case ); } + /** + * @dataProvider get_quote_authors_tests + */ + public function test_get_quote_authors($original, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + $parser = $container->get('text_formatter.parser'); + + $this->assertSame($expected, $utils->get_quote_authors($parser->parse($original))); + } + + public function get_quote_authors_tests() + { + return array( + array( + 'No quotes here', + array() + ), + array( + '[quote="foo"]..[/quote] [quote]..[/quote]', + array('foo') + ), + array( + '[quote="foo"]..[/quote] [quote="bar"]..[/quote]', + array('foo', 'bar') + ), + array( + '[quote="foo"].[quote="baz"]..[/quote].[/quote] [quote="bar"]..[/quote]', + array('foo', 'bar') + ), + ); + } + /** * @dataProvider get_remove_bbcode_tests */ -- cgit v1.2.1 From f7ad2c2b32b309edba006a8d4b58727b50642ea2 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 15 May 2015 02:12:52 +0200 Subject: [ticket/13680] Renamed get_quote_authors to get_outermost_quote_authors PHPBB3-13680 --- tests/text_formatter/s9e/utils_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 78e5869af1..b1b937709c 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -75,18 +75,18 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case } /** - * @dataProvider get_quote_authors_tests + * @dataProvider get_outermost_quote_authors_tests */ - public function test_get_quote_authors($original, $expected) + public function test_get_outermost_quote_authors($original, $expected) { $container = $this->get_test_case_helpers()->set_s9e_services(); $utils = $container->get('text_formatter.utils'); $parser = $container->get('text_formatter.parser'); - $this->assertSame($expected, $utils->get_quote_authors($parser->parse($original))); + $this->assertSame($expected, $utils->get_outermost_quote_authors($parser->parse($original))); } - public function get_quote_authors_tests() + public function get_outermost_quote_authors_tests() { return array( array( -- cgit v1.2.1 From f6c246f8899edb480c7347cb43e2cbdc96c80d17 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 16 May 2015 23:08:42 +0200 Subject: [ticket/13844] Add a functional test that browses the help pages PHPBB3-13844 --- tests/functional/browse_test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index b9e74a280f..4f28879687 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -34,6 +34,18 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case $this->assertGreaterThan(0, $crawler->filter('.postbody')->count()); } + public function test_help_faq() + { + $crawler = self::request('GET', 'app.php/help/faq'); + $this->assertGreaterThan(0, $crawler->filter('h2.faq-title')->count()); + } + + public function test_help_bbcode() + { + $crawler = self::request('GET', 'app.php/help/bbcode'); + $this->assertGreaterThan(0, $crawler->filter('h2.faq-title')->count()); + } + public function test_feed() { $crawler = self::request('GET', 'feed.php', array(), false); -- cgit v1.2.1 From 6dcc14bc5824b3ff74a3cd3acd574ae5e530d1c3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 17 May 2015 21:45:18 +0200 Subject: [ticket/13844] Add unit tests for the help manager PHPBB3-13844 --- tests/help/manager_test.php | 183 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 tests/help/manager_test.php (limited to 'tests') diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php new file mode 100644 index 0000000000..aaf63194fa --- /dev/null +++ b/tests/help/manager_test.php @@ -0,0 +1,183 @@ + + * @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_language_test extends phpbb_test_case +{ + /** @var \phpbb\help\manager */ + protected $manager; + /** @var \phpbb\template\template */ + protected $template; + /** @var \phpbb\language\language */ + protected $language; + + public function setUp() + { + $this->template = $this->getMockBuilder('\phpbb\template\template') + ->disableOriginalConstructor() + ->getMock(); + $this->language = $this->getMockBuilder('\phpbb\language\language') + ->disableOriginalConstructor() + ->getMock(); + + $this->manager = new \phpbb\help\manager( + $this->template, + $this->language + ); + } + + public function add_block_data() + { + return array( + array('abc', false, array(), false), + array('def', true, array(), true), + array( + 'abc', + false, + array( + 'question1' => 'answer1', + 'question2' => 'answer2', + 'question3' => 'answer3', + ), + false + ), + ); + } + + /** + * @dataProvider add_block_data + * + * @param string $block_name + * @param bool $switch + * @param array $questions + * @param bool $switch_expected + */ + public function test_add_block($block_name, $switch, $questions, $switch_expected) + { + $this->language->expects($this->at(0)) + ->method('lang') + ->with($block_name) + ->willReturn(strtoupper($block_name)); + $lang_call_count = 1; + foreach ($questions as $question => $answer) + { + $this->language->expects($this->at($lang_call_count)) + ->method('lang') + ->with($question) + ->willReturn(strtoupper($question)); + $lang_call_count++; + + $this->language->expects($this->at($lang_call_count)) + ->method('lang') + ->with($answer) + ->willReturn(strtoupper($answer)); + $lang_call_count++; + } + + $this->template->expects($this->at(0)) + ->method('assign_block_vars') + ->with('faq_block', array( + 'BLOCK_TITLE' => strtoupper($block_name), + 'SWITCH_COLUMN' => $switch_expected, + )); + $template_call_count = 1; + foreach ($questions as $question => $answer) + { + $this->template->expects($this->at($template_call_count)) + ->method('assign_block_vars') + ->with('faq_block.faq_row', array( + 'FAQ_QUESTION' => strtoupper($question), + 'FAQ_ANSWER' => strtoupper($answer), + )); + $template_call_count++; + } + + $this->manager->add_block($block_name, $switch, $questions); + + $this->assertEquals($switch_expected, $this->manager->switched_column()); + } + + public function add_question_data() + { + return array( + array('abc', false, false), + array('def', true, true), + ); + } + + /** + * @dataProvider add_question_data + * + * @param string $question + * @param string $answer + */ + public function test_add_question($question, $answer) + { + $this->language->expects($this->at(0)) + ->method('lang') + ->with($question) + ->willReturn(strtoupper($question)); + $this->language->expects($this->at(1)) + ->method('lang') + ->with($answer) + ->willReturn(strtoupper($answer)); + + $this->template->expects($this->once()) + ->method('assign_block_vars') + ->with('faq_block.faq_row', array( + 'FAQ_QUESTION' => strtoupper($question), + 'FAQ_ANSWER' => strtoupper($answer), + )); + + $this->manager->add_question($question, $answer); + } + + public function test_add_block_double_switch() + { + $block_name = 'abc'; + $switch_expected = true; + + $this->language->expects($this->at(0)) + ->method('lang') + ->with($block_name) + ->willReturn(strtoupper($block_name)); + + $this->template->expects($this->at(0)) + ->method('assign_block_vars') + ->with('faq_block', array( + 'BLOCK_TITLE' => strtoupper($block_name), + 'SWITCH_COLUMN' => $switch_expected, + )); + + $this->manager->add_block($block_name, true); + $this->assertTrue($this->manager->switched_column()); + + // Add a second block with switch + $block_name = 'def'; + $switch_expected = false; + + $this->language->expects($this->at(0)) + ->method('lang') + ->with($block_name) + ->willReturn(strtoupper($block_name)); + + $this->template->expects($this->at(0)) + ->method('assign_block_vars') + ->with('faq_block', array( + 'BLOCK_TITLE' => strtoupper($block_name), + 'SWITCH_COLUMN' => $switch_expected, + )); + + $this->manager->add_block($block_name, true); + $this->assertTrue($this->manager->switched_column()); + } +} -- cgit v1.2.1 From deadc0665298f18a937fc959da449e9098873c0b Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 30 Apr 2015 23:01:28 +0200 Subject: [ticket/13801] Removed user dependency from text_formatter.s9e.parser PHPBB3-13801 --- tests/test_framework/phpbb_test_case_helpers.php | 2 -- tests/text_formatter/s9e/parser_test.php | 10 +--------- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 685014d3e4..210cda9a94 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -494,11 +494,9 @@ class phpbb_test_case_helpers $parser = new \phpbb\textformatter\s9e\parser( $cache, $cache_key_parser, - $user, $factory, $dispatcher ); - $container->set('text_formatter.parser', $parser); $container->set('text_formatter.s9e.parser', $parser); diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 71966f9d36..3b72e713e1 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -35,7 +35,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( $cache, '_foo_parser', - $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), $factory, new phpbb_mock_event_dispatcher ); @@ -63,7 +62,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( $cache, '_foo_parser', - $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), $factory, new phpbb_mock_event_dispatcher ); @@ -92,7 +90,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( new phpbb_mock_cache, '_foo_parser', - $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), $factory, new phpbb_mock_event_dispatcher ); @@ -126,7 +123,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( $cache, '_foo_parser', - $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), $factory, new phpbb_mock_event_dispatcher ); @@ -191,7 +187,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case new \phpbb\textformatter\s9e\parser( $container->get('cache.driver'), '_foo_parser', - $container->get('user'), $container->get('text_formatter.s9e.factory'), $dispatcher ); @@ -200,9 +195,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case public function setup_event_callback($vars) { return isset($vars['parser']) - && $vars['parser'] instanceof \phpbb\textformatter\s9e\parser - && isset($vars['user']) - && $vars['user'] instanceof \phpbb\user; + && $vars['parser'] instanceof \phpbb\textformatter\s9e\parser; } /** @@ -236,7 +229,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( $container->get('cache.driver'), '_foo_parser', - $container->get('user'), $container->get('text_formatter.s9e.factory'), $dispatcher ); -- cgit v1.2.1 From c1777f481101c0a311939f83f2afd38a0c09e394 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 18 May 2015 03:57:48 +0200 Subject: [ticket/11530] Remove extra quotes when depth limit is exceeded PHPBB3-11530 --- tests/functional/posting_test.php | 81 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 7acf375c5d..080ada5bb0 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -71,4 +71,85 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); $this->assertContains('😀', $crawler->text()); } + + /** + * @testdox max_quote_depth is applied to the text populating the posting form + */ + public function test_quote_depth_form() + { + $text = '0[quote]1[quote]2[/quote]1[/quote]0'; + $expected = array( + 0 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]', + 1 => '[quote="admin"]00[/quote]', + 2 => '[quote="admin"]0[quote]11[/quote]0[/quote]', + 3 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]', + ); + + $this->login(); + $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); + $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + $quote_url = "posting.php?mode=quote&f=2&t={$post['topic_id']}&p={$post['post_id']}&sid={$this->sid}"; + + $this->admin_login(); + foreach ($expected as $quote_depth => $expected_text) + { + $this->set_quote_depth($quote_depth); + $crawler = self::request('GET', $quote_url); + $this->assertContains($expected_text, $crawler->filter('textarea#message')->text()); + } + } + + /** + * @testdox max_quote_depth is applied to the text populating the posting form + */ + public function test_quote_depth_submit() + { + $text = 'depth:0[quote]depth:1[quote]depth:2[quote]depth:3[/quote][/quote][/quote]'; + $contains = array( + 0 => array('depth:0', 'depth:1', 'depth:2', 'depth:3'), + 1 => array('depth:0', 'depth:1'), + 2 => array('depth:0', 'depth:1', 'depth:2'), + 3 => array('depth:0', 'depth:1', 'depth:2', 'depth:3'), + ); + $not_contains = array( + 0 => array(), + 1 => array('depth:2', 'depth:3'), + 2 => array('depth:3'), + 3 => array(), + ); + + $this->login(); + $this->admin_login(); + $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); + + for ($quote_depth = 0; $quote_depth <= 2; ++$quote_depth) + { + $this->set_quote_depth($quote_depth); + + $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + $url = "viewtopic.php?p={$post['post_id']}&sid={$this->sid}"; + + $crawler = self::request('GET', $url); + $text_content = $crawler->filter('#p' . $post['post_id'])->text(); + foreach ($contains[$quote_depth] as $contains_text) + { + $this->assertContains($contains_text, $text_content); + } + foreach ($not_contains[$quote_depth] as $not_contains_text) + { + $this->assertNotContains($not_contains_text, $text_content); + } + } + } + + protected function set_quote_depth($depth) + { + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + $values['config[max_quote_depth]'] = $depth; + $form->setValues($values); + $crawler = self::submit($form); + $this->assertEquals(1, $crawler->filter('.successbox')->count()); + } } -- cgit v1.2.1 From 2cc78b2c3b4e918710478f861c1441a3e28c9ad4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 19 May 2015 11:16:37 +0200 Subject: [ticket/11530] Fixed test description [ci skip] PHPBB3-11530 --- tests/functional/posting_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 080ada5bb0..5c083aef37 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -100,7 +100,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case } /** - * @testdox max_quote_depth is applied to the text populating the posting form + * @testdox max_quote_depth is applied to the submitted text */ public function test_quote_depth_submit() { -- cgit v1.2.1 From b9ff0bbba4cf357baad32576c01f36a9f2627ffa Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Tue, 19 May 2015 22:42:32 +0200 Subject: [ticket/13849] Fix tests PHPBB3-13849 --- tests/di/fixtures/config/test/container/environment.yml | 1 + tests/di/fixtures/other_config/test/container/environment.yml | 1 + 2 files changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/di/fixtures/config/test/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml index 0873078844..14c986d123 100644 --- a/tests/di/fixtures/config/test/container/environment.yml +++ b/tests/di/fixtures/config/test/container/environment.yml @@ -22,4 +22,5 @@ services: - ~ - ~ - ~ + - ~ - [] diff --git a/tests/di/fixtures/other_config/test/container/environment.yml b/tests/di/fixtures/other_config/test/container/environment.yml index 2aa29db2eb..e285b1b781 100644 --- a/tests/di/fixtures/other_config/test/container/environment.yml +++ b/tests/di/fixtures/other_config/test/container/environment.yml @@ -22,4 +22,5 @@ services: - ~ - ~ - ~ + - ~ - [] -- cgit v1.2.1 From 077051fef56f0d9b504a2593dc84a3d05ef02e18 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 May 2015 00:23:42 +0200 Subject: [ticket/13844] Add events PHPBB3-13844 --- tests/help/manager_test.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php index aaf63194fa..68534d9a32 100644 --- a/tests/help/manager_test.php +++ b/tests/help/manager_test.php @@ -11,7 +11,7 @@ * */ -class phpbb_language_test extends phpbb_test_case +class phpbb_help_manager_test extends phpbb_test_case { /** @var \phpbb\help\manager */ protected $manager; @@ -30,8 +30,9 @@ class phpbb_language_test extends phpbb_test_case ->getMock(); $this->manager = new \phpbb\help\manager( - $this->template, - $this->language + new \phpbb_mock_event_dispatcher(), + $this->language, + $this->template ); } -- cgit v1.2.1 From 92078dce3393ea705361e1c3c0a332db778ccb0a Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 29 Apr 2015 23:22:30 +0200 Subject: [ticket/11742] Removed tabs-to-space conversion in [code] PHPBB3-11742 --- tests/text_processing/tickets_data/PHPBB3-11742.html | 1 + tests/text_processing/tickets_data/PHPBB3-11742.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-11742.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-11742.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-11742.html b/tests/text_processing/tickets_data/PHPBB3-11742.html new file mode 100644 index 0000000000..e7890eef19 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-11742.html @@ -0,0 +1 @@ +

            CODE: Select all

            	tab
            \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-11742.txt b/tests/text_processing/tickets_data/PHPBB3-11742.txt new file mode 100644 index 0000000000..db72e5dda0 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-11742.txt @@ -0,0 +1 @@ +[code] tab[/code] \ No newline at end of file -- cgit v1.2.1 From ad84a40c002990ea723d7b756313820b06e8012a Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 3 May 2015 02:40:15 +0200 Subject: [ticket/11742] Updated default formatting tests to match the new default PHPBB3-11742 --- tests/text_formatter/s9e/default_formatting_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 79232562cf..89d2cc53e1 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -68,7 +68,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( '[code]unparsed code[/code]', - '

            CODE: Select all

            unparsed code
            ' + '

            CODE: Select all

            unparsed code
            ' ), array( '[list]no item[/list]', @@ -181,12 +181,12 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case array( // Do not parse textual bbcodes in code '[code]unparsed code [b]bold [i]bold + italic[/i][/b][/code]', - '

            CODE: Select all

            unparsed code [b]bold [i]bold + italic[/i][/b]
            ' + '

            CODE: Select all

            unparsed code [b]bold [i]bold + italic[/i][/b]
            ' ), array( // Do not parse quote bbcodes in code '[code]unparsed code [quote="username"]quoted[/quote][/code]', - '

            CODE: Select all

            unparsed code [quote="username"]quoted[/quote]
            ' + '

            CODE: Select all

            unparsed code [quote="username"]quoted[/quote]
            ' ), array( // Textual bbcode nesting into textual bbcode @@ -195,7 +195,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "[code]\tline1\n line2[/code]", - '

            CODE: Select all

               line1
            ' . "\n" . '  line2
            ' + '

            CODE: Select all

            ' . "\tline1\n  line2
            " ), array( '... http://example.org ...', -- cgit v1.2.1 From 3f52429e3d1548ca1faa203047d9326b0e6d4baa Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 23 May 2015 19:18:02 +0200 Subject: [ticket/11742] Added test PHPBB3-11742 --- tests/text_formatter/s9e/default_formatting_test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 89d2cc53e1..2aa15146aa 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -197,6 +197,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case "[code]\tline1\n line2[/code]", '

            CODE: Select all

            ' . "\tline1\n  line2
            " ), + array( + "[code]\n\tline1\n line2[/code]", + '

            CODE: Select all

            ' . "\tline1\n  line2
            " + ), array( '... http://example.org ...', '... http://example.org ...' -- cgit v1.2.1 From 65316cffafead1b0529dca50f4c110489615438a Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 23 May 2015 21:13:30 -0400 Subject: [ticket/13733] Allow tests the skip class validation PHPBB3-13733 --- tests/extension/extension_base_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php index eee38186db..898c11d902 100644 --- a/tests/extension/extension_base_test.php +++ b/tests/extension/extension_base_test.php @@ -74,6 +74,6 @@ class phpbb_extension_extension_base_test extends phpbb_test_case public function test_suffix_get_classes($extension_name, $expected) { $extension = $this->extension_manager->get_extension($extension_name); - $this->assertEquals($expected, self::$reflection_method_get_migration_file_list->invoke($extension)); + $this->assertEquals($expected, self::$reflection_method_get_migration_file_list->invoke($extension, false)); } } -- cgit v1.2.1 From 8a077e0e943d87ee1d26b0501f0b9bcc472ab904 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 17 May 2015 20:15:06 +0200 Subject: [ticket/13847] Move quote generation to text_formatter.utils PHPBB3-13847 --- tests/functional/posting_test.php | 14 +++++++++ tests/text_formatter/s9e/utils_test.php | 51 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 5c083aef37..8677237772 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -72,6 +72,20 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $this->assertContains('😀', $crawler->text()); } + public function test_quote() + { + $text = 'Test post "\' &&amp;'; + $expected = '[quote="admin"]' . $text . '[/quote]'; + + $this->login(); + $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); + $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + + $crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post['topic_id']}&p={$post['post_id']}&sid={$this->sid}"); + + $this->assertContains($expected, $crawler->filter('textarea#message')->text()); + } + /** * @testdox max_quote_depth is applied to the text populating the posting form */ diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index b1b937709c..3c92965b49 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -108,6 +108,57 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case ); } + /** + * @dataProvider get_generate_quote_tests + */ + public function test_generate_quote($text, $params, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->generate_quote($text, $params)); + } + + public function get_generate_quote_tests() + { + return array( + array( + '...', + array(), + '[quote]...[/quote]', + ), + array( + '...', + array('author' => 'Brian Kibler'), + '[quote="Brian Kibler"]...[/quote]', + ), + array( + '...', + array('author' => 'Brian "Brian Kibler" Kibler of Brian Kibler Gaming'), + '[quote=\'Brian "Brian Kibler" Kibler of Brian Kibler Gaming\']...[/quote]', + ), + array( + '...', + array('author' => "Brian Kibler Gaming's Brian Kibler"), + '[quote="Brian Kibler Gaming\'s Brian Kibler"]...[/quote]', + ), + array( + '...', + array('author' => "\\\"'"), + '[quote="\\\\\\"\'"]...[/quote]', + ), + array( + '...', + array( + 'author' => 'user', + 'post_id' => 123, + 'url' => 'http://example.org' + ), + '[quote="user" post_id="123" url="http://example.org"]...[/quote]', + ), + ); + } + /** * @dataProvider get_remove_bbcode_tests */ -- cgit v1.2.1 From e50d9186ce15367e8f6e2aab5c04481ca0046ec6 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 19 May 2015 23:10:35 +0200 Subject: [ticket/13847] Changed enquote() logic to use whichever is the shortest Will enclose attribute values in single- or double- quotes depending on whichever requires the least escaping. Characters that need to be escaped are always escaped regardless. PHPBB3-13847 --- tests/text_formatter/s9e/utils_test.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 3c92965b49..555f29cb38 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -147,6 +147,21 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case array('author' => "\\\"'"), '[quote="\\\\\\"\'"]...[/quote]', ), + array( + '...', + array('author' => 'Lots of doubles """ one single \' one backslash \\'), + '[quote=\'Lots of doubles """ one single \\\' one backslash \\\\\']...[/quote]', + ), + array( + '...', + array('author' => "Lots of singles ''' one double \" one backslash \\"), + '[quote="Lots of singles \'\'\' one double \\" one backslash \\\\"]...[/quote]', + ), + array( + '...', + array('author' => 'Defaults to doublequotes """\'\'\''), + '[quote="Defaults to doublequotes \\"\\"\\"\'\'\'"]...[/quote]', + ), array( '...', array( -- cgit v1.2.1 From 2a7a06da2a166b814732bdfa790e53b80da8a612 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 25 May 2015 20:54:30 +0200 Subject: [ticket/13847] Updated ucp_pm_compose to use the utils service ...when quoting a post PHPBB3-13847 --- tests/functional/private_messages_test.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index 1f6dc3a979..4851fc4c64 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -66,4 +66,18 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case $crawler = self::submit($form); $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text()); } + + public function test_quote() + { + $text = 'Test post'; + $expected = '[quote="admin"]' . $text . '[/quote]'; + + $this->login(); + $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); + $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + + $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quotepost&p=' . $post['post_id'] . '&sid=' . $this->sid); + + $this->assertContains($expected, $crawler->filter('textarea#message')->text()); + } } -- cgit v1.2.1 From 64e1824abdb2a9c860e049f10ecc81c051160ff5 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 25 May 2015 21:04:12 +0200 Subject: [ticket/13847] Updated ucp_pm_compose to use utils when forwarding PHPBB3-13847 --- tests/functional/private_messages_test.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index 4851fc4c64..3f602d62fb 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -67,7 +67,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text()); } - public function test_quote() + public function test_quote_post() { $text = 'Test post'; $expected = '[quote="admin"]' . $text . '[/quote]'; @@ -80,4 +80,17 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case $this->assertContains($expected, $crawler->filter('textarea#message')->text()); } + + public function test_quote_forward() + { + $text = 'This is a test private message sent by the testing framework.'; + $expected = '[quote="admin"]' . $text . '[/quote]'; + + $this->login(); + $message_id = $this->create_private_message('Test', $text, array(2)); + + $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid); + + $this->assertContains($expected, $crawler->filter('textarea#message')->text()); + } } -- cgit v1.2.1 From 97d05eb2350895f13872c8435f204796938b8b6f Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 28 May 2015 12:23:51 +0200 Subject: [ticket/13860] Fixed PHP notices from undeclared vars/properties PHPBB3-13860 --- tests/text_processing/message_parser_test.php | 53 +++++++++++++++------------ 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/text_processing/message_parser_test.php b/tests/text_processing/message_parser_test.php index 691c0d5b8a..bee1b3fca3 100644 --- a/tests/text_processing/message_parser_test.php +++ b/tests/text_processing/message_parser_test.php @@ -61,6 +61,13 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ->method('lang') ->will($this->returnValueMap($map)); + $user->data = array( + 'is_bot' => false, + 'is_registered' => true, + 'user_id' => 2, + ); + $user->style = array('style_id' => 1); + $user->lang = array( 'NO_POLL_TITLE' => 'You have to enter a poll title.', 'POLL_TITLE_TOO_LONG' => 'The poll title must contain fewer than 100 characters.', @@ -76,7 +83,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case if (isset($setup)) { - $setup($parser, $phpbb_container, $this); + $setup($phpbb_container, $this); } $this->get_test_case_helpers()->set_s9e_services($phpbb_container); @@ -286,7 +293,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=200]200[/size]', '[size=200]200[/size]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_font_size', 200); } @@ -295,7 +302,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=200]200[/size]', '[size=200]200[/size]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_font_size', 0); } @@ -304,7 +311,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=2000]2000[/size]', '[size=2000]2000[/size]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_font_size', 200); }, @@ -314,7 +321,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=0]0[/size]', '[size=0]0[/size]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_font_size', 200); } @@ -323,7 +330,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=200]200[/size]', '[size=200]200[/size]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_font_size', 200); } @@ -332,7 +339,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=200]200[/size]', '[size=200]200[/size]', array(true, true, true, true, true, true, true, true, 'sig'), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_font_size', 120); }, @@ -342,7 +349,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '[img]http://example.org/100x100.png[/img]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 12); }, @@ -352,7 +359,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '[img]http://example.org/100x100.png[/img]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_width', 34); }, @@ -362,7 +369,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '[img]http://example.org/100x100.png[/img]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 0); $phpbb_container->get('config')->set('max_post_img_width', 0); @@ -372,7 +379,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '[img]http://example.org/100x100.png[/img]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 100); $phpbb_container->get('config')->set('max_post_img_width', 100); @@ -382,7 +389,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '[img]http://example.org/100x100.png[/img]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_img_height', 12); $phpbb_container->get('config')->set('max_sig_img_width', 34); @@ -392,7 +399,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/404.png[/img]', '[img]http://example.org/404.png[/img]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 12); }, @@ -402,7 +409,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[flash=999,999]http://example.org/foo.swf[/flash]', '[flash=999,999]http://example.org/foo.swf[/flash]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 123); }, @@ -412,7 +419,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[flash=999,999]http://example.org/foo.swf[/flash]', '[flash=999,999]http://example.org/foo.swf[/flash]', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_width', 456); }, @@ -422,7 +429,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :)', ':) :) :)', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_smilies', 3); } @@ -431,7 +438,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :) :)', ':) :) :) :)', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_smilies', 3); }, @@ -441,7 +448,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :) :)', ':) :) :) :)', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_smilies', 0); } @@ -450,7 +457,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :) :)', ':) :) :) :)', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_smilies', 3); } @@ -459,7 +466,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :) :)', ':) :) :) :)', array(true, true, true, true, true, true, true, true, 'sig'), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_smilies', 3); }, @@ -469,7 +476,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case 'http://example.org http://example.org http://example.org', 'http://example.org http://example.org http://example.org', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_urls', 2); }, @@ -479,7 +486,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case 'http://example.org http://example.org http://example.org', 'http://example.org http://example.org http://example.org', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_urls', 0); } @@ -488,7 +495,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case 'http://example.org http://example.org http://example.org', 'http://example.org http://example.org http://example.org', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_urls', 2); } -- cgit v1.2.1 From c56e2fa2bf44d85008ee0629c956357eff072033 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 28 May 2015 15:52:18 +0200 Subject: [ticket/13872] Remove subsilver2 from md exporter test PHPBB3-13872 --- tests/event/md_exporter_test.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests') diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php index d28e3d611c..a6c1dc78de 100644 --- a/tests/event/md_exporter_test.php +++ b/tests/event/md_exporter_test.php @@ -23,7 +23,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case 'event' => 'acp_bbcodes_actions_append', 'files' => array( 'prosilver' => array(), - 'subsilver2' => array(), 'adm' => array('acp_bbcodes.html'), ), 'since' => '3.1.0-a3', @@ -36,7 +35,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case 'event' => 'acp_bbcodes_actions_prepend', 'files' => array( 'prosilver' => array(), - 'subsilver2' => array(), 'adm' => array('acp_bbcodes.html'), ), 'since' => '3.1.0-a5', @@ -47,7 +45,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case 'event' => 'acp_bbcodes_actions_prepend2', 'files' => array( 'prosilver' => array(), - 'subsilver2' => array(), 'adm' => array('acp_bbcodes.html'), ), 'since' => '3.1.0-a4', @@ -63,7 +60,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case 'event' => 'acp_bbcodes_actions_prepend', 'files' => array( 'prosilver' => array(), - 'subsilver2' => array(), 'adm' => array('acp_bbcodes.html'), ), 'since' => '3.1.0-a5', @@ -74,7 +70,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case 'event' => 'acp_bbcodes_actions_prepend2', 'files' => array( 'prosilver' => array(), - 'subsilver2' => array(), 'adm' => array('acp_bbcodes.html'), ), 'since' => '3.1.0-a4', -- cgit v1.2.1 From 6641ed64785d9e6199bb7b8402b8d3a296c90ae5 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 29 May 2015 14:52:31 +0200 Subject: [ticket/13890] Fix di tests PHPBB3-13890 --- .../di/fixtures/config/production/container/environment.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/di/fixtures/config/production/container/environment.yml b/tests/di/fixtures/config/production/container/environment.yml index 6ac07a44d9..9dcf11d865 100644 --- a/tests/di/fixtures/config/production/container/environment.yml +++ b/tests/di/fixtures/config/production/container/environment.yml @@ -15,3 +15,15 @@ services: ext.manager: class: phpbb\extension\manager_mock + + template.twig.environment: + class: Exception + arguments: + - ~ + - ~ + - ~ + - ~ + - ~ + - ~ + - ~ + - [] -- cgit v1.2.1 From 66c0e0c6a83fbf091aa078ab06dd6467c8c6aa11 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 4 May 2015 15:10:33 +0200 Subject: [ticket/13388] Integrate routing and di parameters resolution PHPBB3-13388 --- tests/controller/common_helper_route.php | 24 +++++++++++++++++++++- tests/controller/controller_test.php | 5 ++++- .../controller/ext/vendor2/foo/config/routing.yml | 4 ++++ tests/pagination/pagination_test.php | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 44e5e12ab0..3c74c16bae 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -89,6 +89,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->user = new \phpbb\user($lang, '\phpbb\datetime');; $container = new phpbb_mock_container_builder(); + $container->setParameter('core.environment', PHPBB_ENVIRONMENT); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); $loader = new \phpbb\template\twig\loader($this->filesystem, ''); @@ -121,7 +122,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); + $this->router = new phpbb_mock_router($container, $this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path @@ -155,6 +156,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller2', array(), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, '/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -195,6 +199,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller2', array(), false, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, '/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -235,6 +242,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -275,6 +285,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, 'app.php/foo/bar', 'no params using empty array'), array('controller2', array(), false, false, 'app.php/foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, 'app.php/foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -315,6 +328,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -355,6 +371,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -435,6 +454,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, '//localhost/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 5781d3ebc1..d0295d66bc 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,7 +40,10 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); + $container = new phpbb_mock_container_builder(); + $container->setParameter('core.environment', PHPBB_ENVIRONMENT); + + $router = new \phpbb\routing\router($container, new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); diff --git a/tests/controller/ext/vendor2/foo/config/routing.yml b/tests/controller/ext/vendor2/foo/config/routing.yml index e3e8ee5f98..7d4ac7be93 100644 --- a/tests/controller/ext/vendor2/foo/config/routing.yml +++ b/tests/controller/ext/vendor2/foo/config/routing.yml @@ -5,3 +5,7 @@ controller1: include_controller2: resource: "routing_2.yml" prefix: /foo + +controller4: + path: /foo/%core.environment% + defaults: { _controller: foo.controller:handle } diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 67c3d0a30f..07f9ec9c56 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -41,7 +41,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $router = new phpbb_mock_router($filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $manager); + $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $manager); $router->find_routing_files($manager->all_enabled(false)); $router->find(dirname(__FILE__) . '/'); -- cgit v1.2.1 From de52580a78bcab47a2311f3993fd9952f963d563 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 1 May 2015 05:15:56 +0200 Subject: [ticket/13803] WIP implementation PHPBB3-13803 --- tests/text_reparser/fixtures/posts.xml | 19 ++++++++++ tests/text_reparser/posttext_test.php | 67 ++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tests/text_reparser/fixtures/posts.xml create mode 100644 tests/text_reparser/posttext_test.php (limited to 'tests') diff --git a/tests/text_reparser/fixtures/posts.xml b/tests/text_reparser/fixtures/posts.xml new file mode 100644 index 0000000000..6485293361 --- /dev/null +++ b/tests/text_reparser/fixtures/posts.xml @@ -0,0 +1,19 @@ + + + + post_id + enable_bbcode + enable_smilies + enable_magic_url + post_text + bbcode_uid + + 1 + 1 + 1 + 1 + Plain text + abcd1234 + +
            +
            diff --git a/tests/text_reparser/posttext_test.php b/tests/text_reparser/posttext_test.php new file mode 100644 index 0000000000..4dec53dc63 --- /dev/null +++ b/tests/text_reparser/posttext_test.php @@ -0,0 +1,67 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; + +class phpbb_textreparser_posttext_test extends phpbb_database_test_case +{ + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + parent::setUp(); + } + + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml'); + } + + /** + * @dataProvider getReparseTests + */ + public function testReparse($min_id, $max_id, $expected) + { + $db = $this->new_dbal(); + $reparser = new \phpbb\textreparser\posttext($db); + $reparser->reparse_range($min_id, $max_id); + $sql = 'SELECT post_id, post_text + FROM ' . POSTS_TABLE . " + WHERE post_id BETWEEN $min_id AND $max_id"; + $result = $db->sql_query($sql); + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + $this->assertEquals($expected, $rows); + } + + public function getReparseTests() + { + return array( + array( + 1, + 1, + array( + array( + 'post_id' => 1, + 'post_text' => 'Plain text' + ) + ) + ), + ); + } +} -- cgit v1.2.1 From e11ae7e9cd5573658b763b1ef72cb889f547f2dd Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 1 May 2015 05:32:48 +0200 Subject: [ticket/13803] Hyphenated class names PHPBB3-13803 --- tests/text_reparser/post_text_test.php | 67 ++++++++++++++++++++++++++++++++++ tests/text_reparser/posttext_test.php | 67 ---------------------------------- 2 files changed, 67 insertions(+), 67 deletions(-) create mode 100644 tests/text_reparser/post_text_test.php delete mode 100644 tests/text_reparser/posttext_test.php (limited to 'tests') diff --git a/tests/text_reparser/post_text_test.php b/tests/text_reparser/post_text_test.php new file mode 100644 index 0000000000..dc13cebf44 --- /dev/null +++ b/tests/text_reparser/post_text_test.php @@ -0,0 +1,67 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; + +class phpbb_textreparser_post_text_test extends phpbb_database_test_case +{ + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + parent::setUp(); + } + + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml'); + } + + /** + * @dataProvider getReparseTests + */ + public function testReparse($min_id, $max_id, $expected) + { + $db = $this->new_dbal(); + $reparser = new \phpbb\textreparser\post_text($db); + $reparser->reparse_range($min_id, $max_id); + $sql = 'SELECT post_id, post_text + FROM ' . POSTS_TABLE . " + WHERE post_id BETWEEN $min_id AND $max_id"; + $result = $db->sql_query($sql); + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + $this->assertEquals($expected, $rows); + } + + public function getReparseTests() + { + return array( + array( + 1, + 1, + array( + array( + 'post_id' => 1, + 'post_text' => 'Plain text' + ) + ) + ), + ); + } +} diff --git a/tests/text_reparser/posttext_test.php b/tests/text_reparser/posttext_test.php deleted file mode 100644 index 4dec53dc63..0000000000 --- a/tests/text_reparser/posttext_test.php +++ /dev/null @@ -1,67 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; - -class phpbb_textreparser_posttext_test extends phpbb_database_test_case -{ - public function setUp() - { - global $config; - if (!isset($config)) - { - $config = new \phpbb\config\config(array()); - } - $this->get_test_case_helpers()->set_s9e_services(); - parent::setUp(); - } - - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml'); - } - - /** - * @dataProvider getReparseTests - */ - public function testReparse($min_id, $max_id, $expected) - { - $db = $this->new_dbal(); - $reparser = new \phpbb\textreparser\posttext($db); - $reparser->reparse_range($min_id, $max_id); - $sql = 'SELECT post_id, post_text - FROM ' . POSTS_TABLE . " - WHERE post_id BETWEEN $min_id AND $max_id"; - $result = $db->sql_query($sql); - $rows = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - $this->assertEquals($expected, $rows); - } - - public function getReparseTests() - { - return array( - array( - 1, - 1, - array( - array( - 'post_id' => 1, - 'post_text' => 'Plain text' - ) - ) - ), - ); - } -} -- cgit v1.2.1 From 986af43f37342953bff548630aa33904c21234f4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 1 May 2015 08:47:01 +0200 Subject: [ticket/13803] Added plugins PHPBB3-13803 --- tests/text_reparser/post_text_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_reparser/post_text_test.php b/tests/text_reparser/post_text_test.php index dc13cebf44..9d9d689db9 100644 --- a/tests/text_reparser/post_text_test.php +++ b/tests/text_reparser/post_text_test.php @@ -38,7 +38,7 @@ class phpbb_textreparser_post_text_test extends phpbb_database_test_case public function testReparse($min_id, $max_id, $expected) { $db = $this->new_dbal(); - $reparser = new \phpbb\textreparser\post_text($db); + $reparser = new \phpbb\textreparser\plugins\post_text($db); $reparser->reparse_range($min_id, $max_id); $sql = 'SELECT post_id, post_text FROM ' . POSTS_TABLE . " -- cgit v1.2.1 From b5911281ae175340817345e63ddbfaf43abb3cec Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 1 May 2015 19:21:01 +0200 Subject: [ticket/13803] Added tests, fixed param order in generate_text_for_storage() PHPBB3-13803 --- tests/text_reparser/fixtures/posts.xml | 42 +++++++++++++++++++++++++++++++++- tests/text_reparser/post_text_test.php | 38 +++++++++++++++++++++++++----- 2 files changed, 73 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/text_reparser/fixtures/posts.xml b/tests/text_reparser/fixtures/posts.xml index 6485293361..3cfbfd2e95 100644 --- a/tests/text_reparser/fixtures/posts.xml +++ b/tests/text_reparser/fixtures/posts.xml @@ -12,7 +12,47 @@ 1 1 1 - Plain text + This post should be [b]ignored[/b] + abcd1234 + + + 2 + 0 + 0 + 0 + [b]Not bold[/b] :) http://example.org + abcd1234 + + + 3 + 1 + 0 + 0 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + + + 4 + 0 + 1 + 0 + :) http://example.org]]> + abcd1234 + + + 5 + 0 + 0 + 1 + http://example.org]]> + abcd1234 + + + 1000 + 1 + 1 + 1 + This post should be [b]ignored[/b] abcd1234 diff --git a/tests/text_reparser/post_text_test.php b/tests/text_reparser/post_text_test.php index 9d9d689db9..19e9c37ecc 100644 --- a/tests/text_reparser/post_text_test.php +++ b/tests/text_reparser/post_text_test.php @@ -40,9 +40,15 @@ class phpbb_textreparser_post_text_test extends phpbb_database_test_case $db = $this->new_dbal(); $reparser = new \phpbb\textreparser\plugins\post_text($db); $reparser->reparse_range($min_id, $max_id); + + $post_ids = array(); + foreach ($expected as $row) + { + $post_ids[] = $row['post_id']; + } $sql = 'SELECT post_id, post_text - FROM ' . POSTS_TABLE . " - WHERE post_id BETWEEN $min_id AND $max_id"; + FROM ' . POSTS_TABLE . ' + WHERE ' . $db->sql_in_set('post_id', $post_ids); $result = $db->sql_query($sql); $rows = $db->sql_fetchrowset($result); $db->sql_freeresult($result); @@ -53,13 +59,33 @@ class phpbb_textreparser_post_text_test extends phpbb_database_test_case { return array( array( - 1, - 1, + 2, + 5, array( array( 'post_id' => 1, - 'post_text' => 'Plain text' - ) + 'post_text' => 'This post should be [b]ignored[/b]', + ), + array( + 'post_id' => 2, + 'post_text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'post_id' => 3, + 'post_text' => '[b]Bold[/b] :) http://example.org', + ), + array( + 'post_id' => 4, + 'post_text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'post_id' => 5, + 'post_text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'post_id' => 1000, + 'post_text' => 'This post should be [b]ignored[/b]', + ), ) ), ); -- cgit v1.2.1 From 459f1d4c1f26658c70d29ac7c4e3f3389a973a59 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 1 May 2015 20:05:15 +0200 Subject: [ticket/13803] Refactored test PHPBB3-13803 --- tests/text_reparser/fixtures/posts.xml | 4 +- tests/text_reparser/post_text_test.php | 75 ++-------------------- tests/text_reparser/test_row_based_plugin.php | 92 +++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 73 deletions(-) create mode 100644 tests/text_reparser/test_row_based_plugin.php (limited to 'tests') diff --git a/tests/text_reparser/fixtures/posts.xml b/tests/text_reparser/fixtures/posts.xml index 3cfbfd2e95..5e725825d8 100644 --- a/tests/text_reparser/fixtures/posts.xml +++ b/tests/text_reparser/fixtures/posts.xml @@ -12,7 +12,7 @@ 1 1 1 - This post should be [b]ignored[/b] + This row should be [b]ignored[/b] abcd1234 @@ -52,7 +52,7 @@ 1 1 1 - This post should be [b]ignored[/b] + This row should be [b]ignored[/b] abcd1234 diff --git a/tests/text_reparser/post_text_test.php b/tests/text_reparser/post_text_test.php index 19e9c37ecc..ac540f170c 100644 --- a/tests/text_reparser/post_text_test.php +++ b/tests/text_reparser/post_text_test.php @@ -10,84 +10,17 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; +include_once __DIR__ . '/test_row_based_plugin.php'; -class phpbb_textreparser_post_text_test extends phpbb_database_test_case +class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_based_plugin { - public function setUp() - { - global $config; - if (!isset($config)) - { - $config = new \phpbb\config\config(array()); - } - $this->get_test_case_helpers()->set_s9e_services(); - parent::setUp(); - } - public function getDataSet() { return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml'); } - /** - * @dataProvider getReparseTests - */ - public function testReparse($min_id, $max_id, $expected) - { - $db = $this->new_dbal(); - $reparser = new \phpbb\textreparser\plugins\post_text($db); - $reparser->reparse_range($min_id, $max_id); - - $post_ids = array(); - foreach ($expected as $row) - { - $post_ids[] = $row['post_id']; - } - $sql = 'SELECT post_id, post_text - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $result = $db->sql_query($sql); - $rows = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - $this->assertEquals($expected, $rows); - } - - public function getReparseTests() + public function get_reparser() { - return array( - array( - 2, - 5, - array( - array( - 'post_id' => 1, - 'post_text' => 'This post should be [b]ignored[/b]', - ), - array( - 'post_id' => 2, - 'post_text' => '[b]Not bold[/b] :) http://example.org', - ), - array( - 'post_id' => 3, - 'post_text' => '[b]Bold[/b] :) http://example.org', - ), - array( - 'post_id' => 4, - 'post_text' => '[b]Not bold[/b] :) http://example.org', - ), - array( - 'post_id' => 5, - 'post_text' => '[b]Not bold[/b] :) http://example.org', - ), - array( - 'post_id' => 1000, - 'post_text' => 'This post should be [b]ignored[/b]', - ), - ) - ), - ); + return new \phpbb\textreparser\plugins\post_text($this->db); } } diff --git a/tests/text_reparser/test_row_based_plugin.php b/tests/text_reparser/test_row_based_plugin.php new file mode 100644 index 0000000000..7dd90f21d0 --- /dev/null +++ b/tests/text_reparser/test_row_based_plugin.php @@ -0,0 +1,92 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; + +abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_test_case +{ + protected $db; + + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + $this->db = $this->new_dbal(); + parent::setUp(); + } + + /** + * @dataProvider getReparseTests + */ + public function testReparse($min_id, $max_id, $expected) + { + $reparser = $this->get_reparser(); + $reparser->reparse_range($min_id, $max_id); + + $ids = array(); + foreach ($expected as $row) + { + $ids[] = $row['id']; + } + + $columns = $reparser->get_columns(); + $sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text + FROM ' . $reparser->get_table_name() . ' + WHERE ' . $this->db->sql_in_set($columns['id'], $ids); + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + $this->assertEquals($expected, $rows); + } + + public function getReparseTests() + { + return array( + array( + 2, + 5, + array( + array( + 'id' => 1, + 'text' => 'This row should be [b]ignored[/b]', + ), + array( + 'id' => 2, + 'text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'id' => 3, + 'text' => '[b]Bold[/b] :) http://example.org', + ), + array( + 'id' => 4, + 'text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'id' => 5, + 'text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'id' => 1000, + 'text' => 'This row should be [b]ignored[/b]', + ), + ) + ), + ); + } +} -- cgit v1.2.1 From 9bf0f794b5876b10491c91548f1a92bc0dff7400 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 2 May 2015 02:55:45 +0200 Subject: [ticket/13803] Added pm_text tests PHPBB3-13803 --- tests/text_reparser/fixtures/privmsgs.xml | 73 +++++++++++++++++++++++++++++++ tests/text_reparser/pm_text_test.php | 26 +++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tests/text_reparser/fixtures/privmsgs.xml create mode 100644 tests/text_reparser/pm_text_test.php (limited to 'tests') diff --git a/tests/text_reparser/fixtures/privmsgs.xml b/tests/text_reparser/fixtures/privmsgs.xml new file mode 100644 index 0000000000..9ca49a2af8 --- /dev/null +++ b/tests/text_reparser/fixtures/privmsgs.xml @@ -0,0 +1,73 @@ + + + + msg_id + enable_bbcode + enable_smilies + enable_magic_url + message_text + bbcode_uid + to_address + bcc_address + + 1 + 1 + 1 + 1 + This row should be [b]ignored[/b] + abcd1234 + + + + + 2 + 0 + 0 + 0 + [b]Not bold[/b] :) http://example.org + abcd1234 + + + + + 3 + 1 + 0 + 0 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + + + + + 4 + 0 + 1 + 0 + :) http://example.org]]> + abcd1234 + + + + + 5 + 0 + 0 + 1 + http://example.org]]> + abcd1234 + + + + + 1000 + 1 + 1 + 1 + This row should be [b]ignored[/b] + abcd1234 + + + +
            +
            diff --git a/tests/text_reparser/pm_text_test.php b/tests/text_reparser/pm_text_test.php new file mode 100644 index 0000000000..6b409d27e3 --- /dev/null +++ b/tests/text_reparser/pm_text_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_pm_text_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/privmsgs.xml'); + } + + public function get_reparser() + { + return new \phpbb\textreparser\plugins\pm_text($this->db); + } +} -- cgit v1.2.1 From 70cd911281056ecb4eefc23e678126e1747debc8 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 2 May 2015 08:51:56 +0200 Subject: [ticket/13803] Added tests PHPBB3-13803 --- tests/text_reparser/fixtures/posts.xml | 32 +++++++++++++++++++++ tests/text_reparser/fixtures/privmsgs.xml | 40 +++++++++++++++++++++++++++ tests/text_reparser/test_row_based_plugin.php | 40 +++++++++++++++++++++++---- 3 files changed, 106 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/text_reparser/fixtures/posts.xml b/tests/text_reparser/fixtures/posts.xml index 5e725825d8..ec31747ed9 100644 --- a/tests/text_reparser/fixtures/posts.xml +++ b/tests/text_reparser/fixtures/posts.xml @@ -47,6 +47,38 @@ http://example.org]]> abcd1234 + + 6 + 1 + 1 + 0 + + abcd1234 + + + 7 + 1 + 1 + 0 + + abcd1234 + + + 8 + 1 + 1 + 0 + + abcd1234 + + + 9 + 1 + 1 + 0 + + abcd1234 + 1000 1 diff --git a/tests/text_reparser/fixtures/privmsgs.xml b/tests/text_reparser/fixtures/privmsgs.xml index 9ca49a2af8..4049b9890a 100644 --- a/tests/text_reparser/fixtures/privmsgs.xml +++ b/tests/text_reparser/fixtures/privmsgs.xml @@ -59,6 +59,46 @@ + + 6 + 1 + 1 + 0 + + abcd1234 + + + + + 7 + 1 + 1 + 0 + + abcd1234 + + + + + 8 + 1 + 1 + 0 + + abcd1234 + + + + + 9 + 1 + 1 + 0 + + abcd1234 + + + 1000 1 diff --git a/tests/text_reparser/test_row_based_plugin.php b/tests/text_reparser/test_row_based_plugin.php index 7dd90f21d0..405341e2fc 100644 --- a/tests/text_reparser/test_row_based_plugin.php +++ b/tests/text_reparser/test_row_based_plugin.php @@ -62,31 +62,59 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t 5, array( array( - 'id' => 1, + 'id' => '1', 'text' => 'This row should be [b]ignored[/b]', ), array( - 'id' => 2, + 'id' => '2', 'text' => '[b]Not bold[/b] :) http://example.org', ), array( - 'id' => 3, + 'id' => '3', 'text' => '[b]Bold[/b] :) http://example.org', ), array( - 'id' => 4, + 'id' => '4', 'text' => '[b]Not bold[/b] :) http://example.org', ), array( - 'id' => 5, + 'id' => '5', 'text' => '[b]Not bold[/b] :) http://example.org', ), array( - 'id' => 1000, + 'id' => '1000', 'text' => 'This row should be [b]ignored[/b]', ), ) ), + array( + 6, + 7, + array( + array( + 'id' => '6', + 'text' => '[flash=123,345]http://example.org/flash.swf[/flash]', + ), + array( + 'id' => '7', + 'text' => '[flash=123,345]http://example.org/flash.swf[/flash]', + ), + ) + ), + array( + 8, + 9, + array( + array( + 'id' => '8', + 'text' => '[img]http://example.org/img.png[/img]', + ), + array( + 'id' => '9', + 'text' => '[img]http://example.org/img.png[/img]', + ), + ) + ), ); } } -- cgit v1.2.1 From 6ab524f8dcf8f918159ba584a659dd88dc9ca3b9 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 3 May 2015 01:39:56 +0200 Subject: [ticket/13803] Added tests PHPBB3-13803 --- tests/text_reparser/fixtures/forums.xml | 91 ++++++++++++++++++++++++++ tests/text_reparser/forum_description_test.php | 26 ++++++++ tests/text_reparser/forum_rules_test.php | 26 ++++++++ 3 files changed, 143 insertions(+) create mode 100644 tests/text_reparser/fixtures/forums.xml create mode 100644 tests/text_reparser/forum_description_test.php create mode 100644 tests/text_reparser/forum_rules_test.php (limited to 'tests') diff --git a/tests/text_reparser/fixtures/forums.xml b/tests/text_reparser/fixtures/forums.xml new file mode 100644 index 0000000000..39c172c969 --- /dev/null +++ b/tests/text_reparser/fixtures/forums.xml @@ -0,0 +1,91 @@ + + + + forum_id + forum_parents + forum_desc + forum_desc_uid + forum_rules + forum_rules_uid + + 1 + + This row should be [b]ignored[/b] + abcd1234 + This row should be [b]ignored[/b] + abcd1234 + + + 2 + + [b]Not bold[/b] :) http://example.org + abcd1234 + [b]Not bold[/b] :) http://example.org + abcd1234 + + + 3 + + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + + + 4 + + :) http://example.org]]> + abcd1234 + :) http://example.org]]> + abcd1234 + + + 5 + + http://example.org]]> + abcd1234 + http://example.org]]> + abcd1234 + + + 6 + + + abcd1234 + + abcd1234 + + + 7 + + + abcd1234 + + abcd1234 + + + 8 + + + abcd1234 + + abcd1234 + + + 9 + + + abcd1234 + + abcd1234 + + + 1000 + + This row should be [b]ignored[/b] + abcd1234 + This row should be [b]ignored[/b] + abcd1234 + +
            +
            diff --git a/tests/text_reparser/forum_description_test.php b/tests/text_reparser/forum_description_test.php new file mode 100644 index 0000000000..66ed261a6f --- /dev/null +++ b/tests/text_reparser/forum_description_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_forum_description_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); + } + + public function get_reparser() + { + return new \phpbb\textreparser\plugins\forum_description($this->db); + } +} diff --git a/tests/text_reparser/forum_rules_test.php b/tests/text_reparser/forum_rules_test.php new file mode 100644 index 0000000000..c89f47cf8e --- /dev/null +++ b/tests/text_reparser/forum_rules_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_forum_rules_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); + } + + public function get_reparser() + { + return new \phpbb\textreparser\plugins\forum_rules($this->db); + } +} -- cgit v1.2.1 From d42b2fe795de913894c0cc9f1df084f8ef0c58f9 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 3 May 2015 02:05:20 +0200 Subject: [ticket/13803] Sort test rows in SQL to match the expected result PHPBB3-13803 --- tests/text_reparser/test_row_based_plugin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_reparser/test_row_based_plugin.php b/tests/text_reparser/test_row_based_plugin.php index 405341e2fc..0258745bf2 100644 --- a/tests/text_reparser/test_row_based_plugin.php +++ b/tests/text_reparser/test_row_based_plugin.php @@ -47,7 +47,8 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t $columns = $reparser->get_columns(); $sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text FROM ' . $reparser->get_table_name() . ' - WHERE ' . $this->db->sql_in_set($columns['id'], $ids); + WHERE ' . $this->db->sql_in_set($columns['id'], $ids) . ' + ORDER BY id'; $result = $this->db->sql_query($sql); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); -- cgit v1.2.1 From a870f8f8603993a2d6a2443c8ad746212071f392 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 6 May 2015 21:32:39 +0200 Subject: [ticket/13803] Added user_signature tests PHPBB3-13803 --- tests/text_reparser/fixtures/users.xml | 91 ++++++++++++++++++++++++++ tests/text_reparser/forum_description_test.php | 2 +- tests/text_reparser/forum_rules_test.php | 2 +- tests/text_reparser/pm_text_test.php | 2 +- tests/text_reparser/post_text_test.php | 2 +- tests/text_reparser/test_row_based_plugin.php | 2 + tests/text_reparser/user_signature_test.php | 26 ++++++++ 7 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 tests/text_reparser/fixtures/users.xml create mode 100644 tests/text_reparser/user_signature_test.php (limited to 'tests') diff --git a/tests/text_reparser/fixtures/users.xml b/tests/text_reparser/fixtures/users.xml new file mode 100644 index 0000000000..60c623b6b1 --- /dev/null +++ b/tests/text_reparser/fixtures/users.xml @@ -0,0 +1,91 @@ + + + + user_id + user_permissions + username_clean + user_options + user_sig + user_sig_bbcode_uid + + 1 + + user1 + 230271 + This row should be [b]ignored[/b] + abcd1234 + + + 2 + + user2 + 895 + [b]Not bold[/b] :) http://example.org + abcd1234 + + + 3 + + user3 + 33663 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + + + 4 + + user4 + 66431 + :) http://example.org]]> + abcd1234 + + + 5 + + user5 + 131967 + http://example.org]]> + abcd1234 + + + 6 + + user6 + 99199 + + abcd1234 + + + 7 + + user7 + 99199 + + abcd1234 + + + 8 + + user8 + 99199 + + abcd1234 + + + 9 + + user9 + 99199 + + abcd1234 + + + 1000 + + user1000 + 230271 + This row should be [b]ignored[/b] + abcd1234 + +
            +
            diff --git a/tests/text_reparser/forum_description_test.php b/tests/text_reparser/forum_description_test.php index 66ed261a6f..3b739353cd 100644 --- a/tests/text_reparser/forum_description_test.php +++ b/tests/text_reparser/forum_description_test.php @@ -19,7 +19,7 @@ class phpbb_textreparser_forum_description_test extends phpbb_textreparser_test_ return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); } - public function get_reparser() + protected function get_reparser() { return new \phpbb\textreparser\plugins\forum_description($this->db); } diff --git a/tests/text_reparser/forum_rules_test.php b/tests/text_reparser/forum_rules_test.php index c89f47cf8e..4c267c9014 100644 --- a/tests/text_reparser/forum_rules_test.php +++ b/tests/text_reparser/forum_rules_test.php @@ -19,7 +19,7 @@ class phpbb_textreparser_forum_rules_test extends phpbb_textreparser_test_row_ba return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); } - public function get_reparser() + protected function get_reparser() { return new \phpbb\textreparser\plugins\forum_rules($this->db); } diff --git a/tests/text_reparser/pm_text_test.php b/tests/text_reparser/pm_text_test.php index 6b409d27e3..3896a57e98 100644 --- a/tests/text_reparser/pm_text_test.php +++ b/tests/text_reparser/pm_text_test.php @@ -19,7 +19,7 @@ class phpbb_textreparser_pm_text_test extends phpbb_textreparser_test_row_based_ return $this->createXMLDataSet(__DIR__ . '/fixtures/privmsgs.xml'); } - public function get_reparser() + protected function get_reparser() { return new \phpbb\textreparser\plugins\pm_text($this->db); } diff --git a/tests/text_reparser/post_text_test.php b/tests/text_reparser/post_text_test.php index ac540f170c..0f934a06ee 100644 --- a/tests/text_reparser/post_text_test.php +++ b/tests/text_reparser/post_text_test.php @@ -19,7 +19,7 @@ class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_base return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml'); } - public function get_reparser() + protected function get_reparser() { return new \phpbb\textreparser\plugins\post_text($this->db); } diff --git a/tests/text_reparser/test_row_based_plugin.php b/tests/text_reparser/test_row_based_plugin.php index 0258745bf2..4d4d64a56d 100644 --- a/tests/text_reparser/test_row_based_plugin.php +++ b/tests/text_reparser/test_row_based_plugin.php @@ -18,6 +18,8 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t { protected $db; + abstract protected function get_reparser(); + public function setUp() { global $config; diff --git a/tests/text_reparser/user_signature_test.php b/tests/text_reparser/user_signature_test.php new file mode 100644 index 0000000000..ab830a303d --- /dev/null +++ b/tests/text_reparser/user_signature_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_user_signature_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/users.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\user_signature($this->db); + } +} -- cgit v1.2.1 From b0eb63e5b9315e8a6f96ea308a835cb7fd712753 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 7 May 2015 11:40:54 +0200 Subject: [ticket/13803] Added group_description tests PHPBB3-13803 --- tests/text_reparser/fixtures/groups.xml | 69 ++++++++++++++++++++++++++ tests/text_reparser/group_description_test.php | 26 ++++++++++ 2 files changed, 95 insertions(+) create mode 100644 tests/text_reparser/fixtures/groups.xml create mode 100644 tests/text_reparser/group_description_test.php (limited to 'tests') diff --git a/tests/text_reparser/fixtures/groups.xml b/tests/text_reparser/fixtures/groups.xml new file mode 100644 index 0000000000..d3df0131a3 --- /dev/null +++ b/tests/text_reparser/fixtures/groups.xml @@ -0,0 +1,69 @@ + + + + group_id + group_desc + group_desc_options + group_desc_uid + + 1 + This row should be [b]ignored[/b] + 7 + abcd1234 + + + 2 + [b]Not bold[/b] :) http://example.org + 0 + abcd1234 + + + 3 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + 1 + abcd1234 + + + 4 + :) http://example.org]]> + 2 + abcd1234 + + + 5 + http://example.org]]> + 4 + abcd1234 + + + 6 + + 7 + abcd1234 + + + 7 + + 7 + abcd1234 + + + 8 + + 7 + abcd1234 + + + 9 + + 7 + abcd1234 + + + 1000 + This row should be [b]ignored[/b] + 7 + abcd1234 + +
            +
            diff --git a/tests/text_reparser/group_description_test.php b/tests/text_reparser/group_description_test.php new file mode 100644 index 0000000000..51035903e1 --- /dev/null +++ b/tests/text_reparser/group_description_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_group_description_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/groups.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\group_description($this->db); + } +} -- cgit v1.2.1 From 8ef15d10e6295eb26fd292a411a8f1edd3853287 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 9 May 2015 18:07:19 +0200 Subject: [ticket/13803] Added poll_title tests PHPBB3-13803 --- tests/text_reparser/fixtures/polls.xml | 68 +++++++++++++++++++++++++++++++++ tests/text_reparser/poll_title_test.php | 26 +++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 tests/text_reparser/fixtures/polls.xml create mode 100644 tests/text_reparser/poll_title_test.php (limited to 'tests') diff --git a/tests/text_reparser/fixtures/polls.xml b/tests/text_reparser/fixtures/polls.xml new file mode 100644 index 0000000000..9baf813c97 --- /dev/null +++ b/tests/text_reparser/fixtures/polls.xml @@ -0,0 +1,68 @@ + + + + post_id + post_text + bbcode_uid + + 1 + + abcd1234 + +
            + + topic_id + topic_first_post_id + poll_title + + 1 + 1 + This row should be [b]ignored[/b] + + + 2 + 1 + [b]Not bold[/b] :) http://example.org + + + 3 + 1 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + + + 4 + 1 + :) http://example.org]]> + + + 5 + 1 + http://example.org]]> + + + 6 + 1 + + + + 7 + 1 + + + + 8 + 1 + + + + 9 + 1 + + + + 1000 + 1 + This row should be [b]ignored[/b] + +
            +
            diff --git a/tests/text_reparser/poll_title_test.php b/tests/text_reparser/poll_title_test.php new file mode 100644 index 0000000000..76ca2ee228 --- /dev/null +++ b/tests/text_reparser/poll_title_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_poll_title_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/polls.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\poll_title($this->db); + } +} -- cgit v1.2.1 From 2dc19cec9d3cb0c1e9ab8ef0afd7515f4bb7cee1 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 9 May 2015 18:14:03 +0200 Subject: [ticket/13803] Added poll_option tests PHPBB3-13803 --- tests/text_reparser/fixtures/poll_options.xml | 78 +++++++++++++++++++++++++++ tests/text_reparser/poll_option_test.php | 26 +++++++++ 2 files changed, 104 insertions(+) create mode 100644 tests/text_reparser/fixtures/poll_options.xml create mode 100644 tests/text_reparser/poll_option_test.php (limited to 'tests') diff --git a/tests/text_reparser/fixtures/poll_options.xml b/tests/text_reparser/fixtures/poll_options.xml new file mode 100644 index 0000000000..f0ed54aafb --- /dev/null +++ b/tests/text_reparser/fixtures/poll_options.xml @@ -0,0 +1,78 @@ + + + + poll_option_id + topic_id + poll_option_text + + 1 + 1 + This row should be [b]ignored[/b] + + + 2 + 1 + [b]Not bold[/b] :) http://example.org + + + 3 + 1 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + + + 4 + 1 + :) http://example.org]]> + + + 5 + 1 + http://example.org]]> + + + 6 + 1 + + + + 7 + 1 + + + + 8 + 1 + + + + 9 + 1 + + + + 1000 + 1 + This row should be [b]ignored[/b] + +
            + + post_id + post_text + bbcode_uid + + 1 + + abcd1234 + +
            + + topic_id + topic_first_post_id + poll_title + + 1 + 1 + This row should be [b]ignored[/b] + +
            +
            diff --git a/tests/text_reparser/poll_option_test.php b/tests/text_reparser/poll_option_test.php new file mode 100644 index 0000000000..0f08f720ff --- /dev/null +++ b/tests/text_reparser/poll_option_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_poll_option_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/poll_options.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\poll_option($this->db); + } +} -- cgit v1.2.1 From 7a8ac4bb714299d2544ec215c24018fe07caa0ec Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 9 May 2015 19:06:48 +0200 Subject: [ticket/13803] Added get_max_id() tests PHPBB3-13803 --- tests/text_reparser/test_row_based_plugin.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/text_reparser/test_row_based_plugin.php b/tests/text_reparser/test_row_based_plugin.php index 4d4d64a56d..489dff280b 100644 --- a/tests/text_reparser/test_row_based_plugin.php +++ b/tests/text_reparser/test_row_based_plugin.php @@ -32,6 +32,12 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t parent::setUp(); } + public function test_get_max_id() + { + $reparser = $this->get_reparser(); + $this->assertEquals(1000, $reparser->get_max_id()); + } + /** * @dataProvider getReparseTests */ -- cgit v1.2.1 From 3827a131ae11dcd3adf852f80ff4d85e7a7d470b Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 9 May 2015 20:12:30 +0200 Subject: [ticket/13803] Rewrote the poll_option plugin As it turns out, poll_option_id is not a primary key. PHPBB3-13803 --- tests/text_reparser/fixtures/poll_options.xml | 53 +++++++++--------- tests/text_reparser/poll_option_test.php | 78 ++++++++++++++++++++++++++- 2 files changed, 100 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/text_reparser/fixtures/poll_options.xml b/tests/text_reparser/fixtures/poll_options.xml index f0ed54aafb..c2fad9f764 100644 --- a/tests/text_reparser/fixtures/poll_options.xml +++ b/tests/text_reparser/fixtures/poll_options.xml @@ -12,47 +12,32 @@ 2 1 - [b]Not bold[/b] :) http://example.org + This row should be [b:abcd1234]ignored[/b:abcd1234] - 3 - 1 - [b:abcd1234]Bold[/b:abcd1234] :) http://example.org - - - 4 1 - :) http://example.org]]> - - - 5 - 1 - http://example.org]]> - - - 6 - 1 - + 2 + [b:abcd1234]Bold[/b:abcd1234] - 7 - 1 - + 2 + 2 + :)]]> - 8 - 1 - + 3 + 2 + http://example.org]]> - 9 1 - + 123 + This row should be [b]ignored[/b] - 1000 - 1 - This row should be [b]ignored[/b] + 2 + 123 + This row should be [b:abcd1234]ignored[/b:abcd1234] @@ -74,5 +59,15 @@ 1This row should be [b]ignored[/b] + + 2 + 1 + This row should be [b]ignored[/b] + + + 123 + 1 + This row should be [b]ignored[/b] +
            diff --git a/tests/text_reparser/poll_option_test.php b/tests/text_reparser/poll_option_test.php index 0f08f720ff..669d859f9a 100644 --- a/tests/text_reparser/poll_option_test.php +++ b/tests/text_reparser/poll_option_test.php @@ -10,10 +10,14 @@ * the docs/CREDITS.txt file. * */ -include_once __DIR__ . '/test_row_based_plugin.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; -class phpbb_textreparser_poll_option_test extends phpbb_textreparser_test_row_based_plugin +class phpbb_textreparser_poll_option_test extends phpbb_database_test_case { + protected $db; + public function getDataSet() { return $this->createXMLDataSet(__DIR__ . '/fixtures/poll_options.xml'); @@ -23,4 +27,74 @@ class phpbb_textreparser_poll_option_test extends phpbb_textreparser_test_row_ba { return new \phpbb\textreparser\plugins\poll_option($this->db); } + + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + $this->db = $this->new_dbal(); + parent::setUp(); + } + + public function test_get_max_id() + { + $reparser = $this->get_reparser(); + $this->assertEquals(123, $reparser->get_max_id()); + } + + public function testReparse() + { + $reparser = $this->get_reparser(); + $reparser->reparse_range(2, 3); + + $sql = 'SELECT topic_id, poll_option_id, poll_option_text + FROM ' . POLL_OPTIONS_TABLE . ' + ORDER BY topic_id, poll_option_id'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + $expected = array( + array( + 'topic_id' => 1, + 'poll_option_id' => 1, + 'poll_option_text' => 'This row should be [b]ignored[/b]', + ), + array( + 'topic_id' => 1, + 'poll_option_id' => 2, + 'poll_option_text' => 'This row should be [b:abcd1234]ignored[/b:abcd1234]', + ), + array( + 'topic_id' => 2, + 'poll_option_id' => 1, + 'poll_option_text' => '[b]Bold[/b]', + ), + array( + 'topic_id' => 2, + 'poll_option_id' => 2, + 'poll_option_text' => ':)', + ), + array( + 'topic_id' => 2, + 'poll_option_id' => 3, + 'poll_option_text' => 'http://example.org', + ), + array( + 'topic_id' => 123, + 'poll_option_id' => 1, + 'poll_option_text' => 'This row should be [b]ignored[/b]', + ), + array( + 'topic_id' => 123, + 'poll_option_id' => 2, + 'poll_option_text' => 'This row should be [b:abcd1234]ignored[/b:abcd1234]', + ), + ); + $this->assertEquals($expected, $rows); + } } -- cgit v1.2.1 From 54b18df084b845c058426b38e7ccfeb534d04ce0 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 10 May 2015 01:54:54 +0200 Subject: [ticket/13803] Added contact_admin_info tests PHPBB3-13803 --- tests/text_reparser/contact_admin_info_test.php | 81 ++++++++++++++++++++++ .../text_reparser/fixtures/contact_admin_info.xml | 23 ++++++ 2 files changed, 104 insertions(+) create mode 100644 tests/text_reparser/contact_admin_info_test.php create mode 100644 tests/text_reparser/fixtures/contact_admin_info.xml (limited to 'tests') diff --git a/tests/text_reparser/contact_admin_info_test.php b/tests/text_reparser/contact_admin_info_test.php new file mode 100644 index 0000000000..5cccdfa4d5 --- /dev/null +++ b/tests/text_reparser/contact_admin_info_test.php @@ -0,0 +1,81 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; + +class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_case +{ + protected $db; + + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/contact_admin_info.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\contact_admin_info(new \phpbb\config\db_text($this->db, CONFIG_TEXT_TABLE)); + } + + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + $this->db = $this->new_dbal(); + parent::setUp(); + } + + public function test_get_max_id() + { + $reparser = $this->get_reparser(); + $this->assertEquals(1, $reparser->get_max_id()); + } + + public function testReparse() + { + $reparser = $this->get_reparser(); + $reparser->reparse_range(1, 1); + + $sql = 'SELECT config_name, config_value + FROM ' . CONFIG_TEXT_TABLE . ' + ORDER BY config_name'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + $expected = array( + array( + 'config_name' => 'contact_admin_info', + 'config_value' => '[email]admin@example.org[/email]', + ), + array( + 'config_name' => 'contact_admin_info_bitfield', + 'config_value' => 'ACA=', + ), + array( + 'config_name' => 'contact_admin_info_flags', + 'config_value' => '7', + ), + array( + 'config_name' => 'contact_admin_info_uid', + 'config_value' => '1a2hbwf5', + ), + ); + $this->assertEquals($expected, $rows); + } +} diff --git a/tests/text_reparser/fixtures/contact_admin_info.xml b/tests/text_reparser/fixtures/contact_admin_info.xml new file mode 100644 index 0000000000..13cd82b1a4 --- /dev/null +++ b/tests/text_reparser/fixtures/contact_admin_info.xml @@ -0,0 +1,23 @@ + + + + config_name + config_value + + contact_admin_info + [email:1a2hbwf5]admin@example.org[/email:1a2hbwf5] + + + contact_admin_info_uid + 1a2hbwf5 + + + contact_admin_info_bitfield + ACA= + + + contact_admin_info_flags + 7 + +
            +
            -- cgit v1.2.1 From c8052ea8230cf7bb70c979dfc87b04527635f4b0 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 29 May 2015 17:35:26 +0200 Subject: [ticket/13803] Set up a global $user for tests PHPBB3-13803 --- tests/test_framework/phpbb_test_case_helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 210cda9a94..cf530cc5be 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -315,7 +315,7 @@ class phpbb_test_case_helpers public function set_s9e_services(ContainerInterface $container = null, $fixture = null, $styles_path = null) { static $first_run; - global $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx; + global $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $user; $cache_dir = __DIR__ . '/../tmp/'; -- cgit v1.2.1 From 132282634ff746c6c4627b87e307df3748f7bbd9 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 29 May 2015 17:36:06 +0200 Subject: [ticket/13803] Moved tests to a subdir PHPBB3-13803 --- tests/text_reparser/contact_admin_info_test.php | 81 ------------- .../text_reparser/fixtures/contact_admin_info.xml | 23 ---- tests/text_reparser/fixtures/forums.xml | 91 --------------- tests/text_reparser/fixtures/groups.xml | 69 ----------- tests/text_reparser/fixtures/poll_options.xml | 73 ------------ tests/text_reparser/fixtures/polls.xml | 68 ----------- tests/text_reparser/fixtures/posts.xml | 91 --------------- tests/text_reparser/fixtures/privmsgs.xml | 113 ------------------ tests/text_reparser/fixtures/users.xml | 91 --------------- tests/text_reparser/forum_description_test.php | 26 ----- tests/text_reparser/forum_rules_test.php | 26 ----- tests/text_reparser/group_description_test.php | 26 ----- .../plugins/contact_admin_info_test.php | 81 +++++++++++++ .../plugins/fixtures/contact_admin_info.xml | 23 ++++ tests/text_reparser/plugins/fixtures/forums.xml | 91 +++++++++++++++ tests/text_reparser/plugins/fixtures/groups.xml | 69 +++++++++++ .../plugins/fixtures/poll_options.xml | 73 ++++++++++++ tests/text_reparser/plugins/fixtures/polls.xml | 68 +++++++++++ tests/text_reparser/plugins/fixtures/posts.xml | 91 +++++++++++++++ tests/text_reparser/plugins/fixtures/privmsgs.xml | 113 ++++++++++++++++++ tests/text_reparser/plugins/fixtures/users.xml | 91 +++++++++++++++ .../plugins/forum_description_test.php | 26 +++++ tests/text_reparser/plugins/forum_rules_test.php | 26 +++++ .../plugins/group_description_test.php | 26 +++++ tests/text_reparser/plugins/pm_text_test.php | 26 +++++ tests/text_reparser/plugins/poll_option_test.php | 100 ++++++++++++++++ tests/text_reparser/plugins/poll_title_test.php | 26 +++++ tests/text_reparser/plugins/post_text_test.php | 26 +++++ .../plugins/test_row_based_plugin.php | 129 +++++++++++++++++++++ .../text_reparser/plugins/user_signature_test.php | 26 +++++ tests/text_reparser/pm_text_test.php | 26 ----- tests/text_reparser/poll_option_test.php | 100 ---------------- tests/text_reparser/poll_title_test.php | 26 ----- tests/text_reparser/post_text_test.php | 26 ----- tests/text_reparser/test_row_based_plugin.php | 129 --------------------- tests/text_reparser/user_signature_test.php | 26 ----- 36 files changed, 1111 insertions(+), 1111 deletions(-) delete mode 100644 tests/text_reparser/contact_admin_info_test.php delete mode 100644 tests/text_reparser/fixtures/contact_admin_info.xml delete mode 100644 tests/text_reparser/fixtures/forums.xml delete mode 100644 tests/text_reparser/fixtures/groups.xml delete mode 100644 tests/text_reparser/fixtures/poll_options.xml delete mode 100644 tests/text_reparser/fixtures/polls.xml delete mode 100644 tests/text_reparser/fixtures/posts.xml delete mode 100644 tests/text_reparser/fixtures/privmsgs.xml delete mode 100644 tests/text_reparser/fixtures/users.xml delete mode 100644 tests/text_reparser/forum_description_test.php delete mode 100644 tests/text_reparser/forum_rules_test.php delete mode 100644 tests/text_reparser/group_description_test.php create mode 100644 tests/text_reparser/plugins/contact_admin_info_test.php create mode 100644 tests/text_reparser/plugins/fixtures/contact_admin_info.xml create mode 100644 tests/text_reparser/plugins/fixtures/forums.xml create mode 100644 tests/text_reparser/plugins/fixtures/groups.xml create mode 100644 tests/text_reparser/plugins/fixtures/poll_options.xml create mode 100644 tests/text_reparser/plugins/fixtures/polls.xml create mode 100644 tests/text_reparser/plugins/fixtures/posts.xml create mode 100644 tests/text_reparser/plugins/fixtures/privmsgs.xml create mode 100644 tests/text_reparser/plugins/fixtures/users.xml create mode 100644 tests/text_reparser/plugins/forum_description_test.php create mode 100644 tests/text_reparser/plugins/forum_rules_test.php create mode 100644 tests/text_reparser/plugins/group_description_test.php create mode 100644 tests/text_reparser/plugins/pm_text_test.php create mode 100644 tests/text_reparser/plugins/poll_option_test.php create mode 100644 tests/text_reparser/plugins/poll_title_test.php create mode 100644 tests/text_reparser/plugins/post_text_test.php create mode 100644 tests/text_reparser/plugins/test_row_based_plugin.php create mode 100644 tests/text_reparser/plugins/user_signature_test.php delete mode 100644 tests/text_reparser/pm_text_test.php delete mode 100644 tests/text_reparser/poll_option_test.php delete mode 100644 tests/text_reparser/poll_title_test.php delete mode 100644 tests/text_reparser/post_text_test.php delete mode 100644 tests/text_reparser/test_row_based_plugin.php delete mode 100644 tests/text_reparser/user_signature_test.php (limited to 'tests') diff --git a/tests/text_reparser/contact_admin_info_test.php b/tests/text_reparser/contact_admin_info_test.php deleted file mode 100644 index 5cccdfa4d5..0000000000 --- a/tests/text_reparser/contact_admin_info_test.php +++ /dev/null @@ -1,81 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; - -class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_case -{ - protected $db; - - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/contact_admin_info.xml'); - } - - protected function get_reparser() - { - return new \phpbb\textreparser\plugins\contact_admin_info(new \phpbb\config\db_text($this->db, CONFIG_TEXT_TABLE)); - } - - public function setUp() - { - global $config; - if (!isset($config)) - { - $config = new \phpbb\config\config(array()); - } - $this->get_test_case_helpers()->set_s9e_services(); - $this->db = $this->new_dbal(); - parent::setUp(); - } - - public function test_get_max_id() - { - $reparser = $this->get_reparser(); - $this->assertEquals(1, $reparser->get_max_id()); - } - - public function testReparse() - { - $reparser = $this->get_reparser(); - $reparser->reparse_range(1, 1); - - $sql = 'SELECT config_name, config_value - FROM ' . CONFIG_TEXT_TABLE . ' - ORDER BY config_name'; - $result = $this->db->sql_query($sql); - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - $expected = array( - array( - 'config_name' => 'contact_admin_info', - 'config_value' => '[email]admin@example.org[/email]', - ), - array( - 'config_name' => 'contact_admin_info_bitfield', - 'config_value' => 'ACA=', - ), - array( - 'config_name' => 'contact_admin_info_flags', - 'config_value' => '7', - ), - array( - 'config_name' => 'contact_admin_info_uid', - 'config_value' => '1a2hbwf5', - ), - ); - $this->assertEquals($expected, $rows); - } -} diff --git a/tests/text_reparser/fixtures/contact_admin_info.xml b/tests/text_reparser/fixtures/contact_admin_info.xml deleted file mode 100644 index 13cd82b1a4..0000000000 --- a/tests/text_reparser/fixtures/contact_admin_info.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - config_name - config_value - - contact_admin_info - [email:1a2hbwf5]admin@example.org[/email:1a2hbwf5] - - - contact_admin_info_uid - 1a2hbwf5 - - - contact_admin_info_bitfield - ACA= - - - contact_admin_info_flags - 7 - -
            -
            diff --git a/tests/text_reparser/fixtures/forums.xml b/tests/text_reparser/fixtures/forums.xml deleted file mode 100644 index 39c172c969..0000000000 --- a/tests/text_reparser/fixtures/forums.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - forum_id - forum_parents - forum_desc - forum_desc_uid - forum_rules - forum_rules_uid - - 1 - - This row should be [b]ignored[/b] - abcd1234 - This row should be [b]ignored[/b] - abcd1234 - - - 2 - - [b]Not bold[/b] :) http://example.org - abcd1234 - [b]Not bold[/b] :) http://example.org - abcd1234 - - - 3 - - [b:abcd1234]Bold[/b:abcd1234] :) http://example.org - abcd1234 - [b:abcd1234]Bold[/b:abcd1234] :) http://example.org - abcd1234 - - - 4 - - :) http://example.org]]> - abcd1234 - :) http://example.org]]> - abcd1234 - - - 5 - - http://example.org]]> - abcd1234 - http://example.org]]> - abcd1234 - - - 6 - - - abcd1234 - - abcd1234 - - - 7 - - - abcd1234 - - abcd1234 - - - 8 - - - abcd1234 - - abcd1234 - - - 9 - - - abcd1234 - - abcd1234 - - - 1000 - - This row should be [b]ignored[/b] - abcd1234 - This row should be [b]ignored[/b] - abcd1234 - -
            -
            diff --git a/tests/text_reparser/fixtures/groups.xml b/tests/text_reparser/fixtures/groups.xml deleted file mode 100644 index d3df0131a3..0000000000 --- a/tests/text_reparser/fixtures/groups.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - group_id - group_desc - group_desc_options - group_desc_uid - - 1 - This row should be [b]ignored[/b] - 7 - abcd1234 - - - 2 - [b]Not bold[/b] :) http://example.org - 0 - abcd1234 - - - 3 - [b:abcd1234]Bold[/b:abcd1234] :) http://example.org - 1 - abcd1234 - - - 4 - :) http://example.org]]> - 2 - abcd1234 - - - 5 - http://example.org]]> - 4 - abcd1234 - - - 6 - - 7 - abcd1234 - - - 7 - - 7 - abcd1234 - - - 8 - - 7 - abcd1234 - - - 9 - - 7 - abcd1234 - - - 1000 - This row should be [b]ignored[/b] - 7 - abcd1234 - -
            -
            diff --git a/tests/text_reparser/fixtures/poll_options.xml b/tests/text_reparser/fixtures/poll_options.xml deleted file mode 100644 index c2fad9f764..0000000000 --- a/tests/text_reparser/fixtures/poll_options.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - poll_option_id - topic_id - poll_option_text - - 1 - 1 - This row should be [b]ignored[/b] - - - 2 - 1 - This row should be [b:abcd1234]ignored[/b:abcd1234] - - - 1 - 2 - [b:abcd1234]Bold[/b:abcd1234] - - - 2 - 2 - :)]]> - - - 3 - 2 - http://example.org]]> - - - 1 - 123 - This row should be [b]ignored[/b] - - - 2 - 123 - This row should be [b:abcd1234]ignored[/b:abcd1234] - -
            - - post_id - post_text - bbcode_uid - - 1 - - abcd1234 - -
            - - topic_id - topic_first_post_id - poll_title - - 1 - 1 - This row should be [b]ignored[/b] - - - 2 - 1 - This row should be [b]ignored[/b] - - - 123 - 1 - This row should be [b]ignored[/b] - -
            -
            diff --git a/tests/text_reparser/fixtures/polls.xml b/tests/text_reparser/fixtures/polls.xml deleted file mode 100644 index 9baf813c97..0000000000 --- a/tests/text_reparser/fixtures/polls.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - post_id - post_text - bbcode_uid - - 1 - - abcd1234 - -
            - - topic_id - topic_first_post_id - poll_title - - 1 - 1 - This row should be [b]ignored[/b] - - - 2 - 1 - [b]Not bold[/b] :) http://example.org - - - 3 - 1 - [b:abcd1234]Bold[/b:abcd1234] :) http://example.org - - - 4 - 1 - :) http://example.org]]> - - - 5 - 1 - http://example.org]]> - - - 6 - 1 - - - - 7 - 1 - - - - 8 - 1 - - - - 9 - 1 - - - - 1000 - 1 - This row should be [b]ignored[/b] - -
            -
            diff --git a/tests/text_reparser/fixtures/posts.xml b/tests/text_reparser/fixtures/posts.xml deleted file mode 100644 index ec31747ed9..0000000000 --- a/tests/text_reparser/fixtures/posts.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - post_id - enable_bbcode - enable_smilies - enable_magic_url - post_text - bbcode_uid - - 1 - 1 - 1 - 1 - This row should be [b]ignored[/b] - abcd1234 - - - 2 - 0 - 0 - 0 - [b]Not bold[/b] :) http://example.org - abcd1234 - - - 3 - 1 - 0 - 0 - [b:abcd1234]Bold[/b:abcd1234] :) http://example.org - abcd1234 - - - 4 - 0 - 1 - 0 - :) http://example.org]]> - abcd1234 - - - 5 - 0 - 0 - 1 - http://example.org]]> - abcd1234 - - - 6 - 1 - 1 - 0 - - abcd1234 - - - 7 - 1 - 1 - 0 - - abcd1234 - - - 8 - 1 - 1 - 0 - - abcd1234 - - - 9 - 1 - 1 - 0 - - abcd1234 - - - 1000 - 1 - 1 - 1 - This row should be [b]ignored[/b] - abcd1234 - -
            -
            diff --git a/tests/text_reparser/fixtures/privmsgs.xml b/tests/text_reparser/fixtures/privmsgs.xml deleted file mode 100644 index 4049b9890a..0000000000 --- a/tests/text_reparser/fixtures/privmsgs.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - msg_id - enable_bbcode - enable_smilies - enable_magic_url - message_text - bbcode_uid - to_address - bcc_address - - 1 - 1 - 1 - 1 - This row should be [b]ignored[/b] - abcd1234 - - - - - 2 - 0 - 0 - 0 - [b]Not bold[/b] :) http://example.org - abcd1234 - - - - - 3 - 1 - 0 - 0 - [b:abcd1234]Bold[/b:abcd1234] :) http://example.org - abcd1234 - - - - - 4 - 0 - 1 - 0 - :) http://example.org]]> - abcd1234 - - - - - 5 - 0 - 0 - 1 - http://example.org]]> - abcd1234 - - - - - 6 - 1 - 1 - 0 - - abcd1234 - - - - - 7 - 1 - 1 - 0 - - abcd1234 - - - - - 8 - 1 - 1 - 0 - - abcd1234 - - - - - 9 - 1 - 1 - 0 - - abcd1234 - - - - - 1000 - 1 - 1 - 1 - This row should be [b]ignored[/b] - abcd1234 - - - -
            -
            diff --git a/tests/text_reparser/fixtures/users.xml b/tests/text_reparser/fixtures/users.xml deleted file mode 100644 index 60c623b6b1..0000000000 --- a/tests/text_reparser/fixtures/users.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - user_id - user_permissions - username_clean - user_options - user_sig - user_sig_bbcode_uid - - 1 - - user1 - 230271 - This row should be [b]ignored[/b] - abcd1234 - - - 2 - - user2 - 895 - [b]Not bold[/b] :) http://example.org - abcd1234 - - - 3 - - user3 - 33663 - [b:abcd1234]Bold[/b:abcd1234] :) http://example.org - abcd1234 - - - 4 - - user4 - 66431 - :) http://example.org]]> - abcd1234 - - - 5 - - user5 - 131967 - http://example.org]]> - abcd1234 - - - 6 - - user6 - 99199 - - abcd1234 - - - 7 - - user7 - 99199 - - abcd1234 - - - 8 - - user8 - 99199 - - abcd1234 - - - 9 - - user9 - 99199 - - abcd1234 - - - 1000 - - user1000 - 230271 - This row should be [b]ignored[/b] - abcd1234 - -
            -
            diff --git a/tests/text_reparser/forum_description_test.php b/tests/text_reparser/forum_description_test.php deleted file mode 100644 index 3b739353cd..0000000000 --- a/tests/text_reparser/forum_description_test.php +++ /dev/null @@ -1,26 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -include_once __DIR__ . '/test_row_based_plugin.php'; - -class phpbb_textreparser_forum_description_test extends phpbb_textreparser_test_row_based_plugin -{ - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); - } - - protected function get_reparser() - { - return new \phpbb\textreparser\plugins\forum_description($this->db); - } -} diff --git a/tests/text_reparser/forum_rules_test.php b/tests/text_reparser/forum_rules_test.php deleted file mode 100644 index 4c267c9014..0000000000 --- a/tests/text_reparser/forum_rules_test.php +++ /dev/null @@ -1,26 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -include_once __DIR__ . '/test_row_based_plugin.php'; - -class phpbb_textreparser_forum_rules_test extends phpbb_textreparser_test_row_based_plugin -{ - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); - } - - protected function get_reparser() - { - return new \phpbb\textreparser\plugins\forum_rules($this->db); - } -} diff --git a/tests/text_reparser/group_description_test.php b/tests/text_reparser/group_description_test.php deleted file mode 100644 index 51035903e1..0000000000 --- a/tests/text_reparser/group_description_test.php +++ /dev/null @@ -1,26 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -include_once __DIR__ . '/test_row_based_plugin.php'; - -class phpbb_textreparser_group_description_test extends phpbb_textreparser_test_row_based_plugin -{ - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/groups.xml'); - } - - protected function get_reparser() - { - return new \phpbb\textreparser\plugins\group_description($this->db); - } -} diff --git a/tests/text_reparser/plugins/contact_admin_info_test.php b/tests/text_reparser/plugins/contact_admin_info_test.php new file mode 100644 index 0000000000..e577d2fd3d --- /dev/null +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -0,0 +1,81 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once __DIR__ . '/../../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; + +class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_case +{ + protected $db; + + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/contact_admin_info.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\contact_admin_info(new \phpbb\config\db_text($this->db, CONFIG_TEXT_TABLE)); + } + + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + $this->db = $this->new_dbal(); + parent::setUp(); + } + + public function test_get_max_id() + { + $reparser = $this->get_reparser(); + $this->assertEquals(1, $reparser->get_max_id()); + } + + public function testReparse() + { + $reparser = $this->get_reparser(); + $reparser->reparse_range(1, 1); + + $sql = 'SELECT config_name, config_value + FROM ' . CONFIG_TEXT_TABLE . ' + ORDER BY config_name'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + $expected = array( + array( + 'config_name' => 'contact_admin_info', + 'config_value' => '[email]admin@example.org[/email]', + ), + array( + 'config_name' => 'contact_admin_info_bitfield', + 'config_value' => 'ACA=', + ), + array( + 'config_name' => 'contact_admin_info_flags', + 'config_value' => '7', + ), + array( + 'config_name' => 'contact_admin_info_uid', + 'config_value' => '1a2hbwf5', + ), + ); + $this->assertEquals($expected, $rows); + } +} diff --git a/tests/text_reparser/plugins/fixtures/contact_admin_info.xml b/tests/text_reparser/plugins/fixtures/contact_admin_info.xml new file mode 100644 index 0000000000..13cd82b1a4 --- /dev/null +++ b/tests/text_reparser/plugins/fixtures/contact_admin_info.xml @@ -0,0 +1,23 @@ + + + + config_name + config_value + + contact_admin_info + [email:1a2hbwf5]admin@example.org[/email:1a2hbwf5] + + + contact_admin_info_uid + 1a2hbwf5 + + + contact_admin_info_bitfield + ACA= + + + contact_admin_info_flags + 7 + +
            +
            diff --git a/tests/text_reparser/plugins/fixtures/forums.xml b/tests/text_reparser/plugins/fixtures/forums.xml new file mode 100644 index 0000000000..39c172c969 --- /dev/null +++ b/tests/text_reparser/plugins/fixtures/forums.xml @@ -0,0 +1,91 @@ + + + + forum_id + forum_parents + forum_desc + forum_desc_uid + forum_rules + forum_rules_uid + + 1 + + This row should be [b]ignored[/b] + abcd1234 + This row should be [b]ignored[/b] + abcd1234 + + + 2 + + [b]Not bold[/b] :) http://example.org + abcd1234 + [b]Not bold[/b] :) http://example.org + abcd1234 + + + 3 + + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + + + 4 + + :) http://example.org]]> + abcd1234 + :) http://example.org]]> + abcd1234 + + + 5 + + http://example.org]]> + abcd1234 + http://example.org]]> + abcd1234 + + + 6 + + + abcd1234 + + abcd1234 + + + 7 + + + abcd1234 + + abcd1234 + + + 8 + + + abcd1234 + + abcd1234 + + + 9 + + + abcd1234 + + abcd1234 + + + 1000 + + This row should be [b]ignored[/b] + abcd1234 + This row should be [b]ignored[/b] + abcd1234 + +
            +
            diff --git a/tests/text_reparser/plugins/fixtures/groups.xml b/tests/text_reparser/plugins/fixtures/groups.xml new file mode 100644 index 0000000000..d3df0131a3 --- /dev/null +++ b/tests/text_reparser/plugins/fixtures/groups.xml @@ -0,0 +1,69 @@ + + + + group_id + group_desc + group_desc_options + group_desc_uid + + 1 + This row should be [b]ignored[/b] + 7 + abcd1234 + + + 2 + [b]Not bold[/b] :) http://example.org + 0 + abcd1234 + + + 3 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + 1 + abcd1234 + + + 4 + :) http://example.org]]> + 2 + abcd1234 + + + 5 + http://example.org]]> + 4 + abcd1234 + + + 6 + + 7 + abcd1234 + + + 7 + + 7 + abcd1234 + + + 8 + + 7 + abcd1234 + + + 9 + + 7 + abcd1234 + + + 1000 + This row should be [b]ignored[/b] + 7 + abcd1234 + +
            +
            diff --git a/tests/text_reparser/plugins/fixtures/poll_options.xml b/tests/text_reparser/plugins/fixtures/poll_options.xml new file mode 100644 index 0000000000..c2fad9f764 --- /dev/null +++ b/tests/text_reparser/plugins/fixtures/poll_options.xml @@ -0,0 +1,73 @@ + + + + poll_option_id + topic_id + poll_option_text + + 1 + 1 + This row should be [b]ignored[/b] + + + 2 + 1 + This row should be [b:abcd1234]ignored[/b:abcd1234] + + + 1 + 2 + [b:abcd1234]Bold[/b:abcd1234] + + + 2 + 2 + :)]]> + + + 3 + 2 + http://example.org]]> + + + 1 + 123 + This row should be [b]ignored[/b] + + + 2 + 123 + This row should be [b:abcd1234]ignored[/b:abcd1234] + +
            + + post_id + post_text + bbcode_uid + + 1 + + abcd1234 + +
            + + topic_id + topic_first_post_id + poll_title + + 1 + 1 + This row should be [b]ignored[/b] + + + 2 + 1 + This row should be [b]ignored[/b] + + + 123 + 1 + This row should be [b]ignored[/b] + +
            +
            diff --git a/tests/text_reparser/plugins/fixtures/polls.xml b/tests/text_reparser/plugins/fixtures/polls.xml new file mode 100644 index 0000000000..9baf813c97 --- /dev/null +++ b/tests/text_reparser/plugins/fixtures/polls.xml @@ -0,0 +1,68 @@ + + + + post_id + post_text + bbcode_uid + + 1 + + abcd1234 + +
            + + topic_id + topic_first_post_id + poll_title + + 1 + 1 + This row should be [b]ignored[/b] + + + 2 + 1 + [b]Not bold[/b] :) http://example.org + + + 3 + 1 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + + + 4 + 1 + :) http://example.org]]> + + + 5 + 1 + http://example.org]]> + + + 6 + 1 + + + + 7 + 1 + + + + 8 + 1 + + + + 9 + 1 + + + + 1000 + 1 + This row should be [b]ignored[/b] + +
            +
            diff --git a/tests/text_reparser/plugins/fixtures/posts.xml b/tests/text_reparser/plugins/fixtures/posts.xml new file mode 100644 index 0000000000..ec31747ed9 --- /dev/null +++ b/tests/text_reparser/plugins/fixtures/posts.xml @@ -0,0 +1,91 @@ + + + + post_id + enable_bbcode + enable_smilies + enable_magic_url + post_text + bbcode_uid + + 1 + 1 + 1 + 1 + This row should be [b]ignored[/b] + abcd1234 + + + 2 + 0 + 0 + 0 + [b]Not bold[/b] :) http://example.org + abcd1234 + + + 3 + 1 + 0 + 0 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + + + 4 + 0 + 1 + 0 + :) http://example.org]]> + abcd1234 + + + 5 + 0 + 0 + 1 + http://example.org]]> + abcd1234 + + + 6 + 1 + 1 + 0 + + abcd1234 + + + 7 + 1 + 1 + 0 + + abcd1234 + + + 8 + 1 + 1 + 0 + + abcd1234 + + + 9 + 1 + 1 + 0 + + abcd1234 + + + 1000 + 1 + 1 + 1 + This row should be [b]ignored[/b] + abcd1234 + +
            +
            diff --git a/tests/text_reparser/plugins/fixtures/privmsgs.xml b/tests/text_reparser/plugins/fixtures/privmsgs.xml new file mode 100644 index 0000000000..4049b9890a --- /dev/null +++ b/tests/text_reparser/plugins/fixtures/privmsgs.xml @@ -0,0 +1,113 @@ + + + + msg_id + enable_bbcode + enable_smilies + enable_magic_url + message_text + bbcode_uid + to_address + bcc_address + + 1 + 1 + 1 + 1 + This row should be [b]ignored[/b] + abcd1234 + + + + + 2 + 0 + 0 + 0 + [b]Not bold[/b] :) http://example.org + abcd1234 + + + + + 3 + 1 + 0 + 0 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + + + + + 4 + 0 + 1 + 0 + :) http://example.org]]> + abcd1234 + + + + + 5 + 0 + 0 + 1 + http://example.org]]> + abcd1234 + + + + + 6 + 1 + 1 + 0 + + abcd1234 + + + + + 7 + 1 + 1 + 0 + + abcd1234 + + + + + 8 + 1 + 1 + 0 + + abcd1234 + + + + + 9 + 1 + 1 + 0 + + abcd1234 + + + + + 1000 + 1 + 1 + 1 + This row should be [b]ignored[/b] + abcd1234 + + + +
            +
            diff --git a/tests/text_reparser/plugins/fixtures/users.xml b/tests/text_reparser/plugins/fixtures/users.xml new file mode 100644 index 0000000000..60c623b6b1 --- /dev/null +++ b/tests/text_reparser/plugins/fixtures/users.xml @@ -0,0 +1,91 @@ + + + + user_id + user_permissions + username_clean + user_options + user_sig + user_sig_bbcode_uid + + 1 + + user1 + 230271 + This row should be [b]ignored[/b] + abcd1234 + + + 2 + + user2 + 895 + [b]Not bold[/b] :) http://example.org + abcd1234 + + + 3 + + user3 + 33663 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + + + 4 + + user4 + 66431 + :) http://example.org]]> + abcd1234 + + + 5 + + user5 + 131967 + http://example.org]]> + abcd1234 + + + 6 + + user6 + 99199 + + abcd1234 + + + 7 + + user7 + 99199 + + abcd1234 + + + 8 + + user8 + 99199 + + abcd1234 + + + 9 + + user9 + 99199 + + abcd1234 + + + 1000 + + user1000 + 230271 + This row should be [b]ignored[/b] + abcd1234 + +
            +
            diff --git a/tests/text_reparser/plugins/forum_description_test.php b/tests/text_reparser/plugins/forum_description_test.php new file mode 100644 index 0000000000..3b739353cd --- /dev/null +++ b/tests/text_reparser/plugins/forum_description_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_forum_description_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\forum_description($this->db); + } +} diff --git a/tests/text_reparser/plugins/forum_rules_test.php b/tests/text_reparser/plugins/forum_rules_test.php new file mode 100644 index 0000000000..4c267c9014 --- /dev/null +++ b/tests/text_reparser/plugins/forum_rules_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_forum_rules_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\forum_rules($this->db); + } +} diff --git a/tests/text_reparser/plugins/group_description_test.php b/tests/text_reparser/plugins/group_description_test.php new file mode 100644 index 0000000000..51035903e1 --- /dev/null +++ b/tests/text_reparser/plugins/group_description_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_group_description_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/groups.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\group_description($this->db); + } +} diff --git a/tests/text_reparser/plugins/pm_text_test.php b/tests/text_reparser/plugins/pm_text_test.php new file mode 100644 index 0000000000..3896a57e98 --- /dev/null +++ b/tests/text_reparser/plugins/pm_text_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_pm_text_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/privmsgs.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\pm_text($this->db); + } +} diff --git a/tests/text_reparser/plugins/poll_option_test.php b/tests/text_reparser/plugins/poll_option_test.php new file mode 100644 index 0000000000..e043858597 --- /dev/null +++ b/tests/text_reparser/plugins/poll_option_test.php @@ -0,0 +1,100 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once __DIR__ . '/../../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; + +class phpbb_textreparser_poll_option_test extends phpbb_database_test_case +{ + protected $db; + + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/poll_options.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\poll_option($this->db); + } + + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + $this->db = $this->new_dbal(); + parent::setUp(); + } + + public function test_get_max_id() + { + $reparser = $this->get_reparser(); + $this->assertEquals(123, $reparser->get_max_id()); + } + + public function testReparse() + { + $reparser = $this->get_reparser(); + $reparser->reparse_range(2, 3); + + $sql = 'SELECT topic_id, poll_option_id, poll_option_text + FROM ' . POLL_OPTIONS_TABLE . ' + ORDER BY topic_id, poll_option_id'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + $expected = array( + array( + 'topic_id' => 1, + 'poll_option_id' => 1, + 'poll_option_text' => 'This row should be [b]ignored[/b]', + ), + array( + 'topic_id' => 1, + 'poll_option_id' => 2, + 'poll_option_text' => 'This row should be [b:abcd1234]ignored[/b:abcd1234]', + ), + array( + 'topic_id' => 2, + 'poll_option_id' => 1, + 'poll_option_text' => '[b]Bold[/b]', + ), + array( + 'topic_id' => 2, + 'poll_option_id' => 2, + 'poll_option_text' => ':)', + ), + array( + 'topic_id' => 2, + 'poll_option_id' => 3, + 'poll_option_text' => 'http://example.org', + ), + array( + 'topic_id' => 123, + 'poll_option_id' => 1, + 'poll_option_text' => 'This row should be [b]ignored[/b]', + ), + array( + 'topic_id' => 123, + 'poll_option_id' => 2, + 'poll_option_text' => 'This row should be [b:abcd1234]ignored[/b:abcd1234]', + ), + ); + $this->assertEquals($expected, $rows); + } +} diff --git a/tests/text_reparser/plugins/poll_title_test.php b/tests/text_reparser/plugins/poll_title_test.php new file mode 100644 index 0000000000..76ca2ee228 --- /dev/null +++ b/tests/text_reparser/plugins/poll_title_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_poll_title_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/polls.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\poll_title($this->db); + } +} diff --git a/tests/text_reparser/plugins/post_text_test.php b/tests/text_reparser/plugins/post_text_test.php new file mode 100644 index 0000000000..0f934a06ee --- /dev/null +++ b/tests/text_reparser/plugins/post_text_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\post_text($this->db); + } +} diff --git a/tests/text_reparser/plugins/test_row_based_plugin.php b/tests/text_reparser/plugins/test_row_based_plugin.php new file mode 100644 index 0000000000..befcb48bda --- /dev/null +++ b/tests/text_reparser/plugins/test_row_based_plugin.php @@ -0,0 +1,129 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once __DIR__ . '/../../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; + +abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_test_case +{ + protected $db; + + abstract protected function get_reparser(); + + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + $this->db = $this->new_dbal(); + parent::setUp(); + } + + public function test_get_max_id() + { + $reparser = $this->get_reparser(); + $this->assertEquals(1000, $reparser->get_max_id()); + } + + /** + * @dataProvider getReparseTests + */ + public function testReparse($min_id, $max_id, $expected) + { + $reparser = $this->get_reparser(); + $reparser->reparse_range($min_id, $max_id); + + $ids = array(); + foreach ($expected as $row) + { + $ids[] = $row['id']; + } + + $columns = $reparser->get_columns(); + $sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text + FROM ' . $reparser->get_table_name() . ' + WHERE ' . $this->db->sql_in_set($columns['id'], $ids) . ' + ORDER BY id'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + $this->assertEquals($expected, $rows); + } + + public function getReparseTests() + { + return array( + array( + 2, + 5, + array( + array( + 'id' => '1', + 'text' => 'This row should be [b]ignored[/b]', + ), + array( + 'id' => '2', + 'text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'id' => '3', + 'text' => '[b]Bold[/b] :) http://example.org', + ), + array( + 'id' => '4', + 'text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'id' => '5', + 'text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'id' => '1000', + 'text' => 'This row should be [b]ignored[/b]', + ), + ) + ), + array( + 6, + 7, + array( + array( + 'id' => '6', + 'text' => '[flash=123,345]http://example.org/flash.swf[/flash]', + ), + array( + 'id' => '7', + 'text' => '[flash=123,345]http://example.org/flash.swf[/flash]', + ), + ) + ), + array( + 8, + 9, + array( + array( + 'id' => '8', + 'text' => '[img]http://example.org/img.png[/img]', + ), + array( + 'id' => '9', + 'text' => '[img]http://example.org/img.png[/img]', + ), + ) + ), + ); + } +} diff --git a/tests/text_reparser/plugins/user_signature_test.php b/tests/text_reparser/plugins/user_signature_test.php new file mode 100644 index 0000000000..ab830a303d --- /dev/null +++ b/tests/text_reparser/plugins/user_signature_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_user_signature_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/users.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\user_signature($this->db); + } +} diff --git a/tests/text_reparser/pm_text_test.php b/tests/text_reparser/pm_text_test.php deleted file mode 100644 index 3896a57e98..0000000000 --- a/tests/text_reparser/pm_text_test.php +++ /dev/null @@ -1,26 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -include_once __DIR__ . '/test_row_based_plugin.php'; - -class phpbb_textreparser_pm_text_test extends phpbb_textreparser_test_row_based_plugin -{ - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/privmsgs.xml'); - } - - protected function get_reparser() - { - return new \phpbb\textreparser\plugins\pm_text($this->db); - } -} diff --git a/tests/text_reparser/poll_option_test.php b/tests/text_reparser/poll_option_test.php deleted file mode 100644 index 669d859f9a..0000000000 --- a/tests/text_reparser/poll_option_test.php +++ /dev/null @@ -1,100 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; - -class phpbb_textreparser_poll_option_test extends phpbb_database_test_case -{ - protected $db; - - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/poll_options.xml'); - } - - protected function get_reparser() - { - return new \phpbb\textreparser\plugins\poll_option($this->db); - } - - public function setUp() - { - global $config; - if (!isset($config)) - { - $config = new \phpbb\config\config(array()); - } - $this->get_test_case_helpers()->set_s9e_services(); - $this->db = $this->new_dbal(); - parent::setUp(); - } - - public function test_get_max_id() - { - $reparser = $this->get_reparser(); - $this->assertEquals(123, $reparser->get_max_id()); - } - - public function testReparse() - { - $reparser = $this->get_reparser(); - $reparser->reparse_range(2, 3); - - $sql = 'SELECT topic_id, poll_option_id, poll_option_text - FROM ' . POLL_OPTIONS_TABLE . ' - ORDER BY topic_id, poll_option_id'; - $result = $this->db->sql_query($sql); - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - $expected = array( - array( - 'topic_id' => 1, - 'poll_option_id' => 1, - 'poll_option_text' => 'This row should be [b]ignored[/b]', - ), - array( - 'topic_id' => 1, - 'poll_option_id' => 2, - 'poll_option_text' => 'This row should be [b:abcd1234]ignored[/b:abcd1234]', - ), - array( - 'topic_id' => 2, - 'poll_option_id' => 1, - 'poll_option_text' => '[b]Bold[/b]', - ), - array( - 'topic_id' => 2, - 'poll_option_id' => 2, - 'poll_option_text' => ':)', - ), - array( - 'topic_id' => 2, - 'poll_option_id' => 3, - 'poll_option_text' => 'http://example.org', - ), - array( - 'topic_id' => 123, - 'poll_option_id' => 1, - 'poll_option_text' => 'This row should be [b]ignored[/b]', - ), - array( - 'topic_id' => 123, - 'poll_option_id' => 2, - 'poll_option_text' => 'This row should be [b:abcd1234]ignored[/b:abcd1234]', - ), - ); - $this->assertEquals($expected, $rows); - } -} diff --git a/tests/text_reparser/poll_title_test.php b/tests/text_reparser/poll_title_test.php deleted file mode 100644 index 76ca2ee228..0000000000 --- a/tests/text_reparser/poll_title_test.php +++ /dev/null @@ -1,26 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -include_once __DIR__ . '/test_row_based_plugin.php'; - -class phpbb_textreparser_poll_title_test extends phpbb_textreparser_test_row_based_plugin -{ - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/polls.xml'); - } - - protected function get_reparser() - { - return new \phpbb\textreparser\plugins\poll_title($this->db); - } -} diff --git a/tests/text_reparser/post_text_test.php b/tests/text_reparser/post_text_test.php deleted file mode 100644 index 0f934a06ee..0000000000 --- a/tests/text_reparser/post_text_test.php +++ /dev/null @@ -1,26 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -include_once __DIR__ . '/test_row_based_plugin.php'; - -class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_based_plugin -{ - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml'); - } - - protected function get_reparser() - { - return new \phpbb\textreparser\plugins\post_text($this->db); - } -} diff --git a/tests/text_reparser/test_row_based_plugin.php b/tests/text_reparser/test_row_based_plugin.php deleted file mode 100644 index 489dff280b..0000000000 --- a/tests/text_reparser/test_row_based_plugin.php +++ /dev/null @@ -1,129 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; - -abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_test_case -{ - protected $db; - - abstract protected function get_reparser(); - - public function setUp() - { - global $config; - if (!isset($config)) - { - $config = new \phpbb\config\config(array()); - } - $this->get_test_case_helpers()->set_s9e_services(); - $this->db = $this->new_dbal(); - parent::setUp(); - } - - public function test_get_max_id() - { - $reparser = $this->get_reparser(); - $this->assertEquals(1000, $reparser->get_max_id()); - } - - /** - * @dataProvider getReparseTests - */ - public function testReparse($min_id, $max_id, $expected) - { - $reparser = $this->get_reparser(); - $reparser->reparse_range($min_id, $max_id); - - $ids = array(); - foreach ($expected as $row) - { - $ids[] = $row['id']; - } - - $columns = $reparser->get_columns(); - $sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text - FROM ' . $reparser->get_table_name() . ' - WHERE ' . $this->db->sql_in_set($columns['id'], $ids) . ' - ORDER BY id'; - $result = $this->db->sql_query($sql); - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - $this->assertEquals($expected, $rows); - } - - public function getReparseTests() - { - return array( - array( - 2, - 5, - array( - array( - 'id' => '1', - 'text' => 'This row should be [b]ignored[/b]', - ), - array( - 'id' => '2', - 'text' => '[b]Not bold[/b] :) http://example.org', - ), - array( - 'id' => '3', - 'text' => '[b]Bold[/b] :) http://example.org', - ), - array( - 'id' => '4', - 'text' => '[b]Not bold[/b] :) http://example.org', - ), - array( - 'id' => '5', - 'text' => '[b]Not bold[/b] :) http://example.org', - ), - array( - 'id' => '1000', - 'text' => 'This row should be [b]ignored[/b]', - ), - ) - ), - array( - 6, - 7, - array( - array( - 'id' => '6', - 'text' => '[flash=123,345]http://example.org/flash.swf[/flash]', - ), - array( - 'id' => '7', - 'text' => '[flash=123,345]http://example.org/flash.swf[/flash]', - ), - ) - ), - array( - 8, - 9, - array( - array( - 'id' => '8', - 'text' => '[img]http://example.org/img.png[/img]', - ), - array( - 'id' => '9', - 'text' => '[img]http://example.org/img.png[/img]', - ), - ) - ), - ); - } -} diff --git a/tests/text_reparser/user_signature_test.php b/tests/text_reparser/user_signature_test.php deleted file mode 100644 index ab830a303d..0000000000 --- a/tests/text_reparser/user_signature_test.php +++ /dev/null @@ -1,26 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -include_once __DIR__ . '/test_row_based_plugin.php'; - -class phpbb_textreparser_user_signature_test extends phpbb_textreparser_test_row_based_plugin -{ - public function getDataSet() - { - return $this->createXMLDataSet(__DIR__ . '/fixtures/users.xml'); - } - - protected function get_reparser() - { - return new \phpbb\textreparser\plugins\user_signature($this->db); - } -} -- cgit v1.2.1 From 2f0d11ba3c28f27e535988de2a8d08f7b17aef92 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 30 May 2015 22:17:14 +0200 Subject: [ticket/13901] Add more whitespace to long quotes for readability PHPBB3-13901 --- tests/text_formatter/s9e/default_formatting_test.php | 4 ++++ tests/text_formatter/s9e/utils_test.php | 10 ++++++++++ 2 files changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 2aa15146aa..67921d5b1e 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -221,6 +221,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '[quote="http://example.org"]...[/quote]', '
            ' ), + array( + "[quote]\nThis is a long quote that is definitely going to exceed 80 characters\n[/quote]\n\nFollowed by a reply", + "
            \nThis is a long quote that is definitely going to exceed 80 characters\n
            \n\nFollowed by a reply" + ), ); } } diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 555f29cb38..d40d450f5a 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -171,6 +171,16 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case ), '[quote="user" post_id="123" url="http://example.org"]...[/quote]', ), + array( + 'This is a long quote that is definitely going to exceed 80 characters', + array(), + "[quote]\nThis is a long quote that is definitely going to exceed 80 characters\n[/quote]", + ), + array( + ' This is a short quote on its own line ', + array(), + '[quote]This is a short quote on its own line[/quote]', + ), ); } -- cgit v1.2.1 From b69e33c2b0dfaaf9274e783cd189a8d1d49bce07 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 30 May 2015 22:20:52 +0200 Subject: [ticket/13901] Add whitespace to short, multiline quotes for readability PHPBB3-13901 --- tests/text_formatter/s9e/utils_test.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index d40d450f5a..152c316b2e 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -181,6 +181,11 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case array(), '[quote]This is a short quote on its own line[/quote]', ), + array( + "This is a short quote\non two lines", + array(), + "[quote]\nThis is a short quote\non two lines\n[/quote]", + ), ); } -- cgit v1.2.1 From 433021f429f22dfd6d5dfc16c11195b19a488161 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 30 May 2015 23:51:09 +0200 Subject: [ticket/13901] Fixed test's expected result PHPBB3-13901 --- tests/functional/private_messages_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index 3f602d62fb..be584c20c1 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -84,7 +84,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case public function test_quote_forward() { $text = 'This is a test private message sent by the testing framework.'; - $expected = '[quote="admin"]' . $text . '[/quote]'; + $expected = "[quote=\"admin\"]\n" . $text . "\n[/quote]"; $this->login(); $message_id = $this->create_private_message('Test', $text, array(2)); -- cgit v1.2.1 From 6ac37145ec1bb41625c0c6a3875e4392ab6b703b Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 31 May 2015 10:13:20 +0200 Subject: [ticket/8420] Added regression test PHPBB3-8420 --- tests/functional/posting_test.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 8677237772..49f0c1d749 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -166,4 +166,18 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler = self::submit($form); $this->assertEquals(1, $crawler->filter('.successbox')->count()); } + + public function test_ticket_8420() + { + $text = '[b][url=http://example.org] :arrow: here[/url][/b]'; + + $this->login(); + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => $text + )); + $crawler = self::submit($form); + $this->assertEquals($text, $crawler->filter('#message')->text()); + } } -- cgit v1.2.1 From fcff3ee4ad2a273081ed3061a550399dfaa9c11e Mon Sep 17 00:00:00 2001 From: MateBartus Date: Sun, 31 May 2015 13:22:03 +0200 Subject: [ticket/13777] Fix tests PHPBB3-13777 --- tests/dbal/migrator_tool_module_test.php | 5 ++- tests/extension/modules_test.php | 51 +++++++++++------------------- tests/functional/extension_module_test.php | 11 ++++--- 3 files changed, 29 insertions(+), 38 deletions(-) (limited to 'tests') diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 695a7e7a7f..a71334f23f 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -41,7 +41,10 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $auth = $this->getMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); - $this->tool = new \phpbb\db\migration\tool\module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules'); + $phpbb_extension_manager = new phpbb_mock_extension_manager($phpbb_root_path); + $module_manager = new \phpbb\module\module_manager($cache, $this->db, $phpbb_extension_manager, MODULES_TABLE, $phpbb_root_path, $phpEx); + + $this->tool = new \phpbb\db\migration\tool\module($this->db, $this->cache, $this->user, $module_manager, $phpbb_root_path, $phpEx, 'phpbb_modules'); } public function exists_data() diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index cbcfdfb787..61ab82c3d0 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -22,6 +22,7 @@ class phpbb_extension_modules_test extends phpbb_test_case { protected $extension_manager; protected $finder; + protected $module_manager; public function setUp() { @@ -43,7 +44,14 @@ class phpbb_extension_modules_test extends phpbb_test_case )); $phpbb_extension_manager = $this->extension_manager; - $this->acp_modules = new acp_modules(); + $this->module_manager = new \phpbb\module\module_manager( + new \phpbb\cache\driver\dummy(), + $this->getMock('\phpbb\db\driver\driver_interface'), + $this->extension_manager, + MODULES_TABLE, + dirname(__FILE__) . '/', + 'php' + ); } public function test_get_module_infos() @@ -56,8 +64,7 @@ class phpbb_extension_modules_test extends phpbb_test_case $phpbb_root_path = dirname(__FILE__) . '/'; // Find acp module info files - $this->acp_modules->module_class = 'acp'; - $acp_modules = $this->acp_modules->get_module_infos(); + $acp_modules = $this->module_manager->get_module_infos('', 'acp'); $this->assertEquals(array( 'vendor2\\foo\\acp\\a_module' => array( 'filename' => 'vendor2\\foo\\acp\\a_module', @@ -76,8 +83,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Find mcp module info files - $this->acp_modules->module_class = 'mcp'; - $acp_modules = $this->acp_modules->get_module_infos(); + $acp_modules = $this->module_manager->get_module_infos('', 'mcp'); $this->assertEquals(array( 'vendor2\\foo\\mcp\\a_module' => array( 'filename' => 'vendor2\\foo\\mcp\\a_module', @@ -89,21 +95,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Find a specific module info file (mcp_a_module) - $this->acp_modules->module_class = 'mcp'; - $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module'); - $this->assertEquals(array( - 'vendor2\\foo\\mcp\\a_module' => array( - 'filename' => 'vendor2\\foo\\mcp\\a_module', - 'title' => 'Foobar', - 'modes' => array( - 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), - ), - ), - ), $acp_modules); - - // Find a specific module info file (mcp_a_module) with passing the module_class - $this->acp_modules->module_class = ''; - $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module', 'mcp'); + $acp_modules = $this->module_manager->get_module_infos('mcp_a_module', 'mcp'); $this->assertEquals(array( 'vendor2\\foo\\mcp\\a_module' => array( 'filename' => 'vendor2\\foo\\mcp\\a_module', @@ -115,18 +107,15 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // The mcp module info file we're looking for shouldn't exist - $this->acp_modules->module_class = 'mcp'; - $acp_modules = $this->acp_modules->get_module_infos('mcp_a_fail'); + $acp_modules = $this->module_manager->get_module_infos('mcp_a_fail', 'mcp'); $this->assertEquals(array(), $acp_modules); // As there are no ucp modules we shouldn't find any - $this->acp_modules->module_class = 'ucp'; - $acp_modules = $this->acp_modules->get_module_infos(); + $acp_modules = $this->module_manager->get_module_infos('', 'ucp'); $this->assertEquals(array(), $acp_modules); // Get module info of specified extension module - $this->acp_modules->module_class = 'acp'; - $acp_modules = $this->acp_modules->get_module_infos('foo_acp_a_module'); + $acp_modules = $this->module_manager->get_module_infos('foo_acp_a_module', 'acp'); $this->assertEquals(array( 'vendor2\\foo\\acp\\a_module' => array ( 'filename' => 'vendor2\\foo\\acp\\a_module', @@ -138,18 +127,16 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // No specific module and module class set to an incorrect name - $acp_modules = $this->acp_modules->get_module_infos('', 'wcp', true); + $acp_modules = $this->module_manager->get_module_infos('', 'wcp', true); $this->assertEquals(array(), $acp_modules); // No specific module, no module_class set in the function parameter, and an incorrect module class - $this->acp_modules->module_class = 'wcp'; - $acp_modules = $this->acp_modules->get_module_infos(); + $acp_modules = $this->module_manager->get_module_infos('', 'wcp'); $this->assertEquals(array(), $acp_modules); // No specific module, module class set to false (will default to the above acp) // Setting $use_all_available will cause get_module_infos() to also load not enabled extensions (vendor2/bar) - $this->acp_modules->module_class = 'acp'; - $acp_modules = $this->acp_modules->get_module_infos('', false, true); + $acp_modules = $this->module_manager->get_module_infos('', 'acp', true); $this->assertEquals(array( 'vendor2\\foo\\acp\\a_module' => array( 'filename' => 'vendor2\\foo\\acp\\a_module', @@ -175,7 +162,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Specific module set to disabled extension - $acp_modules = $this->acp_modules->get_module_infos('vendor2_bar_acp_a_module', 'acp', true); + $acp_modules = $this->module_manager->get_module_infos('vendor2_bar_acp_a_module', 'acp', true); $this->assertEquals(array( 'vendor2\\bar\\acp\\a_module' => array( 'filename' => 'vendor2\\bar\\acp\\a_module', diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index ee084720e4..95107665cd 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -49,8 +49,9 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case $this->phpbb_extension_manager = $this->get_extension_manager(); $this->phpbb_extension_manager->enable('foo/bar'); - $modules = new acp_modules(); $db = $this->get_db(); + $cache = $this->get_cache_driver(); + $modules = new \phpbb\module\module_manager($cache, $db, $this->phpbb_extension_manager, MODULES_TABLE, dirname(__FILE__) . '/../../phpBB/', 'php'); $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " @@ -70,7 +71,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case 'module_mode' => '', 'module_auth' => '', ); - $modules->update_module_data($parent_data, true); + $modules->update_module_data($parent_data); $module_data = array( 'module_basename' => 'foo\\bar\\acp\\main_module', @@ -82,7 +83,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case 'module_mode' => 'mode', 'module_auth' => '', ); - $modules->update_module_data($module_data, true); + $modules->update_module_data($module_data); $parent_data = array( 'module_basename' => '', @@ -94,7 +95,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case 'module_mode' => '', 'module_auth' => '', ); - $modules->update_module_data($parent_data, true); + $modules->update_module_data($parent_data); $module_data = array( 'module_basename' => 'foo\\bar\\ucp\\main_module', @@ -106,7 +107,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case 'module_mode' => 'mode', 'module_auth' => '', ); - $modules->update_module_data($module_data, true); + $modules->update_module_data($module_data); $this->purge_cache(); } -- cgit v1.2.1 From 4044b5df8997b720ef86955f9e660189962182ea Mon Sep 17 00:00:00 2001 From: MateBartus Date: Sun, 31 May 2015 16:03:11 +0200 Subject: [ticket/13777] Reorder get_module_infos() method's arguments PHPBB3-13777 --- tests/extension/modules_test.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index 61ab82c3d0..88634bc6ba 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -64,7 +64,7 @@ class phpbb_extension_modules_test extends phpbb_test_case $phpbb_root_path = dirname(__FILE__) . '/'; // Find acp module info files - $acp_modules = $this->module_manager->get_module_infos('', 'acp'); + $acp_modules = $this->module_manager->get_module_infos('acp'); $this->assertEquals(array( 'vendor2\\foo\\acp\\a_module' => array( 'filename' => 'vendor2\\foo\\acp\\a_module', @@ -83,7 +83,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Find mcp module info files - $acp_modules = $this->module_manager->get_module_infos('', 'mcp'); + $acp_modules = $this->module_manager->get_module_infos('mcp'); $this->assertEquals(array( 'vendor2\\foo\\mcp\\a_module' => array( 'filename' => 'vendor2\\foo\\mcp\\a_module', @@ -95,7 +95,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Find a specific module info file (mcp_a_module) - $acp_modules = $this->module_manager->get_module_infos('mcp_a_module', 'mcp'); + $acp_modules = $this->module_manager->get_module_infos('mcp', 'mcp_a_module'); $this->assertEquals(array( 'vendor2\\foo\\mcp\\a_module' => array( 'filename' => 'vendor2\\foo\\mcp\\a_module', @@ -107,15 +107,15 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // The mcp module info file we're looking for shouldn't exist - $acp_modules = $this->module_manager->get_module_infos('mcp_a_fail', 'mcp'); + $acp_modules = $this->module_manager->get_module_infos('mcp', 'mcp_a_fail'); $this->assertEquals(array(), $acp_modules); // As there are no ucp modules we shouldn't find any - $acp_modules = $this->module_manager->get_module_infos('', 'ucp'); + $acp_modules = $this->module_manager->get_module_infos('ucp'); $this->assertEquals(array(), $acp_modules); // Get module info of specified extension module - $acp_modules = $this->module_manager->get_module_infos('foo_acp_a_module', 'acp'); + $acp_modules = $this->module_manager->get_module_infos('acp', 'foo_acp_a_module'); $this->assertEquals(array( 'vendor2\\foo\\acp\\a_module' => array ( 'filename' => 'vendor2\\foo\\acp\\a_module', @@ -127,16 +127,16 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // No specific module and module class set to an incorrect name - $acp_modules = $this->module_manager->get_module_infos('', 'wcp', true); + $acp_modules = $this->module_manager->get_module_infos('wcp', '', true); $this->assertEquals(array(), $acp_modules); // No specific module, no module_class set in the function parameter, and an incorrect module class - $acp_modules = $this->module_manager->get_module_infos('', 'wcp'); + $acp_modules = $this->module_manager->get_module_infos('wcp'); $this->assertEquals(array(), $acp_modules); // No specific module, module class set to false (will default to the above acp) // Setting $use_all_available will cause get_module_infos() to also load not enabled extensions (vendor2/bar) - $acp_modules = $this->module_manager->get_module_infos('', 'acp', true); + $acp_modules = $this->module_manager->get_module_infos('acp', '', true); $this->assertEquals(array( 'vendor2\\foo\\acp\\a_module' => array( 'filename' => 'vendor2\\foo\\acp\\a_module', @@ -162,7 +162,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Specific module set to disabled extension - $acp_modules = $this->module_manager->get_module_infos('vendor2_bar_acp_a_module', 'acp', true); + $acp_modules = $this->module_manager->get_module_infos('acp', 'vendor2_bar_acp_a_module', true); $this->assertEquals(array( 'vendor2\\bar\\acp\\a_module' => array( 'filename' => 'vendor2\\bar\\acp\\a_module', -- cgit v1.2.1 From d37c995f4be23ca058cec59c44c92ab54015b11d Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 2 Jun 2015 12:37:36 +0200 Subject: [ticket/13906] Added test PHPBB3-13906 --- tests/functional/posting_test.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 49f0c1d749..c107b78384 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -180,4 +180,26 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler = self::submit($form); $this->assertEquals($text, $crawler->filter('#message')->text()); } + + public function test_ticket_13906() + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_sig = '[b:2u8sdcwb]My signature[/b:2u8sdcwb]', + user_sig_bbcode_uid = '2u8sdcwb', + user_sig_bbcode_bitfield = 'QA==' + WHERE user_id = 2"; + $this->get_db()->sql_query($sql); + + $this->login(); + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => 'My post', + )); + $crawler = self::submit($form); + $this->assertContains( + 'My signature', + $crawler->filter('#preview .signature')->html() + ); + } } -- cgit v1.2.1 From 78eeb210e78429d867347ecb7c0eedf707005632 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 2 Jun 2015 22:46:14 +0200 Subject: [ticket/13906] Renamed test PHPBB3-13906 --- tests/functional/posting_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index c107b78384..ccfeb10deb 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -181,7 +181,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $this->assertEquals($text, $crawler->filter('#message')->text()); } - public function test_ticket_13906() + public function test_old_signature_in_preview() { $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '[b:2u8sdcwb]My signature[/b:2u8sdcwb]', -- cgit v1.2.1 From 49f2dd8c5e42265c9b1a21953922644f84752c16 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 4 Jun 2015 19:26:56 +0200 Subject: [ticket/13564] Fix user_delete_test on master PHPBB3-13564 --- tests/functions/user_delete_test.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index db52dcded7..21561492fd 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -28,10 +28,12 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case { parent::setUp(); - global $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user; + global $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx; $this->db = $db = $this->new_dbal(); - $user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $config = new \phpbb\config\config(array( @@ -39,8 +41,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case 'auth_oauth_google_key' => 'foo', 'auth_oauth_google_secret' => 'bar', )); - set_config_count('foobar', 0, false, $config); - $cache = new \phpbb\cache\driver\null(); + $cache = new \phpbb\cache\driver\dummy(); $request = new phpbb_mock_request(); $notification_manager = new phpbb_mock_notification_manager(); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); -- cgit v1.2.1 From eb11c80b2309cc84a7a33fb1b8fb45ca581dabdf Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 13 Jun 2015 14:27:12 +0200 Subject: [ticket/13921] Fix block BBCodes inside of inline BBCodes PHPBB3-13921 --- .../text_processing/tickets_data/PHPBB3-13921.html | 1 + .../text_processing/tickets_data/PHPBB3-13921.txt | 1 + .../text_processing/tickets_data/PHPBB3-13921.xml | 28 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-13921.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-13921.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-13921.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-13921.html b/tests/text_processing/tickets_data/PHPBB3-13921.html new file mode 100644 index 0000000000..6a9dc7f504 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13921.html @@ -0,0 +1 @@ +
            xxx
            \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13921.txt b/tests/text_processing/tickets_data/PHPBB3-13921.txt new file mode 100644 index 0000000000..392da0c3c8 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13921.txt @@ -0,0 +1 @@ +[size=200][center]xxx[/center][/size] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13921.xml b/tests/text_processing/tickets_data/PHPBB3-13921.xml new file mode 100644 index 0000000000..8d39246bb4 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13921.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + center + + 1 + [center]{TEXT}[/center] + {TEXT}]]> + !\[center\](.*?)\[/center\]!ies + '[center:$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', ''', '(', ')'), trim('${1}')).'[/center:$uid]' + !\[center:$uid\](.*?)\[/center:$uid\]!s + ${1}]]> + +
            +
            -- cgit v1.2.1 From 98cb70f5d2e42dafa48413713cc60ddd881c54c6 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 23 Jun 2015 14:31:18 +0200 Subject: [ticket/13961] Move service_collection to di/service_collection namespace PHPBB3-13961 --- tests/functions/user_delete_test.php | 2 +- tests/session/garbage_collection_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index 21561492fd..011d251167 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -46,7 +46,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $notification_manager = new phpbb_mock_notification_manager(); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); $oauth_provider_google = new \phpbb\auth\provider\oauth\service\google($config, $request); - $oauth_provider_collection = new \phpbb\di\service_collection($phpbb_container); + $oauth_provider_collection = new \phpbb\di\service_collection\service_collection($phpbb_container); $oauth_provider_collection->offsetSet('auth.provider.oauth.service.google', $oauth_provider_google); $driver_helper = new \phpbb\passwords\driver\helper($config); diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php index 3fad81c68b..5b337be44e 100644 --- a/tests/session/garbage_collection_test.php +++ b/tests/session/garbage_collection_test.php @@ -30,7 +30,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case global $phpbb_container; - $plugins = new \phpbb\di\service_collection($phpbb_container); + $plugins = new \phpbb\di\service_collection\service_collection($phpbb_container); $plugins->add('core.captcha.plugins.nogd'); $phpbb_container->set( 'captcha.factory', -- cgit v1.2.1 From 9dbd8f4f9b1c8a9edd0d1734c2c61b7360d54836 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 23 Jun 2015 14:35:45 +0200 Subject: [ticket/13961] Add test to service_collection PHPBB3-13961 --- tests/di/service_collection_test.php | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/di/service_collection_test.php (limited to 'tests') diff --git a/tests/di/service_collection_test.php b/tests/di/service_collection_test.php new file mode 100644 index 0000000000..5b51254a4a --- /dev/null +++ b/tests/di/service_collection_test.php @@ -0,0 +1,47 @@ + + * @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_service_collection_test extends \phpbb_test_case +{ + /** + * @var \phpbb\di\service_collection + */ + protected $service_collection; + + public function setUp() + { + $container = new phpbb_mock_container_builder(); + $container->set('foo', new StdClass); + $container->set('bar', new StdClass); + + $this->service_collection = new \phpbb\di\service_collection($container); + $this->service_collection->add('foo'); + $this->service_collection->add('bar'); + + parent::setUp(); + } + + public function test_service_collection() + { + $service_names = array(); + + // Test the iterator + foreach ($this->service_collection as $name => $service) + { + $service_names[] = $name; + $this->assertInstanceOf('StdClass', $service); + } + + $this->assertSame(array('foo', 'bar'), $service_names); + } +} -- cgit v1.2.1 From f5b476b221d2fec5cb5886ca6174b3e7c27b1cba Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 24 Jun 2015 13:13:13 +0200 Subject: [ticket/13961] Add tests for ordered collections PHPBB3-13961 --- tests/di/ordered_service_collection_test.php | 51 ++++++++++++++++++++++++++++ tests/di/service_collection_test.php | 4 +-- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tests/di/ordered_service_collection_test.php (limited to 'tests') diff --git a/tests/di/ordered_service_collection_test.php b/tests/di/ordered_service_collection_test.php new file mode 100644 index 0000000000..046cd8ccef --- /dev/null +++ b/tests/di/ordered_service_collection_test.php @@ -0,0 +1,51 @@ + + * @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_ordered_service_collection_test extends \phpbb_test_case +{ + /** + * @var \phpbb\di\service_collection\ordered_service_collection + */ + protected $service_collection; + + public function setUp() + { + $container = new phpbb_mock_container_builder(); + $container->set('foo', new StdClass); + $container->set('bar', new StdClass); + $container->set('foobar', new StdClass); + $container->set('barfoo', new StdClass); + + $this->service_collection = new \phpbb\di\service_collection\ordered_service_collection($container); + $this->service_collection->add('foo', 7); + $this->service_collection->add('bar', 3); + $this->service_collection->add('barfoo', 5); + $this->service_collection->add('foobar', 2); + + parent::setUp(); + } + + public function test_service_collection() + { + $service_names = array(); + + // Test the iterator + foreach ($this->service_collection as $name => $service) + { + $service_names[] = $name; + $this->assertInstanceOf('StdClass', $service); + } + + $this->assertSame(array('foobar', 'bar', 'barfoo', 'foo'), $service_names); + } +} diff --git a/tests/di/service_collection_test.php b/tests/di/service_collection_test.php index 5b51254a4a..e78a5180b6 100644 --- a/tests/di/service_collection_test.php +++ b/tests/di/service_collection_test.php @@ -14,7 +14,7 @@ class phpbb_service_collection_test extends \phpbb_test_case { /** - * @var \phpbb\di\service_collection + * @var \phpbb\di\service_collection\service_collection */ protected $service_collection; @@ -24,7 +24,7 @@ class phpbb_service_collection_test extends \phpbb_test_case $container->set('foo', new StdClass); $container->set('bar', new StdClass); - $this->service_collection = new \phpbb\di\service_collection($container); + $this->service_collection = new \phpbb\di\service_collection\service_collection($container); $this->service_collection->add('foo'); $this->service_collection->add('bar'); -- cgit v1.2.1 From f02cc27014c27acaf44b27066959426db27b3493 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 16 Jun 2015 08:16:56 +0200 Subject: [ticket/10620] Implemented quote improvements PHPBB3-10620 --- tests/functional/posting_test.php | 17 +++++++----- tests/functional/private_messages_test.php | 20 ++++++++++++-- tests/test_framework/phpbb_test_case_helpers.php | 32 +++++++++++++++++++++- .../text_formatter/s9e/default_formatting_test.php | 22 +++++++++++++++ 4 files changed, 80 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index ccfeb10deb..d9e6cc5ab3 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -75,7 +75,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case public function test_quote() { $text = 'Test post "\' &&amp;'; - $expected = '[quote="admin"]' . $text . '[/quote]'; + $expected = '([quote="admin"[^]]*\\]' . preg_quote($text) . '\\[/quote\\])'; $this->login(); $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); @@ -83,7 +83,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post['topic_id']}&p={$post['post_id']}&sid={$this->sid}"); - $this->assertContains($expected, $crawler->filter('textarea#message')->text()); + $this->assertRegexp($expected, $crawler->filter('textarea#message')->text()); } /** @@ -93,10 +93,10 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case { $text = '0[quote]1[quote]2[/quote]1[/quote]0'; $expected = array( - 0 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]', - 1 => '[quote="admin"]00[/quote]', - 2 => '[quote="admin"]0[quote]11[/quote]0[/quote]', - 3 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]', + 0 => '0[quote]1[quote]2[/quote]1[/quote]0', + 1 => '00', + 2 => '0[quote]11[/quote]0', + 3 => '0[quote]1[quote]2[/quote]1[/quote]0', ); $this->login(); @@ -109,7 +109,10 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case { $this->set_quote_depth($quote_depth); $crawler = self::request('GET', $quote_url); - $this->assertContains($expected_text, $crawler->filter('textarea#message')->text()); + $this->assertRegexp( + '(\\[quote="admin"[^]]*\\]' . preg_quote($expected_text) . '\\[/quote\\])', + $crawler->filter('textarea#message')->text() + ); } } diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index be584c20c1..9bfb5bc7ad 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -69,16 +69,30 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case public function test_quote_post() { - $text = 'Test post'; - $expected = '[quote="admin"]' . $text . '[/quote]'; + $text = 'Test post'; $this->login(); $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + $expected = '(\\[quote="admin" post_id="' . $post['post_id'] . '" time="\\d+" user_id="2"\\]' . $text . '\\[/quote\\])'; + $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quotepost&p=' . $post['post_id'] . '&sid=' . $this->sid); - $this->assertContains($expected, $crawler->filter('textarea#message')->text()); + $this->assertRegexp($expected, $crawler->filter('textarea#message')->text()); + } + + public function test_quote_pm() + { + $text = 'This is a test private message sent by the testing framework.'; + $expected = '(\\[quote="admin" time="\\d+" user_id="2"\\]' . $text . '\\[/quote\\])'; + + $this->login(); + $message_id = $this->create_private_message('Test', $text, array(2)); + + $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quote&p=' . $message_id . '&sid=' . $this->sid); + + $this->assertRegexp($expected, $crawler->filter('textarea#message')->text()); } public function test_quote_forward() diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index cf530cc5be..62a56ed693 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -476,11 +476,21 @@ class phpbb_test_case_helpers { $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); - $user = new \phpbb\user($lang, '\phpbb\datetime'); + + $user = $this->test_case->getMockBuilder('\phpbb\user') + ->setConstructorArgs(array($lang, '\phpbb\datetime')) + ->setMethods(array('format_date')) + ->getMock(); + $user->expects($this->test_case->any()) + ->method('format_date') + ->will($this->test_case->returnCallback(__CLASS__ . '::format_date')); + + $user->date_format = 'Y-m-d H:i:s'; $user->optionset('viewcensors', true); $user->optionset('viewflash', true); $user->optionset('viewimg', true); $user->optionset('viewsmilies', true); + $user->timezone = new \DateTimeZone('UTC'); $container->set('user', $user); } $user->add_lang('common'); @@ -490,6 +500,14 @@ class phpbb_test_case_helpers $user->style = array('style_id' => 1); } + // Create and register a quote_helper + $quote_helper = new \phpbb\textformatter\s9e\quote_helper( + $container->get('user'), + $phpbb_root_path, + $phpEx + ); + $container->set('text_formatter.s9e.quote_helper', $quote_helper); + // Create and register the text_formatter.s9e.parser service and its alias $parser = new \phpbb\textformatter\s9e\parser( $cache, @@ -515,6 +533,7 @@ class phpbb_test_case_helpers $auth = ($container->has('auth')) ? $container->get('auth') : new \phpbb\auth\auth; // Calls configured in services.yml + $renderer->configure_quote_helper($quote_helper); $renderer->configure_smilies_path($config, $container->get('path_helper')); $renderer->configure_user($user, $config, $auth); @@ -528,4 +547,15 @@ class phpbb_test_case_helpers return $container; } + + /** + * Mocked replacement for \phpbb\user::format_date() + * + * @param integer $gmepoch unix timestamp + * @return string + */ + static public function format_date($gmepoch) + { + return gmdate('Y-m-d H:i:s', $gmepoch); + } } diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 67921d5b1e..3f8e375ad1 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -225,6 +225,28 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case "[quote]\nThis is a long quote that is definitely going to exceed 80 characters\n[/quote]\n\nFollowed by a reply", "
            \nThis is a long quote that is definitely going to exceed 80 characters\n
            \n\nFollowed by a reply" ), + array( + '[quote="Username" post_id="123"]...[/quote]', + '
            Username wrote: ...
            ' + ), + array( + // Users are not allowed to submit their own URL for the post + '[quote="Username" post_url="http://fake.example.org"]...[/quote]', + '
            Username wrote:...
            ' + ), + array( + '[quote="Username" time="58705871"]...[/quote]', + '
            1971-11-11 11:11:11 Username wrote:...
            ' + ), + array( + '[quote="Username" user_id="123"]...[/quote]', + '
            Username wrote:...
            ' + ), + array( + // Users are not allowed to submit their own URL for the profile + '[quote="Username" profile_url="http://fake.example.org"]...[/quote]', + '
            Username wrote:...
            ' + ), ); } } -- cgit v1.2.1 From 4f1b25706f6a1ae6eb1c6c60ef27b42bb7ac4b40 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 24 Jun 2015 22:20:39 +0200 Subject: [ticket/10620] Removed extraneous quotes from attribute values PHPBB3-10620 --- tests/functional/posting_test.php | 4 ++-- tests/functional/private_messages_test.php | 6 +++--- tests/text_formatter/s9e/default_formatting_test.php | 10 +++++----- tests/text_formatter/s9e/utils_test.php | 10 +++++++--- 4 files changed, 17 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index d9e6cc5ab3..4f4ecfef45 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -75,7 +75,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case public function test_quote() { $text = 'Test post "\' &&amp;'; - $expected = '([quote="admin"[^]]*\\]' . preg_quote($text) . '\\[/quote\\])'; + $expected = '([quote=admin[^]]*\\]' . preg_quote($text) . '\\[/quote\\])'; $this->login(); $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); @@ -110,7 +110,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $this->set_quote_depth($quote_depth); $crawler = self::request('GET', $quote_url); $this->assertRegexp( - '(\\[quote="admin"[^]]*\\]' . preg_quote($expected_text) . '\\[/quote\\])', + '(\\[quote=admin[^]]*\\]' . preg_quote($expected_text) . '\\[/quote\\])', $crawler->filter('textarea#message')->text() ); } diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index 9bfb5bc7ad..a7d1a29e80 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -75,7 +75,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); - $expected = '(\\[quote="admin" post_id="' . $post['post_id'] . '" time="\\d+" user_id="2"\\]' . $text . '\\[/quote\\])'; + $expected = '(\\[quote=admin post_id=' . $post['post_id'] . ' time=\\d+ user_id=2\\]' . $text . '\\[/quote\\])'; $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quotepost&p=' . $post['post_id'] . '&sid=' . $this->sid); @@ -85,7 +85,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case public function test_quote_pm() { $text = 'This is a test private message sent by the testing framework.'; - $expected = '(\\[quote="admin" time="\\d+" user_id="2"\\]' . $text . '\\[/quote\\])'; + $expected = '(\\[quote=admin time=\\d+ user_id=2\\]' . $text . '\\[/quote\\])'; $this->login(); $message_id = $this->create_private_message('Test', $text, array(2)); @@ -98,7 +98,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case public function test_quote_forward() { $text = 'This is a test private message sent by the testing framework.'; - $expected = "[quote=\"admin\"]\n" . $text . "\n[/quote]"; + $expected = '[quote=admin]' . $text . '[/quote]'; $this->login(); $message_id = $this->create_private_message('Test', $text, array(2)); diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 3f8e375ad1..38604b49a0 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -218,7 +218,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '
            ' ), array( - '[quote="http://example.org"]...[/quote]', + '[quote=http://example.org]...[/quote]', '
            ' ), array( @@ -226,7 +226,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case "
            \nThis is a long quote that is definitely going to exceed 80 characters\n
            \n\nFollowed by a reply" ), array( - '[quote="Username" post_id="123"]...[/quote]', + '[quote=Username post_id=123]...[/quote]', '
            Username wrote: ...
            ' ), array( @@ -235,16 +235,16 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '
            Username wrote:...
            ' ), array( - '[quote="Username" time="58705871"]...[/quote]', + '[quote=Username time=58705871]...[/quote]', '
            1971-11-11 11:11:11 Username wrote:...
            ' ), array( - '[quote="Username" user_id="123"]...[/quote]', + '[quote=Username user_id=123]...[/quote]', '
            Username wrote:...
            ' ), array( // Users are not allowed to submit their own URL for the profile - '[quote="Username" profile_url="http://fake.example.org"]...[/quote]', + '[quote=Username profile_url=http://fake.example.org]...[/quote]', '
            Username wrote:...
            ' ), ); diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 152c316b2e..f2b480facb 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -98,11 +98,15 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case array('foo') ), array( - '[quote="foo"]..[/quote] [quote="bar"]..[/quote]', + '[quote=foo]..[/quote] [quote]..[/quote]', + array('foo') + ), + array( + '[quote=foo]..[/quote] [quote=bar]..[/quote]', array('foo', 'bar') ), array( - '[quote="foo"].[quote="baz"]..[/quote].[/quote] [quote="bar"]..[/quote]', + '[quote=foo].[quote=baz]..[/quote].[/quote] [quote=bar]..[/quote]', array('foo', 'bar') ), ); @@ -169,7 +173,7 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case 'post_id' => 123, 'url' => 'http://example.org' ), - '[quote="user" post_id="123" url="http://example.org"]...[/quote]', + '[quote=user post_id=123 url=http://example.org]...[/quote]', ), array( 'This is a long quote that is definitely going to exceed 80 characters', -- cgit v1.2.1 From 7ce2d996a82b5a2f68560a4136c1f3938a1955d4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 24 Jun 2015 22:36:38 +0200 Subject: [ticket/10620] Added tests PHPBB3-10620 --- .../text_formatter/s9e/default_formatting_test.php | 5 ++++ tests/text_formatter/s9e/utils_test.php | 30 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 38604b49a0..ed75555b42 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -247,6 +247,11 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '[quote=Username profile_url=http://fake.example.org]...[/quote]', '
            Username wrote:...
            ' ), + array( + // From phpbb_textformatter_s9e_utils_test::test_generate_quote() + '[quote=\'[quote="foo"]\']...[/quote]', + '
            [quote="foo"] wrote:...
            ' + ), ); } } diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index f2b480facb..1c03783792 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -175,6 +175,36 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case ), '[quote=user post_id=123 url=http://example.org]...[/quote]', ), + array( + '...', + array('author' => ' '), + '[quote=" "]...[/quote]', + ), + array( + '...', + array('author' => 'foo bar'), + '[quote="foo bar"]...[/quote]', + ), + array( + '...', + array('author' => '\\'), + '[quote="\\\\"]...[/quote]', + ), + array( + '...', + array('author' => '[quote="foo"]'), + '[quote=\'[quote="foo"]\']...[/quote]', + ), + array( + '...', + array('author' => '""'), + '[quote=\'""\']...[/quote]', + ), + array( + '...', + array('author' => "''"), + '[quote="\'\'"]...[/quote]', + ), array( 'This is a long quote that is definitely going to exceed 80 characters', array(), -- cgit v1.2.1 From 1f6b9bc0487ba43a614b05528dcd9ae830cc3b0f Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 24 Jun 2015 23:42:36 +0200 Subject: [ticket/10620] Fixed functional tests to account for newlines PHPBB3-10620 --- tests/functional/posting_test.php | 4 ++-- tests/functional/private_messages_test.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 4f4ecfef45..e9b62c0b6c 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -75,7 +75,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case public function test_quote() { $text = 'Test post "\' &&amp;'; - $expected = '([quote=admin[^]]*\\]' . preg_quote($text) . '\\[/quote\\])'; + $expected = "(\\[quote=admin[^\\]]*\\]\n" . preg_quote($text) . "\n\\[/quote\\])"; $this->login(); $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); @@ -110,7 +110,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $this->set_quote_depth($quote_depth); $crawler = self::request('GET', $quote_url); $this->assertRegexp( - '(\\[quote=admin[^]]*\\]' . preg_quote($expected_text) . '\\[/quote\\])', + "(\\[quote=admin[^\\]]*\\]\n?" . preg_quote($expected_text) . "\n?\\[/quote\\])", $crawler->filter('textarea#message')->text() ); } diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index a7d1a29e80..7fda26fb49 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -85,7 +85,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case public function test_quote_pm() { $text = 'This is a test private message sent by the testing framework.'; - $expected = '(\\[quote=admin time=\\d+ user_id=2\\]' . $text . '\\[/quote\\])'; + $expected = "(\\[quote=admin time=\\d+ user_id=2\\]\n" . $text . "\n\\[/quote\\])"; $this->login(); $message_id = $this->create_private_message('Test', $text, array(2)); @@ -98,7 +98,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case public function test_quote_forward() { $text = 'This is a test private message sent by the testing framework.'; - $expected = '[quote=admin]' . $text . '[/quote]'; + $expected = "[quote=admin]\n" . $text . "\n[/quote]"; $this->login(); $message_id = $this->create_private_message('Test', $text, array(2)); -- cgit v1.2.1 From 9d364aee4a739d0a8c8b745449940a37d81c9abf Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 25 Jun 2015 02:23:00 +0200 Subject: [ticket/10620] Moved quote's date to the upper corner PHPBB3-10620 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index ed75555b42..40bec9ceee 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -236,7 +236,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( '[quote=Username time=58705871]...[/quote]', - '
            1971-11-11 11:11:11 Username wrote:...
            ' + '
            Username wrote:
            1971-11-11 11:11:11
            ...
            ' ), array( '[quote=Username user_id=123]...[/quote]', -- cgit v1.2.1 From b09293d5ff38633d506083cffc0a9dd2c98c15c4 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 26 Jun 2015 01:02:04 +0200 Subject: [ticket/13961] Move back service_collections under original namespace PHPBB3-13961 --- tests/di/ordered_service_collection_test.php | 4 ++-- tests/di/service_collection_test.php | 4 ++-- tests/functions/user_delete_test.php | 2 +- tests/session/garbage_collection_test.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/di/ordered_service_collection_test.php b/tests/di/ordered_service_collection_test.php index 046cd8ccef..47e6d23744 100644 --- a/tests/di/ordered_service_collection_test.php +++ b/tests/di/ordered_service_collection_test.php @@ -14,7 +14,7 @@ class phpbb_ordered_service_collection_test extends \phpbb_test_case { /** - * @var \phpbb\di\service_collection\ordered_service_collection + * @var \phpbb\di\ordered_service_collection */ protected $service_collection; @@ -26,7 +26,7 @@ class phpbb_ordered_service_collection_test extends \phpbb_test_case $container->set('foobar', new StdClass); $container->set('barfoo', new StdClass); - $this->service_collection = new \phpbb\di\service_collection\ordered_service_collection($container); + $this->service_collection = new \phpbb\di\ordered_service_collection($container); $this->service_collection->add('foo', 7); $this->service_collection->add('bar', 3); $this->service_collection->add('barfoo', 5); diff --git a/tests/di/service_collection_test.php b/tests/di/service_collection_test.php index e78a5180b6..5b51254a4a 100644 --- a/tests/di/service_collection_test.php +++ b/tests/di/service_collection_test.php @@ -14,7 +14,7 @@ class phpbb_service_collection_test extends \phpbb_test_case { /** - * @var \phpbb\di\service_collection\service_collection + * @var \phpbb\di\service_collection */ protected $service_collection; @@ -24,7 +24,7 @@ class phpbb_service_collection_test extends \phpbb_test_case $container->set('foo', new StdClass); $container->set('bar', new StdClass); - $this->service_collection = new \phpbb\di\service_collection\service_collection($container); + $this->service_collection = new \phpbb\di\service_collection($container); $this->service_collection->add('foo'); $this->service_collection->add('bar'); diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index 011d251167..21561492fd 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -46,7 +46,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $notification_manager = new phpbb_mock_notification_manager(); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); $oauth_provider_google = new \phpbb\auth\provider\oauth\service\google($config, $request); - $oauth_provider_collection = new \phpbb\di\service_collection\service_collection($phpbb_container); + $oauth_provider_collection = new \phpbb\di\service_collection($phpbb_container); $oauth_provider_collection->offsetSet('auth.provider.oauth.service.google', $oauth_provider_google); $driver_helper = new \phpbb\passwords\driver\helper($config); diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php index 5b337be44e..3fad81c68b 100644 --- a/tests/session/garbage_collection_test.php +++ b/tests/session/garbage_collection_test.php @@ -30,7 +30,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case global $phpbb_container; - $plugins = new \phpbb\di\service_collection\service_collection($phpbb_container); + $plugins = new \phpbb\di\service_collection($phpbb_container); $plugins->add('core.captcha.plugins.nogd'); $phpbb_container->set( 'captcha.factory', -- cgit v1.2.1 From 353b3b4cfd7133ea0cef4a7fdb34d0451b16a0dd Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 27 Jun 2015 12:33:44 +0200 Subject: [ticket/13970] Save the value of the optional [code] parameter PHPBB3-13970 --- tests/text_formatter/s9e/default_formatting_test.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 67921d5b1e..4829e9bbc8 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -15,6 +15,17 @@ require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case { + public function test_bbcode_code_lang_is_saved() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $parser = $container->get('text_formatter.parser'); + + $original = '[code]...[/code][code=php]...[/code]'; + $expected = '[code]...[/code][code=php]...[/code]'; + + $this->assertXmlStringEqualsXmlString($expected, $parser->parse($original)); + } + /** * @dataProvider get_default_formatting_tests */ -- cgit v1.2.1 From 57a07f4ff71d1513d1891ad8cca6c29c40dfa6b7 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 6 Jul 2015 01:15:18 +0200 Subject: [ticket/13985] Updated s9e\TextFormatter PHPBB3-13985 --- tests/text_processing/tickets_data/PHPBB3-10989.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-10989.html b/tests/text_processing/tickets_data/PHPBB3-10989.html index f003ad3dfa..cd24df60e5 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10989.html +++ b/tests/text_processing/tickets_data/PHPBB3-10989.html @@ -1,6 +1,6 @@
            Lorem wrote:[quote="Lorem"
            Suspendisse iaculis porta tempor. Nulla.
            Nullam a tortor sit amet.
            - Proin ac mi eget magna. + Proin ac mi eget magna.
            Lorem wrote:Quisque fermentum tortor quis odio scelerisque consequat fermentum urna gravida. In semper vehicula condimentum. Donec suscipit ante imperdiet augue rhoncus.
            -- cgit v1.2.1 From a44711e57478c6f9d1fa38582deae72cad240560 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 6 Jul 2015 19:17:40 +0200 Subject: [ticket/13990] Reparse markup inside of forum rules/description PHPBB3-13990 --- tests/text_reparser/plugins/fixtures/forums.xml | 22 ++++++++ tests/text_reparser/plugins/fixtures/groups.xml | 8 +-- .../plugins/fixtures/poll_options.xml | 60 ++++++++++++++++++++++ tests/text_reparser/plugins/fixtures/polls.xml | 40 +++++++++++++-- tests/text_reparser/plugins/poll_option_test.php | 17 +++++- 5 files changed, 137 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/text_reparser/plugins/fixtures/forums.xml b/tests/text_reparser/plugins/fixtures/forums.xml index 39c172c969..c12c8d6d48 100644 --- a/tests/text_reparser/plugins/fixtures/forums.xml +++ b/tests/text_reparser/plugins/fixtures/forums.xml @@ -5,87 +5,109 @@ forum_parents forum_desc forum_desc_uid + forum_desc_options forum_rules forum_rules_uid + forum_rules_options 1 This row should be [b]ignored[/b] abcd1234 + 0 This row should be [b]ignored[/b] abcd1234 + 0 2 [b]Not bold[/b] :) http://example.org abcd1234 + 0 [b]Not bold[/b] :) http://example.org abcd1234 + 0 3 [b:abcd1234]Bold[/b:abcd1234] :) http://example.org abcd1234 + 1 [b:abcd1234]Bold[/b:abcd1234] :) http://example.org abcd1234 + 1 4 :) http://example.org]]> abcd1234 + 2 :) http://example.org]]> abcd1234 + 2 5 http://example.org]]> abcd1234 + 4 http://example.org]]> abcd1234 + 4 6 abcd1234 + 1 abcd1234 + 1 7 abcd1234 + 0 abcd1234 + 0 8 abcd1234 + 1 abcd1234 + 1 9 abcd1234 + 0 abcd1234 + 0 1000 This row should be [b]ignored[/b] abcd1234 + 0 This row should be [b]ignored[/b] abcd1234 + 0 diff --git a/tests/text_reparser/plugins/fixtures/groups.xml b/tests/text_reparser/plugins/fixtures/groups.xml index d3df0131a3..15151426bc 100644 --- a/tests/text_reparser/plugins/fixtures/groups.xml +++ b/tests/text_reparser/plugins/fixtures/groups.xml @@ -38,25 +38,25 @@ 6 - 7 + 1 abcd1234 7 - 7 + 1 abcd1234 8 - 7 + 1 abcd1234 9 - 7 + 1 abcd1234 diff --git a/tests/text_reparser/plugins/fixtures/poll_options.xml b/tests/text_reparser/plugins/fixtures/poll_options.xml index c2fad9f764..48ba024315 100644 --- a/tests/text_reparser/plugins/fixtures/poll_options.xml +++ b/tests/text_reparser/plugins/fixtures/poll_options.xml @@ -29,6 +29,21 @@ 2 http://example.org]]> + + 1 + 11 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + + + 1 + 12 + :) http://example.org]]> + + + 1 + 13 + http://example.org]]> + 1 123 @@ -42,9 +57,39 @@ post_id + enable_bbcode + enable_smilies + enable_magic_urlpost_textbbcode_uid + 1 + 1 + 1 + 1 + + abcd1234 + + + 11 + 1 + 0 + 0 + + abcd1234 + + + 12 + 0 + 1 + 0 + + abcd1234 + + + 13 + 0 + 0 1 abcd1234 @@ -64,6 +109,21 @@ 1 This row should be [b]ignored[/b] + + 11 + 11 + BBCode + + + 12 + 12 + Smilies + + + 13 + 13 + Magic URLs + 123 1 diff --git a/tests/text_reparser/plugins/fixtures/polls.xml b/tests/text_reparser/plugins/fixtures/polls.xml index 9baf813c97..2960d640a9 100644 --- a/tests/text_reparser/plugins/fixtures/polls.xml +++ b/tests/text_reparser/plugins/fixtures/polls.xml @@ -2,9 +2,39 @@
            post_id + enable_bbcode + enable_smilies + enable_magic_urlpost_textbbcode_uid + 1 + 0 + 0 + 0 + + abcd1234 + + + 2 + 1 + 0 + 0 + + abcd1234 + + + 3 + 0 + 1 + 0 + + abcd1234 + + + 4 + 0 + 0 1 abcd1234 @@ -26,22 +56,22 @@ 3 - 1 + 2 [b:abcd1234]Bold[/b:abcd1234] :) http://example.org 4 - 1 + 3 :) http://example.org]]> 5 - 1 + 4 http://example.org]]> 6 - 1 + 2 @@ -51,7 +81,7 @@ 8 - 1 + 2 diff --git a/tests/text_reparser/plugins/poll_option_test.php b/tests/text_reparser/plugins/poll_option_test.php index e043858597..acabda2146 100644 --- a/tests/text_reparser/plugins/poll_option_test.php +++ b/tests/text_reparser/plugins/poll_option_test.php @@ -49,7 +49,7 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case public function testReparse() { $reparser = $this->get_reparser(); - $reparser->reparse_range(2, 3); + $reparser->reparse_range(2, 13); $sql = 'SELECT topic_id, poll_option_id, poll_option_text FROM ' . POLL_OPTIONS_TABLE . ' @@ -84,6 +84,21 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case 'poll_option_id' => 3, 'poll_option_text' => 'http://example.org', ), + array( + 'topic_id' => 11, + 'poll_option_id' => 1, + 'poll_option_text' => '[b]Bold[/b] :) http://example.org', + ), + array( + 'topic_id' => 12, + 'poll_option_id' => 1, + 'poll_option_text' => '[b]Not bold[/b] :) http://example.org', + ), + array( + 'topic_id' => 13, + 'poll_option_id' => 1, + 'poll_option_text' => '[b]Not bold[/b] :) http://example.org', + ), array( 'topic_id' => 123, 'poll_option_id' => 1, -- cgit v1.2.1 From 7ccb6389124c5e990abaa917a6684fc3f4d072db Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 6 Jul 2015 01:43:43 +0200 Subject: [ticket/13987] Add --dry-run option to reparser CLI PHPBB3-13987 --- .../plugins/contact_admin_info_test.php | 33 ++++++++++++------ tests/text_reparser/plugins/poll_option_test.php | 31 ++++++++++++----- .../plugins/test_row_based_plugin.php | 40 +++++++++++++++------- 3 files changed, 73 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/text_reparser/plugins/contact_admin_info_test.php b/tests/text_reparser/plugins/contact_admin_info_test.php index e577d2fd3d..e3df1ee2b8 100644 --- a/tests/text_reparser/plugins/contact_admin_info_test.php +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -28,6 +28,18 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas return new \phpbb\textreparser\plugins\contact_admin_info(new \phpbb\config\db_text($this->db, CONFIG_TEXT_TABLE)); } + protected function get_rows() + { + $sql = 'SELECT config_name, config_value + FROM ' . CONFIG_TEXT_TABLE . ' + ORDER BY config_name'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + return $rows; + } + public function setUp() { global $config; @@ -46,18 +58,19 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas $this->assertEquals(1, $reparser->get_max_id()); } - public function testReparse() + public function test_dry_run() { + $old_rows = $this->get_rows(); $reparser = $this->get_reparser(); - $reparser->reparse_range(1, 1); - - $sql = 'SELECT config_name, config_value - FROM ' . CONFIG_TEXT_TABLE . ' - ORDER BY config_name'; - $result = $this->db->sql_query($sql); - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); + $reparser->reparse_range(1, 1, true); + $new_rows = $this->get_rows(); + $this->assertEquals($old_rows, $new_rows); + } + public function test_reparse() + { + $reparser = $this->get_reparser(); + $reparser->reparse_range(1, 1); $expected = array( array( 'config_name' => 'contact_admin_info', @@ -76,6 +89,6 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas 'config_value' => '1a2hbwf5', ), ); - $this->assertEquals($expected, $rows); + $this->assertEquals($expected, $this->get_rows()); } } diff --git a/tests/text_reparser/plugins/poll_option_test.php b/tests/text_reparser/plugins/poll_option_test.php index acabda2146..cc6163a81b 100644 --- a/tests/text_reparser/plugins/poll_option_test.php +++ b/tests/text_reparser/plugins/poll_option_test.php @@ -28,6 +28,18 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case return new \phpbb\textreparser\plugins\poll_option($this->db); } + protected function get_rows() + { + $sql = 'SELECT topic_id, poll_option_id, poll_option_text + FROM ' . POLL_OPTIONS_TABLE . ' + ORDER BY topic_id, poll_option_id'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + return $rows; + } + public function setUp() { global $config; @@ -46,18 +58,19 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case $this->assertEquals(123, $reparser->get_max_id()); } + public function test_dry_run() + { + $old_rows = $this->get_rows(); + $reparser = $this->get_reparser(); + $reparser->reparse_range(1, 1, true); + $new_rows = $this->get_rows(); + $this->assertEquals($old_rows, $new_rows); + } + public function testReparse() { $reparser = $this->get_reparser(); $reparser->reparse_range(2, 13); - - $sql = 'SELECT topic_id, poll_option_id, poll_option_text - FROM ' . POLL_OPTIONS_TABLE . ' - ORDER BY topic_id, poll_option_id'; - $result = $this->db->sql_query($sql); - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - $expected = array( array( 'topic_id' => 1, @@ -110,6 +123,6 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case 'poll_option_text' => 'This row should be [b:abcd1234]ignored[/b:abcd1234]', ), ); - $this->assertEquals($expected, $rows); + $this->assertEquals($expected, $this->get_rows()); } } diff --git a/tests/text_reparser/plugins/test_row_based_plugin.php b/tests/text_reparser/plugins/test_row_based_plugin.php index befcb48bda..9f9ecc609a 100644 --- a/tests/text_reparser/plugins/test_row_based_plugin.php +++ b/tests/text_reparser/plugins/test_row_based_plugin.php @@ -20,6 +20,21 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t abstract protected function get_reparser(); + protected function get_rows(array $ids) + { + $reparser = $this->get_reparser(); + $columns = $reparser->get_columns(); + $sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text + FROM ' . $reparser->get_table_name() . ' + WHERE ' . $this->db->sql_in_set($columns['id'], $ids) . ' + ORDER BY id'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + return $rows; + } + public function setUp() { global $config; @@ -38,10 +53,19 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t $this->assertEquals(1000, $reparser->get_max_id()); } + public function test_dry_run() + { + $old_rows = $this->get_rows(array(1)); + $reparser = $this->get_reparser(); + $reparser->reparse_range(1, 1, true); + $new_rows = $this->get_rows(array(1)); + $this->assertEquals($old_rows, $new_rows); + } + /** - * @dataProvider getReparseTests + * @dataProvider get_reparse_tests */ - public function testReparse($min_id, $max_id, $expected) + public function test_reparse($min_id, $max_id, $expected) { $reparser = $this->get_reparser(); $reparser->reparse_range($min_id, $max_id); @@ -52,18 +76,10 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t $ids[] = $row['id']; } - $columns = $reparser->get_columns(); - $sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text - FROM ' . $reparser->get_table_name() . ' - WHERE ' . $this->db->sql_in_set($columns['id'], $ids) . ' - ORDER BY id'; - $result = $this->db->sql_query($sql); - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - $this->assertEquals($expected, $rows); + $this->assertEquals($expected, $this->get_rows($ids)); } - public function getReparseTests() + public function get_reparse_tests() { return array( array( -- cgit v1.2.1 From cf4cdcda586a2371aa92ae452951f9660737ae09 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 6 Jul 2015 01:57:54 +0200 Subject: [ticket/13987] Replaced optional parameter with explicit API Added disable_save() and enable_save() to toggle a dry run PHPBB3-13987 --- tests/text_reparser/plugins/contact_admin_info_test.php | 4 +++- tests/text_reparser/plugins/poll_option_test.php | 4 +++- tests/text_reparser/plugins/test_row_based_plugin.php | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/text_reparser/plugins/contact_admin_info_test.php b/tests/text_reparser/plugins/contact_admin_info_test.php index e3df1ee2b8..1dc03834b6 100644 --- a/tests/text_reparser/plugins/contact_admin_info_test.php +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -62,7 +62,8 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas { $old_rows = $this->get_rows(); $reparser = $this->get_reparser(); - $reparser->reparse_range(1, 1, true); + $reparser->disable_save(); + $reparser->reparse_range(1, 1); $new_rows = $this->get_rows(); $this->assertEquals($old_rows, $new_rows); } @@ -70,6 +71,7 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas public function test_reparse() { $reparser = $this->get_reparser(); + $reparser->enable_save(); $reparser->reparse_range(1, 1); $expected = array( array( diff --git a/tests/text_reparser/plugins/poll_option_test.php b/tests/text_reparser/plugins/poll_option_test.php index cc6163a81b..dfa3a030ed 100644 --- a/tests/text_reparser/plugins/poll_option_test.php +++ b/tests/text_reparser/plugins/poll_option_test.php @@ -62,7 +62,8 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case { $old_rows = $this->get_rows(); $reparser = $this->get_reparser(); - $reparser->reparse_range(1, 1, true); + $reparser->disable_save(); + $reparser->reparse_range(1, 1); $new_rows = $this->get_rows(); $this->assertEquals($old_rows, $new_rows); } @@ -70,6 +71,7 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case public function testReparse() { $reparser = $this->get_reparser(); + $reparser->enable_save(); $reparser->reparse_range(2, 13); $expected = array( array( diff --git a/tests/text_reparser/plugins/test_row_based_plugin.php b/tests/text_reparser/plugins/test_row_based_plugin.php index 9f9ecc609a..bbae44c8e0 100644 --- a/tests/text_reparser/plugins/test_row_based_plugin.php +++ b/tests/text_reparser/plugins/test_row_based_plugin.php @@ -57,7 +57,8 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t { $old_rows = $this->get_rows(array(1)); $reparser = $this->get_reparser(); - $reparser->reparse_range(1, 1, true); + $reparser->disable_save(); + $reparser->reparse_range(1, 1); $new_rows = $this->get_rows(array(1)); $this->assertEquals($old_rows, $new_rows); } -- cgit v1.2.1 From d63412af4c177a97997ddd65c91ee6ced7760bc9 Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 7 Jul 2015 22:50:06 +0700 Subject: [ticket/13377] Add test entries PHPBB3-13377 --- tests/text_processing/decode_message_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/text_processing/decode_message_test.php b/tests/text_processing/decode_message_test.php index c9c1da52d5..7de599f2b1 100644 --- a/tests/text_processing/decode_message_test.php +++ b/tests/text_processing/decode_message_test.php @@ -38,6 +38,14 @@ class phpbb_text_processing_decode_message_test extends phpbb_test_case ':)', ':)' ), + array( + 'www.phpbb.com', + 'www.phpbb.com' + ), + array( + 'http://www.phpbb.com', + 'http://www.phpbb.com' + ), /** * Fails as per PHPBB3-8420 * @link http://tracker.phpbb.com/browse/PHPBB3-8420 -- cgit v1.2.1 From 5ad0af3d3df698f7c749fee1f65962e0ba3cf663 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 7 Jul 2015 19:16:58 +0200 Subject: [ticket/13740] Fixes and Tests for database helper PHPBB3-13740 --- tests/installer/database_helper_test.php | 151 +++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 tests/installer/database_helper_test.php (limited to 'tests') diff --git a/tests/installer/database_helper_test.php b/tests/installer/database_helper_test.php new file mode 100644 index 0000000000..80c76c004b --- /dev/null +++ b/tests/installer/database_helper_test.php @@ -0,0 +1,151 @@ + + * @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_installer_database_helper_test extends phpbb_test_case +{ + /** + * @var phpbb\install\helper\database + */ + private $database_helper; + + /** + * @var phpbb\db\driver\driver_interface + */ + private $dbms_mock; + + public function setUp() + { + $filesystem = new \phpbb\filesystem\filesystem(); + $phpbb_root_path = ''; + $this->database_helper = new \phpbb\install\helper\database($filesystem, $phpbb_root_path); + + // I used oracle because it tolerates the shortest table prefixes + // so it's the simplest to write test cases for + $this->dbms_mock = $this->getMock('\phpbb\db\driver\oracle'); + } + + /** + * @param string $input + * @param string $expected + * + * @dataProvider comment_string_provider + */ + public function test_remove_comments($input, $expected) + { + $this->assertEquals($expected, $this->database_helper->remove_comments($input)); + } + + /** + * @param array $expected + * @param string $sql + * @param string $delimiter + * + * @dataProvider sql_file_string_provider + */ + public function test_split_sql($expected, $sql, $delimiter) + { + $this->assertEquals($expected, $this->database_helper->split_sql_file($sql, $delimiter)); + } + + /** + * @param bool|array $expected + * @param string $test_string + * + * @dataProvider prefix_test_case_provider + */ + public function test_validate_table_prefix($expected, $test_string) + { + $this->assertEquals($expected, $this->database_helper->validate_table_prefix($this->dbms_mock, $test_string)); + } + + // Data provider for the remove comments function + public function comment_string_provider() + { + return array( + array( + 'abc', + 'abc', + ), + array( + 'abc /* asdf */', + "abc \n", + ), + array( + 'abc /* asdf */ f', + "abc \n f", + ), + array( + '# abc', + "\n", + ), + ); + } + + // Data provider for the sql file splitter function + public function sql_file_string_provider() + { + return array( + array( + array( + 'abcd "efgh"' . "\n" . 'qwerty', + 'SELECT * FROM table', + ), + 'abcd "efgh" + qwerty; + SELECT * FROM table', + ';', + ), + array( + array( + 'SELECT * FROM table1', + 'SELECT * FROM table2 WHERE i_am="king"', + ), + 'SELECT * FROM table1; SELECT * FROM table2 WHERE i_am="king"', + ';', + ), + ); + } + + // Test data for prefix test + public function prefix_test_case_provider() + { + return array( + array( + true, + 'phpbb_', + ), + array( + true, + 'phpbb', + ), + array( + array( + array('title' => 'INST_ERR_DB_INVALID_PREFIX'), + ), + '1hpbb_', + ), + array( + array( + array('title' => 'INST_ERR_DB_INVALID_PREFIX'), + ), + '?hpbb_', + ), + array( + array( + array('title' => 'INST_ERR_PREFIX_TOO_LONG'), + ), + 'php_bb_', + ), + ); + } +} -- cgit v1.2.1 From 9d54867485300eefe7fcd8e8c2080eb655e713ed Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 8 Jul 2015 01:00:28 +0200 Subject: [ticket/13740] Test navigation provider PHPBB3-13740 --- tests/installer/navigation_provider_test.php | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/installer/navigation_provider_test.php (limited to 'tests') diff --git a/tests/installer/navigation_provider_test.php b/tests/installer/navigation_provider_test.php new file mode 100644 index 0000000000..5bfce0eba8 --- /dev/null +++ b/tests/installer/navigation_provider_test.php @@ -0,0 +1,34 @@ + + * @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_installer_navigation_provider_test extends phpbb_test_case +{ + public function test_navigation() + { + // Mock nav interface + $nav_mock = $this->getMockBuilder('\phpbb\install\helper\navigation\navigation_interface') + ->method('get') + ->willReturn(array('foo' => 'bar')) + ->getMock(); + + // Set up dependencies + $container = new phpbb_mock_container_builder(); + $container->set('foo', $nav_mock); + $nav_collection = new \phpbb\di\service_collection($container); + $nav_collection->add('foo'); + + // Let's test + $nav_provider = new \phpbb\install\helper\navigation\navigation_provider($nav_collection); + $this->assertEquals(array('foo' => 'bar'), $nav_provider->get()); + } +} -- cgit v1.2.1 From 612eead5a9932d459d8b65f9217f895c33b51c39 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 8 Jul 2015 01:27:05 +0200 Subject: [ticket/13740] Installer config test PHPBB3-13740 --- tests/installer/installer_config_test.php | 86 +++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 tests/installer/installer_config_test.php (limited to 'tests') diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php new file mode 100644 index 0000000000..d1110bf8f8 --- /dev/null +++ b/tests/installer/installer_config_test.php @@ -0,0 +1,86 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +use phpbb\install\helper\config; + +class phpbb_installer_config_test extends phpbb_test_case +{ + /** + * @var \phpbb\install\helper\config + */ + private $config; + + public function setUp() + { + $phpbb_root_path = __DIR__ . './../../phpBB/'; + $filesystem = $this->getMock('\phpbb\filesystem\filesystem'); + $php_ini = $this->getMockBuilder('\phpbb\php\ini') + ->method('get_int') + ->willReturn(-1) + ->method('get_bytes') + ->willReturn(-1) + ->getMock(); + + $this->config = new config($filesystem, $php_ini, $phpbb_root_path); + } + + /** + * @covers config::set + * @covers config::get + */ + public function test_set_get_var() + { + $this->config->set('foo', 'bar'); + $this->assertEquals('bar', $this->config->get('foo')); + } + + public function test_get_time_remaining() + { + $this->assertGreaterThan(0, $this->config->get_time_remaining()); + } + + public function test_get_memory_remaining() + { + $this->assertGreaterThan(0, $this->config->get_memory_remaining()); + } + + /** + * @covers config::set_finished_task + * @covers config::set_active_module + * @covers config::set_task_progress_count + * @covers config::increment_current_task_progress + * @covers config::get_progress_data + */ + public function test_progress_tracking() + { + $this->config->set_finished_task('foo', 3); + $this->config->set_active_module('bar', 4); + $this->config->set_task_progress_count(10); + $this->config->increment_current_task_progress(); + + $this->assertContains(array('current_task_progress' => 1), $this->config->get_progress_data()); + + $this->config->increment_current_task_progress(2); + + $this->assertEquals(array( + 'last_task_module_index' => 4, + 'last_task_module_name' => 'bar', // Stores the service name of the latest finished module + 'last_task_index' => 3, + 'last_task_name' => 'foo', // Stores the service name of the latest finished task + 'max_task_progress' => 10, + 'current_task_progress' => 3, + ), + $this->config->get_progress_data() + ); + } +} -- cgit v1.2.1 From 1c01252b5d899c488e007659234b6224ac3f4c19 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 8 Jul 2015 13:17:42 +0200 Subject: [ticket/13740] Fix test stubs PHPBB3-13740 --- tests/installer/database_helper_test.php | 20 ++++---------------- tests/installer/installer_config_test.php | 11 ++++++----- tests/installer/navigation_provider_test.php | 8 ++++---- 3 files changed, 14 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/installer/database_helper_test.php b/tests/installer/database_helper_test.php index 80c76c004b..84445c86c5 100644 --- a/tests/installer/database_helper_test.php +++ b/tests/installer/database_helper_test.php @@ -28,10 +28,6 @@ class phpbb_installer_database_helper_test extends phpbb_test_case $filesystem = new \phpbb\filesystem\filesystem(); $phpbb_root_path = ''; $this->database_helper = new \phpbb\install\helper\database($filesystem, $phpbb_root_path); - - // I used oracle because it tolerates the shortest table prefixes - // so it's the simplest to write test cases for - $this->dbms_mock = $this->getMock('\phpbb\db\driver\oracle'); } /** @@ -65,7 +61,7 @@ class phpbb_installer_database_helper_test extends phpbb_test_case */ public function test_validate_table_prefix($expected, $test_string) { - $this->assertEquals($expected, $this->database_helper->validate_table_prefix($this->dbms_mock, $test_string)); + $this->assertEquals($expected, $this->database_helper->validate_table_prefix('oracle', $test_string)); } // Data provider for the remove comments function @@ -100,17 +96,9 @@ class phpbb_installer_database_helper_test extends phpbb_test_case 'abcd "efgh"' . "\n" . 'qwerty', 'SELECT * FROM table', ), - 'abcd "efgh" - qwerty; - SELECT * FROM table', - ';', - ), - array( - array( - 'SELECT * FROM table1', - 'SELECT * FROM table2 WHERE i_am="king"', - ), - 'SELECT * FROM table1; SELECT * FROM table2 WHERE i_am="king"', + 'abcd "efgh"' . "\n" . + 'qwerty' . "\n" . + 'SELECT * FROM table', ';', ), ); diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php index d1110bf8f8..6c0079a1ec 100644 --- a/tests/installer/installer_config_test.php +++ b/tests/installer/installer_config_test.php @@ -25,11 +25,11 @@ class phpbb_installer_config_test extends phpbb_test_case $phpbb_root_path = __DIR__ . './../../phpBB/'; $filesystem = $this->getMock('\phpbb\filesystem\filesystem'); $php_ini = $this->getMockBuilder('\phpbb\php\ini') - ->method('get_int') - ->willReturn(-1) - ->method('get_bytes') - ->willReturn(-1) ->getMock(); + $php_ini->method('get_int') + ->willReturn(-1); + $php_ini->method('get_bytes') + ->willReturn(-1); $this->config = new config($filesystem, $php_ini, $phpbb_root_path); } @@ -68,7 +68,8 @@ class phpbb_installer_config_test extends phpbb_test_case $this->config->set_task_progress_count(10); $this->config->increment_current_task_progress(); - $this->assertContains(array('current_task_progress' => 1), $this->config->get_progress_data()); + $progress_data = $this->config->get_progress_data(); + $this->assertEquals(1, $progress_data['current_task_progress']); $this->config->increment_current_task_progress(2); diff --git a/tests/installer/navigation_provider_test.php b/tests/installer/navigation_provider_test.php index 5bfce0eba8..ea39af66cd 100644 --- a/tests/installer/navigation_provider_test.php +++ b/tests/installer/navigation_provider_test.php @@ -16,14 +16,14 @@ class phpbb_installer_navigation_provider_test extends phpbb_test_case public function test_navigation() { // Mock nav interface - $nav_mock = $this->getMockBuilder('\phpbb\install\helper\navigation\navigation_interface') - ->method('get') - ->willReturn(array('foo' => 'bar')) + $nav_stub = $this->getMockBuilder('\phpbb\install\helper\navigation\navigation_interface') ->getMock(); + $nav_stub->method('get') + ->willReturn(array('foo' => 'bar')); // Set up dependencies $container = new phpbb_mock_container_builder(); - $container->set('foo', $nav_mock); + $container->set('foo', $nav_stub); $nav_collection = new \phpbb\di\service_collection($container); $nav_collection->add('foo'); -- cgit v1.2.1 From 80f91da9b9ab7f4c2d66ba5632802a3a5dfa489f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 8 Jul 2015 15:11:10 -0700 Subject: [ticket/13995] Fix errors in tests from merge conflict PHPBB3-13995 --- tests/template/template_includecss_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index ea851e3568..ac62e820ae 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -103,11 +103,11 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te ), array( array('TEST' => 3), - '', + '', ), array( array('TEST' => 4), - '', + '', ), ); } -- cgit v1.2.1 From d517ed846be665ec04d9ca000d5f26f8a9571206 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 12 Jun 2014 23:16:51 +0200 Subject: [ticket/12692] Add unit test PHPBB3-12692 --- tests/console/fixtures/png | Bin 0 -> 129 bytes tests/console/fixtures/thumbnail.xml | 40 +++++++++++++ tests/console/fixtures/txt | 2 + tests/console/thumbnail_test.php | 107 +++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 tests/console/fixtures/png create mode 100644 tests/console/fixtures/thumbnail.xml create mode 100644 tests/console/fixtures/txt create mode 100644 tests/console/thumbnail_test.php (limited to 'tests') diff --git a/tests/console/fixtures/png b/tests/console/fixtures/png new file mode 100644 index 0000000000..c143a26a06 Binary files /dev/null and b/tests/console/fixtures/png differ diff --git a/tests/console/fixtures/thumbnail.xml b/tests/console/fixtures/thumbnail.xml new file mode 100644 index 0000000000..8037523633 --- /dev/null +++ b/tests/console/fixtures/thumbnail.xml @@ -0,0 +1,40 @@ + + +
            + attach_id + physical_filename + real_filename + thumbnail + extension + mimetype + attach_comment + + + 1 + test_png_1 + real_test.png + 0 + png + image/png + + + + 2 + test_png_2 + real_test.png + 1 + png + image/png + + + + 10 + test_txt + real_test.txt + 0 + txt + text/plain + + +
            + diff --git a/tests/console/fixtures/txt b/tests/console/fixtures/txt new file mode 100644 index 0000000000..a78c858f5c --- /dev/null +++ b/tests/console/fixtures/txt @@ -0,0 +1,2 @@ +mime trigger +The HTML tags should remain uppercase so that case-insensitivity can be checked. diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php new file mode 100644 index 0000000000..7ac18d931a --- /dev/null +++ b/tests/console/thumbnail_test.php @@ -0,0 +1,107 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use phpbb\console\command\thumbnail\generate; +use phpbb\console\command\thumbnail\delete; +use phpbb\console\command\thumbnail\recreate; + +class phpbb_console_command_thumbnail_test extends phpbb_database_test_case +{ + protected $db; + protected $config; + protected $cache; + protected $user; + protected $phpEx; + protected $phpbb_root_path; + protected $application; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/thumbnail.xml'); + } + + public function setUp() + { + global $config, $phpbb_root_path, $phpEx; + + parent::setUp(); + + $config = $this->config = new \phpbb\config\config(array( + 'img_min_thumb_filesize' => 2, + 'img_max_thumb_width' => 2, + 'img_imagick' => '', + )); + + $this->db = $this->db = $this->new_dbal(); + $this->user = $this->getMock('\phpbb\user'); + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + + $this->cache = $this->getMock('\phpbb\cache\service', array(), array(new phpbb_mock_cache(), $this->config, $this->db, $this->phpbb_root_path, $this->phpEx)); + $this->cache->expects($this->any())->method('obtain_attach_extensions')->will($this->returnValue(array( + 'png' => array('display_cat' => ATTACHMENT_CATEGORY_IMAGE), + 'txt' => array('display_cat' => ATTACHMENT_CATEGORY_NONE), + ))); + + $this->application = new Application(); + $this->application->add(new generate($this->db, $this->user, $this->cache, $this->phpbb_root_path, $this->phpEx)); + $this->application->add(new delete($this->db, $this->user, $this->phpbb_root_path)); + $this->application->add(new recreate($this->user)); + } + + public function test_thumbnails() + { + copy(dirname(__FILE__) . '/fixtures/png', $this->phpbb_root_path . 'files/test_png_1'); + copy(dirname(__FILE__) . '/fixtures/png', $this->phpbb_root_path . 'files/test_png_2'); + copy(dirname(__FILE__) . '/fixtures/png', $this->phpbb_root_path . 'files/thumb_test_png_2'); + copy(dirname(__FILE__) . '/fixtures/txt', $this->phpbb_root_path . 'files/test_txt'); + + $command_tester = $this->get_command_tester('thumbnail:generate'); + $exit_status = $command_tester->execute(array('command' => 'thumbnail:generate')); + + $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1')); + $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2')); + $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt')); + $this->assertSame(0, $exit_status); + + $command_tester = $this->get_command_tester('thumbnail:delete'); + $exit_status = $command_tester->execute(array('command' => 'thumbnail:delete')); + + $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1')); + $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2')); + $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt')); + $this->assertSame(0, $exit_status); + + $command_tester = $this->get_command_tester('thumbnail:recreate'); + $exit_status = $command_tester->execute(array('command' => 'thumbnail:recreate')); + + $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1')); + $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2')); + $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt')); + $this->assertSame(0, $exit_status); + + unlink($this->phpbb_root_path . 'files/test_png_1'); + unlink($this->phpbb_root_path . 'files/test_png_2'); + unlink($this->phpbb_root_path . 'files/test_txt'); + unlink($this->phpbb_root_path . 'files/thumb_test_png_1'); + unlink($this->phpbb_root_path . 'files/thumb_test_png_2'); + } + + public function get_command_tester($command_name) + { + $command = $this->application->find($command_name); + return new CommandTester($command); + } +} -- cgit v1.2.1 From 487fea8cfffe872e888ebcc3e1f5538b72bcaec1 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 22 Jul 2014 16:24:40 +0200 Subject: [ticket/12692] Move the language strings to cli.php PHPBB3-12692 --- tests/console/thumbnail_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php index 7ac18d931a..11d2717f73 100644 --- a/tests/console/thumbnail_test.php +++ b/tests/console/thumbnail_test.php @@ -56,8 +56,8 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case ))); $this->application = new Application(); - $this->application->add(new generate($this->db, $this->user, $this->cache, $this->phpbb_root_path, $this->phpEx)); - $this->application->add(new delete($this->db, $this->user, $this->phpbb_root_path)); + $this->application->add(new generate($this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx)); + $this->application->add(new delete($this->user, $this->db, $this->phpbb_root_path)); $this->application->add(new recreate($this->user)); } -- cgit v1.2.1 From a55c83b77168e77fd4d0101b8c58741f442b2d39 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 8 Aug 2014 15:22:05 +0200 Subject: [ticket/12692] Add a proper extension to the fixtures PHPBB3-12692 --- tests/console/fixtures/png | Bin 129 -> 0 bytes tests/console/fixtures/png.png | Bin 0 -> 129 bytes tests/console/fixtures/txt | 2 -- tests/console/fixtures/txt.txt | 2 ++ tests/console/thumbnail_test.php | 10 ++++++---- 5 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 tests/console/fixtures/png create mode 100644 tests/console/fixtures/png.png delete mode 100644 tests/console/fixtures/txt create mode 100644 tests/console/fixtures/txt.txt (limited to 'tests') diff --git a/tests/console/fixtures/png b/tests/console/fixtures/png deleted file mode 100644 index c143a26a06..0000000000 Binary files a/tests/console/fixtures/png and /dev/null differ diff --git a/tests/console/fixtures/png.png b/tests/console/fixtures/png.png new file mode 100644 index 0000000000..c143a26a06 Binary files /dev/null and b/tests/console/fixtures/png.png differ diff --git a/tests/console/fixtures/txt b/tests/console/fixtures/txt deleted file mode 100644 index a78c858f5c..0000000000 --- a/tests/console/fixtures/txt +++ /dev/null @@ -1,2 +0,0 @@ -mime trigger -The HTML tags should remain uppercase so that case-insensitivity can be checked. diff --git a/tests/console/fixtures/txt.txt b/tests/console/fixtures/txt.txt new file mode 100644 index 0000000000..a78c858f5c --- /dev/null +++ b/tests/console/fixtures/txt.txt @@ -0,0 +1,2 @@ +mime trigger +The HTML tags should remain uppercase so that case-insensitivity can be checked. diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php index 11d2717f73..6af8e7e174 100644 --- a/tests/console/thumbnail_test.php +++ b/tests/console/thumbnail_test.php @@ -11,6 +11,8 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\thumbnail\generate; @@ -63,10 +65,10 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case public function test_thumbnails() { - copy(dirname(__FILE__) . '/fixtures/png', $this->phpbb_root_path . 'files/test_png_1'); - copy(dirname(__FILE__) . '/fixtures/png', $this->phpbb_root_path . 'files/test_png_2'); - copy(dirname(__FILE__) . '/fixtures/png', $this->phpbb_root_path . 'files/thumb_test_png_2'); - copy(dirname(__FILE__) . '/fixtures/txt', $this->phpbb_root_path . 'files/test_txt'); + copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_1'); + copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_2'); + copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/thumb_test_png_2'); + copy(dirname(__FILE__) . '/fixtures/txt.txt', $this->phpbb_root_path . 'files/test_txt'); $command_tester = $this->get_command_tester('thumbnail:generate'); $exit_status = $command_tester->execute(array('command' => 'thumbnail:generate')); -- cgit v1.2.1 From 556504df24a72d0cd5fbbd5b266f815f1353ab4c Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 18 Aug 2014 16:27:09 +0200 Subject: [ticket/12692] Fix tests PHPBB3-12692 --- tests/console/thumbnail_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php index 6af8e7e174..094d8ca051 100644 --- a/tests/console/thumbnail_test.php +++ b/tests/console/thumbnail_test.php @@ -47,7 +47,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case )); $this->db = $this->db = $this->new_dbal(); - $this->user = $this->getMock('\phpbb\user'); + $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; -- cgit v1.2.1 From 794726a464452a6056d8a2ba06c4394767d4c497 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 8 Jul 2015 18:08:50 +0200 Subject: [ticket/13740] Fix database test PHPBB3-13740 --- tests/installer/database_helper_test.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/installer/database_helper_test.php b/tests/installer/database_helper_test.php index 84445c86c5..d2ebe76ad5 100644 --- a/tests/installer/database_helper_test.php +++ b/tests/installer/database_helper_test.php @@ -18,11 +18,6 @@ class phpbb_installer_database_helper_test extends phpbb_test_case */ private $database_helper; - /** - * @var phpbb\db\driver\driver_interface - */ - private $dbms_mock; - public function setUp() { $filesystem = new \phpbb\filesystem\filesystem(); @@ -61,7 +56,7 @@ class phpbb_installer_database_helper_test extends phpbb_test_case */ public function test_validate_table_prefix($expected, $test_string) { - $this->assertEquals($expected, $this->database_helper->validate_table_prefix('oracle', $test_string)); + $this->assertEquals($expected, $this->database_helper->validate_table_prefix('sqlite3', $test_string)); } // Data provider for the remove comments function @@ -97,7 +92,7 @@ class phpbb_installer_database_helper_test extends phpbb_test_case 'SELECT * FROM table', ), 'abcd "efgh"' . "\n" . - 'qwerty' . "\n" . + 'qwerty;' . "\n" . 'SELECT * FROM table', ';', ), @@ -130,9 +125,16 @@ class phpbb_installer_database_helper_test extends phpbb_test_case ), array( array( - array('title' => 'INST_ERR_PREFIX_TOO_LONG'), + array('title' => array('INST_ERR_PREFIX_TOO_LONG', 200)), + ), + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + ), + array( + array( + array('title' => 'INST_ERR_DB_INVALID_PREFIX'), + array('title' => array('INST_ERR_PREFIX_TOO_LONG', 200)), ), - 'php_bb_', + '_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', ), ); } -- cgit v1.2.1 From 62103cec300ddadb904862ee2a74d68f71eb32ca Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 9 Jul 2015 15:26:48 +0200 Subject: [ticket/13740] Use service collection instead of array of task names PHPBB3-13740 --- tests/installer/installer_config_test.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php index 6c0079a1ec..4b83eb9a8f 100644 --- a/tests/installer/installer_config_test.php +++ b/tests/installer/installer_config_test.php @@ -63,8 +63,8 @@ class phpbb_installer_config_test extends phpbb_test_case */ public function test_progress_tracking() { - $this->config->set_finished_task('foo', 3); - $this->config->set_active_module('bar', 4); + $this->config->set_finished_task('foo'); + $this->config->set_active_module('bar'); $this->config->set_task_progress_count(10); $this->config->increment_current_task_progress(); @@ -74,10 +74,8 @@ class phpbb_installer_config_test extends phpbb_test_case $this->config->increment_current_task_progress(2); $this->assertEquals(array( - 'last_task_module_index' => 4, - 'last_task_module_name' => 'bar', // Stores the service name of the latest finished module - 'last_task_index' => 3, - 'last_task_name' => 'foo', // Stores the service name of the latest finished task + 'last_task_module_name' => 'bar', + 'last_task_name' => 'foo', 'max_task_progress' => 10, 'current_task_progress' => 3, ), -- cgit v1.2.1 From 051b7d1867351df293d055b62e0eb051758f90da Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 10 Jul 2015 14:54:21 +0200 Subject: [ticket/13740] Module base test PHPBB3-13740 --- tests/installer/mocks/test_installer_module.php | 20 +++++++ tests/installer/mocks/test_installer_task_mock.php | 44 +++++++++++++++ tests/installer/module_base_test.php | 65 ++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 tests/installer/mocks/test_installer_module.php create mode 100644 tests/installer/mocks/test_installer_task_mock.php create mode 100644 tests/installer/module_base_test.php (limited to 'tests') diff --git a/tests/installer/mocks/test_installer_module.php b/tests/installer/mocks/test_installer_module.php new file mode 100644 index 0000000000..e6ebbba263 --- /dev/null +++ b/tests/installer/mocks/test_installer_module.php @@ -0,0 +1,20 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +class test_installer_module extends \phpbb\install\module_base +{ + public function get_navigation_stage_path() + { + return array(); + } +} diff --git a/tests/installer/mocks/test_installer_task_mock.php b/tests/installer/mocks/test_installer_task_mock.php new file mode 100644 index 0000000000..ccd62b3bf4 --- /dev/null +++ b/tests/installer/mocks/test_installer_task_mock.php @@ -0,0 +1,44 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +class test_installer_task_mock extends \phpbb\install\task_base +{ + private $task_was_runned; + + public function __construct() + { + $this->task_was_runned = false; + + parent::__construct(); + } + + public function run() + { + $this->task_was_runned = true; + } + + public function was_task_runned() + { + return $this->task_was_runned; + } + + public function get_task_lang_name() + { + return ''; + } + + public static function get_step_count() + { + return 2; + } +} diff --git a/tests/installer/module_base_test.php b/tests/installer/module_base_test.php new file mode 100644 index 0000000000..fd92c9b674 --- /dev/null +++ b/tests/installer/module_base_test.php @@ -0,0 +1,65 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once __DIR__ . '/mocks/test_installer_task_mock.php'; +require_once __DIR__ . '/mocks/test_installer_module.php'; + +class module_base_test extends phpbb_test_case +{ + /** + * @var \phpbb\install\module_interface + */ + protected $module; + + /** + * @var phpbb_mock_container_builder + */ + protected $container; + + public function setUp() + { + // DI container mock + $this->container = new phpbb_mock_container_builder(); + $this->container->set('task_one', new test_installer_task_mock()); + $this->container->set('task_two', new test_installer_task_mock()); + + // the collection + $module_collection = new \phpbb\di\ordered_service_collection($this->container); + $module_collection->add('task_one'); + $module_collection->add('task_two'); + $module_collection->add_service_class('task_one', 'test_installer_task_mock'); + $module_collection->add_service_class('task_two', 'test_installer_task_mock'); + + $this->module = new test_installer_module($module_collection, true, false); + + $iohandler = $this->getMock('\phpbb\install\helper\iohandler\iohandler_interface'); + $config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \phpbb\php\ini(), '', 'php'); + $this->module->setup($config, $iohandler); + } + + public function test_run() + { + $this->module->run(); + + $task = $this->container->get('task_one'); + $this->assertTrue($task->was_task_runned()); + + $task = $this->container->get('task_two'); + $this->assertTrue($task->was_task_runned()); + } + + public function test_step_count() + { + $this->assertEquals(4, $this->module->get_step_count()); + } +} -- cgit v1.2.1 From ca671708cb3ed4fbf218373f5ac310cf955676a4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 12 Jul 2015 18:55:23 +0200 Subject: [ticket/14000] Added support for emoji PHPBB3-14000 --- tests/text_formatter/s9e/default_formatting_test.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index c67976301f..390bc65264 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -29,7 +29,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case /** * @dataProvider get_default_formatting_tests */ - public function test_default_formatting($original, $expected) + public function test_default_formatting($original, $expected, $setup = null) { $fixture = __DIR__ . '/fixtures/default_formatting.xml'; $container = $this->get_test_case_helpers()->set_s9e_services(null, $fixture); @@ -37,6 +37,11 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case $parser = $container->get('text_formatter.parser'); $renderer = $container->get('text_formatter.renderer'); + if (isset($setup)) + { + call_user_func($setup, $container); + } + $parsed_text = $parser->parse($original); $this->assertSame($expected, $renderer->render($parsed_text)); @@ -263,6 +268,18 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '[quote=\'[quote="foo"]\']...[/quote]', '
            [quote="foo"] wrote:...
            ' ), + array( + "Emoji: \xF0\x9F\x98\x80", + 'Emoji: ' . ' + ), + array( + "Emoji: \xF0\x9F\x98\x80", + "Emoji: \xF0\x9F\x98\x80", + function ($container) + { + $container->get('text_formatter.renderer')->set_viewsmilies(false); + } + ), ); } } -- cgit v1.2.1 From 0d52d36b37e0434824e93af592bbe0ce3c994da6 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 13 Jul 2015 10:31:07 +0200 Subject: [ticket/14000] Replaced test content with non-emoji characters PHPBB3-14000 --- tests/functional/posting_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index e9b62c0b6c..724c42b289 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -57,9 +57,9 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $this->login(); $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.'); - $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', "This is a test with these weird characters: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6"); + $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', "This is a test with these weird characters: \xF0\x9F\x84\x90 \xF0\x9F\x84\x91"); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains("\xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", $crawler->text()); + $this->assertContains("\xF0\x9F\x84\x90 \xF0\x9F\x84\x91", $crawler->text()); } public function test_html_entities() -- cgit v1.2.1 From 675cf5e897944318f9666b088a5053f339fe1032 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 13 Jul 2015 16:08:57 +0200 Subject: [ticket/14008] Do not add a user_id value to quotes from guests PHPBB3-14008 --- tests/text_formatter/s9e/utils_test.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 1c03783792..dade259790 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -175,6 +175,15 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case ), '[quote=user post_id=123 url=http://example.org]...[/quote]', ), + array( + '...', + array( + 'author' => 'user', + 'post_id' => 123, + 'user_id' => ANONYMOUS + ), + '[quote=user post_id=123]...[/quote]', + ), array( '...', array('author' => ' '), -- cgit v1.2.1 From be0d4e20d4be8bc3217e5d025058e065b8f2071a Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Mon, 28 Apr 2014 14:00:27 +0200 Subject: [ticket/11444] Moving the in-board notifications to a method class Currently the in-board method for the notifications is hardcoded and cannot be disabled. This method should be in his own class extending `phpbb\notification\method\method_interface`. It also add the possibility, for each method, to be enabled by default (ie: no entry in the DB => notification enabled). https://tracker.phpbb.com/browse/PHPBB3-11444 https://tracker.phpbb.com/browse/PHPBB3-11967 PHPBB3-11444 --- tests/functional/notification_test.php | 8 +-- tests/mock/container_builder.php | 10 +++- tests/mock/notification_manager.php | 7 ++- tests/mock/notification_type_post.php | 5 +- tests/notification/base.php | 33 ++++++++++-- .../ext/test/notification/type/test.php | 5 +- .../submit_post_notification.type.bookmark.xml | 10 ++-- .../submit_post_notification.type.post.xml | 14 ++--- ...submit_post_notification.type.post_in_queue.xml | 14 ++--- .../submit_post_notification.type.quote.xml | 10 ++-- .../submit_post_notification.type.topic.xml | 8 +-- tests/notification/manager_helper.php | 7 +-- tests/notification/notification_test.php | 48 ++++++++--------- tests/notification/submit_post_base.php | 61 ++++++++++++++++------ tests/notification/user_list_trim_test.php | 2 +- 15 files changed, 152 insertions(+), 90 deletions(-) (limited to 'tests') diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index ec03f7a6a4..5c6b87d50b 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -21,15 +21,15 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case return array( // Rows inserted by phpBB/install/schemas/schema_data.sql // Also see PHPBB3-11460 - array('notification.type.post_notification', true), - array('notification.type.topic_notification', true), + array('notification.type.post_notification.method.board', true), + array('notification.type.topic_notification.method.board', true), array('notification.type.post_notification.method.email', true), array('notification.type.topic_notification.method.email', true), // Default behaviour for in-board notifications: // If user did not opt-out, in-board notifications are on. - array('notification.type.bookmark_notification', true), - array('notification.type.quote_notification', true), + array('notification.type.bookmark_notification.method.board', true), + array('notification.type.quote_notification.method.board', true), // Default behaviour for email notifications: // If user did not opt-in, email notifications are off. diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php index 297e3a65e6..e04a83804d 100644 --- a/tests/mock/container_builder.php +++ b/tests/mock/container_builder.php @@ -52,7 +52,15 @@ class phpbb_mock_container_builder implements ContainerInterface { if ($this->has($id)) { - return $this->services[$id]; + $service = $this->services[$id]; + if (is_array($service) && is_callable($service[0])) + { + return call_user_func_array($service[0], $service[1]); + } + else + { + return $service; + } } throw new Exception('Could not find service: ' . $id); diff --git a/tests/mock/notification_manager.php b/tests/mock/notification_manager.php index 6a590bc0ca..952c0db489 100644 --- a/tests/mock/notification_manager.php +++ b/tests/mock/notification_manager.php @@ -32,19 +32,18 @@ class phpbb_mock_notification_manager ); } - public function mark_notifications_read() + public function mark_notifications() { } - public function mark_notifications_read_by_parent() + public function mark_notifications_by_parent() { } - public function mark_notifications_read_by_id() + public function mark_notifications_by_id() { } - public function add_notifications() { return array(); diff --git a/tests/mock/notification_type_post.php b/tests/mock/notification_type_post.php index 6d8f6dc504..fd2d1b63cd 100644 --- a/tests/mock/notification_type_post.php +++ b/tests/mock/notification_type_post.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) class phpbb_mock_notification_type_post extends \phpbb\notification\type\post { - public function __construct($user_loader, $db, $cache, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) + public function __construct($user_loader, $db, $cache, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $user_notifications_table) { $this->user_loader = $user_loader; $this->db = $db; @@ -34,7 +34,6 @@ class phpbb_mock_notification_type_post extends \phpbb\notification\type\post $this->php_ext = $php_ext; $this->notification_types_table = $notification_types_table; - $this->notifications_table = $notifications_table; - $this->user_notifications_table = $user_notifications_table; + $this->user_notifications_table = $user_notifications_table; } } diff --git a/tests/notification/base.php b/tests/notification/base.php index 45b0b6f179..c898c76947 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -39,6 +39,13 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case ); } + protected function get_notification_methods() + { + return array( + 'notification.method.board', + ); + } + protected function setUp() { parent::setUp(); @@ -55,6 +62,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case 'allow_bookmarks' => true, 'allow_topic_notify' => true, 'allow_forum_notify' => true, + 'allow_board_notifications' => true, )); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); @@ -87,7 +95,6 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $phpbb_root_path, $phpEx, 'phpbb_notification_types', - 'phpbb_notifications', 'phpbb_user_notifications' ); @@ -107,6 +114,18 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $this->notifications->set_var('notification_types', $types); + $methods = array(); + foreach ($this->get_notification_methods() as $method) + { + $method_parts = explode('.', $method); + $class = $this->build_type('phpbb\notification\method\\' . array_pop($method_parts)); + + $methods[$method] = $class; + $this->container->set($method, $class); + } + + $this->notifications->set_var('notification_methods', $methods); + $this->db->sql_query('DELETE FROM phpbb_notification_types'); $this->db->sql_query('DELETE FROM phpbb_notifications'); $this->db->sql_query('DELETE FROM phpbb_user_notifications'); @@ -116,7 +135,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case { global $phpbb_root_path, $phpEx; - $instance = new $type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); + $instance = new $type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_user_notifications'); if ($type === 'phpbb\\notification\\type\\quote') { @@ -126,9 +145,17 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case return $instance; } + protected function build_method($method) + { + global $phpbb_root_path, $phpEx; + + return new $method($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, + $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); + } + protected function assert_notifications($expected, $options = array()) { - $notifications = $this->notifications->load_notifications(array_merge(array( + $notifications = $this->notifications->load_notifications('notification.method.board', array_merge(array( 'count_unread' => true, 'order_by' => 'notification_time', 'order_dir' => 'ASC', diff --git a/tests/notification/ext/test/notification/type/test.php b/tests/notification/ext/test/notification/type/test.php index b02a563f06..7f3b4a4ef1 100644 --- a/tests/notification/ext/test/notification/type/test.php +++ b/tests/notification/ext/test/notification/type/test.php @@ -47,12 +47,13 @@ class test extends \phpbb\notification\type\base { $this->notification_time = $post['post_time']; - return parent::create_insert_array($post, $pre_create_data); + parent::create_insert_array($post, $pre_create_data); } public function create_update_array($type_data) { - $data = $this->create_insert_array($type_data); + $this->create_insert_array($type_data); + $data = $this->get_insert_array(); // Unset data unique to each row unset( diff --git a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml index a1413e2cf8..7f069abc59 100644 --- a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml +++ b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml @@ -126,35 +126,35 @@ notification.type.bookmark 0 2 - + notification.method.board 1
            notification.type.bookmark 0 3 - + notification.method.board 1 notification.type.bookmark 0 4 - + notification.method.board 1 notification.type.bookmark 0 5 - + notification.method.board 1 notification.type.bookmark 0 6 - + notification.method.board 0 diff --git a/tests/notification/fixtures/submit_post_notification.type.post.xml b/tests/notification/fixtures/submit_post_notification.type.post.xml index ed75787c70..a4bf9d3ee4 100644 --- a/tests/notification/fixtures/submit_post_notification.type.post.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post.xml @@ -156,49 +156,49 @@ notification.type.post 0 2 - + notification.method.board 1
            notification.type.post 0 3 - + notification.method.board 1 notification.type.post 0 4 - + notification.method.board 1 notification.type.post 0 5 - + notification.method.board 1 notification.type.post 0 6 - + notification.method.board 1 notification.type.post 0 7 - + notification.method.board 1 notification.type.post 0 8 - + notification.method.board 1 diff --git a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml index 2dea8e34dd..0a955c48d2 100644 --- a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml @@ -110,49 +110,49 @@ notification.type.needs_approval 0 2 - + notification.method.board 1 notification.type.needs_approval 0 3 - + notification.method.board 1 notification.type.needs_approval 0 4 - + notification.method.board 1 notification.type.needs_approval 0 5 - + notification.method.board 1 notification.type.needs_approval 0 6 - + notification.method.board 1 notification.type.needs_approval 0 7 - + notification.method.board 0 notification.type.needs_approval 0 9 - + notification.method.board 1 diff --git a/tests/notification/fixtures/submit_post_notification.type.quote.xml b/tests/notification/fixtures/submit_post_notification.type.quote.xml index dd5bc620cd..c66830fbf5 100644 --- a/tests/notification/fixtures/submit_post_notification.type.quote.xml +++ b/tests/notification/fixtures/submit_post_notification.type.quote.xml @@ -98,35 +98,35 @@ notification.type.quote 0 2 - + notification.method.board 1 notification.type.quote 0 3 - + notification.method.board 1 notification.type.quote 0 4 - + notification.method.board 1 notification.type.quote 0 5 - + notification.method.board 1 notification.type.quote 0 6 - + notification.method.board 0 diff --git a/tests/notification/fixtures/submit_post_notification.type.topic.xml b/tests/notification/fixtures/submit_post_notification.type.topic.xml index 1ba8d05699..e0f6583f48 100644 --- a/tests/notification/fixtures/submit_post_notification.type.topic.xml +++ b/tests/notification/fixtures/submit_post_notification.type.topic.xml @@ -106,28 +106,28 @@ notification.type.topic 0 2 - + notification.method.board 1 notification.type.topic 0 6 - + notification.method.board 1 notification.type.topic 0 7 - + notification.method.board 1 notification.type.topic 0 8 - + notification.method.board 1 diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 48bf5b177b..40cf9b3ad4 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -46,7 +46,7 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager $item_parts = explode('.', $item_type); $item_type = 'phpbb\notification\type\\' . array_pop($item_parts); - $item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); + $item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->user_notifications_table); if ($item_type === 'phpbb\\notification\\type\\quote') { @@ -65,9 +65,10 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager */ public function get_method_class($method_name) { - $method_name = 'phpbb\notification\method\\' . $method_name; + $method_parts = explode('.', $method_name); + $method_name = 'phpbb\notification\method\\' . array_pop($method_parts); - $method = new $method_name($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); + $method = new $method_name($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, NOTIFICATIONS_TABLE, $this->user_notifications_table); $method->set_notification_manager($this); diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index 79fa5338c4..167cde13ca 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -29,7 +29,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base $quote_type_id = $this->notifications->get_notification_type_id('notification.type.quote'); $test_type_id = $this->notifications->get_notification_type_id('test'); - $this->assertEquals(array( + self::assertEquals(array( 'test' => $test_type_id, 'notification.type.quote' => $quote_type_id, 'notification.type.post' => $post_type_id, @@ -40,13 +40,13 @@ class phpbb_notification_test extends phpbb_tests_notification_base 'notification.type.post', ) )); - $this->assertEquals($quote_type_id, $this->notifications->get_notification_type_id('notification.type.quote')); + self::assertEquals($quote_type_id, $this->notifications->get_notification_type_id('notification.type.quote')); try { - $this->assertEquals(false, $this->notifications->get_notification_type_id('fail')); + self::assertEquals(false, $this->notifications->get_notification_type_id('fail')); - $this->fail('Non-existent type should throw an exception'); + self::fail('Non-existent type should throw an exception'); } catch (Exception $e) {} } @@ -55,15 +55,15 @@ class phpbb_notification_test extends phpbb_tests_notification_base { $subscription_types = $this->notifications->get_subscription_types(); - $this->assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types); - $this->assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types); + self::assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types); + self::assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types); - $this->assertArrayHasKey('notification.type.bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('notification.type.post', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('notification.type.quote', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('notification.type.topic', $subscription_types['NOTIFICATION_GROUP_POSTING']); + self::assertArrayHasKey('notification.type.bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']); + self::assertArrayHasKey('notification.type.post', $subscription_types['NOTIFICATION_GROUP_POSTING']); + self::assertArrayHasKey('notification.type.quote', $subscription_types['NOTIFICATION_GROUP_POSTING']); + self::assertArrayHasKey('notification.type.topic', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('notification.type.pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']); + self::assertArrayHasKey('notification.type.pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']); //get_subscription_types //get_subscription_methods @@ -72,12 +72,12 @@ class phpbb_notification_test extends phpbb_tests_notification_base public function test_subscriptions() { $expected_subscriptions = array( - 'notification.type.post' => array(''), - 'notification.type.topic' => array(''), - 'notification.type.quote' => array(''), - 'notification.type.bookmark' => array(''), - 'test' => array(''), - 'notification.type.pm' => array(''), + 'notification.type.post' => array('notification.method.board'), + 'notification.type.topic' => array('notification.method.board'), + 'notification.type.quote' => array('notification.method.board'), + 'notification.type.bookmark' => array('notification.method.board'), + 'test' => array('notification.method.board'), + 'notification.type.pm' => array('notification.method.board'), ); $subscriptions = $this->notifications->get_global_subscriptions(2); @@ -89,16 +89,16 @@ class phpbb_notification_test extends phpbb_tests_notification_base foreach ($subscriptions as $item_type => $methods) { - $this->assert_array_content_equals($methods, $expected_subscriptions[$item_type]); + $this->assert_array_content_equals($methods, $expected_subscriptions[$item_type]); } - $this->notifications->delete_subscription('notification.type.post', 0, '', 2); + $this->notifications->delete_subscription('notification.type.post', 0, 'notification.method.board', 2); - $this->assertArrayNotHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2)); + self::assertArrayNotHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2)); - $this->notifications->add_subscription('notification.type.post', 0, '', 2); + $this->notifications->add_subscription('notification.type.post', 0, 'notification.method.board', 2); - $this->assertArrayHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2)); + self::assertArrayHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2)); } public function test_notifications() @@ -124,11 +124,11 @@ class phpbb_notification_test extends phpbb_tests_notification_base 'user_id' => 0, ))); - $this->assertEquals(array( + self::assertEquals(array( 'notifications' => array(), 'unread_count' => 0, 'total_count' => 0, - ), $this->notifications->load_notifications(array( + ), $this->notifications->load_notifications('notification.method.board', array( 'count_unread' => true, ))); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 04fb6658c3..73711369ed 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -50,7 +50,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c { parent::setUp(); - global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path; + global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path, $user_loader; // Database $this->db = $this->new_dbal(); @@ -69,7 +69,11 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c ))); // Config - $config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,)); + $config = new \phpbb\config\config(array( + 'num_topics' => 1, + 'num_posts' => 1, + 'allow_board_notifications' => true, + )); $cache = new \phpbb\cache\service( new \phpbb\cache\driver\dummy(), @@ -111,30 +115,46 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $notification_types_array = array(); foreach ($notification_types as $type) { - $class_name = '\phpbb\notification\type\\' . $type; - $class = new $class_name( - $user_loader, $db, $cache->get_driver(), $user, $auth, $config, - $phpbb_root_path, $phpEx, - NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); - - if ($type === 'quote') - { - $class->set_utils(new \phpbb\textformatter\s9e\utils); - } - - $phpbb_container->set('notification.type.' . $type, $class); - + $class = $this->build_type($type); + $phpbb_container->set('notification.type.' . $type, array(array($this, 'build_type'), array($type))); $notification_types_array['notification.type.' . $type] = $class; } + // Methods Types + $class_name = 'phpbb\notification\method\board'; + $class = new $class_name( + $user_loader, $db, $cache->get_driver(), $user, $auth, $config, + $phpbb_root_path, $phpEx, + NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE); + $phpbb_container->set('notification.method.board', $class); + $notification_methods_array = array('notification.method.board' => $class); + // Notification Manager - $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), + $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, $notification_methods_array, $phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user, $phpbb_root_path, $phpEx, - NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); + NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE); $phpbb_container->set('notification_manager', $phpbb_notifications); } + public function build_type($type) + { + global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path, $user_loader; + + $class_name = '\phpbb\notification\type\\' . $type; + $class = new $class_name( + $user_loader, $db, $cache->get_driver(), $user, $auth, $config, + $phpbb_root_path, $phpEx, + NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE); + + if ($type === 'quote') + { + $class->set_utils(new \phpbb\textformatter\s9e\utils); + } + + return $class; + } + /** * @dataProvider submit_post_data */ @@ -157,4 +177,11 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $this->assertEquals($expected_after, $this->db->sql_fetchrowset($result)); $this->db->sql_freeresult($result); } + + protected function build_method($method) + { + global $phpbb_root_path, $phpEx; + + return new $method($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); + } } diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index f7b4fcb215..d57fbf0485 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -61,7 +61,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $user_loader->load_users(array(2, 3, 4, 5, 6)); $this->notification = new phpbb_mock_notification_type_post( - $user_loader, null, null, $user, null, null, $phpbb_root_path, $phpEx, null, null, null + $user_loader, null, null, $user, null, null, $phpbb_root_path, $phpEx, null, null ); } -- cgit v1.2.1 From fc34057f288c6b8c656a0ed1ac2cb5a86f86206d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 9 Jul 2015 17:04:40 +0200 Subject: [ticket/11444] Update tests and cleanup types/methods PHPBB3-11444 --- tests/mock/container_builder.php | 5 ++ tests/notification/base.php | 54 ++++++++-------- .../fixtures/services_notification.yml | 70 +++++++++++++++++++++ tests/notification/manager_helper.php | 37 ----------- tests/notification/notification_test.php | 2 +- tests/notification/submit_post_base.php | 71 +++++++++------------- tests/notification/submit_post_type_quote_test.php | 3 +- tests/test_framework/phpbb_test_case_helpers.php | 34 +++++++---- 8 files changed, 157 insertions(+), 119 deletions(-) create mode 100644 tests/notification/fixtures/services_notification.yml (limited to 'tests') diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php index e04a83804d..134589b0b8 100644 --- a/tests/mock/container_builder.php +++ b/tests/mock/container_builder.php @@ -188,4 +188,9 @@ class phpbb_mock_container_builder implements ContainerInterface public function isScopeActive($name) { } + + public function isFrozen() + { + return false; + } } diff --git a/tests/notification/base.php b/tests/notification/base.php index c898c76947..1295f099f0 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -11,6 +11,10 @@ * */ +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + require_once dirname(__FILE__) . '/manager_helper.php'; abstract class phpbb_tests_notification_base extends phpbb_database_test_case @@ -70,8 +74,9 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $this->user = $user; $this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $auth = $this->auth = new phpbb_mock_notifications_auth(); + $cache_driver = new \phpbb\cache\driver\dummy(); $cache = $this->cache = new \phpbb\cache\service( - new \phpbb\cache\driver\dummy(), + $cache_driver, $this->config, $this->db, $phpbb_root_path, @@ -80,36 +85,48 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $phpbb_container = $this->container = new phpbb_mock_container_builder(); + $phpbb_container = $this->container = new ContainerBuilder(); + $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__ . '/fixtures')); + $loader->load('services_notification.yml'); + $phpbb_container->set('user_loader', $this->user_loader); + $phpbb_container->set('user', $user); + $phpbb_container->set('config', $this->config); + $phpbb_container->set('dbal.conn', $this->db); + $phpbb_container->set('auth', $auth); + $phpbb_container->set('cache.driver', $cache_driver); + $phpbb_container->set('cache', $cache); + $phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils()); + $phpbb_container->set('dispatcher', $this->phpbb_dispatcher); + $phpbb_container->setParameter('core.root_path', $phpbb_root_path); + $phpbb_container->setParameter('core.php_ext', $phpEx); + $phpbb_container->setParameter('tables.notifications', 'phpbb_notifications'); + $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); + $phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types'); $this->notifications = new phpbb_notification_manager_helper( array(), array(), $this->container, $this->user_loader, - $this->config, $this->phpbb_dispatcher, $this->db, $this->cache, $this->user, - $phpbb_root_path, - $phpEx, 'phpbb_notification_types', 'phpbb_user_notifications' ); $phpbb_container->set('notification_manager', $this->notifications); + $phpbb_container->compile(); $this->notifications->setDependencies($this->auth, $this->config); $types = array(); foreach ($this->get_notification_types() as $type) { - $type_parts = explode('.', $type); - $class = $this->build_type('phpbb\notification\type\\' . array_pop($type_parts)); + $class = $this->build_type($type); $types[$type] = $class; - $this->container->set($type, $class); } $this->notifications->set_var('notification_types', $types); @@ -117,11 +134,9 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $methods = array(); foreach ($this->get_notification_methods() as $method) { - $method_parts = explode('.', $method); - $class = $this->build_type('phpbb\notification\method\\' . array_pop($method_parts)); + $class = $this->container->get($method); $methods[$method] = $class; - $this->container->set($method, $class); } $this->notifications->set_var('notification_methods', $methods); @@ -133,26 +148,11 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case protected function build_type($type) { - global $phpbb_root_path, $phpEx; - - $instance = new $type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_user_notifications'); - - if ($type === 'phpbb\\notification\\type\\quote') - { - $instance->set_utils(new \phpbb\textformatter\s9e\utils); - } + $instance = $this->container->get($type); return $instance; } - protected function build_method($method) - { - global $phpbb_root_path, $phpEx; - - return new $method($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, - $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); - } - protected function assert_notifications($expected, $options = array()) { $notifications = $this->notifications->load_notifications('notification.method.board', array_merge(array( diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml new file mode 100644 index 0000000000..7eaa7e81ec --- /dev/null +++ b/tests/notification/fixtures/services_notification.yml @@ -0,0 +1,70 @@ +imports: + - { resource: ../../../phpBB/config/default/container/services_notification.yml } + +services: + notification_manager: + synthetic: true + + user_loader: + synthetic: true + + user: + synthetic: true + + config: + synthetic: true + + dbal.conn: + synthetic: true + + auth: + synthetic: true + + cache.driver: + synthetic: true + + path_helper: + synthetic: true + + groupposition.legend: + synthetic: true + + groupposition.teampage: + synthetic: true + + groupposition.teampage: + synthetic: true + + text_formatter.s9e.factory: + synthetic: true + + text_formatter.s9e.quote_helper: + synthetic: true + + text_formatter.parser: + synthetic: true + + text_formatter.s9e.parser: + synthetic: true + + text_formatter.renderer: + synthetic: true + + text_formatter.s9e.renderer: + synthetic: true + + text_formatter.utils: + synthetic: true + + text_formatter.s9e.utils: + synthetic: true + + text_formatter.data_access: + synthetic: true + + test: + class: phpbb\notification\type\test + scope: prototype + parent: notification.type.base + tags: + - { name: notification.type } diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 40cf9b3ad4..2e8699e1e0 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -37,41 +37,4 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager $this->auth = $auth; $this->config = $config; } - - /** - * Helper to get the notifications item type class and set it up - */ - public function get_item_type_class($item_type, $data = array()) - { - $item_parts = explode('.', $item_type); - $item_type = 'phpbb\notification\type\\' . array_pop($item_parts); - - $item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->user_notifications_table); - - if ($item_type === 'phpbb\\notification\\type\\quote') - { - $item->set_utils(new \phpbb\textformatter\s9e\utils); - } - - $item->set_notification_manager($this); - - $item->set_initial_data($data); - - return $item; - } - - /** - * Helper to get the notifications method class and set it up - */ - public function get_method_class($method_name) - { - $method_parts = explode('.', $method_name); - $method_name = 'phpbb\notification\method\\' . array_pop($method_parts); - - $method = new $method_name($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, NOTIFICATIONS_TABLE, $this->user_notifications_table); - - $method->set_notification_manager($this); - - return $method; - } } diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index 167cde13ca..ec42aa193c 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -81,9 +81,9 @@ class phpbb_notification_test extends phpbb_tests_notification_base ); $subscriptions = $this->notifications->get_global_subscriptions(2); - foreach ($expected_subscriptions as $item_type => $methods) { + self::assertArrayHasKey($item_type, $subscriptions); $this->assert_array_content_equals($methods, $subscriptions[$item_type]); } diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 73711369ed..72b25abf0a 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -11,6 +11,10 @@ * */ +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php'; @@ -75,8 +79,9 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c 'allow_board_notifications' => true, )); + $cache_driver = new \phpbb\cache\driver\dummy(); $cache = new \phpbb\cache\service( - new \phpbb\cache\driver\dummy(), + $cache_driver, $config, $db, $phpbb_root_path, @@ -103,58 +108,49 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $type_cast_helper = $this->getMock('\phpbb\request\type_cast_helper_interface'); $request = $this->getMock('\phpbb\request\request'); - // Container - $phpbb_container = new phpbb_mock_container_builder(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); - $user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE); + // Container + $phpbb_container = new ContainerBuilder(); + $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__ . '/fixtures')); + $loader->load('services_notification.yml'); + $phpbb_container->set('user_loader', $user_loader); + $phpbb_container->set('user', $user); + $phpbb_container->set('config', $config); + $phpbb_container->set('dbal.conn', $db); + $phpbb_container->set('auth', $auth); + $phpbb_container->set('cache.driver', $cache_driver); + $phpbb_container->set('cache', $cache); + $phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils()); + $phpbb_container->set('dispatcher', $phpbb_dispatcher); + $phpbb_container->setParameter('core.root_path', $phpbb_root_path); + $phpbb_container->setParameter('core.php_ext', $phpEx); + $phpbb_container->setParameter('tables.notifications', 'phpbb_notifications'); + $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); + $phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types'); + $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); + $phpbb_container->compile(); + // Notification Types $notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'topic_in_queue', 'approve_topic', 'approve_post'); $notification_types_array = array(); foreach ($notification_types as $type) { - $class = $this->build_type($type); - $phpbb_container->set('notification.type.' . $type, array(array($this, 'build_type'), array($type))); + $class = $phpbb_container->get('notification.type.' . $type); $notification_types_array['notification.type.' . $type] = $class; } // Methods Types - $class_name = 'phpbb\notification\method\board'; - $class = new $class_name( - $user_loader, $db, $cache->get_driver(), $user, $auth, $config, - $phpbb_root_path, $phpEx, - NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE); - $phpbb_container->set('notification.method.board', $class); - $notification_methods_array = array('notification.method.board' => $class); + $notification_methods_array = array('notification.method.board' => $phpbb_container->get('notification.method.board')); // Notification Manager $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, $notification_methods_array, - $phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user, - $phpbb_root_path, $phpEx, + $phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $user, NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE); $phpbb_container->set('notification_manager', $phpbb_notifications); } - public function build_type($type) - { - global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path, $user_loader; - - $class_name = '\phpbb\notification\type\\' . $type; - $class = new $class_name( - $user_loader, $db, $cache->get_driver(), $user, $auth, $config, - $phpbb_root_path, $phpEx, - NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE); - - if ($type === 'quote') - { - $class->set_utils(new \phpbb\textformatter\s9e\utils); - } - - return $class; - } - /** * @dataProvider submit_post_data */ @@ -177,11 +173,4 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $this->assertEquals($expected_after, $this->db->sql_fetchrowset($result)); $this->db->sql_freeresult($result); } - - protected function build_method($method) - { - global $phpbb_root_path, $phpEx; - - return new $method($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); - } } diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php index 8ad6a62b09..3fab8c05ba 100644 --- a/tests/notification/submit_post_type_quote_test.php +++ b/tests/notification/submit_post_type_quote_test.php @@ -51,7 +51,8 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ */ public function submit_post_data() { - $parser = $this->get_test_case_helpers()->set_s9e_services()->get('text_formatter.parser'); + // The new mock container is needed because the data providers may be executed before phpunit call setUp() + $parser = $this->get_test_case_helpers()->set_s9e_services(new phpbb_mock_container_builder())->get('text_formatter.parser'); return array( /** diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 62a56ed693..70bd309653 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -426,24 +426,34 @@ class phpbb_test_case_helpers $cache_key_parser = $prefix . '_parser'; $cache_key_renderer = $prefix . '_renderer'; $container->set('cache.driver', $cache); - $container->setParameter('cache.dir', $cache_dir); + + if (!$container->isFrozen()) + { + $container->setParameter('cache.dir', $cache_dir); + } // Create a path_helper - if (!$container->has('path_helper')) + if (!$container->has('path_helper') || $container->getDefinition('path_helper')->isSynthetic()) { + $path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem(), + $this->test_case->getMock('\phpbb\request\request'), + $phpbb_root_path, + $phpEx + ); + $container->set( 'path_helper', - new \phpbb\path_helper( - new \phpbb\symfony_request( - new phpbb_mock_request() - ), - new \phpbb\filesystem(), - $this->test_case->getMock('\phpbb\request\request'), - $phpbb_root_path, - $phpEx - ) + $path_helper ); } + else + { + $path_helper = $container->get('path_helper'); + } // Create an event dispatcher if ($container->has('dispatcher')) @@ -534,7 +544,7 @@ class phpbb_test_case_helpers // Calls configured in services.yml $renderer->configure_quote_helper($quote_helper); - $renderer->configure_smilies_path($config, $container->get('path_helper')); + $renderer->configure_smilies_path($config, $path_helper); $renderer->configure_user($user, $config, $auth); $container->set('text_formatter.renderer', $renderer); -- cgit v1.2.1 From 11bef3e22ed8cc2109ab7a5b4229f393d3648862 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 10 Jul 2015 00:15:58 +0200 Subject: [ticket/11444] Update tests PHPBB3-11444 --- tests/functional/notification_test.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index 5c6b87d50b..87c36dd4d1 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -11,6 +11,8 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + /** * @group functional */ -- cgit v1.2.1 From da7fc9e5daf6e72f9b86dbc5e002febb202f516e Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 10 Jun 2015 15:11:27 +0200 Subject: [ticket/13935] Allow more admin-configurable schemes in post links PHPBB3-13935 --- tests/functional/posting_test.php | 41 ++++++++++++++++++++++++ tests/test_framework/phpbb_test_case_helpers.php | 30 +++++++++++++---- tests/text_formatter/s9e/factory_test.php | 1 + 3 files changed, 66 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 724c42b289..fa9ff028da 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -205,4 +205,45 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler->filter('#preview .signature')->html() ); } + + public function test_allowed_schemes_links() + { + $text = 'http://example.org/ tcp://localhost:22/ServiceName'; + + $this->login(); + $this->admin_login(); + + // Post with default settings + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => $text, + )); + $crawler = self::submit($form); + $this->assertContains( + 'http://example.org/ tcp://localhost:22/ServiceName', + $crawler->filter('#preview .content')->html() + ); + + // Update allowed schemes + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + $values['config[allowed_schemes_links]'] = 'https,tcp'; + $form->setValues($values); + $crawler = self::submit($form); + $this->assertEquals(1, $crawler->filter('.successbox')->count()); + + // Post with new settings + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => $text, + )); + $crawler = self::submit($form); + $this->assertContains( + 'http://example.org/ tcp://localhost:22/ServiceName', + $crawler->filter('#preview .content')->html() + ); + } } diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 70bd309653..3eefcdc5e3 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -473,8 +473,30 @@ class phpbb_test_case_helpers $phpbb_dispatcher = $dispatcher; } + // Set up the a minimum config + if ($container->has('config')) + { + $config = $container->get('config'); + } + else + { + $config = new \phpbb\config\config(array()); + } + $default_config = array( + 'allow_nocensors' => false, + 'allowed_schemes_links' => 'http,https,ftp', + 'smilies_path' => 'images/smilies', + ); + foreach ($default_config as $config_name => $config_value) + { + if (!isset($config[$config_name])) + { + $config[$config_name] = $config_value; + } + } + // Create and register the text_formatter.s9e.factory service - $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $cache_dir, $cache_key_parser, $cache_key_renderer); + $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, $cache_dir, $cache_key_parser, $cache_key_renderer); $container->set('text_formatter.s9e.factory', $factory); // Create a user if none was provided, and add the common lang strings @@ -537,12 +559,8 @@ class phpbb_test_case_helpers $dispatcher ); - $config = ($container->has('config')) - ? $container->get('config') - : new \phpbb\config\config(array('smilies_path' => 'images/smilies', 'allow_nocensors' => false)); - $auth = ($container->has('auth')) ? $container->get('auth') : new \phpbb\auth\auth; - // Calls configured in services.yml + $auth = ($container->has('auth')) ? $container->get('auth') : new \phpbb\auth\auth; $renderer->configure_quote_helper($quote_helper); $renderer->configure_smilies_path($config, $path_helper); $renderer->configure_user($user, $config, $auth); diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 8382097544..c8bf595092 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -49,6 +49,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $dal, $this->cache, $this->dispatcher, + new \phpbb\config\config(array('allowed_schemes_links' => 'http,https,ftp')), $this->get_cache_dir(), '_foo_parser', '_foo_renderer' -- cgit v1.2.1 From 9129cd0e9e62007e23c9b57d3c157a68119b431f Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 13 Jul 2015 18:23:42 +0200 Subject: [ticket/13935] Removed UI PHPBB3-13935 --- tests/functional/posting_test.php | 41 --------------------------------------- 1 file changed, 41 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index fa9ff028da..724c42b289 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -205,45 +205,4 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler->filter('#preview .signature')->html() ); } - - public function test_allowed_schemes_links() - { - $text = 'http://example.org/ tcp://localhost:22/ServiceName'; - - $this->login(); - $this->admin_login(); - - // Post with default settings - $crawler = self::request('GET', 'posting.php?mode=post&f=2'); - $form = $crawler->selectButton('Preview')->form(array( - 'subject' => 'Test subject', - 'message' => $text, - )); - $crawler = self::submit($form); - $this->assertContains( - 'http://example.org/ tcp://localhost:22/ServiceName', - $crawler->filter('#preview .content')->html() - ); - - // Update allowed schemes - $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); - $form = $crawler->selectButton('Submit')->form(); - $values = $form->getValues(); - $values['config[allowed_schemes_links]'] = 'https,tcp'; - $form->setValues($values); - $crawler = self::submit($form); - $this->assertEquals(1, $crawler->filter('.successbox')->count()); - - // Post with new settings - $crawler = self::request('GET', 'posting.php?mode=post&f=2'); - $form = $crawler->selectButton('Preview')->form(array( - 'subject' => 'Test subject', - 'message' => $text, - )); - $crawler = self::submit($form); - $this->assertContains( - 'http://example.org/ tcp://localhost:22/ServiceName', - $crawler->filter('#preview .content')->html() - ); - } } -- cgit v1.2.1 From ca141f2e1ed7a83c21aaea0e7cc711017e7d140b Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 17 Jul 2015 18:28:27 +0200 Subject: [ticket/14036] Replace path_helper with a mock PHPBB3-14036 --- tests/test_framework/phpbb_test_case_helpers.php | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 70bd309653..3ad4d95039 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -435,20 +435,15 @@ class phpbb_test_case_helpers // Create a path_helper if (!$container->has('path_helper') || $container->getDefinition('path_helper')->isSynthetic()) { - $path_helper = new \phpbb\path_helper( - new \phpbb\symfony_request( - new phpbb_mock_request() - ), - new \phpbb\filesystem(), - $this->test_case->getMock('\phpbb\request\request'), - $phpbb_root_path, - $phpEx - ); - - $container->set( - 'path_helper', - $path_helper - ); + $path_helper = $this->test_case->getMockBuilder('phpbb\\path_helper') + ->disableOriginalConstructor() + ->setMethods(array('get_web_root_path')) + ->getMock(); + $path_helper->expects($this->test_case->any()) + ->method('get_web_root_path') + ->will($this->test_case->returnValue('./')); + + $container->set('path_helper', $path_helper); } else { -- cgit v1.2.1 From 6cc2510cee581370ed103a87f2c38d2aee282641 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 17 Jul 2015 19:10:36 +0200 Subject: [ticket/14036] Fixed mocked web root path ...to match what it would return normally PHPBB3-14036 --- tests/test_framework/phpbb_test_case_helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 3ad4d95039..c0f278c130 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -441,7 +441,7 @@ class phpbb_test_case_helpers ->getMock(); $path_helper->expects($this->test_case->any()) ->method('get_web_root_path') - ->will($this->test_case->returnValue('./')); + ->will($this->test_case->returnValue('phpBB/')); $container->set('path_helper', $path_helper); } -- cgit v1.2.1 From 172b021c898846b06924dc258804271715e9a4ba Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 27 Jul 2015 16:04:34 +0200 Subject: [ticket/14053] Fix tests for installer config @covers annotations causing build failures on bamboo, so removed them PHPBB3-14053 --- tests/installer/installer_config_test.php | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'tests') diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php index 4b83eb9a8f..c7334ebd93 100644 --- a/tests/installer/installer_config_test.php +++ b/tests/installer/installer_config_test.php @@ -34,10 +34,6 @@ class phpbb_installer_config_test extends phpbb_test_case $this->config = new config($filesystem, $php_ini, $phpbb_root_path); } - /** - * @covers config::set - * @covers config::get - */ public function test_set_get_var() { $this->config->set('foo', 'bar'); @@ -54,13 +50,6 @@ class phpbb_installer_config_test extends phpbb_test_case $this->assertGreaterThan(0, $this->config->get_memory_remaining()); } - /** - * @covers config::set_finished_task - * @covers config::set_active_module - * @covers config::set_task_progress_count - * @covers config::increment_current_task_progress - * @covers config::get_progress_data - */ public function test_progress_tracking() { $this->config->set_finished_task('foo'); -- cgit v1.2.1 From ca17bc7187c8836be7650209886b1024d01b268c Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 29 May 2015 11:31:47 +0200 Subject: [ticket/12143] Add some tests PHPBB3-12143 --- tests/group/helper_test.php | 68 ++++++++++++++++++++++++++++++++++++++++ tests/language/language_test.php | 14 +++++++++ 2 files changed, 82 insertions(+) create mode 100644 tests/group/helper_test.php (limited to 'tests') diff --git a/tests/group/helper_test.php b/tests/group/helper_test.php new file mode 100644 index 0000000000..a325ac7ac9 --- /dev/null +++ b/tests/group/helper_test.php @@ -0,0 +1,68 @@ + + * @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_group_helper_test extends phpbb_test_case +{ + /** @var \phpbb\group\helper */ + protected $group_helper; + + public function setUp() + { + global $phpbb_root_path, $phpEx; + + // Set up language service + $lang = new \phpbb\language\language( + new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx) + ); + + // Set up language data for testing + $reflection_class = new ReflectionClass('\phpbb\language\language'); + + // Set default language files loaded flag to true + $loaded_flag = $reflection_class->getProperty('common_language_files_loaded'); + $loaded_flag->setAccessible(true); + $loaded_flag->setValue($lang, true); + + // Set up test language data + $lang_array = $reflection_class->getProperty('lang'); + $lang_array->setAccessible(true); + $lang_array->setValue($lang, $this->get_test_language_data_set()); + + // Set up group helper + $this->group_helper = new \phpbb\group\helper($lang); + } + + public function test_get_name() + { + // They should be totally fine + $this->assertEquals('Bots', 'Bots'); + $this->assertEquals('Some new group', 'new_group'); + $this->assertEquals('Should work', 'group_with_ümlauts'); + + // This should fail (obviously) + $this->assertNotEquals('They key does not contain uppercase letters', 'not_uppercase'); + + // The key doesn't exist so just return group name... + $this->assertEquals('Awesome group', 'Awesome group'); + } + + protected function get_test_language_data_set() + { + return array( + 'G_BOTS' => 'Bots', + 'G_NEW_GROUP' => 'Some new group', + 'G_not_uppercase' => 'The key does not contain uppercase letters', + 'G_GROUP_WITH_ÜMLAUTS' => 'Should work', + ); + } +} diff --git a/tests/language/language_test.php b/tests/language/language_test.php index 95de403bd4..6a814e39dc 100644 --- a/tests/language/language_test.php +++ b/tests/language/language_test.php @@ -39,6 +39,20 @@ class phpbb_language_test extends phpbb_test_case $lang_array->setValue($this->lang, $this->get_test_data_set()); } + public function test_is_set() + { + // Check for non-existing key + $this->assertFalse($this->lang->is_set('VALUE')); + $this->assertFalse($this->lang->is_set(array('dateformat', 'MAYBE'))); + + // Check for existing key + $this->assertTrue($this->lang->is_set('FOO')); + $this->assertTrue($this->lang->is_set(array('dateformat', 'AGO'))); + + // Array doesn't exist at all... + $this->assertFalse($this->lang->is_set(array('PHPBB', 'PHP'))); + } + public function test_lang() { // No param -- cgit v1.2.1 From 981bd8bed4f126ec01e02d9e1737c4d42994461c Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 29 May 2015 14:40:23 +0200 Subject: [ticket/12143] Fix those tests I always have to fix them.. :( PHPBB3-12143 --- tests/group/helper_test.php | 10 +++++----- tests/notification/group_request_test.php | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/group/helper_test.php b/tests/group/helper_test.php index a325ac7ac9..2377a6f47c 100644 --- a/tests/group/helper_test.php +++ b/tests/group/helper_test.php @@ -45,15 +45,15 @@ class phpbb_group_helper_test extends phpbb_test_case public function test_get_name() { // They should be totally fine - $this->assertEquals('Bots', 'Bots'); - $this->assertEquals('Some new group', 'new_group'); - $this->assertEquals('Should work', 'group_with_ümlauts'); + $this->assertEquals('Bots', $this->group_helper->get_name('Bots')); + $this->assertEquals('Some new group', $this->group_helper->get_name('new_group')); + $this->assertEquals('Should work', $this->group_helper->get_name('group_with_ümlauts')); // This should fail (obviously) - $this->assertNotEquals('They key does not contain uppercase letters', 'not_uppercase'); + $this->assertNotEquals('They key does not contain uppercase letters', $this->group_helper->get_name('not_uppercase')); // The key doesn't exist so just return group name... - $this->assertEquals('Awesome group', 'Awesome group'); + $this->assertEquals('Awesome group', $this->group_helper->get_name('Awesome group')); } protected function get_test_language_data_set() diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index a24808fbbd..d16e198861 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -49,6 +49,11 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas $this->user, $this->cache->get_driver() )); + $this->container->set('group_helper', new \phpbb\group\helper( + new \phpbb\language\language( + new phpbb\language\language_file_loader($phpbb_root_path, $phpEx) + ) + )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher; $phpbb_log = new \phpbb\log\dummy(); $this->get_test_case_helpers()->set_s9e_services(); -- cgit v1.2.1 From 25103698040977fd0d655d6e658157a07bb24990 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 19 Jul 2015 22:53:28 +0200 Subject: [ticket/12143] Fix tests after rebase PHPBB3-12143 --- tests/notification/fixtures/services_notification.yml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml index 7eaa7e81ec..e0a404b12b 100644 --- a/tests/notification/fixtures/services_notification.yml +++ b/tests/notification/fixtures/services_notification.yml @@ -23,6 +23,9 @@ services: cache.driver: synthetic: true + group_helper: + synthetic: true + path_helper: synthetic: true -- cgit v1.2.1 From 618065ec16030f1d142667473ee2ff42cd80e72b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 8 Jul 2015 16:58:45 +0200 Subject: [ticket/12692] Fix tests and update style PHPBB3-12692 --- tests/console/thumbnail_test.php | 59 ++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php index 094d8ca051..b5ed02b5e7 100644 --- a/tests/console/thumbnail_test.php +++ b/tests/console/thumbnail_test.php @@ -11,6 +11,7 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; use Symfony\Component\Console\Application; @@ -36,7 +37,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case public function setUp() { - global $config, $phpbb_root_path, $phpEx; + global $config, $phpbb_root_path, $phpEx, $phpbb_filesystem; parent::setUp(); @@ -47,12 +48,15 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case )); $this->db = $this->db = $this->new_dbal(); - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime') + ); $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; $this->cache = $this->getMock('\phpbb\cache\service', array(), array(new phpbb_mock_cache(), $this->config, $this->db, $this->phpbb_root_path, $this->phpEx)); - $this->cache->expects($this->any())->method('obtain_attach_extensions')->will($this->returnValue(array( + $this->cache->expects(self::any())->method('obtain_attach_extensions')->will(self::returnValue(array( 'png' => array('display_cat' => ATTACHMENT_CATEGORY_IMAGE), 'txt' => array('display_cat' => ATTACHMENT_CATEGORY_NONE), ))); @@ -61,44 +65,51 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case $this->application->add(new generate($this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx)); $this->application->add(new delete($this->user, $this->db, $this->phpbb_root_path)); $this->application->add(new recreate($this->user)); - } - public function test_thumbnails() - { + $phpbb_filesystem = new \phpbb\filesystem\filesystem(); + copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_1'); copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_2'); copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/thumb_test_png_2'); copy(dirname(__FILE__) . '/fixtures/txt.txt', $this->phpbb_root_path . 'files/test_txt'); + } + + protected function tearDown() + { + parent::tearDown(); + + unlink($this->phpbb_root_path . 'files/test_png_1'); + unlink($this->phpbb_root_path . 'files/test_png_2'); + unlink($this->phpbb_root_path . 'files/test_txt'); + unlink($this->phpbb_root_path . 'files/thumb_test_png_1'); + unlink($this->phpbb_root_path . 'files/thumb_test_png_2'); + } + public function test_thumbnails() + { $command_tester = $this->get_command_tester('thumbnail:generate'); $exit_status = $command_tester->execute(array('command' => 'thumbnail:generate')); - $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1')); - $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2')); - $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt')); - $this->assertSame(0, $exit_status); + self::assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1')); + self::assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2')); + self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt')); + self::assertSame(0, $exit_status); $command_tester = $this->get_command_tester('thumbnail:delete'); $exit_status = $command_tester->execute(array('command' => 'thumbnail:delete')); - $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1')); - $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2')); - $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt')); - $this->assertSame(0, $exit_status); + self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1')); + self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2')); + self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt')); + self::assertSame(0, $exit_status); $command_tester = $this->get_command_tester('thumbnail:recreate'); $exit_status = $command_tester->execute(array('command' => 'thumbnail:recreate')); - $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1')); - $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2')); - $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt')); - $this->assertSame(0, $exit_status); - - unlink($this->phpbb_root_path . 'files/test_png_1'); - unlink($this->phpbb_root_path . 'files/test_png_2'); - unlink($this->phpbb_root_path . 'files/test_txt'); - unlink($this->phpbb_root_path . 'files/thumb_test_png_1'); - unlink($this->phpbb_root_path . 'files/thumb_test_png_2'); + self::assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1')); + self::assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2')); + self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt')); + self::assertSame(0, $exit_status); } public function get_command_tester($command_name) -- cgit v1.2.1 From df334b1da8049c57c09eb052313c0e4d869f6cce Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 12 Aug 2015 17:13:51 +0700 Subject: [ticket/14094] Fix segmentation fault error on PHP 7 tests PHPBB3-14094 --- tests/datetime/from_format_test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php index 7ecb546768..32b88ff588 100644 --- a/tests/datetime/from_format_test.php +++ b/tests/datetime/from_format_test.php @@ -113,6 +113,10 @@ class phpbb_datetime_from_format_test extends phpbb_test_case { global $phpbb_root_path, $phpEx; + // This magically fixes the segmentation fault error on PHP7 tests + // while date_default_timezone_set('UTC') does not + date_default_timezone_set('Europe/Paris'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); -- cgit v1.2.1 From 8e5e954438b232f4ce7aec6a5db3d52b974c07a8 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Sun, 22 Feb 2015 23:36:27 +0100 Subject: [ticket/13645] Move the feeds to controllers PHPBB3-13645 --- tests/controller/common_helper_route.php | 25 ++-- tests/functional/browse_test.php | 2 +- .../functional/controllers_compatibility_test.php | 13 ++ tests/functional/feed_test.php | 133 +++++++++++---------- tests/mock/controller_helper.php | 13 -- tests/pagination/pagination_test.php | 3 +- 6 files changed, 104 insertions(+), 85 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 3c74c16bae..4c0c8569a3 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -125,6 +125,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->router = new phpbb_mock_router($container, $this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); + // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); } @@ -168,7 +169,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); } @@ -211,7 +213,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); } @@ -254,7 +257,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); } @@ -297,7 +301,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); } @@ -340,7 +345,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); } @@ -383,7 +389,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); } @@ -423,7 +430,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); } @@ -466,7 +474,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); } } diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index 4f28879687..280e814c06 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -48,7 +48,7 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case public function test_feed() { - $crawler = self::request('GET', 'feed.php', array(), false); + $crawler = self::request('GET', 'app.php/feed', array(), false); self::assert_response_xml(); $this->assertGreaterThan(0, $crawler->filter('entry')->count()); } diff --git a/tests/functional/controllers_compatibility_test.php b/tests/functional/controllers_compatibility_test.php index 7ba0b0d991..9499888a1a 100644 --- a/tests/functional/controllers_compatibility_test.php +++ b/tests/functional/controllers_compatibility_test.php @@ -24,6 +24,19 @@ class phpbb_functional_controllers_compatibility_test extends phpbb_functional_t $this->assert301('report.php?pm=1', 'app.php/pm/1/report'); } + public function test_feed_compatibility() + { + $this->assert301('feed.php', 'app.php/feed'); + $this->assert301('feed.php?mode=foobar', 'app.php/feed/foobar'); + $this->assert301('feed.php?mode=news', 'app.php/feed/news'); + $this->assert301('feed.php?mode=topics', 'app.php/feed/topics'); + $this->assert301('feed.php?mode=topics_news', 'app.php/feed/topics_news'); + $this->assert301('feed.php?mode=topics_active', 'app.php/feed/topics_active'); + $this->assert301('feed.php?mode=forums', 'app.php/feed/forums'); + $this->assert301('feed.php?f=1', 'app.php/feed/forum/1'); + $this->assert301('feed.php?t=1', 'app.php/feed/topic/1'); + } + protected function assert301($from, $to) { self::$client->followRedirects(false); diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 9041c8dc69..fc3f052e91 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -11,6 +11,8 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + /** * @group functional */ @@ -24,9 +26,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { parent::__construct($name, $data, $dataName); - $this->backupStaticAttributesBlacklist += array( - 'phpbb_functional_feed_test' => array('init_values'), - ); + $this->backupStaticAttributesBlacklist['phpbb_functional_feed_test'] = array('init_values'); + + $this->purge_cache(); } public function test_setup_config_before_state() @@ -55,66 +57,64 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form->setValues($values); $crawler = self::submit($form); - $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text()); + self::assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text()); // Special config (Guest can't see attachments) $this->add_lang('acp/permissions'); $crawler = self::request('GET', "adm/index.php?i=acp_permissions&sid={$this->sid}&icat=16&mode=setting_group_global&group_id[0]=1"); - $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); + self::assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); $form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form(); $form['setting[1][0][u_download]']->select(-1); $crawler = self::submit($form); - $this->assertContainsLang('AUTH_UPDATED', $crawler->filter('.successbox')->text()); + self::assertContainsLang('AUTH_UPDATED', $crawler->filter('.successbox')->text()); } public function test_dump_board_state() { - $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); + $crawler = self::request('GET', 'app.php/feed/forums', array(), false); self::assert_response_xml(); self::$init_values['disapprove_user']['forums_value'] = $crawler->filterXPath('//entry')->count(); - $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); + $crawler = self::request('GET', 'app.php/feed/overall', array(), false); self::assert_response_xml(); self::$init_values['disapprove_user']['overall_value'] = $crawler->filterXPath('//entry')->count(); - $crawler = self::request('GET', 'feed.php?mode=topics', array(), false); + $crawler = self::request('GET', 'app.php/feed/topics', array(), false); self::assert_response_xml(); self::$init_values['disapprove_user']['topics_value'] = $crawler->filterXPath('//entry')->count(); - $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false); + $crawler = self::request('GET', 'app.php/feed/topics_new', array(), false); self::assert_response_xml(); self::$init_values['disapprove_user']['topics_new_value'] = $crawler->filterXPath('//entry')->count(); - $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false); + $crawler = self::request('GET', 'app.php/feed/topics_active', array(), false); self::assert_response_xml(); self::$init_values['disapprove_user']['topics_active_value'] = $crawler->filterXPath('//entry')->count(); $this->login(); - $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); + $crawler = self::request('GET', 'app.php/feed/forums', array(), false); self::assert_response_xml(); self::$init_values['admin']['forums_value'] = $crawler->filterXPath('//entry')->count(); - $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); + $crawler = self::request('GET', 'app.php/feed/overall', array(), false); self::assert_response_xml(); self::$init_values['admin']['overall_value'] = $crawler->filterXPath('//entry')->count(); - $crawler = self::request('GET', 'feed.php?mode=topics', array(), false); + $crawler = self::request('GET', 'app.php/feed/topics', array(), false); self::assert_response_xml(); self::$init_values['admin']['topics_value'] = $crawler->filterXPath('//entry')->count(); - $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false); + $crawler = self::request('GET', 'app.php/feed/topics_new', array(), false); self::assert_response_xml(); self::$init_values['admin']['topics_new_value'] = $crawler->filterXPath('//entry')->count(); - $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false); + $crawler = self::request('GET', 'app.php/feed/topics_active', array(), false); self::assert_response_xml(); self::$init_values['admin']['topics_active_value'] = $crawler->filterXPath('//entry')->count(); - - } public function test_setup_forums() @@ -132,7 +132,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form = $crawler->selectButton('update')->form(array( 'forum_perm_from' => 2, )); - $crawler = self::submit($form); + self::submit($form); $this->load_ids(array( 'forums' => array( @@ -149,7 +149,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form = $crawler->selectButton('update')->form(array( 'forum_perm_from' => 2, )); - $crawler = self::submit($form); + self::submit($form); // 'Feeds #news' will be used for feed.php?mode=news $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); @@ -160,9 +160,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form = $crawler->selectButton('update')->form(array( 'forum_perm_from' => 2, )); - $crawler = self::submit($form); + self::submit($form); - // 'Feeds #exclude' will not be displayed on feed.php?mode=forums + // 'Feeds #exclude' will not be displayed on app.php/feed/forums $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); $form = $crawler->selectButton('addforum')->form(array( 'forum_name' => 'Feeds #exclude', @@ -171,7 +171,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form = $crawler->selectButton('update')->form(array( 'forum_perm_from' => 2, )); - $crawler = self::submit($form); + self::submit($form); } public function test_setup_config_after_forums() @@ -195,7 +195,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form['feed_exclude_id']->select(array($this->data['forums']['Feeds #exclude'])); $crawler = self::submit($form); - $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text()); + self::assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text()); } public function test_feeds_empty() @@ -266,6 +266,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case 'id' => $this->data['forums']['Feeds #exclude'], 'contents_lang' => array('NO_FEED'), 'invalid' => true, + 'response_code' => 404, ), ), 't' => array( @@ -273,6 +274,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case 'id' => $this->data['topics']['Feeds #exclude - Topic #1'], 'contents_lang' => array('NO_FEED'), 'invalid' => true, + 'response_code' => 404, ), ), 'overall' => array( @@ -325,7 +327,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #2', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text()); + self::assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text()); $this->data['topics']['Feeds #news - Topic #2'] = (int) $post['topic_id']; $this->data['posts']['Feeds #news - Topic #2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -333,7 +335,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post2 = $this->create_post($this->data['forums']['Feeds #news'], $post['topic_id'], 'Re: Feeds #news - Topic #2', 'This is a test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); - $this->assertContains('Re: Feeds #news - Topic #2', $crawler->filter('html')->text()); + self::assertContains('Re: Feeds #news - Topic #2', $crawler->filter('html')->text()); $this->data['posts']['Re: Feeds #news - Topic #2'] = (int) $post2['post_id']; } @@ -489,7 +491,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); - $this->assertContains('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text()); + self::assertContains('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text()); $this->data['posts']['Re: Feeds #1 - Topic #2'] = (int) $post2['post_id']; } @@ -510,14 +512,14 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->add_lang('posting'); $crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Feeds #1']}&p={$this->data['posts']['Re: Feeds #1 - Topic #2']}&sid={$this->sid}"); - $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + self::assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); $form = $crawler->selectButton('Yes')->form(); $crawler = self::submit($form); - $this->assertContainsLang('POST_DELETED', $crawler->text()); + self::assertContainsLang('POST_DELETED', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}"); - $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); + self::assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); } public function test_feeds_softdeleted_post_admin() @@ -609,15 +611,15 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->add_lang('posting'); $crawler = $this->get_quickmod_page($this->data['topics']['Feeds #1 - Topic #2'], 'DELETE_TOPIC'); - $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + self::assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); $this->add_lang('mcp'); $form = $crawler->selectButton('Yes')->form(); $crawler = self::submit($form); - $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); + self::assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}"); - $this->assertContains('Feeds #1 - Topic #2', $crawler->filter('h2')->text()); + self::assertContains('Feeds #1 - Topic #2', $crawler->filter('h2')->text()); } public function test_feeds_softdeleted_topic_admin() @@ -710,8 +712,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case 't' => array( array( 'id' => $this->data['topics']['Feeds #1 - Topic #2'], - 'contents_lang' => array('SORRY_AUTH_READ'), + 'contents_lang' => array('SORRY_AUTH_READ_TOPIC'), 'invalid' => true, + 'response_code' => 403, ), ), 'overall' => array( @@ -752,10 +755,10 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case // Test creating a reply $this->login('disapprove_user'); - $post2 = $this->create_post($this->data['forums']['Feeds #1.1'], $post['topic_id'], 'Re: Feeds #1.1 - Topic #2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD'); + $this->create_post($this->data['forums']['Feeds #1.1'], $post['topic_id'], 'Re: Feeds #1.1 - Topic #2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1.1 - Topic #2']}&sid={$this->sid}"); - $this->assertNotContains('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text()); + self::assertNotContains('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text()); } public function test_feeds_unapproved_post_admin() @@ -847,7 +850,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id']; $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}"); - $this->assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); + self::assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); $this->logout(); $this->set_flood_interval(15); @@ -863,10 +866,10 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form = $crawler->selectButton('Submit')->form(); $values = $form->getValues(); - $values["config[flood_interval]"] = $flood_interval; + $values['config[flood_interval]'] = $flood_interval; $form->setValues($values); $crawler = self::submit($form); - $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + self::assertGreaterThan(0, $crawler->filter('.successbox')->count()); $this->logout(); } @@ -958,8 +961,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case 't' => array( array( 'id' => $this->data['topics']['Feeds #1.1 - Topic #3'], - 'contents_lang' => array('SORRY_AUTH_READ'), + 'contents_lang' => array('SORRY_AUTH_READ_TOPIC'), 'invalid' => true, + 'response_code' => 403, ), ), 'overall' => array( @@ -998,7 +1002,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #3', 'This is a test topic posted by the testing framework. [attachment=0]Attachment #0[/attachment]', array('upload_files' => 1)); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('Feeds #1 - Topic #3', $crawler->filter('html')->text()); + self::assertContains('Feeds #1 - Topic #3', $crawler->filter('html')->text()); $this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id']; } @@ -1216,7 +1220,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post2 = $this->create_post($this->data['forums']['Feeds #1'], $this->data['topics']['Feeds #1 - Topic #3'], 'Re: Feeds #1 - Topic #3-1', 'This is a test post posted by the testing framework. [attachment=0]Attachment #0[/attachment]'); $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); - $this->assertContains('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text()); + self::assertContains('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text()); $this->data['posts']['Re: Feeds #1 - Topic #3-1'] = (int) $post2['post_id']; } @@ -1316,9 +1320,14 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { foreach ($feeds as $feed_data) { - if ($mode === 'f' || $mode === 't') + if ($mode === 'f') + { + $params = "/forum/{$feed_data['id']}"; + $this->assert_feed($params, $feed_data); + } + else if ($mode === 't') { - $params = "?{$mode}={$feed_data['id']}"; + $params = "/topic/{$feed_data['id']}"; $this->assert_feed($params, $feed_data); } else @@ -1342,10 +1351,10 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case case 'news': break; default: - $this->fail('Unsupported feed mode: ' . $mode); + self::fail('Unsupported feed mode: ' . $mode); } - $params = "?mode={$mode}"; + $params = "/{$mode}"; $this->assert_feed($params, $feed_data); } } @@ -1354,19 +1363,19 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case protected function assert_feed($params, $data) { - $crawler = self::request('GET', 'feed.php' . $params, array(), false); + $crawler = self::request('GET', 'app.php/feed' . $params, array(), false); if (empty($data['invalid'])) { self::assert_response_xml(); - $this->assertEquals($data['nb_entries'], $crawler->filter('entry')->count(), "Tested feed : 'feed.php{$params}'"); + self::assertEquals($data['nb_entries'], $crawler->filter('entry')->count(), "Tested feed : 'app.php/feed{$params}'"); if (!empty($data['xpath'])) { foreach($data['xpath'] as $xpath => $count_expected) { - $this->assertCount($count_expected, $crawler->filterXPath($xpath), "Tested feed : 'feed.php{$params}', Search for {$xpath}"); + self::assertCount($count_expected, $crawler->filterXPath($xpath), "Tested feed : 'app.php/feed{$params}', Search for {$xpath}"); } } @@ -1375,7 +1384,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case foreach($data['contents'] as $entry_id => $string) { $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); - $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'"); + self::assertContains($string, $content, "Tested feed : 'app.php/feed{$params}'"); } } @@ -1384,7 +1393,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case foreach($data['contents_lang'] as $entry_id => $string) { $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); - $this->assertContainsLang($string, $content, "Tested feed : 'feed.php{$params}'"); + self::assertContainsLang($string, $content, "Tested feed : 'app.php/feed{$params}'"); } } @@ -1392,21 +1401,21 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { foreach($data['attachments'] as $entry_id => $attachments) { + $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); foreach ($attachments as $i => $attachment) { - $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); $url = "./download/file.php?id={$attachment['id']}"; $string = "Attachment #{$i}"; if ($attachment['displayed']) { - $this->assertContains($url, $content, "Tested feed : 'feed.php{$params}'"); - $this->assertNotContains($string, $content, "Tested feed : 'feed.php{$params}'"); + self::assertContains($url, $content, "Tested feed : 'app.php/feed{$params}'"); + self::assertNotContains($string, $content, "Tested feed : 'app.php/feed{$params}'"); } else { - $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'"); - $this->assertNotContains($url, $content, "Tested feed : 'feed.php{$params}'"); + self::assertContains($string, $content, "Tested feed : 'app.php/feed{$params}'"); + self::assertNotContains($url, $content, "Tested feed : 'app.php/feed{$params}'"); } } } @@ -1414,14 +1423,14 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case } else { - self::assert_response_html(); + self::assert_response_html($data['response_code'] ?: 202); if (!empty($data['contents_lang'])) { + $content = $crawler->filter('html')->text(); foreach($data['contents_lang'] as $string) { - $content = $crawler->filter('html')->text(); - $this->assertContainsLang($string, $content, "Tested feed : 'feed.php{$params}'"); + self::assertContainsLang($string, $content, "Tested feed : 'app.php/feed{$params}'"); } } } @@ -1439,7 +1448,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - if (in_array($row['forum_name'], $data['forums'])) + if (in_array($row['forum_name'], $data['forums'], false)) { $this->data['forums'][$row['forum_name']] = (int) $row['forum_id']; } @@ -1455,7 +1464,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - if (in_array($row['topic_title'], $data['topics'])) + if (in_array($row['topic_title'], $data['topics'], false)) { $this->data['topics'][$row['topic_title']] = (int) $row['topic_id']; } @@ -1472,7 +1481,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - if (in_array($row['post_subject'], $data['posts'])) + if (in_array($row['post_subject'], $data['posts'], false)) { $this->data['posts'][$row['post_subject']] = (int) $row['post_id']; $post_ids[] = (int) $row['post_id']; diff --git a/tests/mock/controller_helper.php b/tests/mock/controller_helper.php index 1d9f5dc5bf..0116dced49 100644 --- a/tests/mock/controller_helper.php +++ b/tests/mock/controller_helper.php @@ -13,19 +13,6 @@ class phpbb_mock_controller_helper extends \phpbb\controller\helper { - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext) - { - $this->template = $template; - $this->user = $user; - $this->config = $config; - $this->symfony_request = $symfony_request; - $this->request = $request; - $this->filesystem = $filesystem; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->router = $router; - } - public function get_current_url() { return ''; diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 07f9ec9c56..0607098d93 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -54,7 +54,8 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $request ); - $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $router, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $router, $symfony_request, $request, $filesystem, '', 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $symfony_request, $request, $this->routing_helper); $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher); } -- cgit v1.2.1 From 2e81771c6e18009a16b11b515e869a6a9afb0d2e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 26 Aug 2015 12:49:18 +0200 Subject: [ticket/14124] Update cron tests PHPBB3-14124 --- tests/console/cron/run_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index 51ea49b282..d6c7b21781 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -78,6 +78,10 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $this->assertSame(false, $this->lock->owns_lock()); } + /** + * @expectedException \phpbb\exception\runtime_exception + * @expectedExceptionMessage CRON_LOCK_ERROR + */ public function test_error_lock() { $this->lock->acquire(); @@ -126,6 +130,10 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $this->assertSame(false, $this->lock->owns_lock()); } + /** + * @expectedException \phpbb\exception\runtime_exception + * @expectedExceptionMessage CRON_NO_SUCH_TASK + */ public function test_arg_invalid() { $command_tester = $this->get_command_tester(); -- cgit v1.2.1 From e19d446881ba98d8a1082732585da3f6d4bd262f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 26 Aug 2015 10:05:14 -0700 Subject: [ticket/14128] Fix img bbcode regression, lost postimage class PHPBB3-14128 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html | 2 +- tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html | 2 +- tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html | 2 +- tests/text_formatter/s9e/renderer_test.php | 4 ++-- tests/text_processing/generate_text_for_display_test.php | 2 +- tests/text_processing/tickets_data/PHPBB3-12195.html | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 390bc65264..3047653d51 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -132,7 +132,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( '[img]https://area51.phpbb.com/images/area51.png[/img]', - 'Image' + 'Image' ), array( '[url]https://area51.phpbb.com/[/url]', diff --git a/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html index a17446581a..76a35542be 100644 --- a/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html +++ b/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html @@ -31,7 +31,7 @@ {TEXT} -{L_IMAGE} +{L_IMAGE} {DESCRIPTION} diff --git a/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html index cd2f0acae3..fad8d828fd 100644 --- a/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html +++ b/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html @@ -31,7 +31,7 @@ {TEXT} -{L_IMAGE} +{L_IMAGE} {DESCRIPTION} diff --git a/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html index 909c09df5a..3e38d13a32 100644 --- a/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html +++ b/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html @@ -31,7 +31,7 @@ {TEXT} -{L_IMAGE} +{L_IMAGE} {DESCRIPTION} diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 3c0bbb96c7..ad5bfa78fc 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -112,7 +112,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ), array( '[img]http://example.org/foo.png[/img]', - 'Image', + 'Image', array('set_viewimg' => true) ), array( @@ -231,7 +231,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ), array( '[img]http://localhost/mrgreen.gif[/img]', - 'Image' + 'Image' ), array( '[img]http://localhost/mrgreen.gif[/img]', diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index f2b0d6c78b..dba3713447 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -173,7 +173,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca ), array( '[img]http://localhost/mrgreen.gif[/img]', - 'Image' + 'Image' ), array( '[img]http://localhost/mrgreen.gif[/img]', diff --git a/tests/text_processing/tickets_data/PHPBB3-12195.html b/tests/text_processing/tickets_data/PHPBB3-12195.html index d8e0f8d523..c286c0fee9 100644 --- a/tests/text_processing/tickets_data/PHPBB3-12195.html +++ b/tests/text_processing/tickets_data/PHPBB3-12195.html @@ -1 +1 @@ -Image \ No newline at end of file +Image \ No newline at end of file -- cgit v1.2.1 From 1fbdf615f2aa9c9be4816a9d927d36f88b68f20d Mon Sep 17 00:00:00 2001 From: Zoddo Date: Sun, 30 Aug 2015 19:53:11 +0200 Subject: [ticket/9485] Fix tests PHPBB3-9485 --- tests/log/fixtures/delete_log.xml | 16 ++++++++++++++++ tests/log/fixtures/empty_log.xml | 1 + tests/log/fixtures/full_log.xml | 12 ++++++++++++ tests/log/function_view_log_test.php | 16 ++++++++++++++++ 4 files changed, 45 insertions(+) (limited to 'tests') diff --git a/tests/log/fixtures/delete_log.xml b/tests/log/fixtures/delete_log.xml index 4b2402102e..393c686f0c 100644 --- a/tests/log/fixtures/delete_log.xml +++ b/tests/log/fixtures/delete_log.xml @@ -6,6 +6,7 @@ user_id forum_id topic_id + post_id reportee_id log_ip log_time @@ -18,6 +19,7 @@ 0 0 0 + 0 127.0.0.1 1 LOG_INSTALL_INSTALLED @@ -30,6 +32,7 @@ 0 0 0 + 0 127.0.0.1 1 LOG_KEY_NOT_EXISTS @@ -42,6 +45,7 @@ 0 0 0 + 0 127.0.0.1 1 LOG_CRITICAL @@ -54,6 +58,7 @@ 12 34 0 + 0 127.0.0.1 1 LOG_MOD @@ -66,6 +71,7 @@ 12 45 0 + 0 127.0.0.1 1 LOG_MOD @@ -78,6 +84,7 @@ 23 56 0 + 0 127.0.0.1 1 LOG_MOD @@ -90,6 +97,7 @@ 12 45 0 + 0 127.0.0.1 1 LOG_MOD2 @@ -101,6 +109,7 @@ 1 0 0 + 0 2 127.0.0.1 1 @@ -113,6 +122,7 @@ 1 0 0 + 0 1 127.0.0.1 1 @@ -126,6 +136,7 @@ 0 0 0 + 0 127.0.0.1 1 LOG_SINGULAR_PLURAL @@ -138,6 +149,7 @@ 15 3 0 + 0 127.0.0.1 1 LOG_MOD3 @@ -150,6 +162,7 @@ 13 0 0 + 0 127.0.0.1 1 @@ -162,6 +175,7 @@ 14 0 0 + 0 127.0.0.1 1 @@ -174,6 +188,7 @@ 0 0 0 + 0 127.0.0.1 1 @@ -186,6 +201,7 @@ 0 0 0 + 0 127.0.0.1 1 diff --git a/tests/log/fixtures/empty_log.xml b/tests/log/fixtures/empty_log.xml index 261b6a622a..47fd639b17 100644 --- a/tests/log/fixtures/empty_log.xml +++ b/tests/log/fixtures/empty_log.xml @@ -6,6 +6,7 @@ user_id forum_id topic_id + post_id reportee_id log_ip log_time diff --git a/tests/log/fixtures/full_log.xml b/tests/log/fixtures/full_log.xml index ef35884444..5b9ded9ffb 100644 --- a/tests/log/fixtures/full_log.xml +++ b/tests/log/fixtures/full_log.xml @@ -6,6 +6,7 @@ user_id forum_id topic_id + post_id reportee_id log_ip log_time @@ -18,6 +19,7 @@ 0 0 0 + 0 127.0.0.1 1 LOG_INSTALL_INSTALLED @@ -30,6 +32,7 @@ 0 0 0 + 0 127.0.0.1 1 LOG_KEY_NOT_EXISTS @@ -42,6 +45,7 @@ 0 0 0 + 0 127.0.0.1 1 LOG_CRITICAL @@ -54,6 +58,7 @@ 12 34 0 + 0 127.0.0.1 1 LOG_MOD @@ -66,6 +71,7 @@ 12 45 0 + 0 127.0.0.1 1 LOG_MOD @@ -78,6 +84,7 @@ 23 56 0 + 0 127.0.0.1 1 LOG_MOD @@ -90,6 +97,7 @@ 12 45 0 + 0 127.0.0.1 1 LOG_MOD2 @@ -101,6 +109,7 @@ 1 0 0 + 0 2 127.0.0.1 1 @@ -113,6 +122,7 @@ 1 0 0 + 0 1 127.0.0.1 1 @@ -126,6 +136,7 @@ 0 0 0 + 0 127.0.0.1 1 LOG_SINGULAR_PLURAL @@ -138,6 +149,7 @@ 15 3 0 + 0 127.0.0.1 1 LOG_MOD3 diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 02e0b3912f..81b1f4a78c 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -46,6 +46,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 0, 'topic_id' => 0, + 'post_id' => 0, 'viewforum' => '', 'action' => 'LOG_INSTALL_INSTALLED 3.1.0-dev', @@ -65,6 +66,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 0, 'topic_id' => 0, + 'post_id' => 0, 'viewforum' => '', 'action' => '{LOG KEY NOT EXISTS}
            additional_data', @@ -84,6 +86,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 0, 'topic_id' => 0, + 'post_id' => 0, 'viewforum' => '', 'action' => '{LOG CRITICAL}
            critical data', @@ -103,10 +106,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 12, 'topic_id' => 34, + 'post_id' => 0, 'viewforum' => '', 'action' => '{LOG MOD}', 'viewtopic' => '', + 'viewpost' => '', 'viewlogs' => '', ), 5 => array( @@ -124,10 +129,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 12, 'topic_id' => 45, + 'post_id' => 0, 'viewforum' => '', 'action' => '{LOG MOD}', 'viewtopic' => '', + 'viewpost' => '', 'viewlogs' => '', ), 6 => array( @@ -145,10 +152,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 23, 'topic_id' => 56, + 'post_id' => 0, 'viewforum' => append_sid("phpBB/viewforum.$phpEx", 'f=23'), 'action' => '{LOG MOD}', 'viewtopic' => append_sid("phpBB/viewtopic.$phpEx", 'f=23&t=56'), + 'viewpost' => '', 'viewlogs' => append_sid("phpBB/mcp.$phpEx", 'i=logs&mode=topic_logs&t=56'), ), 7 => array( @@ -166,10 +175,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 12, 'topic_id' => 45, + 'post_id' => 0, 'viewforum' => '', 'action' => 'LOG_MOD2', 'viewtopic' => '', + 'viewpost' => '', 'viewlogs' => '', ), 8 => array( @@ -187,6 +198,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 0, 'topic_id' => 0, + 'post_id' => 0, 'viewforum' => '', 'action' => 'LOG_USER admin', @@ -206,6 +218,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 0, 'topic_id' => 0, + 'post_id' => 0, 'viewforum' => '', 'action' => 'LOG_USER guest', @@ -225,6 +238,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 0, 'topic_id' => 0, + 'post_id' => 0, 'viewforum' => '', 'action' => 'LOG_SINGULAR_PLURAL 2', @@ -244,10 +258,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'time' => 1, 'forum_id' => 15, 'topic_id' => 3, + 'post_id' => 0, 'viewforum' => '', 'action' => 'LOG_MOD3 guest ', 'viewtopic' => '', + 'viewpost' => '', 'viewlogs' => '', ), ); -- cgit v1.2.1 From 58286171f1035495c8c2a6fdffce9f3842601e66 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 8 Sep 2015 12:59:55 +0200 Subject: [ticket/14150] Update fast-image-size to newest version PHPBB3-14150 --- tests/avatar/manager_test.php | 2 +- tests/upload/imagesize_test.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 6d77f2ed3a..9804869c81 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -57,7 +57,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case new \phpbb\mimetype\content_guesser, ); $guesser = new \phpbb\mimetype\guesser($guessers); - $imagesize = new \fastImageSize\fastImageSize(); + $imagesize = new \FastImageSize\FastImageSize(); $dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/upload/imagesize_test.php b/tests/upload/imagesize_test.php index bfea4b819d..d20e866dab 100644 --- a/tests/upload/imagesize_test.php +++ b/tests/upload/imagesize_test.php @@ -16,7 +16,7 @@ require_once(__DIR__ . '/../../phpBB/includes/functions.php'); class phpbb_upload_imagesize_test extends \phpbb_test_case { - /** @var \fastImageSize\fastImageSize */ + /** @var \FastImageSize\FastImageSize */ protected $imagesize; /** @var string Path to fixtures */ @@ -25,7 +25,7 @@ class phpbb_upload_imagesize_test extends \phpbb_test_case public function setUp() { parent::setUp(); - $this->imagesize = new \fastImageSize\fastImageSize(); + $this->imagesize = new \FastImageSize\FastImageSize(); $this->path = __DIR__ . '/fixture/'; } -- cgit v1.2.1 From 57de89628622a80fcb386c0d95724fe4c6148929 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 14 Aug 2015 09:10:05 +0200 Subject: [ticket/13904] Remove unneeded parameters from avatars and fix tests PHPBB3-13904 --- tests/avatar/manager_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 9804869c81..faf6976028 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -73,6 +73,8 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case ->will($this->returnValue('avatar.driver.barfoo')); $avatar_drivers = array($this->avatar_foobar, $this->avatar_barfoo); + $files_factory = new \phpbb\files\factory($phpbb_container); + foreach ($this->avatar_drivers() as $driver) { if ($driver !== 'upload') @@ -81,7 +83,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case } else { - $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $filesystem, $path_helper, $guesser, $dispatcher, $cache)); + $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $path_helper, $dispatcher, $files_factory, $cache)); } $cur_avatar->expects($this->any()) ->method('get_name') -- cgit v1.2.1 From 2915647a546b4c0733a0e1a0cdc924272e41615b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 00:29:03 +0200 Subject: [ticket/13904] Fix filespec tests PHPBB3-13904 --- tests/upload/filespec_test.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index f953970f64..f3260bf1a9 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -91,7 +91,8 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - return new filespec(array_merge($upload_ary, $override), null, $this->filesystem, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->mimetype_guesser); + return $filespec->set_upload_ary(array_merge($upload_ary, $override)); } protected function tearDown() @@ -226,7 +227,7 @@ class phpbb_filespec_test extends phpbb_test_case */ public function test_get_extension($filename, $expected) { - $this->assertEquals($expected, filespec::get_extension($filename)); + $this->assertEquals($expected, \phpbb\files\filespec::get_extension($filename)); } public function is_image_variables() -- cgit v1.2.1 From dbfdb61f829166989149ac26bda36bbb4642e1af Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 00:45:56 +0200 Subject: [ticket/13904] Fix fileupload tests PHPBB3-13904 --- tests/upload/fileupload_test.php | 42 +++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 9de384b64f..fe6096aebf 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -27,7 +27,7 @@ class phpbb_fileupload_test extends phpbb_test_case // Global $config required by unique_id // Global $user required by several functions dealing with translations // Global $request required by form_upload, local_upload and is_valid - global $config, $user, $request, $phpbb_filesystem; + global $config, $user, $request, $phpbb_filesystem, $phpbb_container; if (!is_array($config)) { @@ -44,6 +44,13 @@ class phpbb_fileupload_test extends phpbb_test_case $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem(); + $phpbb_container = new phpbb_mock_container_builder($this->phpbb_root_path, $this->phpEx); + $phpbb_container->set('files.filespec', new \phpbb\files\filespec( + $this->filesystem, + new \phpbb\mimetype\guesser(array( + 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), + )))); + $this->path = __DIR__ . '/fixture/'; } @@ -69,7 +76,9 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new fileupload($this->filesystem, '', array('png'), 100); + $upload = new \phpbb\files\upload($this->filesystem); + $upload->set_allowed_extensions(array('png')) + ->set_max_filesize(100); $file = $this->gen_valid_filespec(); $upload->common_checks($file); $this->assertEquals('DISALLOWED_EXTENSION', $file->error[0]); @@ -77,7 +86,9 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new fileupload($this->filesystem, '', array('jpg'), 100); + $upload = new \phpbb\files\upload($this->filesystem); + $upload->set_allowed_extensions(array('jpg')) + ->set_max_filesize(100); $file = $this->gen_valid_filespec(); $file->realname = 'invalid?'; $upload->common_checks($file); @@ -86,7 +97,9 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new fileupload($this->filesystem, '', array('jpg'), 100); + $upload = new \phpbb\files\upload($this->filesystem); + $upload->set_allowed_extensions(array('jpg')) + ->set_max_filesize(100); $file = $this->gen_valid_filespec(); $file->filesize = 1000; $upload->common_checks($file); @@ -95,7 +108,9 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); + $upload = new \phpbb\files\upload($this->filesystem); + $upload->set_allowed_extensions(array('jpg')) + ->set_max_filesize(1000); $file = $this->gen_valid_filespec(); $upload->common_checks($file); $this->assertEquals(0, sizeof($file->error)); @@ -103,7 +118,9 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); + $upload = new \phpbb\files\upload($this->filesystem); + $upload->set_allowed_extensions(array('jpg')) + ->set_max_filesize(1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); $file = $upload->local_upload($this->path . 'jpg.jpg'); @@ -113,7 +130,9 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); + $upload = new \phpbb\files\upload($this->filesystem); + $upload->set_allowed_extensions(array('jpg')) + ->set_max_filesize(1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); $file = $upload->local_upload($this->path . 'jpg.jpg'); @@ -125,7 +144,9 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); + $upload = new \phpbb\files\upload($this->filesystem); + $upload->set_allowed_extensions(array('jpg')) + ->set_max_filesize(1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg'); @@ -138,7 +159,10 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new fileupload($this->filesystem, '', false, false, 1, 1, 100, 100); + $upload = new \phpbb\files\upload($this->filesystem); + $upload->set_allowed_extensions(false) + ->set_max_filesize(false) + ->set_allowed_dimensions(1, 1, 100, 100); $file1 = $this->gen_valid_filespec(); $file2 = $this->gen_valid_filespec(); -- cgit v1.2.1 From f32a94ae5d5df156cc33e34a98d9a2e92385c393 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 14 Aug 2015 09:12:43 +0200 Subject: [ticket/13904] Pass filesystem to upload avatar again PHPBB3-13904 --- tests/avatar/manager_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index faf6976028..9003f72de2 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -83,7 +83,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case } else { - $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $path_helper, $dispatcher, $files_factory, $cache)); + $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $filesystem, $path_helper, $dispatcher, $files_factory, $cache)); } $cur_avatar->expects($this->any()) ->method('get_name') -- cgit v1.2.1 From a53825ad760cc8437d8c26eb1f947622c0fcf229 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 11:48:55 +0200 Subject: [ticket/13904] No longer use fileerror class for extending filespec class PHPBB3-13904 --- tests/upload/fileupload_test.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index fe6096aebf..d4785c782c 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -22,6 +22,12 @@ class phpbb_fileupload_test extends phpbb_test_case private $filesystem; + /** @var \Symfony\Component\DependencyInjection\ContainerInterface */ + protected $container; + + /** @var \phpbb\files\factory */ + protected $factory; + protected function setUp() { // Global $config required by unique_id @@ -44,12 +50,13 @@ class phpbb_fileupload_test extends phpbb_test_case $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem(); - $phpbb_container = new phpbb_mock_container_builder($this->phpbb_root_path, $this->phpEx); - $phpbb_container->set('files.filespec', new \phpbb\files\filespec( + $this->container = new phpbb_mock_container_builder($this->phpbb_root_path, $this->phpEx); + $this->container->set('files.filespec', new \phpbb\files\filespec( $this->filesystem, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), )))); + $this->factory = new \phpbb\files\factory($this->container); $this->path = __DIR__ . '/fixture/'; } @@ -76,7 +83,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new \phpbb\files\upload($this->filesystem); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); $upload->set_allowed_extensions(array('png')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -86,7 +93,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new \phpbb\files\upload($this->filesystem); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -97,7 +104,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new \phpbb\files\upload($this->filesystem); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -108,7 +115,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new \phpbb\files\upload($this->filesystem); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); $file = $this->gen_valid_filespec(); @@ -118,7 +125,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new \phpbb\files\upload($this->filesystem); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -130,7 +137,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new \phpbb\files\upload($this->filesystem); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -144,7 +151,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new \phpbb\files\upload($this->filesystem); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -159,7 +166,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new \phpbb\files\upload($this->filesystem); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); $upload->set_allowed_extensions(false) ->set_max_filesize(false) ->set_allowed_dimensions(1, 1, 100, 100); -- cgit v1.2.1 From c34fd1e7c030860169bcbde9ac3c4f75d610cd60 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 12:22:14 +0200 Subject: [ticket/13904] Fix fileupload functional tests PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 35 ++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 4aa1a83b30..34e9ca2b05 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -11,15 +11,17 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions_upload.php'; - /** * @group functional */ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case { + /** @var \phpbb\filesystem\filesystem_interface */ protected $filesystem; + /** @var \phpbb\files\factory */ + protected $factory; + public function setUp() { parent::setUp(); @@ -41,6 +43,11 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $user = new phpbb_mock_user(); $user->lang = new phpbb_mock_lang(); $this->filesystem = new \phpbb\filesystem\filesystem(); + + $container = new phpbb_mock_container_builder(); + $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem)); + $this->factory = new \phpbb\files\factory($container); + $container->set('files.factory', $this->factory); } public function tearDown() @@ -52,21 +59,33 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { - $upload = new fileupload($this->filesystem, '', array('jpg'), 100); + /** @var \phpbb\files\upload $upload */ + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload->set_error_prefix('') + ->set_allowed_extensions(array('jpg')) + ->set_max_filesize(100); $file = $upload->remote_upload(self::$root_url . 'develop/blank.gif'); $this->assertEquals('URL_INVALID', $file->error[0]); } public function test_empty_file() { - $upload = new fileupload($this->filesystem, '', array('jpg'), 100); + /** @var \phpbb\files\upload $upload */ + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload->set_error_prefix('') + ->set_allowed_extensions(array('jpg')) + ->set_max_filesize(100); $file = $upload->remote_upload(self::$root_url . 'develop/blank.jpg'); $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); } public function test_successful_upload() { - $upload = new fileupload($this->filesystem, '', array('gif'), 1000); + /** @var \phpbb\files\upload $upload */ + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload->set_error_prefix('') + ->set_allowed_extensions(array('gif')) + ->set_max_filesize(1000); $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->filename)); @@ -74,7 +93,11 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_too_large() { - $upload = new fileupload($this->filesystem, '', array('gif'), 100); + /** @var \phpbb\files\upload $upload */ + $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload->set_error_prefix('') + ->set_allowed_extensions(array('gif')) + ->set_max_filesize(100); $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(1, sizeof($file->error)); $this->assertEquals('WRONG_FILESIZE', $file->error[0]); -- cgit v1.2.1 From 25df7f814920a67b1d9b1e65e797c44960026585 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 12:24:31 +0200 Subject: [ticket/13904] Remove functions_fileupload.php PHPBB3-13904 --- tests/upload/filespec_test.php | 1 - tests/upload/fileupload_test.php | 1 - 2 files changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index f3260bf1a9..10577ec8f3 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -13,7 +13,6 @@ require_once __DIR__ . '/../../phpBB/includes/functions.php'; require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_upload.php'; class phpbb_filespec_test extends phpbb_test_case { diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index d4785c782c..8b7056e9cf 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -13,7 +13,6 @@ require_once __DIR__ . '/../../phpBB/includes/functions.php'; require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_upload.php'; require_once __DIR__ . '/../mock/filespec.php'; class phpbb_fileupload_test extends phpbb_test_case -- cgit v1.2.1 From ef59e0228a993bcaf7bf59c7cb24511f3cbe1b78 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 13:42:58 +0200 Subject: [ticket/13904] Fix tests again PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 15 ++++++++++----- tests/upload/fileupload_test.php | 25 +++++++++++++++---------- 2 files changed, 25 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 34e9ca2b05..7301297096 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -22,6 +22,9 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case /** @var \phpbb\files\factory */ protected $factory; + /** @var \phpbb\language\language */ + protected $language; + public function setUp() { parent::setUp(); @@ -30,7 +33,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case // Global $config required by unique_id // Global $user required by fileupload::remote_upload - global $config, $user; + global $config, $user, $phpbb_root_path, $phpEx; if (!is_array($config)) { @@ -48,6 +51,8 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); + + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); } public function tearDown() @@ -60,7 +65,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -71,7 +76,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_empty_file() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -82,7 +87,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_successful_upload() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(1000); @@ -94,7 +99,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_too_large() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 8b7056e9cf..87e10ac954 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -27,12 +27,15 @@ class phpbb_fileupload_test extends phpbb_test_case /** @var \phpbb\files\factory */ protected $factory; + /** @var \phpbb\language\language */ + protected $language; + protected function setUp() { // Global $config required by unique_id // Global $user required by several functions dealing with translations // Global $request required by form_upload, local_upload and is_valid - global $config, $user, $request, $phpbb_filesystem, $phpbb_container; + global $config, $user, $request, $phpbb_filesystem, $phpbb_root_path, $phpEx; if (!is_array($config)) { @@ -49,7 +52,7 @@ class phpbb_fileupload_test extends phpbb_test_case $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem(); - $this->container = new phpbb_mock_container_builder($this->phpbb_root_path, $this->phpEx); + $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec( $this->filesystem, new \phpbb\mimetype\guesser(array( @@ -57,6 +60,8 @@ class phpbb_fileupload_test extends phpbb_test_case )))); $this->factory = new \phpbb\files\factory($this->container); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->path = __DIR__ . '/fixture/'; } @@ -82,7 +87,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_allowed_extensions(array('png')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -92,7 +97,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -103,7 +108,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -114,7 +119,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); $file = $this->gen_valid_filespec(); @@ -124,7 +129,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -136,7 +141,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -150,7 +155,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -165,7 +170,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); $upload->set_allowed_extensions(false) ->set_max_filesize(false) ->set_allowed_dimensions(1, 1, 100, 100); -- cgit v1.2.1 From 697ac5f4aa151b06ed65f8352652443bf297682a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 15:06:24 +0200 Subject: [ticket/13904] Use language class instead of global user in filespec PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 10 +++------- tests/upload/filespec_test.php | 19 ++++++++----------- tests/upload/fileupload_test.php | 12 ++++-------- 3 files changed, 15 insertions(+), 26 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 7301297096..ae4de26df4 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -32,8 +32,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case // URL // Global $config required by unique_id - // Global $user required by fileupload::remote_upload - global $config, $user, $phpbb_root_path, $phpEx; + global $config, $phpbb_root_path, $phpEx; if (!is_array($config)) { @@ -43,16 +42,13 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; - $user = new phpbb_mock_user(); - $user->lang = new phpbb_mock_lang(); $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $container = new phpbb_mock_container_builder(); - $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem)); + $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); - - $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); } public function tearDown() diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 10577ec8f3..b28adc3f28 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -25,12 +25,13 @@ class phpbb_filespec_test extends phpbb_test_case private $filesystem; public $path; + /** @var \phpbb\language\language */ + protected $language; + protected function setUp() { // Global $config required by unique_id - // Global $user required by filespec::additional_checks and - // filespec::move_file - global $config, $user, $phpbb_filesystem; + global $config, $phpbb_root_path, $phpEx; if (!is_array($config)) { @@ -44,9 +45,6 @@ class phpbb_filespec_test extends phpbb_test_case // See: phpBB/install/schemas/schema_data.sql $config['mime_triggers'] = 'body|head|html|img|plaintext|a href|pre|script|table|title'; - $user = new phpbb_mock_user(); - $user->lang = new phpbb_mock_lang(); - $this->config = &$config; $this->path = __DIR__ . '/fixture/'; @@ -75,8 +73,9 @@ class phpbb_filespec_test extends phpbb_test_case $guessers[2]->set_priority(-2); $guessers[3]->set_priority(-2); $this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); - $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem(); + $this->filesystem = new \phpbb\filesystem\filesystem(); } private function get_filespec($override = array()) @@ -90,15 +89,13 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - $filespec = new \phpbb\files\filespec($this->filesystem, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->mimetype_guesser); return $filespec->set_upload_ary(array_merge($upload_ary, $override)); } protected function tearDown() { - global $user; $this->config = array(); - $user = null; $iterator = new DirectoryIterator($this->path . 'copies'); foreach ($iterator as $fileinfo) @@ -289,7 +286,7 @@ class phpbb_filespec_test extends phpbb_test_case array('txt_copy', 'txt_as_img', 'image/jpg', 'txt', false, true), array('txt_copy_2', 'txt_moved', 'text/plain', 'txt', false, true), array('jpg_copy', 'jpg_moved', 'image/png', 'jpg', false, true), - array('png_copy', 'png_moved', 'image/png', 'jpg', 'IMAGE_FILETYPE_MISMATCH png jpg', true), + array('png_copy', 'png_moved', 'image/png', 'jpg', 'Image file type mismatch: expected extension png but extension jpg given.', true), ); } diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 87e10ac954..56e29a3ac2 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -33,9 +33,8 @@ class phpbb_fileupload_test extends phpbb_test_case protected function setUp() { // Global $config required by unique_id - // Global $user required by several functions dealing with translations // Global $request required by form_upload, local_upload and is_valid - global $config, $user, $request, $phpbb_filesystem, $phpbb_root_path, $phpEx; + global $config, $request, $phpbb_root_path, $phpEx; if (!is_array($config)) { @@ -45,23 +44,20 @@ class phpbb_fileupload_test extends phpbb_test_case $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; - $user = new phpbb_mock_user(); - $user->lang = new phpbb_mock_lang(); - $request = new phpbb_mock_request(); - $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem(); + $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec( $this->filesystem, + $this->language, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), )))); $this->factory = new \phpbb\files\factory($this->container); - $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); - $this->path = __DIR__ . '/fixture/'; } -- cgit v1.2.1 From 47f8f2cc88bdcd40087c8e391be1d33d36a2d308 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 15:24:38 +0200 Subject: [ticket/13904] Pass request service to upload instead of using global PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 12 ++++++++---- tests/upload/fileupload_test.php | 24 +++++++++++++----------- 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index ae4de26df4..4754153cbf 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -25,6 +25,9 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case /** @var \phpbb\language\language */ protected $language; + /** @var \phpbb\request\request_interface */ + protected $request; + public function setUp() { parent::setUp(); @@ -44,6 +47,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->request = $this->getMock('\phpbb\request\request'); $container = new phpbb_mock_container_builder(); $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language)); @@ -61,7 +65,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -72,7 +76,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_empty_file() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -83,7 +87,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_successful_upload() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(1000); @@ -95,7 +99,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_too_large() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 56e29a3ac2..deb4404585 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -30,11 +30,13 @@ class phpbb_fileupload_test extends phpbb_test_case /** @var \phpbb\language\language */ protected $language; + /** @var \phpbb\request\request_interface */ + protected $request; + protected function setUp() { // Global $config required by unique_id - // Global $request required by form_upload, local_upload and is_valid - global $config, $request, $phpbb_root_path, $phpEx; + global $config, $phpbb_root_path, $phpEx; if (!is_array($config)) { @@ -44,7 +46,7 @@ class phpbb_fileupload_test extends phpbb_test_case $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; - $request = new phpbb_mock_request(); + $this->request = $this->getMock('\phpbb\request\request'); $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); @@ -83,7 +85,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('png')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -93,7 +95,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -104,7 +106,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -115,7 +117,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); $file = $this->gen_valid_filespec(); @@ -125,7 +127,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -137,7 +139,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -151,7 +153,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -166,7 +168,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(false) ->set_max_filesize(false) ->set_allowed_dimensions(1, 1, 100, 100); -- cgit v1.2.1 From 52652ca1824e91ecfe7549167aebd92c314af678 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 15:29:32 +0200 Subject: [ticket/13904] Remove phpbb_root_path global from upload class PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 12 ++++++++---- tests/upload/fileupload_test.php | 20 ++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 4754153cbf..a32c339afa 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -28,6 +28,9 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case /** @var \phpbb\request\request_interface */ protected $request; + /** @var string phpBB root path */ + protected $phpbb_root_path; + public function setUp() { parent::setUp(); @@ -53,6 +56,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); + $this->phpbb_root_path = $phpbb_root_path; } public function tearDown() @@ -65,7 +69,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -76,7 +80,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_empty_file() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -87,7 +91,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_successful_upload() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(1000); @@ -99,7 +103,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_too_large() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index deb4404585..0832f269cb 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -33,6 +33,9 @@ class phpbb_fileupload_test extends phpbb_test_case /** @var \phpbb\request\request_interface */ protected $request; + /** @var string phpBB root path */ + protected $phpbb_root_path; + protected function setUp() { // Global $config required by unique_id @@ -61,6 +64,7 @@ class phpbb_fileupload_test extends phpbb_test_case $this->factory = new \phpbb\files\factory($this->container); $this->path = __DIR__ . '/fixture/'; + $this->phpbb_root_path = $phpbb_root_path; } private function gen_valid_filespec() @@ -85,7 +89,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -95,7 +99,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -106,7 +110,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -117,7 +121,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); $file = $this->gen_valid_filespec(); @@ -127,7 +131,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -139,7 +143,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -153,7 +157,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -168,7 +172,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(false) ->set_max_filesize(false) ->set_allowed_dimensions(1, 1, 100, 100); -- cgit v1.2.1 From b871dbcf1f2d0483cbe19cddf94a5bdc9659ab00 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 15:46:41 +0200 Subject: [ticket/13904] Remove phpbb_root_path global from filespec class PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 2 +- tests/upload/filespec_test.php | 11 +++++++---- tests/upload/fileupload_test.php | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index a32c339afa..f69ba9f122 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -53,7 +53,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->request = $this->getMock('\phpbb\request\request'); $container = new phpbb_mock_container_builder(); - $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language)); + $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); $this->phpbb_root_path = $phpbb_root_path; diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index b28adc3f28..b0df72a6ff 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -28,6 +28,9 @@ class phpbb_filespec_test extends phpbb_test_case /** @var \phpbb\language\language */ protected $language; + /** @var string phpBB root path */ + protected $phpbb_root_path; + protected function setUp() { // Global $config required by unique_id @@ -76,6 +79,7 @@ class phpbb_filespec_test extends phpbb_test_case $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->phpbb_root_path = $phpbb_root_path; } private function get_filespec($override = array()) @@ -89,7 +93,7 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); return $filespec->set_upload_ary(array_merge($upload_ary, $override)); } @@ -297,8 +301,7 @@ class phpbb_filespec_test extends phpbb_test_case { // Global $phpbb_root_path and $phpEx are required by phpbb_chmod global $phpbb_root_path, $phpEx; - $phpbb_root_path = ''; - $phpEx = 'php'; + $this->phpbb_root_path = ''; $upload = new phpbb_mock_fileupload(); $upload->max_filesize = self::UPLOAD_MAX_FILESIZE; @@ -319,7 +322,7 @@ class phpbb_filespec_test extends phpbb_test_case $this->assertEquals($error, $filespec->error[0]); } - $phpEx = ''; + $this->phpbb_root_path = $phpbb_root_path; } /** diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 0832f269cb..c62e9a1947 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -58,6 +58,7 @@ class phpbb_fileupload_test extends phpbb_test_case $this->container->set('files.filespec', new \phpbb\files\filespec( $this->filesystem, $this->language, + $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), )))); -- cgit v1.2.1 From c65f0d748ae3cef90e08ce2c700e65734392da45 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Jun 2015 15:58:57 +0200 Subject: [ticket/13904] Add more tests for upload class PHPBB3-13904 --- tests/files/upload_test.php | 96 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 tests/files/upload_test.php (limited to 'tests') diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php new file mode 100644 index 0000000000..4323f6cc92 --- /dev/null +++ b/tests/files/upload_test.php @@ -0,0 +1,96 @@ + + * @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_files_upload_test extends phpbb_test_case +{ + private $path; + + private $filesystem; + + /** @var \Symfony\Component\DependencyInjection\ContainerInterface */ + protected $container; + + /** @var \phpbb\files\factory */ + protected $factory; + + /** @var \phpbb\language\language */ + protected $language; + + /** @var \phpbb\request\request_interface */ + protected $request; + + /** @var string phpBB root path */ + protected $phpbb_root_path; + + protected function setUp() + { + // Global $config required by unique_id + global $config, $phpbb_root_path, $phpEx; + + if (!is_array($config)) + { + $config = array(); + } + + $config['rand_seed'] = ''; + $config['rand_seed_last_update'] = time() + 600; + + $this->request = $this->getMock('\phpbb\request\request'); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + + $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); + $this->container->set('files.filespec', new \phpbb\files\filespec( + $this->filesystem, + $this->language, + $phpbb_root_path, + new \phpbb\mimetype\guesser(array( + 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), + )))); + $this->factory = new \phpbb\files\factory($this->container); + + $this->path = __DIR__ . '/fixture/'; + $this->phpbb_root_path = $phpbb_root_path; + } + + public function test_reset_vars() + { + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload->set_max_filesize(500); + $this->assertEquals(500, $upload->max_filesize); + $upload->reset_vars(); + $this->assertEquals(0, $upload->max_filesize); + } + + public function test_set_disallowed_content() + { + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload->set_disallowed_content(array('foo')); + $this->assertEquals(array('foo'), $upload->disallowed_content); + $upload->set_disallowed_content(array('foo', 'bar', 'meh')); + $this->assertEquals(array('foo', 'bar', 'meh'), $upload->disallowed_content); + $upload->set_disallowed_content(''); + $this->assertEquals(array('foo', 'bar', 'meh'), $upload->disallowed_content); + $this->assertINstanceOf('\phpbb\files\upload', $upload->set_disallowed_content(array())); + $this->assertEquals(array(), $upload->disallowed_content); + $upload->reset_vars(); + $this->assertEquals(array(), $upload->disallowed_content); + } + + public function test_is_valid() + { + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $this->assertFalse($upload->is_valid('foobar')); + } +} -- cgit v1.2.1 From adcc901af181b6727dd7af89a3926c9923a58471 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 15 Jul 2015 16:08:20 +0200 Subject: [ticket/13904] Fix minor issues and move local_upload to its own class PHPBB3-13904 --- tests/upload/fileupload_test.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index c62e9a1947..7a84b34473 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -43,7 +43,7 @@ class phpbb_fileupload_test extends phpbb_test_case if (!is_array($config)) { - $config = array(); + $config = new \phpbb\config\config(array()); } $config['rand_seed'] = ''; @@ -53,6 +53,15 @@ class phpbb_fileupload_test extends phpbb_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $guessers = array( + new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), + new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), + new \phpbb\mimetype\content_guesser(), + new \phpbb\mimetype\extension_guesser(), + ); + $guessers[2]->set_priority(-2); + $guessers[3]->set_priority(-2); + $this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers); $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec( @@ -63,6 +72,18 @@ class phpbb_fileupload_test extends phpbb_test_case 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), )))); $this->factory = new \phpbb\files\factory($this->container); + $plupload = new \phpbb\plupload\plupload($phpbb_root_path, $config, $this->request, new \phpbb\user($this->language, '\phpbb\datetime'), new \phpbb\php\ini(), $this->mimetype_guesser); + $this->container->set('files.types.form', new \phpbb\files\types\form( + $this->factory, + $this->language, + $plupload, + $this->request + ), phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $this->container->set('files.types.local', new \phpbb\files\types\local( + $this->factory, + $this->language, + $this->request + ), phpbb_mock_container_builder::SCOPE_PROTOTYPE); $this->path = __DIR__ . '/fixture/'; $this->phpbb_root_path = $phpbb_root_path; @@ -137,7 +158,7 @@ class phpbb_fileupload_test extends phpbb_test_case ->set_max_filesize(1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); - $file = $upload->local_upload($this->path . 'jpg.jpg'); + $file = $upload->handle_upload('local', $this->path . 'jpg.jpg'); $this->assertEquals(0, sizeof($file->error)); unlink($this->path . 'jpg.jpg'); } @@ -149,7 +170,7 @@ class phpbb_fileupload_test extends phpbb_test_case ->set_max_filesize(1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); - $file = $upload->local_upload($this->path . 'jpg.jpg'); + $file = $upload->handle_upload('local', $this->path . 'jpg.jpg'); $this->assertEquals(0, sizeof($file->error)); $this->assertFalse($file->move_file('../tests/upload/fixture')); $this->assertFalse($file->file_moved); @@ -164,7 +185,7 @@ class phpbb_fileupload_test extends phpbb_test_case copy($this->path . 'jpg', $this->path . 'jpg.jpg'); copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg'); - $file = $upload->local_upload($this->path . 'jpg.jpg'); + $file = $upload->handle_upload('local', $this->path . 'jpg.jpg'); $this->assertEquals(0, sizeof($file->error)); $file->move_file('../tests/upload/fixture/copies', true); $this->assertEquals(0, sizeof($file->error)); -- cgit v1.2.1 From 57ccfe0c483254e54b7b40bc1906ef946daf4f55 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 15 Jul 2015 18:00:52 +0200 Subject: [ticket/13904] Move remote upload to its own type class PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index f69ba9f122..0f1e4d6e59 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -73,7 +73,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); - $file = $upload->remote_upload(self::$root_url . 'develop/blank.gif'); + $file = $upload->handle_upload('remote', self::$root_url . 'develop/blank.gif'); $this->assertEquals('URL_INVALID', $file->error[0]); } @@ -84,7 +84,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); - $file = $upload->remote_upload(self::$root_url . 'develop/blank.jpg'); + $file = $upload->handle_upload('remote', self::$root_url . 'develop/blank.jpg'); $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); } @@ -95,7 +95,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(1000); - $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $file = $upload->handle_upload('remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->filename)); } @@ -107,7 +107,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); - $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $file = $upload->handle_upload('remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(1, sizeof($file->error)); $this->assertEquals('WRONG_FILESIZE', $file->error[0]); } -- cgit v1.2.1 From 759a1a09fae5147afe346729764f050ecc67076b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 15 Jul 2015 21:30:42 +0200 Subject: [ticket/13904] Fix remote upload functional tests PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 0f1e4d6e59..1bb63719c6 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -56,6 +56,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); + $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->request)); $this->phpbb_root_path = $phpbb_root_path; } -- cgit v1.2.1 From a09c6d1fb760151b1a6c654b597b4578c3136be1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 15 Jul 2015 23:10:23 +0200 Subject: [ticket/13904] Split code up and pass root path to remote upload type PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 1bb63719c6..a754d8c91d 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -56,7 +56,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); - $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->request)); + $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->request, $phpbb_root_path)); $this->phpbb_root_path = $phpbb_root_path; } -- cgit v1.2.1 From 845233fc626b0d5e6d9e61039fde8e31b4dd28aa Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 16 Jul 2015 00:21:23 +0200 Subject: [ticket/13904] Improve test coverage and use constants instead of magic numbers PHPBB3-13904 --- tests/files/upload_test.php | 23 +++++++++++++++++++++++ tests/upload/fileupload_test.php | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) (limited to 'tests') diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php index 4323f6cc92..057bb8a4f2 100644 --- a/tests/files/upload_test.php +++ b/tests/files/upload_test.php @@ -93,4 +93,27 @@ class phpbb_files_upload_test extends phpbb_test_case $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); $this->assertFalse($upload->is_valid('foobar')); } + + public function data_internal_error() + { + return array( + array(UPLOAD_ERR_INI_SIZE, 'PHP_SIZE_OVERRUN'), + array(UPLOAD_ERR_FORM_SIZE, 'WRONG_FILESIZE'), + array(UPLOAD_ERR_PARTIAL, 'PARTIAL_UPLOAD'), + array(UPLOAD_ERR_NO_FILE, 'NOT_UPLOADED'), + array(UPLOAD_ERR_NO_TMP_DIR, 'Temporary folder could not be found. Please check your PHP installation.'), + array(UPLOAD_ERR_CANT_WRITE, 'Can’t write to temporary folder.'), + array(UPLOAD_ERR_EXTENSION, 'A PHP extension has stopped the file upload.'), + array(9, false), + ); + } + + /** + * @dataProvider data_internal_error + */ + public function test_assign_internal_error($error_code, $expected) + { + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $this->assertSame($expected, $upload->assign_internal_error($error_code)); + } } diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 7a84b34473..ab42a4a153 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -119,6 +119,25 @@ class phpbb_fileupload_test extends phpbb_test_case $this->assertEquals('DISALLOWED_EXTENSION', $file->error[0]); } + public function test_common_checks_disallowed_content() + { + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload->set_allowed_extensions(array('jpg')) + ->set_max_filesize(1000); + $file = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path); + $file->set_upload_ary(array( + 'size' => 50, + 'tmp_name' => dirname(__FILE__) . '/fixture/disallowed', + 'name' => 'disallowed.jpg', + 'type' => 'image/jpg' + )) + ->set_upload_namespace($upload); + file_put_contents(dirname(__FILE__) . '/fixture/disallowed', '' . file_get_contents(dirname(__FILE__) . '/fixture/jpg')); + $upload->common_checks($file); + $this->assertEquals('DISALLOWED_CONTENT', $file->error[0]); + unlink(dirname(__FILE__) . '/fixture/disallowed'); + } + public function test_common_checks_invalid_filename() { $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); -- cgit v1.2.1 From 3e99816fa2f184b859d47308254aa8f07d68f1dd Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 16 Jul 2015 12:06:23 +0200 Subject: [ticket/13904] Set visibility in files and improve test coverage PHPBB3-13904 --- tests/files/upload_test.php | 13 ++++--- tests/functional/fileupload_remote_test.php | 2 +- tests/upload/filespec_test.php | 60 ++++++++++++++++++++++++++--- 3 files changed, 64 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php index 057bb8a4f2..dc0080d25c 100644 --- a/tests/files/upload_test.php +++ b/tests/files/upload_test.php @@ -76,16 +76,19 @@ class phpbb_files_upload_test extends phpbb_test_case public function test_set_disallowed_content() { $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $disallowed_content = new ReflectionProperty($upload, 'disallowed_content'); + $disallowed_content->setAccessible(true); + $upload->set_disallowed_content(array('foo')); - $this->assertEquals(array('foo'), $upload->disallowed_content); + $this->assertEquals(array('foo'), $disallowed_content->getValue($upload)); $upload->set_disallowed_content(array('foo', 'bar', 'meh')); - $this->assertEquals(array('foo', 'bar', 'meh'), $upload->disallowed_content); + $this->assertEquals(array('foo', 'bar', 'meh'), $disallowed_content->getValue($upload)); $upload->set_disallowed_content(''); - $this->assertEquals(array('foo', 'bar', 'meh'), $upload->disallowed_content); + $this->assertEquals(array('foo', 'bar', 'meh'), $disallowed_content->getValue($upload)); $this->assertINstanceOf('\phpbb\files\upload', $upload->set_disallowed_content(array())); - $this->assertEquals(array(), $upload->disallowed_content); + $this->assertEquals(array(), $disallowed_content->getValue($upload)); $upload->reset_vars(); - $this->assertEquals(array(), $upload->disallowed_content); + $this->assertEquals(array(), $disallowed_content->getValue($upload)); } public function test_is_valid() diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index a754d8c91d..a6aa233aaf 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -98,7 +98,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case ->set_max_filesize(1000); $file = $upload->handle_upload('remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(0, sizeof($file->error)); - $this->assertTrue(file_exists($file->filename)); + $this->assertTrue(file_exists($file->get('filename'))); } public function test_too_large() diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index b0df72a6ff..f885b1acfc 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -133,7 +133,7 @@ class phpbb_filespec_test extends phpbb_test_case { $upload = new phpbb_mock_fileupload(); $filespec = $this->get_filespec(); - $filespec->upload = $upload; + $filespec->set_upload_namespace($upload); $filespec->file_moved = true; $filespec->filesize = $filespec->get_filesize($this->path . $filename); @@ -174,6 +174,7 @@ class phpbb_filespec_test extends phpbb_test_case array($chunks[2] . $chunks[9]), array($chunks[3] . $chunks[4]), array($chunks[5] . $chunks[6]), + array('foobar.png'), ); } @@ -185,7 +186,7 @@ class phpbb_filespec_test extends phpbb_test_case $bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|'); $filespec = $this->get_filespec(array('name' => $filename)); $filespec->clean_filename('real', self::PREFIX); - $name = $filespec->realname; + $name = $filespec->get('realname'); $this->assertEquals(0, preg_match('/%(\w{2})/', $name)); foreach ($bad_chars as $char) @@ -201,7 +202,7 @@ class phpbb_filespec_test extends phpbb_test_case { $filespec = $this->get_filespec(); $filespec->clean_filename('unique', self::PREFIX); - $name = $filespec->realname; + $name = $filespec->get('realname'); $this->assertEquals(strlen($name), 32 + strlen(self::PREFIX)); $this->assertRegExp('#^[A-Za-z0-9]+$#', substr($name, strlen(self::PREFIX))); @@ -210,6 +211,55 @@ class phpbb_filespec_test extends phpbb_test_case } } + public function test_clean_filename_unique_ext() + { + $filenames = array(); + for ($tests = 0; $tests < self::TEST_COUNT; $tests++) + { + $filespec = $this->get_filespec(array('name' => 'foobar.jpg')); + $filespec->clean_filename('unique_ext', self::PREFIX); + $name = $filespec->get('realname'); + + $this->assertEquals(strlen($name), 32 + strlen(self::PREFIX) + strlen('.jpg')); + $this->assertRegExp('#^[A-Za-z0-9]+\.jpg$#', substr($name, strlen(self::PREFIX))); + $this->assertFalse(isset($filenames[$name])); + $filenames[$name] = true; + } + } + + public function data_clean_filename_avatar() + { + return array( + array(false, false, ''), + array('foobar.png', 'u5.png', 'avatar', 'u', 5), + array('foobar.png', 'g9.png', 'avatar', 'g', 9), + + ); + } + + /** + * @dataProvider data_clean_filename_avatar + */ + public function test_clean_filename_avatar($filename, $expected, $mode, $prefix = '', $user_id = '') + { + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); + + if ($filename) + { + $upload_ary = array( + 'name' => $filename, + 'type' => '', + 'size' => '', + 'tmp_name' => '', + 'error' => '', + ); + $filespec->set_upload_ary($upload_ary); + } + $filespec->clean_filename($mode, $prefix, $user_id); + + $this->assertSame($expected, $filespec->get('realname')); + } + public function get_extension_variables() { return array( @@ -312,7 +362,7 @@ class phpbb_filespec_test extends phpbb_test_case 'type' => $mime_type, )); $filespec->extension = $extension; - $filespec->upload = $upload; + $filespec->set_upload_namespace($upload); $filespec->local = true; $this->assertEquals($expected, $filespec->move_file($this->path . 'copies')); @@ -336,6 +386,6 @@ class phpbb_filespec_test extends phpbb_test_case $type_cast_helper->set_var($upload_name, $filename, 'string', true, true); $filespec = $this->get_filespec(array('name'=> $upload_name)); - $this->assertSame(trim(utf8_basename(htmlspecialchars($filename))), $filespec->uploadname); + $this->assertSame(trim(utf8_basename(htmlspecialchars($filename))), $filespec->get('uploadname')); } } -- cgit v1.2.1 From 46e3d8219671e996677be1943a7e3c80f1039693 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 16 Jul 2015 16:30:59 +0200 Subject: [ticket/13904] Add more tests and test cases PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 1 + tests/mock/fileupload.php | 3 +- tests/upload/filespec_test.php | 43 +++++++++++++++++++++++++++++ tests/upload/fileupload_test.php | 4 ++- 4 files changed, 49 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index a6aa233aaf..1a74b3b498 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -99,6 +99,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $file = $upload->handle_upload('remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->get('filename'))); + $this->assertTrue($file->is_uploaded()); } public function test_too_large() diff --git a/tests/mock/fileupload.php b/tests/mock/fileupload.php index 8cc4d77ea1..5a0afc6cd3 100644 --- a/tests/mock/fileupload.php +++ b/tests/mock/fileupload.php @@ -19,9 +19,10 @@ class phpbb_mock_fileupload { public $max_filesize = 100; public $error_prefix = ''; + public $valid_dimensions = true; public function valid_dimensions($filespec) { - return true; + return $this->valid_dimensions; } } diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index f885b1acfc..a6ea850763 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -112,6 +112,13 @@ class phpbb_filespec_test extends phpbb_test_case } } + public function test_empty_upload_ary() + { + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); + $this->assertInstanceOf('\phpbb\files\filespec', $filespec->set_upload_ary(array())); + $this->assertTrue($filespec->init_error()); + } + public function additional_checks_variables() { // False here just indicates the file is too large and fails the @@ -140,6 +147,19 @@ class phpbb_filespec_test extends phpbb_test_case $this->assertEquals($expected, $filespec->additional_checks()); } + public function test_additional_checks_dimensions() + { + $upload = new phpbb_mock_fileupload(); + $filespec = $this->get_filespec(); + $filespec->set_upload_namespace($upload); + $upload->valid_dimensions = false; + $filespec->file_moved = true; + $upload->max_filesize = 0; + + $this->assertEquals(false, $filespec->additional_checks()); + $this->assertSame(array('WRONG_SIZE'), $filespec->error); + } + public function check_content_variables() { // False here indicates that a file is non-binary and contains @@ -388,4 +408,27 @@ class phpbb_filespec_test extends phpbb_test_case $this->assertSame(trim(utf8_basename(htmlspecialchars($filename))), $filespec->get('uploadname')); } + + public function test_is_uploaded() + { + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, null); + $reflection_filespec = new ReflectionClass($filespec); + $plupload_property = $reflection_filespec->getProperty('plupload'); + $plupload_property->setAccessible(true); + $plupload_mock = $this->getMockBuilder('\phpbb\plupload\plupload') + ->disableOriginalConstructor() + ->getMock(); + $plupload_mock->expects($this->any()) + ->method('is_active') + ->will($this->returnValue(true)); + $plupload_property->setValue($filespec, $plupload_mock); + $is_uploaded = $reflection_filespec->getMethod('is_uploaded'); + + // Plupload is active and file does not exist + $this->assertFalse($is_uploaded->invoke($filespec)); + + // Plupload is not active and file was not uploaded + $plupload_property->setValue($filespec, null); + $this->assertFalse($is_uploaded->invoke($filespec)); + } } diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index ab42a4a153..d1d8b55ff3 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -179,7 +179,9 @@ class phpbb_fileupload_test extends phpbb_test_case copy($this->path . 'jpg', $this->path . 'jpg.jpg'); $file = $upload->handle_upload('local', $this->path . 'jpg.jpg'); $this->assertEquals(0, sizeof($file->error)); - unlink($this->path . 'jpg.jpg'); + $this->assertFalse($file->additional_checks()); + $this->assertTrue($file->move_file('../tests/upload/fixture/copies', true)); + $file->remove(); } public function test_move_existent_file() -- cgit v1.2.1 From 7ba0fe47a8610b1bd882f00cd1e158c7b29d248c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 17 Jul 2015 09:29:09 +0200 Subject: [ticket/13904] Test move file on existing error PHPBB3-13904 --- tests/upload/filespec_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index a6ea850763..1ba473555f 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -395,6 +395,14 @@ class phpbb_filespec_test extends phpbb_test_case $this->phpbb_root_path = $phpbb_root_path; } + public function test_move_file_error() + { + $filespec = $this->get_filespec(); + $this->assertFalse($filespec->move_file('foobar')); + $filespec->error[] = 'foo'; + $this->assertFalse($filespec->move_file('foo')); + } + /** * @dataProvider clean_filename_variables */ -- cgit v1.2.1 From cdde86ce7e0c594fad5992789b3fae466bd526cc Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 26 Aug 2015 13:57:42 +0200 Subject: [ticket/13904] Use \phpbb\php\ini class for ini_get() PHPBB3-13904 --- tests/files/upload_test.php | 13 +++++++++---- tests/functional/fileupload_remote_test.php | 14 +++++++++----- tests/upload/filespec_test.php | 8 ++++---- tests/upload/fileupload_test.php | 27 ++++++++++++++++----------- 4 files changed, 38 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php index dc0080d25c..d11ebc742b 100644 --- a/tests/files/upload_test.php +++ b/tests/files/upload_test.php @@ -23,6 +23,9 @@ class phpbb_files_upload_test extends phpbb_test_case /** @var \phpbb\files\factory */ protected $factory; + /** @var \phpbb\php\ini */ + protected $php_ini; + /** @var \phpbb\language\language */ protected $language; @@ -49,10 +52,12 @@ class phpbb_files_upload_test extends phpbb_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->php_ini = new \phpbb\php\ini; $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec( $this->filesystem, + $this->php_ini, $this->language, $phpbb_root_path, new \phpbb\mimetype\guesser(array( @@ -66,7 +71,7 @@ class phpbb_files_upload_test extends phpbb_test_case public function test_reset_vars() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_max_filesize(500); $this->assertEquals(500, $upload->max_filesize); $upload->reset_vars(); @@ -75,7 +80,7 @@ class phpbb_files_upload_test extends phpbb_test_case public function test_set_disallowed_content() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $disallowed_content = new ReflectionProperty($upload, 'disallowed_content'); $disallowed_content->setAccessible(true); @@ -93,7 +98,7 @@ class phpbb_files_upload_test extends phpbb_test_case public function test_is_valid() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $this->assertFalse($upload->is_valid('foobar')); } @@ -116,7 +121,7 @@ class phpbb_files_upload_test extends phpbb_test_case */ public function test_assign_internal_error($error_code, $expected) { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $this->assertSame($expected, $upload->assign_internal_error($error_code)); } } diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 1a74b3b498..45c1e914c2 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -22,6 +22,9 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case /** @var \phpbb\files\factory */ protected $factory; + /** @var \phpbb\php\ini */ + protected $php_ini; + /** @var \phpbb\language\language */ protected $language; @@ -51,9 +54,10 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->request = $this->getMock('\phpbb\request\request'); + $this->php_ini = new \phpbb\php\ini; $container = new phpbb_mock_container_builder(); - $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path)); + $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->php_ini, $this->language, $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->request, $phpbb_root_path)); @@ -70,7 +74,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -81,7 +85,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_empty_file() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -92,7 +96,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_successful_upload() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(1000); @@ -105,7 +109,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_too_large() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 1ba473555f..8a9e53f30b 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -93,7 +93,7 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, new \phpbb\php\ini, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); return $filespec->set_upload_ary(array_merge($upload_ary, $override)); } @@ -114,7 +114,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_empty_upload_ary() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, new \phpbb\php\ini, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); $this->assertInstanceOf('\phpbb\files\filespec', $filespec->set_upload_ary(array())); $this->assertTrue($filespec->init_error()); } @@ -262,7 +262,7 @@ class phpbb_filespec_test extends phpbb_test_case */ public function test_clean_filename_avatar($filename, $expected, $mode, $prefix = '', $user_id = '') { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, new \phpbb\php\ini, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); if ($filename) { @@ -419,7 +419,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_is_uploaded() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, null); + $filespec = new \phpbb\files\filespec($this->filesystem, new \phpbb\php\ini, $this->language, $this->phpbb_root_path, null); $reflection_filespec = new ReflectionClass($filespec); $plupload_property = $reflection_filespec->getProperty('plupload'); $plupload_property->setAccessible(true); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index d1d8b55ff3..957fb47755 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -27,6 +27,9 @@ class phpbb_fileupload_test extends phpbb_test_case /** @var \phpbb\files\factory */ protected $factory; + /** @var \phpbb\php\ini */ + protected $php_ini; + /** @var \phpbb\language\language */ protected $language; @@ -50,6 +53,7 @@ class phpbb_fileupload_test extends phpbb_test_case $config['rand_seed_last_update'] = time() + 600; $this->request = $this->getMock('\phpbb\request\request'); + $this->php_ini = new \phpbb\php\ini; $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); @@ -66,13 +70,14 @@ class phpbb_fileupload_test extends phpbb_test_case $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec( $this->filesystem, + $this->php_ini, $this->language, $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), )))); $this->factory = new \phpbb\files\factory($this->container); - $plupload = new \phpbb\plupload\plupload($phpbb_root_path, $config, $this->request, new \phpbb\user($this->language, '\phpbb\datetime'), new \phpbb\php\ini(), $this->mimetype_guesser); + $plupload = new \phpbb\plupload\plupload($phpbb_root_path, $config, $this->request, new \phpbb\user($this->language, '\phpbb\datetime'), $this->php_ini, $this->mimetype_guesser); $this->container->set('files.types.form', new \phpbb\files\types\form( $this->factory, $this->language, @@ -111,7 +116,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -121,10 +126,10 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_disallowed_content() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); - $file = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path); + $file = new \phpbb\files\filespec($this->filesystem, $this->php_ini, $this->language, $this->phpbb_root_path); $file->set_upload_ary(array( 'size' => 50, 'tmp_name' => dirname(__FILE__) . '/fixture/disallowed', @@ -140,7 +145,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -151,7 +156,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -162,7 +167,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); $file = $this->gen_valid_filespec(); @@ -172,7 +177,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -186,7 +191,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -200,7 +205,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -215,7 +220,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(false) ->set_max_filesize(false) ->set_allowed_dimensions(1, 1, 100, 100); -- cgit v1.2.1 From 36545d5cbe7188efbedf2e1f44b1a7b9617b50c1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 26 Aug 2015 16:18:10 +0200 Subject: [ticket/13904] Switch around constructor arguments PHPBB3-13904 --- tests/files/upload_test.php | 10 +++++----- tests/functional/fileupload_remote_test.php | 10 +++++----- tests/upload/filespec_test.php | 8 ++++---- tests/upload/fileupload_test.php | 22 +++++++++++----------- 4 files changed, 25 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php index d11ebc742b..6f4a10e6aa 100644 --- a/tests/files/upload_test.php +++ b/tests/files/upload_test.php @@ -57,8 +57,8 @@ class phpbb_files_upload_test extends phpbb_test_case $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec( $this->filesystem, - $this->php_ini, $this->language, + $this->php_ini, $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), @@ -71,7 +71,7 @@ class phpbb_files_upload_test extends phpbb_test_case public function test_reset_vars() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_max_filesize(500); $this->assertEquals(500, $upload->max_filesize); $upload->reset_vars(); @@ -80,7 +80,7 @@ class phpbb_files_upload_test extends phpbb_test_case public function test_set_disallowed_content() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $disallowed_content = new ReflectionProperty($upload, 'disallowed_content'); $disallowed_content->setAccessible(true); @@ -98,7 +98,7 @@ class phpbb_files_upload_test extends phpbb_test_case public function test_is_valid() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $this->assertFalse($upload->is_valid('foobar')); } @@ -121,7 +121,7 @@ class phpbb_files_upload_test extends phpbb_test_case */ public function test_assign_internal_error($error_code, $expected) { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $this->assertSame($expected, $upload->assign_internal_error($error_code)); } } diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 45c1e914c2..4fd8ae1f19 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -57,7 +57,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->php_ini = new \phpbb\php\ini; $container = new phpbb_mock_container_builder(); - $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->php_ini, $this->language, $this->phpbb_root_path)); + $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->request, $phpbb_root_path)); @@ -74,7 +74,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -85,7 +85,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_empty_file() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -96,7 +96,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_successful_upload() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(1000); @@ -109,7 +109,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_too_large() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 8a9e53f30b..595439c917 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -93,7 +93,7 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - $filespec = new \phpbb\files\filespec($this->filesystem, new \phpbb\php\ini, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser); return $filespec->set_upload_ary(array_merge($upload_ary, $override)); } @@ -114,7 +114,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_empty_upload_ary() { - $filespec = new \phpbb\files\filespec($this->filesystem, new \phpbb\php\ini, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser); $this->assertInstanceOf('\phpbb\files\filespec', $filespec->set_upload_ary(array())); $this->assertTrue($filespec->init_error()); } @@ -262,7 +262,7 @@ class phpbb_filespec_test extends phpbb_test_case */ public function test_clean_filename_avatar($filename, $expected, $mode, $prefix = '', $user_id = '') { - $filespec = new \phpbb\files\filespec($this->filesystem, new \phpbb\php\ini, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser); if ($filename) { @@ -419,7 +419,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_is_uploaded() { - $filespec = new \phpbb\files\filespec($this->filesystem, new \phpbb\php\ini, $this->language, $this->phpbb_root_path, null); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, null); $reflection_filespec = new ReflectionClass($filespec); $plupload_property = $reflection_filespec->getProperty('plupload'); $plupload_property->setAccessible(true); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 957fb47755..40f8704271 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -70,8 +70,8 @@ class phpbb_fileupload_test extends phpbb_test_case $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec( $this->filesystem, - $this->php_ini, $this->language, + $this->php_ini, $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), @@ -116,7 +116,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -126,10 +126,10 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_disallowed_content() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); - $file = new \phpbb\files\filespec($this->filesystem, $this->php_ini, $this->language, $this->phpbb_root_path); + $file = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, $this->phpbb_root_path); $file->set_upload_ary(array( 'size' => 50, 'tmp_name' => dirname(__FILE__) . '/fixture/disallowed', @@ -145,7 +145,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -156,7 +156,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -167,7 +167,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); $file = $this->gen_valid_filespec(); @@ -177,7 +177,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -191,7 +191,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -205,7 +205,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -220,7 +220,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->php_ini, $this->language, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(false) ->set_max_filesize(false) ->set_allowed_dimensions(1, 1, 100, 100); -- cgit v1.2.1 From 16f3b8c2b9de388223cbe8ace9e1d9bcf0ba5e11 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 27 Aug 2015 10:51:10 +0200 Subject: [ticket/13904] Modify files for changes in ini wrapper PHPBB3-13904 --- tests/cache/apc_driver_test.php | 6 ++-- tests/files/upload_test.php | 4 +-- tests/functional/fileupload_remote_test.php | 4 +-- tests/installer/installer_config_test.php | 6 ++-- tests/installer/module_base_test.php | 2 +- tests/plupload/plupload_test.php | 2 +- tests/upload/filespec_test.php | 8 ++--- tests/upload/fileupload_test.php | 4 +-- tests/wrapper/phpbb_php_ini_fake.php | 2 +- tests/wrapper/phpbb_php_ini_test.php | 46 +++++++++++++---------------- 10 files changed, 39 insertions(+), 45 deletions(-) (limited to 'tests') diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php index 10130b465b..706f274448 100644 --- a/tests/cache/apc_driver_test.php +++ b/tests/cache/apc_driver_test.php @@ -34,14 +34,14 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case self::markTestSkipped('APC extension is not loaded'); } - $php_ini = new \phpbb\php\ini; + $php_ini = new \bantu\IniGetWrapper\IniGetWrapper; - if (!$php_ini->get_bool('apc.enabled')) + if (!$php_ini->getBool('apc.enabled')) { self::markTestSkipped('APC is not enabled. Make sure apc.enabled=1 in php.ini'); } - if (PHP_SAPI == 'cli' && !$php_ini->get_bool('apc.enable_cli')) + if (PHP_SAPI == 'cli' && !$php_ini->getBool('apc.enable_cli')) { self::markTestSkipped('APC is not enabled for CLI. Set apc.enable_cli=1 in php.ini'); } diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php index 6f4a10e6aa..da9d78afbc 100644 --- a/tests/files/upload_test.php +++ b/tests/files/upload_test.php @@ -23,7 +23,7 @@ class phpbb_files_upload_test extends phpbb_test_case /** @var \phpbb\files\factory */ protected $factory; - /** @var \phpbb\php\ini */ + /** @var \bantu\IniGetWrapper\IniGetWrapper */ protected $php_ini; /** @var \phpbb\language\language */ @@ -52,7 +52,7 @@ class phpbb_files_upload_test extends phpbb_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); - $this->php_ini = new \phpbb\php\ini; + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec( diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 4fd8ae1f19..6752ff01f4 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -22,7 +22,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case /** @var \phpbb\files\factory */ protected $factory; - /** @var \phpbb\php\ini */ + /** @var \bantu\IniGetWrapper\IniGetWrapper */ protected $php_ini; /** @var \phpbb\language\language */ @@ -54,7 +54,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->request = $this->getMock('\phpbb\request\request'); - $this->php_ini = new \phpbb\php\ini; + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $container = new phpbb_mock_container_builder(); $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, $this->phpbb_root_path)); diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php index c7334ebd93..7de23aea36 100644 --- a/tests/installer/installer_config_test.php +++ b/tests/installer/installer_config_test.php @@ -24,11 +24,11 @@ class phpbb_installer_config_test extends phpbb_test_case { $phpbb_root_path = __DIR__ . './../../phpBB/'; $filesystem = $this->getMock('\phpbb\filesystem\filesystem'); - $php_ini = $this->getMockBuilder('\phpbb\php\ini') + $php_ini = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper') ->getMock(); - $php_ini->method('get_int') + $php_ini->method('getInt') ->willReturn(-1); - $php_ini->method('get_bytes') + $php_ini->method('getBytes') ->willReturn(-1); $this->config = new config($filesystem, $php_ini, $phpbb_root_path); diff --git a/tests/installer/module_base_test.php b/tests/installer/module_base_test.php index fd92c9b674..9578010047 100644 --- a/tests/installer/module_base_test.php +++ b/tests/installer/module_base_test.php @@ -43,7 +43,7 @@ class module_base_test extends phpbb_test_case $this->module = new test_installer_module($module_collection, true, false); $iohandler = $this->getMock('\phpbb\install\helper\iohandler\iohandler_interface'); - $config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \phpbb\php\ini(), '', 'php'); + $config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \bantu\IniGetWrapper\IniGetWrapper(), '', 'php'); $this->module->setup($config, $iohandler); } diff --git a/tests/plupload/plupload_test.php b/tests/plupload/plupload_test.php index aa7793567d..3312f4d0a0 100644 --- a/tests/plupload/plupload_test.php +++ b/tests/plupload/plupload_test.php @@ -48,7 +48,7 @@ class phpbb_plupload_test extends phpbb_test_case $config, new phpbb_mock_request, new \phpbb\user($lang, '\phpbb\datetime'), - new \phpbb\php\ini, + new \bantu\IniGetWrapper\IniGetWrapper, new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)) ); diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 595439c917..a53c27f045 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -93,7 +93,7 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser); return $filespec->set_upload_ary(array_merge($upload_ary, $override)); } @@ -114,7 +114,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_empty_upload_ary() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser); $this->assertInstanceOf('\phpbb\files\filespec', $filespec->set_upload_ary(array())); $this->assertTrue($filespec->init_error()); } @@ -262,7 +262,7 @@ class phpbb_filespec_test extends phpbb_test_case */ public function test_clean_filename_avatar($filename, $expected, $mode, $prefix = '', $user_id = '') { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser); if ($filename) { @@ -419,7 +419,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_is_uploaded() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, null); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, null); $reflection_filespec = new ReflectionClass($filespec); $plupload_property = $reflection_filespec->getProperty('plupload'); $plupload_property->setAccessible(true); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 40f8704271..43106599e4 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -27,7 +27,7 @@ class phpbb_fileupload_test extends phpbb_test_case /** @var \phpbb\files\factory */ protected $factory; - /** @var \phpbb\php\ini */ + /** @var \bantu\IniGetWrapper\IniGetWrapper */ protected $php_ini; /** @var \phpbb\language\language */ @@ -53,7 +53,7 @@ class phpbb_fileupload_test extends phpbb_test_case $config['rand_seed_last_update'] = time() + 600; $this->request = $this->getMock('\phpbb\request\request'); - $this->php_ini = new \phpbb\php\ini; + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); diff --git a/tests/wrapper/phpbb_php_ini_fake.php b/tests/wrapper/phpbb_php_ini_fake.php index f218ff6d03..300ce30cfe 100644 --- a/tests/wrapper/phpbb_php_ini_fake.php +++ b/tests/wrapper/phpbb_php_ini_fake.php @@ -11,7 +11,7 @@ * */ -class phpbb_php_ini_fake extends \phpbb\php\ini +class phpbb_php_ini_fake extends \bantu\IniGetWrapper\IniGetWrapper { function get($varname) { diff --git a/tests/wrapper/phpbb_php_ini_test.php b/tests/wrapper/phpbb_php_ini_test.php index 27c2487f0a..8ef63757a5 100644 --- a/tests/wrapper/phpbb_php_ini_test.php +++ b/tests/wrapper/phpbb_php_ini_test.php @@ -16,6 +16,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case { + /** @var \phpbb_php_ini_fake php_ini */ protected $php_ini; public function setUp() @@ -25,44 +26,37 @@ class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case public function test_get_string() { - $this->assertSame(false, $this->php_ini->get_string(false)); - $this->assertSame('phpbb', $this->php_ini->get_string(' phpbb ')); + $this->assertSame('', $this->php_ini->getString(false)); + $this->assertSame('phpbb', $this->php_ini->getString(' phpbb ')); } public function test_get_bool() { - $this->assertSame(true, $this->php_ini->get_bool('ON')); - $this->assertSame(true, $this->php_ini->get_bool('on')); - $this->assertSame(true, $this->php_ini->get_bool('1')); + $this->assertSame(true, $this->php_ini->getBool('ON')); + $this->assertSame(true, $this->php_ini->getBool('on')); + $this->assertSame(true, $this->php_ini->getBool('1')); - $this->assertSame(false, $this->php_ini->get_bool('OFF')); - $this->assertSame(false, $this->php_ini->get_bool('off')); - $this->assertSame(false, $this->php_ini->get_bool('0')); - $this->assertSame(false, $this->php_ini->get_bool('')); + $this->assertSame(false, $this->php_ini->getBool('OFF')); + $this->assertSame(false, $this->php_ini->getBool('off')); + $this->assertSame(false, $this->php_ini->getBool('0')); + $this->assertSame(false, $this->php_ini->getBool('')); } public function test_get_int() { - $this->assertSame(1234, $this->php_ini->get_int('1234')); - $this->assertSame(-12345, $this->php_ini->get_int('-12345')); - $this->assertSame(false, $this->php_ini->get_int('phpBB')); - } - - public function test_get_float() - { - $this->assertSame(1234.0, $this->php_ini->get_float('1234')); - $this->assertSame(-12345.0, $this->php_ini->get_float('-12345')); - $this->assertSame(false, $this->php_ini->get_float('phpBB')); + $this->assertSame(1234, $this->php_ini->getNumeric('1234')); + $this->assertSame(-12345, $this->php_ini->getNumeric('-12345')); + $this->assertSame(null, $this->php_ini->getNumeric('phpBB')); } public function test_get_bytes_invalid() { - $this->assertSame(false, $this->php_ini->get_bytes(false)); - $this->assertSame(false, $this->php_ini->get_bytes('phpBB')); - $this->assertSame(false, $this->php_ini->get_bytes('k')); - $this->assertSame(false, $this->php_ini->get_bytes('-k')); - $this->assertSame(false, $this->php_ini->get_bytes('M')); - $this->assertSame(false, $this->php_ini->get_bytes('-M')); + $this->assertSame(null, $this->php_ini->getBytes(false)); + $this->assertSame(null, $this->php_ini->getBytes('phpBB')); + $this->assertSame(null, $this->php_ini->getBytes('k')); + $this->assertSame(null, $this->php_ini->getBytes('-k')); + $this->assertSame(null, $this->php_ini->getBytes('M')); + $this->assertSame(null, $this->php_ini->getBytes('-M')); } /** @@ -70,7 +64,7 @@ class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case */ public function test_get_bytes($expected, $value) { - $actual = $this->php_ini->get_bytes($value); + $actual = $this->php_ini->getBytes($value); $this->assertTrue(is_float($actual) || is_int($actual)); $this->assertEquals($expected, $actual); -- cgit v1.2.1 From b29b62debe4077ec688ebee9e9363db2c8614dd5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 27 Aug 2015 12:48:06 +0200 Subject: [ticket/13904] Use ini_get() wrapper in file upload types PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 2 +- tests/upload/fileupload_test.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 6752ff01f4..29701e072a 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -60,7 +60,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); - $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->request, $phpbb_root_path)); + $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path)); $this->phpbb_root_path = $phpbb_root_path; } diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 43106599e4..8675567e22 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -81,12 +81,14 @@ class phpbb_fileupload_test extends phpbb_test_case $this->container->set('files.types.form', new \phpbb\files\types\form( $this->factory, $this->language, + $this->php_ini, $plupload, $this->request ), phpbb_mock_container_builder::SCOPE_PROTOTYPE); $this->container->set('files.types.local', new \phpbb\files\types\local( $this->factory, $this->language, + $this->php_ini, $this->request ), phpbb_mock_container_builder::SCOPE_PROTOTYPE); -- cgit v1.2.1 From c3ccd423d2a6f3aab1183b22177df6f605f33371 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 1 Sep 2015 10:58:35 +0200 Subject: [ticket/13904] Add back tests for retrieving floats PHPBB3-13904 --- tests/wrapper/phpbb_php_ini_test.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/wrapper/phpbb_php_ini_test.php b/tests/wrapper/phpbb_php_ini_test.php index 8ef63757a5..9f46a78d5b 100644 --- a/tests/wrapper/phpbb_php_ini_test.php +++ b/tests/wrapper/phpbb_php_ini_test.php @@ -49,6 +49,13 @@ class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case $this->assertSame(null, $this->php_ini->getNumeric('phpBB')); } + public function test_get_float() + { + $this->assertSame(1234.0, $this->php_ini->getNumeric('1234.0')); + $this->assertSame(-12345.0, $this->php_ini->getNumeric('-12345.0')); + $this->assertSame(null, $this->php_ini->getNumeric('phpBB')); + } + public function test_get_bytes_invalid() { $this->assertSame(null, $this->php_ini->getBytes(false)); -- cgit v1.2.1 From 591995267a3f1931131fa630bd3ff120476f881f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Sep 2015 17:20:54 +0200 Subject: [ticket/13904] Improve test coverage of filespec class PHPBB3-13904 --- tests/files/upload_test.php | 1 + tests/functional/fileupload_remote_test.php | 2 +- tests/upload/filespec_test.php | 119 +++++++++++++++++++++++++++- tests/upload/fileupload_test.php | 3 +- 4 files changed, 119 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php index da9d78afbc..0d02926702 100644 --- a/tests/files/upload_test.php +++ b/tests/files/upload_test.php @@ -59,6 +59,7 @@ class phpbb_files_upload_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, + new \fastImageSize\fastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 29701e072a..1484acc4d5 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -57,7 +57,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $container = new phpbb_mock_container_builder(); - $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, $this->phpbb_root_path)); + $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \fastImageSize\fastImageSize(), $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path)); diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index a53c27f045..10a442cd1d 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -93,7 +93,7 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \fastImageSize\fastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser); return $filespec->set_upload_ary(array_merge($upload_ary, $override)); } @@ -114,7 +114,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_empty_upload_ary() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \fastImageSize\fastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser); $this->assertInstanceOf('\phpbb\files\filespec', $filespec->set_upload_ary(array())); $this->assertTrue($filespec->init_error()); } @@ -262,7 +262,7 @@ class phpbb_filespec_test extends phpbb_test_case */ public function test_clean_filename_avatar($filename, $expected, $mode, $prefix = '', $user_id = '') { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \fastImageSize\fastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser); if ($filename) { @@ -403,6 +403,117 @@ class phpbb_filespec_test extends phpbb_test_case $this->assertFalse($filespec->move_file('foo')); } + public function data_move_file_copy() + { + return array( + array('gif_copy', true, false, array()), + array('gif_copy', true, true, array()), + array('foo_bar', false, false, array('GENERAL_UPLOAD_ERROR')), + array('foo_bar', false, true, array('GENERAL_UPLOAD_ERROR')), + ); + } + + /** + * @dataProvider data_move_file_copy + */ + public function test_move_file_copy($tmp_name, $move_success, $safe_mode_on, $expected_error) + { + // Initialise a blank filespec object for use with trivial methods + $upload_ary = array( + 'name' => 'gif_moved', + 'type' => 'image/gif', + 'size' => '', + 'tmp_name' => $this->path . 'copies/' . $tmp_name, + 'error' => '', + ); + + $php_ini = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper') + ->getMock(); + $php_ini->expects($this->any()) + ->method('getBool') + ->with($this->anything()) + ->willReturn($safe_mode_on); + $upload = new phpbb_mock_fileupload(); + $upload->max_filesize = self::UPLOAD_MAX_FILESIZE; + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $php_ini, new \fastImageSize\fastImagesize, '', $this->mimetype_guesser); + $filespec->set_upload_ary($upload_ary); + $filespec->local = false; + $filespec->extension = 'gif'; + $filespec->set_upload_namespace($upload); + + $this->assertEquals($move_success, $filespec->move_file($this->path . 'copies')); + $this->assertEquals($filespec->file_moved, file_exists($this->path . 'copies/gif_moved')); + $this->assertSame($expected_error, $filespec->error); + } + + public function data_move_file_imagesize() + { + return array( + array( + array( + 'width' => 2, + 'height' => 2, + 'type' => IMAGETYPE_GIF, + ), + array() + ), + array( + array( + 'width' => 2, + 'height' => 2, + 'type' => -1, + ), + array('Image file type -1 for mimetype image/gif not supported.') + ), + array( + array( + 'width' => 0, + 'height' => 0, + 'type' => IMAGETYPE_GIF, + ), + array('The image file you tried to attach is invalid.') + ), + array( + false, + array('It was not possible to determine the dimensions of the image. Please verify that the URL you entered is correct.') + ) + ); + } + + /** + * @dataProvider data_move_file_imagesize + */ + public function test_move_file_imagesize($imagesize_return, $expected_error) + { + // Initialise a blank filespec object for use with trivial methods + $upload_ary = array( + 'name' => 'gif_moved', + 'type' => 'image/gif', + 'size' => '', + 'tmp_name' => $this->path . 'copies/gif_copy', + 'error' => '', + ); + + $imagesize = $this->getMockBuilder('\fastImageSize\fastImageSize') + ->getMock(); + $imagesize->expects($this->any()) + ->method('getImageSize') + ->with($this->anything()) + ->willReturn($imagesize_return); + + $upload = new phpbb_mock_fileupload(); + $upload->max_filesize = self::UPLOAD_MAX_FILESIZE; + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $imagesize, '', $this->mimetype_guesser); + $filespec->set_upload_ary($upload_ary); + $filespec->local = false; + $filespec->extension = 'gif'; + $filespec->set_upload_namespace($upload); + + $this->assertEquals(true, $filespec->move_file($this->path . 'copies')); + $this->assertEquals($filespec->file_moved, file_exists($this->path . 'copies/gif_moved')); + $this->assertSame($expected_error, $filespec->error); + } + /** * @dataProvider clean_filename_variables */ @@ -419,7 +530,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_is_uploaded() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, null); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \fastImageSize\fastImageSize(), $this->phpbb_root_path, null); $reflection_filespec = new ReflectionClass($filespec); $plupload_property = $reflection_filespec->getProperty('plupload'); $plupload_property->setAccessible(true); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 8675567e22..bb3092528b 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -72,6 +72,7 @@ class phpbb_fileupload_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, + new \fastImageSize\fastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), @@ -131,7 +132,7 @@ class phpbb_fileupload_test extends phpbb_test_case $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); - $file = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, $this->phpbb_root_path); + $file = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \fastImageSize\fastImageSize(), $this->phpbb_root_path); $file->set_upload_ary(array( 'size' => 50, 'tmp_name' => dirname(__FILE__) . '/fixture/disallowed', -- cgit v1.2.1 From 1b9e6e352fd4a78e195d22a7dad6cd4f8f11d97c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Sep 2015 11:34:42 +0200 Subject: [ticket/13904] Improve test coverage of form upload type PHPBB3-13904 --- tests/files/types_form_test.php | 174 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 tests/files/types_form_test.php (limited to 'tests') diff --git a/tests/files/types_form_test.php b/tests/files/types_form_test.php new file mode 100644 index 0000000000..51219f7b4e --- /dev/null +++ b/tests/files/types_form_test.php @@ -0,0 +1,174 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_files_types_form_test extends phpbb_test_case +{ + private $path; + + private $filesystem; + + /** @var \Symfony\Component\DependencyInjection\ContainerInterface */ + protected $container; + + /** @var \phpbb\files\factory */ + protected $factory; + + /** @var \bantu\IniGetWrapper\IniGetWrapper */ + protected $php_ini; + + /** @var \phpbb\language\language */ + protected $language; + + /** @var \phpbb\request\request_interface */ + protected $request; + + /** @var \phpbb\plupload\plupload */ + protected $plupload; + + /** @var string phpBB root path */ + protected $phpbb_root_path; + + protected function setUp() + { + global $phpbb_root_path, $phpEx; + + $this->request = $this->getMock('\phpbb\request\request'); + $this->request->expects($this->any()) + ->method('file') + ->willReturn(array()); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; + + $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); + $this->container->set('files.filespec', new \phpbb\files\filespec( + $this->filesystem, + $this->language, + $this->php_ini, + new \fastImageSize\fastImageSize(), + $phpbb_root_path, + new \phpbb\mimetype\guesser(array( + 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), + )))); + $this->factory = new \phpbb\files\factory($this->container); + $this->plupload = $this->getMockBuilder('\phpbb\plupload\plupload') + ->disableOriginalConstructor() + ->getMock(); + $this->plupload->expects($this->any()) + ->method('handle_upload') + ->willReturn(array()); + + $this->path = __DIR__ . '/fixture/'; + $this->phpbb_root_path = $phpbb_root_path; + } + + public function data_upload_form() + { + return array( + array( + array(), + array(''), + ), + array( + array( + 'tmp_name' => 'foo', + 'name' => 'foo', + 'size' => 500, + 'type' => 'image/png', + 'error' => UPLOAD_ERR_PARTIAL, + ), + array('PARTIAL_UPLOAD'), + ), + array( + array( + 'tmp_name' => 'foo', + 'name' => 'foo', + 'size' => 500, + 'type' => 'image/png', + 'error' => -9, + ), + array('NOT_UPLOADED'), + ), + array( + array( + 'tmp_name' => 'foo', + 'name' => 'foo', + 'size' => 0, + 'type' => 'image/png', + ), + array('EMPTY_FILEUPLOAD'), + ), + array( + array( + 'tmp_name' => 'none', + 'name' => 'none', + 'size' => 50, + 'type' => 'image/png', + ), + array('PHP_SIZE_OVERRUN'), + ), + array( + array( + 'tmp_name' => 'tests/upload/fixture/png', + 'name' => 'foo.png', + 'size' => 500, + 'type' => 'image/png', + 'local_mode' => true, + ), + array(), + array('local_mode' => true), + ), + ); + } + + /** + * @dataProvider data_upload_form + */ + public function test_upload_form($upload, $expected, $plupload = array()) + { + $this->request = $this->getMock('\phpbb\request\request'); + $this->request->expects($this->any()) + ->method('file') + ->willReturn($upload); + $filespec = new \phpbb\files\filespec( + $this->filesystem, + $this->language, + $this->php_ini, + new \fastImageSize\fastImageSize(), + $this->phpbb_root_path, + new \phpbb\mimetype\guesser(array( + 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), + ))); + $this->container->set('files.filespec', $filespec); + $this->factory = new \phpbb\files\factory($this->container); + $this->plupload = $this->getMockBuilder('\phpbb\plupload\plupload') + ->disableOriginalConstructor() + ->getMock(); + $this->plupload->expects($this->any()) + ->method('handle_upload') + ->willReturn($plupload); + + $type_form = new \phpbb\files\types\form($this->factory, $this->language, $this->php_ini, $this->plupload, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $upload->set_allowed_extensions(array('png')); + $type_form->set_upload($upload); + + + $file = $type_form->upload('foobar'); + $this->assertSame($expected, $file->error); + $this->assertInstanceOf('\phpbb\files\filespec', $file); + } +} -- cgit v1.2.1 From 82bca32015b94b140b7c810fc5d7e721e8ee341f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Sep 2015 11:35:12 +0200 Subject: [ticket/13904] Improve test coverage of remote upload type PHPBB3-13904 --- tests/files/types_remote_test.php | 77 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tests/files/types_remote_test.php (limited to 'tests') diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php new file mode 100644 index 0000000000..405a8c4104 --- /dev/null +++ b/tests/files/types_remote_test.php @@ -0,0 +1,77 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_files_types_remote_test extends phpbb_test_case +{ + private $path; + + private $filesystem; + + /** @var \Symfony\Component\DependencyInjection\ContainerInterface */ + protected $container; + + /** @var \phpbb\files\factory */ + protected $factory; + + /** @var \bantu\IniGetWrapper\IniGetWrapper */ + protected $php_ini; + + /** @var \phpbb\language\language */ + protected $language; + + /** @var \phpbb\request\request_interface */ + protected $request; + + /** @var string phpBB root path */ + protected $phpbb_root_path; + + protected function setUp() + { + global $phpbb_root_path, $phpEx; + + $this->request = $this->getMock('\phpbb\request\request'); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; + + $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); + $this->container->set('files.filespec', new \phpbb\files\filespec( + $this->filesystem, + $this->language, + $this->php_ini, + new \fastImageSize\fastImageSize(), + $phpbb_root_path, + new \phpbb\mimetype\guesser(array( + 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), + )))); + $this->factory = new \phpbb\files\factory($this->container); + + $this->path = __DIR__ . '/fixture/'; + $this->phpbb_root_path = $phpbb_root_path; + } + + public function test_upload_fsock_fail() + { + $type_remote = new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $upload->set_allowed_extensions(array('png')); + $type_remote->set_upload($upload); + + $file = $type_remote->upload('https://bärföö.com/foo.png'); + + $this->assertSame(array('NOT_UPLOADED'), $file->error); + } +} -- cgit v1.2.1 From e5bffbf40ff59614cea1b5f3f662d91cf8e63323 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Sep 2015 11:35:31 +0200 Subject: [ticket/13904] Improve test coverage of base upload type class PHPBB3-13904 --- tests/files/types_base_test.php | 93 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 tests/files/types_base_test.php (limited to 'tests') diff --git a/tests/files/types_base_test.php b/tests/files/types_base_test.php new file mode 100644 index 0000000000..dc82ee2639 --- /dev/null +++ b/tests/files/types_base_test.php @@ -0,0 +1,93 @@ + + * @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_files_types_base_test extends phpbb_test_case +{ + private $path; + + private $filesystem; + + /** @var \Symfony\Component\DependencyInjection\ContainerInterface */ + protected $container; + + /** @var \phpbb\files\factory */ + protected $factory; + + /** @var \bantu\IniGetWrapper\IniGetWrapper */ + protected $php_ini; + + /** @var \phpbb\language\language */ + protected $language; + + /** @var \phpbb\request\request_interface */ + protected $request; + + /** @var string phpBB root path */ + protected $phpbb_root_path; + + protected function setUp() + { + global $phpbb_root_path, $phpEx; + + $this->request = $this->getMock('\phpbb\request\request'); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; + + $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); + $this->container->set('files.filespec', new \phpbb\files\filespec( + $this->filesystem, + $this->language, + $this->php_ini, + new \fastImageSize\fastImageSize(), + $phpbb_root_path, + new \phpbb\mimetype\guesser(array( + 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), + )))); + $this->factory = new \phpbb\files\factory($this->container); + + $this->path = __DIR__ . '/fixture/'; + $this->phpbb_root_path = $phpbb_root_path; + } + + public function data_check_upload_size() + { + return array( + array('foo', '500KB', array()), + array('none', '500KB', array('PHP_SIZE_OVERRUN')), + array('none', '', array('PHP_SIZE_NA')), + ); + } + + /** + * @dataProvider data_check_upload_size + */ + public function test_check_upload_size($filename, $max_filesize, $expected) + { + $php_ini = $this->getMock('\bantu\IniGetWrapper\IniGetWrapper'); + $php_ini->expects($this->any()) + ->method('getString') + ->willReturn($max_filesize); + $type_form = new \phpbb\files\types\local($this->factory, $this->language, $php_ini, $this->request); + $file = $this->getMockBuilder('\phpbb\files\filespec') + ->disableOriginalConstructor() + ->getMock(); + $file->expects($this->any()) + ->method('get') + ->willReturn($filename); + $type_form->check_upload_size($file); + + $this->assertSame($expected, $file->error); + } +} -- cgit v1.2.1 From 00e5ff9e2e9c0dd7325f33a22888d6888af4b197 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Sep 2015 22:51:44 +0200 Subject: [ticket/13904] Add unit tests for local upload type PHPBB3-13904 --- tests/files/types_local_test.php | 161 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 tests/files/types_local_test.php (limited to 'tests') diff --git a/tests/files/types_local_test.php b/tests/files/types_local_test.php new file mode 100644 index 0000000000..8712c9cd5a --- /dev/null +++ b/tests/files/types_local_test.php @@ -0,0 +1,161 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_files_types_local_test extends phpbb_test_case +{ + private $path; + + private $filesystem; + + /** @var \Symfony\Component\DependencyInjection\ContainerInterface */ + protected $container; + + /** @var \phpbb\files\factory */ + protected $factory; + + /** @var \bantu\IniGetWrapper\IniGetWrapper */ + protected $php_ini; + + /** @var \phpbb\language\language */ + protected $language; + + /** @var \phpbb\request\request_interface */ + protected $request; + + /** @var \phpbb\plupload\plupload */ + protected $plupload; + + /** @var string phpBB root path */ + protected $phpbb_root_path; + + protected function setUp() + { + global $phpbb_root_path, $phpEx; + + $this->request = $this->getMock('\phpbb\request\request'); + $this->request->expects($this->any()) + ->method('file') + ->willReturn(array()); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; + + $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); + $this->container->set('files.filespec', new \phpbb\files\filespec( + $this->filesystem, + $this->language, + $this->php_ini, + new \fastImageSize\fastImageSize(), + $phpbb_root_path, + new \phpbb\mimetype\guesser(array( + 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), + )))); + $this->factory = new \phpbb\files\factory($this->container); + $this->plupload = $this->getMockBuilder('\phpbb\plupload\plupload') + ->disableOriginalConstructor() + ->getMock(); + $this->plupload->expects($this->any()) + ->method('handle_upload') + ->willReturn(array()); + + $this->path = __DIR__ . '/fixture/'; + $this->phpbb_root_path = $phpbb_root_path; + } + + public function test_upload_init_error() + { + $filespec = $this->getMockBuilder('\phpbb\files\filespec') + ->disableOriginalConstructor() + ->getMock(); + $filespec->expects($this->any()) + ->method('init_error') + ->willReturn(true); + $filespec->expects($this->any()) + ->method('set_upload_ary') + ->willReturnSelf(); + $filespec->expects($this->any()) + ->method('set_upload_namespace') + ->willReturnSelf(); + $this->container->set('files.filespec', $filespec); + $this->factory = new \phpbb\files\factory($this->container); + + $type_local = new \phpbb\files\types\local($this->factory, $this->language, $this->php_ini, $this->request); + + + $file = $type_local->upload('foo', false); + $this->assertSame(array(''), $file->error); + $this->assertInstanceOf('\phpbb\files\filespec', $file); + } + + public function data_upload_form() + { + return array( + array( + 'foo', + array( + 'tmp_name' => 'foo', + 'size' => 500, + 'type' => 'image/png', + ), + array('NOT_UPLOADED'), + ), + array( + 'none', + false, + array('PHP_SIZE_OVERRUN'), + ), + array( + 'tests/upload/fixture/png', + array( + 'realname' => 'foo.png', + 'size' => 500, + 'type' => 'image/png', + 'local_mode' => true, + ), + array(), + ), + ); + } + + /** + * @dataProvider data_upload_form + */ + public function test_upload_form($filename, $upload_ary, $expected) + { + $filespec = new \phpbb\files\filespec( + $this->filesystem, + $this->language, + $this->php_ini, + new \fastImageSize\fastImageSize(), + $this->phpbb_root_path, + new \phpbb\mimetype\guesser(array( + 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), + ))); + $filespec->local = true; + $this->container->set('files.filespec', $filespec); + $this->factory = new \phpbb\files\factory($this->container); + + $type_local = new \phpbb\files\types\local($this->factory, $this->language, $this->php_ini, $this->request); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $upload->set_allowed_extensions(array('png')); + $type_local->set_upload($upload); + + + $file = $type_local->upload($filename, $upload_ary); + $this->assertSame($expected, $file->error); + $this->assertInstanceOf('\phpbb\files\filespec', $file); + } +} -- cgit v1.2.1 From e60c8a5a8bfa1aa500c096ea90cd32fda9465f9a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Sep 2015 22:52:20 +0200 Subject: [ticket/13904] Improve code coverage PHPBB3-13904 --- tests/files/type_foo.php | 31 ++++++++++++++++++ tests/files/types_remote_test.php | 66 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 tests/files/type_foo.php (limited to 'tests') diff --git a/tests/files/type_foo.php b/tests/files/type_foo.php new file mode 100644 index 0000000000..20eddfcbc4 --- /dev/null +++ b/tests/files/type_foo.php @@ -0,0 +1,31 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\files\types; + +class foo extends \phpbb\files\types\remote +{ + static public $tempnam_path; +} + +function tempnam($one, $two) +{ + if (empty(foo::$tempnam_path)) + { + return \tempnam($one, $two); + } + else + { + return foo::$tempnam_path; + } +} diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index 405a8c4104..6d513ac5c0 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -12,6 +12,7 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/type_foo.php'; class phpbb_files_types_remote_test extends phpbb_test_case { @@ -39,8 +40,9 @@ class phpbb_files_types_remote_test extends phpbb_test_case protected function setUp() { - global $phpbb_root_path, $phpEx; + global $config, $phpbb_root_path, $phpEx; + $config = new \phpbb\config\config(array()); $this->request = $this->getMock('\phpbb\request\request'); $this->filesystem = new \phpbb\filesystem\filesystem(); @@ -74,4 +76,66 @@ class phpbb_files_types_remote_test extends phpbb_test_case $this->assertSame(array('NOT_UPLOADED'), $file->error); } + + public function data_get_max_file_size() + { + return array( + array('', 'http://example.com/foo/bar.png'), + array('2k', 'http://example.com/foo/bar.png'), + array('500k', 'http://example.com/foo/bar.png'), + array('500M', 'http://example.com/foo/bar.png'), + array('500m', 'http://example.com/foo/bar.png'), + array('500k', 'http://google.com/.png', 'DISALLOWED_CONTENT'), + array('1', 'http://google.com/.png', 'WRONG_FILESIZE'), + array('500g', 'http://example.com/foo/bar.png'), + array('foobar', 'http://example.com/foo/bar.png'), + array('-5k', 'http://example.com/foo/bar.png'), + ); + } + + /** + * @dataProvider data_get_max_file_size + */ + public function test_get_max_file_size($max_file_size, $link, $expected = 'URL_NOT_FOUND') + { + $php_ini = $this->getMock('\bantu\IniGetWrapper\IniGetWrapper', array('getString')); + $php_ini->expects($this->any()) + ->method('getString') + ->willReturn($max_file_size); + $type_remote = new \phpbb\files\types\remote($this->factory, $this->language, $php_ini, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $upload->set_allowed_extensions(array('png')); + $type_remote->set_upload($upload); + + $file = $type_remote->upload($link); + + $this->assertSame(array($expected), $file->error); + } + + public function test_upload_timeout() + { + $type_remote = new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $upload->set_allowed_extensions(array('png')); + $type_remote->set_upload($upload); + $upload->upload_timeout = -5; + + $file = $type_remote->upload('http://google.com/.png'); + + $this->assertSame(array('REMOTE_UPLOAD_TIMEOUT'), $file->error); + } + + public function test_upload_wrong_path() + { + $type_remote = new \phpbb\files\types\foo($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $upload->set_allowed_extensions(array('png')); + $type_remote->set_upload($upload); + $type_remote::$tempnam_path = $this->phpbb_root_path . 'cache/wrong/path'; + + $file = $type_remote->upload('http://google.com/.png'); + + $this->assertSame(array('NOT_UPLOADED'), $file->error); + $type_remote::$tempnam_path = ''; + } } -- cgit v1.2.1 From 327e36a4d68ff9607967af52ef8f6a00c60343ff Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 9 Sep 2015 09:41:40 +0200 Subject: [ticket/13904] Modify files for updated fast-image-size library PHPBB3-13904 --- tests/files/types_base_test.php | 2 +- tests/files/types_form_test.php | 4 ++-- tests/files/types_local_test.php | 4 ++-- tests/files/types_remote_test.php | 2 +- tests/files/upload_test.php | 2 +- tests/functional/fileupload_remote_test.php | 2 +- tests/upload/filespec_test.php | 12 ++++++------ tests/upload/fileupload_test.php | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/files/types_base_test.php b/tests/files/types_base_test.php index dc82ee2639..e630bf8c48 100644 --- a/tests/files/types_base_test.php +++ b/tests/files/types_base_test.php @@ -50,7 +50,7 @@ class phpbb_files_types_base_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, - new \fastImageSize\fastImageSize(), + new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), diff --git a/tests/files/types_form_test.php b/tests/files/types_form_test.php index 51219f7b4e..efcece49d1 100644 --- a/tests/files/types_form_test.php +++ b/tests/files/types_form_test.php @@ -58,7 +58,7 @@ class phpbb_files_types_form_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, - new \fastImageSize\fastImageSize(), + new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), @@ -147,7 +147,7 @@ class phpbb_files_types_form_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, - new \fastImageSize\fastImageSize(), + new \FastImageSize\FastImageSize(), $this->phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), diff --git a/tests/files/types_local_test.php b/tests/files/types_local_test.php index 8712c9cd5a..1367bbfcf8 100644 --- a/tests/files/types_local_test.php +++ b/tests/files/types_local_test.php @@ -58,7 +58,7 @@ class phpbb_files_types_local_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, - new \fastImageSize\fastImageSize(), + new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), @@ -139,7 +139,7 @@ class phpbb_files_types_local_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, - new \fastImageSize\fastImageSize(), + new \FastImageSize\FastImageSize(), $this->phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index 6d513ac5c0..a85844ee78 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -54,7 +54,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, - new \fastImageSize\fastImageSize(), + new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php index 0d02926702..1716eca6c9 100644 --- a/tests/files/upload_test.php +++ b/tests/files/upload_test.php @@ -59,7 +59,7 @@ class phpbb_files_upload_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, - new \fastImageSize\fastImageSize(), + new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 1484acc4d5..3349ffc576 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -57,7 +57,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $container = new phpbb_mock_container_builder(); - $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \fastImageSize\fastImageSize(), $this->phpbb_root_path)); + $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path)); diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 10a442cd1d..08c064698c 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -93,7 +93,7 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \fastImageSize\fastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser); return $filespec->set_upload_ary(array_merge($upload_ary, $override)); } @@ -114,7 +114,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_empty_upload_ary() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \fastImageSize\fastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser); $this->assertInstanceOf('\phpbb\files\filespec', $filespec->set_upload_ary(array())); $this->assertTrue($filespec->init_error()); } @@ -262,7 +262,7 @@ class phpbb_filespec_test extends phpbb_test_case */ public function test_clean_filename_avatar($filename, $expected, $mode, $prefix = '', $user_id = '') { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \fastImageSize\fastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser); if ($filename) { @@ -435,7 +435,7 @@ class phpbb_filespec_test extends phpbb_test_case ->willReturn($safe_mode_on); $upload = new phpbb_mock_fileupload(); $upload->max_filesize = self::UPLOAD_MAX_FILESIZE; - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $php_ini, new \fastImageSize\fastImagesize, '', $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $php_ini, new \FastImageSize\FastImagesize, '', $this->mimetype_guesser); $filespec->set_upload_ary($upload_ary); $filespec->local = false; $filespec->extension = 'gif'; @@ -494,7 +494,7 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - $imagesize = $this->getMockBuilder('\fastImageSize\fastImageSize') + $imagesize = $this->getMockBuilder('\FastImageSize\FastImageSize') ->getMock(); $imagesize->expects($this->any()) ->method('getImageSize') @@ -530,7 +530,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_is_uploaded() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \fastImageSize\fastImageSize(), $this->phpbb_root_path, null); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, null); $reflection_filespec = new ReflectionClass($filespec); $plupload_property = $reflection_filespec->getProperty('plupload'); $plupload_property->setAccessible(true); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index bb3092528b..01b625efbb 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -72,7 +72,7 @@ class phpbb_fileupload_test extends phpbb_test_case $this->filesystem, $this->language, $this->php_ini, - new \fastImageSize\fastImageSize(), + new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), @@ -132,7 +132,7 @@ class phpbb_fileupload_test extends phpbb_test_case $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); - $file = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \fastImageSize\fastImageSize(), $this->phpbb_root_path); + $file = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path); $file->set_upload_ary(array( 'size' => 50, 'tmp_name' => dirname(__FILE__) . '/fixture/disallowed', -- cgit v1.2.1 From 70ad0c6a8f7d16b767aa78cde2acc9a3b3512e6f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 9 Sep 2015 10:43:12 +0200 Subject: [ticket/13904] Add language entries for error messages in upload class PHPBB3-13904 --- tests/files/upload_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php index 1716eca6c9..c41204a0d5 100644 --- a/tests/files/upload_test.php +++ b/tests/files/upload_test.php @@ -110,9 +110,9 @@ class phpbb_files_upload_test extends phpbb_test_case array(UPLOAD_ERR_FORM_SIZE, 'WRONG_FILESIZE'), array(UPLOAD_ERR_PARTIAL, 'PARTIAL_UPLOAD'), array(UPLOAD_ERR_NO_FILE, 'NOT_UPLOADED'), - array(UPLOAD_ERR_NO_TMP_DIR, 'Temporary folder could not be found. Please check your PHP installation.'), - array(UPLOAD_ERR_CANT_WRITE, 'Can’t write to temporary folder.'), - array(UPLOAD_ERR_EXTENSION, 'A PHP extension has stopped the file upload.'), + array(UPLOAD_ERR_NO_TMP_DIR, 'NO_TEMP_DIR'), + array(UPLOAD_ERR_CANT_WRITE, 'NO_TEMP_DIR'), + array(UPLOAD_ERR_EXTENSION, 'PHP_UPLOAD_STOPPED'), array(9, false), ); } -- cgit v1.2.1 From 40e614f56436447dffd272351e23b79c2da9fa3f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 9 Sep 2015 12:58:22 +0200 Subject: [ticket/13904] Fix tests after changes to factory PHPBB3-13904 --- tests/functional/fileupload_remote_test.php | 8 ++++---- tests/upload/fileupload_test.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 3349ffc576..7e0f192b40 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -78,7 +78,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); - $file = $upload->handle_upload('remote', self::$root_url . 'develop/blank.gif'); + $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/blank.gif'); $this->assertEquals('URL_INVALID', $file->error[0]); } @@ -89,7 +89,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); - $file = $upload->handle_upload('remote', self::$root_url . 'develop/blank.jpg'); + $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/blank.jpg'); $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); } @@ -100,7 +100,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(1000); - $file = $upload->handle_upload('remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $file = $upload->handle_upload('files.types.remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->get('filename'))); $this->assertTrue($file->is_uploaded()); @@ -113,7 +113,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); - $file = $upload->handle_upload('remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $file = $upload->handle_upload('files.types.remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(1, sizeof($file->error)); $this->assertEquals('WRONG_FILESIZE', $file->error[0]); } diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 01b625efbb..211e72a6e9 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -185,7 +185,7 @@ class phpbb_fileupload_test extends phpbb_test_case ->set_max_filesize(1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); - $file = $upload->handle_upload('local', $this->path . 'jpg.jpg'); + $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); $this->assertEquals(0, sizeof($file->error)); $this->assertFalse($file->additional_checks()); $this->assertTrue($file->move_file('../tests/upload/fixture/copies', true)); @@ -199,7 +199,7 @@ class phpbb_fileupload_test extends phpbb_test_case ->set_max_filesize(1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); - $file = $upload->handle_upload('local', $this->path . 'jpg.jpg'); + $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); $this->assertEquals(0, sizeof($file->error)); $this->assertFalse($file->move_file('../tests/upload/fixture')); $this->assertFalse($file->file_moved); @@ -214,7 +214,7 @@ class phpbb_fileupload_test extends phpbb_test_case copy($this->path . 'jpg', $this->path . 'jpg.jpg'); copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg'); - $file = $upload->handle_upload('local', $this->path . 'jpg.jpg'); + $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); $this->assertEquals(0, sizeof($file->error)); $file->move_file('../tests/upload/fixture/copies', true); $this->assertEquals(0, sizeof($file->error)); -- cgit v1.2.1 From 759dc9bb84d712c11148a9689d294c09aa0f81d4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Sep 2015 09:30:56 +0200 Subject: [ticket/13904] Set properties to protected where possible in filespec PHPBB3-13904 --- tests/files/types_local_test.php | 4 +++- tests/upload/filespec_test.php | 31 +++++++++++++++++++------------ tests/upload/fileupload_test.php | 2 +- 3 files changed, 23 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/files/types_local_test.php b/tests/files/types_local_test.php index 1367bbfcf8..f4fa7fad3f 100644 --- a/tests/files/types_local_test.php +++ b/tests/files/types_local_test.php @@ -144,7 +144,9 @@ class phpbb_files_types_local_test extends phpbb_test_case new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), ))); - $filespec->local = true; + $filespec_local = new ReflectionProperty($filespec, 'local'); + $filespec_local->setAccessible(true); + $filespec_local->setValue($filespec, true); $this->container->set('files.filespec', $filespec); $this->factory = new \phpbb\files\factory($this->container); diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 08c064698c..1351b46002 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -82,6 +82,13 @@ class phpbb_filespec_test extends phpbb_test_case $this->phpbb_root_path = $phpbb_root_path; } + private function set_reflection_property(&$class, $property_name, $value) + { + $property = new ReflectionProperty($class, $property_name); + $property->setAccessible(true); + $property->setValue($class, $value); + } + private function get_filespec($override = array()) { // Initialise a blank filespec object for use with trivial methods @@ -141,8 +148,8 @@ class phpbb_filespec_test extends phpbb_test_case $upload = new phpbb_mock_fileupload(); $filespec = $this->get_filespec(); $filespec->set_upload_namespace($upload); - $filespec->file_moved = true; - $filespec->filesize = $filespec->get_filesize($this->path . $filename); + $this->set_reflection_property($filespec, 'file_moved', true); + $this->set_reflection_property($filespec, 'filesize', $filespec->get_filesize($this->path . $filename)); $this->assertEquals($expected, $filespec->additional_checks()); } @@ -153,7 +160,7 @@ class phpbb_filespec_test extends phpbb_test_case $filespec = $this->get_filespec(); $filespec->set_upload_namespace($upload); $upload->valid_dimensions = false; - $filespec->file_moved = true; + $this->set_reflection_property($filespec, 'file_moved', true); $upload->max_filesize = 0; $this->assertEquals(false, $filespec->additional_checks()); @@ -381,12 +388,12 @@ class phpbb_filespec_test extends phpbb_test_case 'name' => $realname, 'type' => $mime_type, )); - $filespec->extension = $extension; + $this->set_reflection_property($filespec, 'extension', $extension); $filespec->set_upload_namespace($upload); - $filespec->local = true; + $this->set_reflection_property($filespec, 'local', true); $this->assertEquals($expected, $filespec->move_file($this->path . 'copies')); - $this->assertEquals($filespec->file_moved, file_exists($this->path . 'copies/' . $realname)); + $this->assertEquals($filespec->get('file_moved'), file_exists($this->path . 'copies/' . $realname)); if ($error) { $this->assertEquals($error, $filespec->error[0]); @@ -437,12 +444,12 @@ class phpbb_filespec_test extends phpbb_test_case $upload->max_filesize = self::UPLOAD_MAX_FILESIZE; $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $php_ini, new \FastImageSize\FastImagesize, '', $this->mimetype_guesser); $filespec->set_upload_ary($upload_ary); - $filespec->local = false; - $filespec->extension = 'gif'; + $this->set_reflection_property($filespec, 'local', false); + $this->set_reflection_property($filespec, 'extension', 'gif'); $filespec->set_upload_namespace($upload); $this->assertEquals($move_success, $filespec->move_file($this->path . 'copies')); - $this->assertEquals($filespec->file_moved, file_exists($this->path . 'copies/gif_moved')); + $this->assertEquals($filespec->get('file_moved'), file_exists($this->path . 'copies/gif_moved')); $this->assertSame($expected_error, $filespec->error); } @@ -505,12 +512,12 @@ class phpbb_filespec_test extends phpbb_test_case $upload->max_filesize = self::UPLOAD_MAX_FILESIZE; $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $imagesize, '', $this->mimetype_guesser); $filespec->set_upload_ary($upload_ary); - $filespec->local = false; - $filespec->extension = 'gif'; + $this->set_reflection_property($filespec, 'local', false); + $this->set_reflection_property($filespec, 'extension', 'gif'); $filespec->set_upload_namespace($upload); $this->assertEquals(true, $filespec->move_file($this->path . 'copies')); - $this->assertEquals($filespec->file_moved, file_exists($this->path . 'copies/gif_moved')); + $this->assertEquals($filespec->get('file_moved'), file_exists($this->path . 'copies/gif_moved')); $this->assertSame($expected_error, $filespec->error); } diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 211e72a6e9..05cb8dcf93 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -202,7 +202,7 @@ class phpbb_fileupload_test extends phpbb_test_case $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); $this->assertEquals(0, sizeof($file->error)); $this->assertFalse($file->move_file('../tests/upload/fixture')); - $this->assertFalse($file->file_moved); + $this->assertFalse($file->get('file_moved')); $this->assertEquals(1, sizeof($file->error)); } -- cgit v1.2.1 From 956723af0ed94f79dbbeed2bcfc8617b2c73960e Mon Sep 17 00:00:00 2001 From: Michael Miday Date: Tue, 15 Sep 2015 22:23:24 +0200 Subject: [ticket/12769] Properly include FA --- tests/functional/forum_style_test.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/functional/forum_style_test.php b/tests/functional/forum_style_test.php index 65be94f4d0..b3c1115b7f 100644 --- a/tests/functional/forum_style_test.php +++ b/tests/functional/forum_style_test.php @@ -16,16 +16,28 @@ */ class phpbb_functional_forum_style_test extends phpbb_functional_test_case { + public function test_font_awesome_style() + { + $crawler = self::request('GET', 'viewtopic.php?t=1&f=2'); + $this->assertContains('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href')); + + $crawler = self::request('GET', 'viewtopic.php?t=1'); + $this->assertContains('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href')); + + $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); + $this->assertContains('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href')); + } + public function test_default_forum_style() { $crawler = self::request('GET', 'viewtopic.php?t=1&f=2'); - $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1'); - $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); - $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); } public function test_custom_forum_style() @@ -35,13 +47,13 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2'); $crawler = self::request('GET', 'viewtopic.php?t=1&f=2'); - $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1'); - $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); - $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href')); + $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2'); $this->delete_style(2, 'test_style'); -- cgit v1.2.1 From 635b5999b915c982616153f31f8dbc61f996be08 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 19 Sep 2015 19:56:01 +0200 Subject: [ticket/14178] Fix installer's database helper test PHPBB3-14178 --- tests/installer/database_helper_test.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/installer/database_helper_test.php b/tests/installer/database_helper_test.php index d2ebe76ad5..ed355884f6 100644 --- a/tests/installer/database_helper_test.php +++ b/tests/installer/database_helper_test.php @@ -56,7 +56,23 @@ class phpbb_installer_database_helper_test extends phpbb_test_case */ public function test_validate_table_prefix($expected, $test_string) { - $this->assertEquals($expected, $this->database_helper->validate_table_prefix('sqlite3', $test_string)); + $db_helper_mock = $this->getMockBuilder('\phpbb\install\helper\database') + ->setMethods(array('get_available_dbms')) + ->disableOriginalConstructor() + ->getMock(); + + $db_helper_mock->method('get_available_dbms') + ->willReturn(array('sqlite3' => array( + 'LABEL' => 'SQLite3', + 'SCHEMA' => 'sqlite', + 'MODULE' => 'sqlite3', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\sqlite3', + 'AVAILABLE' => true, + '2.0.x' => false, + ))); + + $this->assertEquals($expected, $db_helper_mock->validate_table_prefix('sqlite3', $test_string)); } // Data provider for the remove comments function -- cgit v1.2.1 From 7f3dfde1634758c4928aca22db2f0e9675b2d61e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Sep 2015 10:05:23 +0200 Subject: [ticket/14180] Use unix line endings in type_foo PHPBB3-14180 --- tests/files/type_foo.php | 62 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/files/type_foo.php b/tests/files/type_foo.php index 20eddfcbc4..95940b9d2f 100644 --- a/tests/files/type_foo.php +++ b/tests/files/type_foo.php @@ -1,31 +1,31 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\files\types; - -class foo extends \phpbb\files\types\remote -{ - static public $tempnam_path; -} - -function tempnam($one, $two) -{ - if (empty(foo::$tempnam_path)) - { - return \tempnam($one, $two); - } - else - { - return foo::$tempnam_path; - } -} + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\files\types; + +class foo extends \phpbb\files\types\remote +{ + static public $tempnam_path; +} + +function tempnam($one, $two) +{ + if (empty(foo::$tempnam_path)) + { + return \tempnam($one, $two); + } + else + { + return foo::$tempnam_path; + } +} -- cgit v1.2.1 From 664119ec6b2bbdf8886ab2cfb495bbb3ca3f2d08 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 4 Oct 2015 20:58:22 +0200 Subject: [ticket/14216] Do not run thumbnail test if gd is disabled PHPBB3-14216 --- tests/console/thumbnail_test.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php index b5ed02b5e7..45d7adacb9 100644 --- a/tests/console/thumbnail_test.php +++ b/tests/console/thumbnail_test.php @@ -39,6 +39,11 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case { global $config, $phpbb_root_path, $phpEx, $phpbb_filesystem; + if (!@extension_loaded('gd')) + { + $this->markTestSkipped('Thumbnail tests require gd extension.'); + } + parent::setUp(); $config = $this->config = new \phpbb\config\config(array( -- cgit v1.2.1 From 403c647b9e84640977ca0f98d21d15ceb4957bdb Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 7 Oct 2015 23:09:13 +0200 Subject: [ticket/14220] Move route loading to services PHPBB3-14220 --- tests/controller/common_helper_route.php | 8 +++++--- tests/controller/controller_test.php | 11 +++++++---- tests/pagination/pagination_test.php | 9 ++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 4c0c8569a3..72c5328b0b 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -122,9 +122,11 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($container, $this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); - $this->router->find_routing_files($this->extension_manager->all_enabled(false)); - $this->router->find(dirname(__FILE__) . '/'); + $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( + new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/') + ); + $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); + $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index d0295d66bc..431b26b2bc 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -38,14 +38,17 @@ class phpbb_controller_controller_test extends phpbb_test_case )); } - public function test_router_find_files() + public function test_router_default_loader() { $container = new phpbb_mock_container_builder(); $container->setParameter('core.environment', PHPBB_ENVIRONMENT); - $router = new \phpbb\routing\router($container, new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); - $router->find_routing_files($this->extension_manager->all_enabled(false)); - $routes = $router->find(__DIR__)->get_routes(); + $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( + new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/') + ); + $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); + $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $routes = $router->get_routes(); // This will need to be updated if any new routes are defined $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('core_controller')); diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 0607098d93..6a3b46cdae 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -41,9 +41,12 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $manager); - $router->find_routing_files($manager->all_enabled(false)); - $router->find(dirname(__FILE__) . '/'); + + $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( + new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/') + ); + $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager); + $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $request = new phpbb_mock_request(); $request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER); -- cgit v1.2.1 From 2ce73a22e76ed021ec06cb29cd84af8b10f77c48 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Sep 2015 10:06:58 +0200 Subject: [ticket/14168] Fix tests after adding attachment delete class PHPBB3-14168 --- tests/content_visibility/delete_post_test.php | 2 ++ tests/functions_user/delete_user_test.php | 1 + tests/privmsgs/delete_user_pms_test.php | 1 + 3 files changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index b59b6493d4..d6534456d0 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -312,12 +312,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); + $attachment_delete = new \phpbb\attachment\delete($config, $db); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); + $phpbb_container->set('attachment.delete', $attachment_delete); delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 9e2caf9d21..163e5d77e2 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -36,6 +36,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete($config, $db)); $phpbb_container->set( 'auth.provider.db', new phpbb_mock_auth_provider() diff --git a/tests/privmsgs/delete_user_pms_test.php b/tests/privmsgs/delete_user_pms_test.php index 0f061e9784..f8c40f588a 100644 --- a/tests/privmsgs/delete_user_pms_test.php +++ b/tests/privmsgs/delete_user_pms_test.php @@ -91,6 +91,7 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db)); phpbb_delete_user_pms($delete_user); -- cgit v1.2.1 From 40117c77304468120245ae05b6b99f1d2a68c9f6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Sep 2015 10:56:32 +0200 Subject: [ticket/14168] Add attachment resync class PHPBB3-14168 --- tests/content_visibility/delete_post_test.php | 2 +- tests/functions_user/delete_user_test.php | 2 +- tests/privmsgs/delete_user_pms_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index d6534456d0..bb609b6ab7 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -312,7 +312,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $attachment_delete = new \phpbb\attachment\delete($config, $db); + $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb\attachment\resync($db)); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 163e5d77e2..b877164629 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -36,7 +36,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete($config, $db)); + $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete($config, $db, new \phpbb\attachment\resync($db))); $phpbb_container->set( 'auth.provider.db', new phpbb_mock_auth_provider() diff --git a/tests/privmsgs/delete_user_pms_test.php b/tests/privmsgs/delete_user_pms_test.php index f8c40f588a..7345721d8b 100644 --- a/tests/privmsgs/delete_user_pms_test.php +++ b/tests/privmsgs/delete_user_pms_test.php @@ -91,7 +91,7 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db)); + $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb\attachment\resync($db))); phpbb_delete_user_pms($delete_user); -- cgit v1.2.1 From 583f42a2aa5ba8132e9e516b363ba0180fe46289 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Sep 2015 16:28:53 +0200 Subject: [ticket/14168] Add tests for attachment resync class PHPBB3-14168 --- tests/attachment/fixtures/resync.xml | 81 ++++++++++++++++++++++++++++++++++++ tests/attachment/resync_test.php | 74 ++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 tests/attachment/fixtures/resync.xml create mode 100644 tests/attachment/resync_test.php (limited to 'tests') diff --git a/tests/attachment/fixtures/resync.xml b/tests/attachment/fixtures/resync.xml new file mode 100644 index 0000000000..132f62382c --- /dev/null +++ b/tests/attachment/fixtures/resync.xml @@ -0,0 +1,81 @@ + + + + post_msg_id + topic_id + in_message + is_orphan + attach_comment + + 1 + 1 + 0 + 0 + foo + + + 1 + 1 + 1 + 0 + foo2 + +
            + + post_id + post_text + poster_id + post_attachment + + 1 + foo + 1 + 1 + + + 2 + foo + 1 + 1 + +
            + + msg_id + message_text + message_attachment + to_address + bcc_address + + 1 + foo + 1 + 2 + 2 + + + 2 + foo + 1 + 2 + 2 + +
            + + topic_id + forum_id + topic_title + topic_attachment + + 1 + 1 + foo + 1 + + + 2 + 1 + bar + 1 + +
            +
            diff --git a/tests/attachment/resync_test.php b/tests/attachment/resync_test.php new file mode 100644 index 0000000000..de8a42637e --- /dev/null +++ b/tests/attachment/resync_test.php @@ -0,0 +1,74 @@ + +* @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_attachment_resync_test extends \phpbb_database_test_case +{ + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + + /** @var \phpbb\attachment\resync */ + protected $resync; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml'); + } + + public function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + $this->resync = new \phpbb\attachment\resync($this->db); + } + + public function data_resync() + { + return array( + array('', array(1), 'post_id', POSTS_TABLE, array('post_attachment' => '1'), array('post_attachment' => '1')), + array('post', array(1), 'post_id', POSTS_TABLE, array('post_attachment' => '1'), array('post_attachment' => '1')), + array('post', array(2), 'post_id', POSTS_TABLE, array('post_attachment' => '1'), array('post_attachment' => '0')), + array('topic', array(1), 'topic_id', TOPICS_TABLE, array('topic_attachment' => '1'), array('topic_attachment' => '1')), + array('topic', array(2), 'topic_id', TOPICS_TABLE, array('topic_attachment' => '1'), array('topic_attachment' => '0')), + array('message', array(1), 'msg_id', PRIVMSGS_TABLE, array('message_attachment' => '1'), array('message_attachment' => '1')), + array('message', array(2), 'msg_id', PRIVMSGS_TABLE, array('message_attachment' => '1'), array('message_attachment' => '0')), + ); + } + + /** + * @dataProvider data_resync + */ + public function test_resync($type, $ids, $sql_id, $exist_table, $exist_data, $resync_data) + { + $sql_prefix = ($type) ?: 'post'; + $sql = 'SELECT ' . $sql_prefix . '_attachment + FROM ' . $exist_table . ' + WHERE ' . $sql_id . ' = ' . $ids[0]; + $result = $this->db->sql_query($sql); + $data = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertSame($exist_data, $data); + + $this->resync->resync($type, $ids); + + $sql = 'SELECT ' . $sql_prefix . '_attachment + FROM ' . $exist_table . ' + WHERE ' . $sql_id . ' = ' . $ids[0]; + $result = $this->db->sql_query($sql); + $data = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertSame($resync_data, $data); + } +} -- cgit v1.2.1 From b00c7511f022dfafb32f570db1f5fe762a62ef21 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Sep 2015 22:16:23 +0200 Subject: [ticket/14168] Add tests for attachment delete class PHPBB3-14168 --- tests/attachment/delete_test.php | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/attachment/delete_test.php (limited to 'tests') diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php new file mode 100644 index 0000000000..19a5e0bcca --- /dev/null +++ b/tests/attachment/delete_test.php @@ -0,0 +1,70 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once(dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'); + +class phpbb_attachment_delete_test extends \phpbb_database_test_case +{ + /** @var \phpbb\config\config */ + protected $config; + + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + + /** @var \phpbb\attachment\resync */ + protected $resync; + + /** @var \phpbb\attachment\delete */ + protected $attachment_delete; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml'); + } + + public function setUp() + { + global $db; + + parent::setUp(); + + $this->config = new \phpbb\config\config(array()); + $this->db = $this->new_dbal(); + $db = $this->db; + $this->resync = new \phpbb\attachment\resync($this->db); + $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->resync); + } + + public function data_attachment_delete() + { + return array( + array('attach', '', false, false), + array('meh', 5, false, 0), + array('attach', array(5), false, 0), + array('attach', array(1,2), false, 2), + array('attach', array(1,2), true, 2), + array('post', 5, false, 0), + array('topic', 5, false, 0), + array('topic', 1, true, 2), + array('user', 1, false, 0), + ); + } + + /** + * @dataProvider data_attachment_delete + */ + public function test_attachment_delete($mode, $ids, $resync, $expected) + { + $this->assertSame($expected, $this->attachment_delete->delete($mode, $ids, $resync)); + } +} -- cgit v1.2.1 From c6f9e3a966cffdc09c64f73a25ac98d6bbe559cd Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Sep 2015 22:17:28 +0200 Subject: [ticket/14168] Fix resync tests on sqlite3 PHPBB3-14168 --- tests/attachment/resync_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/attachment/resync_test.php b/tests/attachment/resync_test.php index de8a42637e..f882af9ae5 100644 --- a/tests/attachment/resync_test.php +++ b/tests/attachment/resync_test.php @@ -58,7 +58,7 @@ class phpbb_attachment_resync_test extends \phpbb_database_test_case $data = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); - $this->assertSame($exist_data, $data); + $this->assertEquals($exist_data, $data); $this->resync->resync($type, $ids); @@ -69,6 +69,6 @@ class phpbb_attachment_resync_test extends \phpbb_database_test_case $data = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); - $this->assertSame($resync_data, $data); + $this->assertEquals($resync_data, $data); } } -- cgit v1.2.1 From 8d03b9e001526fb237cdb744dd832c1dd4182d01 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 23 Sep 2015 09:09:09 +0200 Subject: [ticket/14168] Reset sequence before tests in delete tests PHPBB3-14168 --- tests/attachment/delete_test.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php index 19a5e0bcca..df7e305dc5 100644 --- a/tests/attachment/delete_test.php +++ b/tests/attachment/delete_test.php @@ -65,6 +65,13 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case */ public function test_attachment_delete($mode, $ids, $resync, $expected) { + // We need to reset the attachment ID sequence to properly test this + if ($this->db->get_sql_layer() === 'postgres') + { + $sql = 'ALTER SEQUENCE phpbb_attachments_seq RESTART WITH 1'; + $this->db->sql_query($sql); + } + $this->assertSame($expected, $this->attachment_delete->delete($mode, $ids, $resync)); } } -- cgit v1.2.1 From 04786313892df25f5adce555ebae6b2e5ad4d222 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 23 Sep 2015 10:17:38 +0200 Subject: [ticket/14168] Move phpbb_unlink() into attachment delete class PHPBB3-14168 --- tests/attachment/delete_test.php | 55 +++++++++++++++++++++++++-- tests/attachment/fixtures/resync.xml | 15 ++++++++ tests/content_visibility/delete_post_test.php | 2 +- tests/functions_user/delete_user_test.php | 4 +- tests/privmsgs/delete_user_pms_test.php | 4 +- 5 files changed, 72 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php index df7e305dc5..8db6487542 100644 --- a/tests/attachment/delete_test.php +++ b/tests/attachment/delete_test.php @@ -21,12 +21,17 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case /** @var \phpbb\db\driver\driver_interface */ protected $db; + /** @var \phpbb\filesystem\filesystem */ + protected $filesystem; + /** @var \phpbb\attachment\resync */ protected $resync; /** @var \phpbb\attachment\delete */ protected $attachment_delete; + protected $phpbb_root_path; + public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml'); @@ -34,7 +39,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case public function setUp() { - global $db; + global $db, $phpbb_root_path; parent::setUp(); @@ -42,7 +47,15 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case $this->db = $this->new_dbal(); $db = $this->db; $this->resync = new \phpbb\attachment\resync($this->db); - $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->resync); + $this->filesystem = $this->getMock('\phpbb\filesystem\filesystem', array('remove', 'exists')); + $this->filesystem->expects($this->any()) + ->method('remove') + ->willReturn(false); + $this->filesystem->expects($this->any()) + ->method('exists') + ->willReturn(true); + $this->phpbb_root_path = $phpbb_root_path; + $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->filesystem, $this->resync, $phpbb_root_path); } public function data_attachment_delete() @@ -55,7 +68,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case array('attach', array(1,2), true, 2), array('post', 5, false, 0), array('topic', 5, false, 0), - array('topic', 1, true, 2), + array('topic', 1, true, 3), array('user', 1, false, 0), ); } @@ -74,4 +87,40 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case $this->assertSame($expected, $this->attachment_delete->delete($mode, $ids, $resync)); } + + public function data_attachment_unlink() + { + return array( + array(true, true, true), + array(true, false, false), + array(true, true, false, true), + ); + } + + /** + * @dataProvider data_attachment_unlink + */ + public function test_attachment_delete_success($remove_success, $exists_success, $expected, $throw_exception = false) + { + $this->filesystem = $this->getMock('\phpbb\filesystem\filesystem', array('remove', 'exists')); + if ($throw_exception) + { + $this->filesystem->expects($this->any()) + ->method('remove') + ->willThrowException(new \phpbb\filesystem\exception\filesystem_exception);; + } + else + { + $this->filesystem->expects($this->any()) + ->method('remove') + ->willReturn($remove_success); + } + + $this->filesystem->expects($this->any()) + ->method('exists') + ->willReturn($exists_success); + + $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->filesystem, $this->resync, $this->phpbb_root_path); + $this->assertSame($expected, $this->attachment_delete->unlink_attachment('foobar')); + } } diff --git a/tests/attachment/fixtures/resync.xml b/tests/attachment/fixtures/resync.xml index 132f62382c..d15f6d17f9 100644 --- a/tests/attachment/fixtures/resync.xml +++ b/tests/attachment/fixtures/resync.xml @@ -6,12 +6,16 @@ in_message is_orphan attach_comment + physical_filename + thumbnail 1 1 0 0 foo + foo + 0 1 @@ -19,6 +23,17 @@ 1 0 foo2 + foo2 + 0 + + + 1 + 1 + 1 + 0 + foo2 + foo2 + 1 diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index bb609b6ab7..c383ebfa2f 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -312,7 +312,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb\attachment\resync($db)); + $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index b877164629..f28c7286e3 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -25,7 +25,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case { parent::setUp(); - global $cache, $config, $db, $phpbb_dispatcher, $phpbb_container; + global $cache, $config, $db, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path; $db = $this->db = $this->new_dbal(); $config = new \phpbb\config\config(array( @@ -36,7 +36,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete($config, $db, new \phpbb\attachment\resync($db))); + $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete($config, $db, new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); $phpbb_container->set( 'auth.provider.db', new phpbb_mock_auth_provider() diff --git a/tests/privmsgs/delete_user_pms_test.php b/tests/privmsgs/delete_user_pms_test.php index 7345721d8b..1da4b76f9f 100644 --- a/tests/privmsgs/delete_user_pms_test.php +++ b/tests/privmsgs/delete_user_pms_test.php @@ -85,13 +85,13 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case */ public function test_delete_user_pms($delete_user, $remaining_privmsgs, $remaining_privmsgs_to) { - global $db, $phpbb_container; + global $db, $phpbb_container, $phpbb_root_path; $db = $this->new_dbal(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb\attachment\resync($db))); + $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); phpbb_delete_user_pms($delete_user); -- cgit v1.2.1 From 8a6224bf8ad37ff5c739137dbbe4264e4328910e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 23 Sep 2015 11:39:27 +0200 Subject: [ticket/14168] Add basic test file for attachments upload PHPBB3-14168 --- tests/attachment/upload_test.php | 183 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 tests/attachment/upload_test.php (limited to 'tests') diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php new file mode 100644 index 0000000000..2c08b5b72a --- /dev/null +++ b/tests/attachment/upload_test.php @@ -0,0 +1,183 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once(dirname(__FILE__) . '/../../phpBB/includes/functions.php'); + +class phpbb_attachment_upload_test extends \phpbb_database_test_case +{ + /** @var \phpbb\auth\auth */ + protected $auth; + + /** @var \phpbb\cache\service */ + protected $cache; + + /** @var \phpbb\config\config */ + protected $config; + + /** @var \phpbb\files\upload */ + protected $files_upload; + + /** @var \phpbb\language\language */ + protected $language; + + /** @var \phpbb\mimetype\guesser */ + protected $mimetype_guesser; + + /** @var \phpbb\event\dispatcher */ + protected $phpbb_dispatcher; + + /** @var \phpbb\plupload\plupload */ + protected $plupload; + + /** @var \phpbb\user */ + protected $user; + + /** @var string phpBB root path */ + protected $phpbb_root_path; + + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + + /** @var \phpbb\attachment\upload */ + protected $upload; + + private $filesystem; + + /** @var \Symfony\Component\DependencyInjection\ContainerInterface */ + protected $container; + + /** @var \phpbb\files\factory */ + protected $factory; + + /** @var \bantu\IniGetWrapper\IniGetWrapper */ + protected $php_ini; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml'); + } + + public function setUp() + { + global $config, $phpbb_root_path, $phpEx; + + parent::setUp(); + + $this->auth = new \phpbb\auth\auth(); + $this->config = new \phpbb\config\config(array()); + $config = $this->config; + $this->db = $this->new_dbal(); + $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $this->config, $this->db, $phpbb_root_path, $phpEx); + $this->request = $this->getMock('\phpbb\request\request'); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; + $guessers = array( + new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), + new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), + new \phpbb\mimetype\content_guesser(), + new \phpbb\mimetype\extension_guesser(), + ); + $guessers[2]->set_priority(-2); + $guessers[3]->set_priority(-2); + $this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers); + $this->plupload = new \phpbb\plupload\plupload($phpbb_root_path, $this->config, $this->request, new \phpbb\user($this->language, '\phpbb\datetime'), $this->php_ini, $this->mimetype_guesser); + $factory_mock = $this->getMockBuilder('\phpbb\files\factory') + ->disableOriginalConstructor() + ->getMock(); + $factory_mock->expects($this->any()) + ->method('get') + ->willReturn(new \phpbb\files\filespec( + $this->filesystem, + $this->language, + $this->php_ini, + new \FastImageSize\FastImageSize(), + $this->phpbb_root_path, + $this->mimetype_guesser + )); + + $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); + $this->container->set('files.filespec', new \phpbb\files\filespec( + $this->filesystem, + $this->language, + $this->php_ini, + new \FastImageSize\FastImageSize(), + $phpbb_root_path, + new \phpbb\mimetype\guesser(array( + 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), + )))); + $this->container->set('files.types.form', new \phpbb\files\types\form( + $factory_mock, + $this->language, + $this->php_ini, + $this->plupload, + $this->request + )); + $this->container->set('files.types.local', new \phpbb\files\types\local( + $factory_mock, + $this->language, + $this->php_ini, + $this->request + )); + $this->factory = new \phpbb\files\factory($this->container); + $this->files_upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $this->user = new \phpbb\user($this->language, '\phpbb\datetime'); + + + $this->upload = new \phpbb\attachment\upload( + $this->auth, + $this->cache, + $this->config, + $this->files_upload, + $this->language, + $this->mimetype_guesser, + $this->phpbb_dispatcher, + $this->plupload, + $this->user, + $this->phpbb_root_path + ); + } + + public function data_upload() + { + return array( + array('foobar', 1, false, array( + 'error' => array( + 'Upload initiated but no valid file upload form found.', + ), + 'post_attach' => false, + ) + ), + array('foobar', 1, true, array( + 'error' => array( + 'NOT_UPLOADED', + ), + 'post_attach' => false, + 'thumbnail' => 0, + ) + ), + ); + } + + /** + * @dataProvider data_upload + */ + public function test_upload($form_name, $forum_id, $local, $expected) + { + $filedata = $this->upload->upload($form_name, $forum_id, $local); + + $this->assertSame($expected, $filedata); + } +} -- cgit v1.2.1 From 6c80fd92c6ab4aebb5701e6b1a46c46208d793c9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 3 Oct 2015 20:10:13 +0200 Subject: [ticket/14168] Add tests for init_error() during upload PHPBB3-14168 --- tests/attachment/upload_test.php | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests') diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index 2c08b5b72a..03d688cc1f 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -180,4 +180,53 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->assertSame($expected, $filedata); } + + public function test_init_error() + { + $filespec = $this->getMockBuilder('\phpbb\files\filespec') + ->disableOriginalConstructor() + ->getMock(); + $filespec->expects($this->any()) + ->method('init_error') + ->willReturn(true); + $filespec->expects($this->any()) + ->method('set_upload_namespace') + ->willReturnSelf(); + $filespec->expects($this->any()) + ->method('set_upload_ary') + ->willReturnSelf(); + $this->container->set('files.filespec', $filespec); + $factory_mock = $this->getMockBuilder('\phpbb\files\factory') + ->disableOriginalConstructor() + ->getMock(); + $factory_mock->expects($this->any()) + ->method('get') + ->willReturn($filespec); + $this->container->set('files.types.local', new \phpbb\files\types\local( + $factory_mock, + $this->language, + $this->php_ini, + $this->request + )); + + $this->upload = new \phpbb\attachment\upload( + $this->auth, + $this->cache, + $this->config, + $this->files_upload, + $this->language, + $this->mimetype_guesser, + $this->phpbb_dispatcher, + $this->plupload, + $this->user, + $this->phpbb_root_path + ); + + $filedata = $this->upload->upload('foobar', 1, true); + + $this->assertSame(array( + 'error' => array(), + 'post_attach' => false, + ), $filedata); + } } -- cgit v1.2.1 From 36ea105236c87e84ca2b9f0a193b5b8721e8cf97 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 4 Oct 2015 11:10:07 +0200 Subject: [ticket/14168] Move image check and don't use trigger_error() PHPBB3-14168 --- tests/attachment/fixtures/resync.xml | 34 ++++++++++ tests/attachment/upload_test.php | 125 +++++++++++++++++++++++++++++++++-- 2 files changed, 154 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/attachment/fixtures/resync.xml b/tests/attachment/fixtures/resync.xml index d15f6d17f9..6e2cc62f68 100644 --- a/tests/attachment/fixtures/resync.xml +++ b/tests/attachment/fixtures/resync.xml @@ -36,6 +36,40 @@ 1
            + + extension + group_id + + jpg + 1 + + + png + 1 + +
            + + cat_id + group_id + download_mode + upload_icon + max_filesize + allow_group + allow_in_pm + allowed_forums + group_name + + 1 + 1 + 1 + + 1000 + 1 + 1 + a:1:{i:0;i:1;} + Images + +
            post_idpost_text diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index 03d688cc1f..d1007dbd77 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -74,7 +74,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case parent::setUp(); $this->auth = new \phpbb\auth\auth(); - $this->config = new \phpbb\config\config(array()); + $this->config = new \phpbb\config\config(array( + 'upload_path' => '../attachment/fixtures/', + )); $config = $this->config; $this->db = $this->new_dbal(); $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $this->config, $this->db, $phpbb_root_path, $phpEx); @@ -153,14 +155,33 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case public function data_upload() { return array( - array('foobar', 1, false, array( + array('foobar', 1, false, + array(), + array( 'error' => array( 'Upload initiated but no valid file upload form found.', ), 'post_attach' => false, ) ), - array('foobar', 1, true, array( + array('foobar', 1, true, + array( + 'realname' => 'foobar.jpg', + 'type' => 'jpg', + 'size' => 100, + ), + array( + 'error' => array( + 'NOT_UPLOADED', + 'The image file you tried to attach is invalid.', + ), + 'post_attach' => false, + 'thumbnail' => 0, + ) + ), + array('foobar', 1, true, + array(), + array( 'error' => array( 'NOT_UPLOADED', ), @@ -174,9 +195,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case /** * @dataProvider data_upload */ - public function test_upload($form_name, $forum_id, $local, $expected) + public function test_upload($form_name, $forum_id, $local, $filedata, $expected) { - $filedata = $this->upload->upload($form_name, $forum_id, $local); + $filedata = $this->upload->upload($form_name, $forum_id, $local, '', false, $filedata); $this->assertSame($expected, $filedata); } @@ -229,4 +250,98 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case 'post_attach' => false, ), $filedata); } + + public function data_image_not_image() + { + return array( + array(false), + array(true), + ); + } + + /** + * @dataProvider data_image_not_image + */ + public function test_image_not_image($plupload_active) + { + $filespec = $this->getMock('\phpbb\files\filespec', + array( + 'init_error', + 'is_image', + 'move_file', + 'is_uploaded', + ), + array( + $this->filesystem, + $this->language, + $this->php_ini, + new \FastImageSize\FastImageSize(), + $this->phpbb_root_path, + $this->mimetype_guesser, + $this->plupload + )); + $filespec->set_upload_namespace($this->files_upload); + $filespec->expects($this->any()) + ->method('init_error') + ->willReturn(false); + $filespec->expects($this->any()) + ->method('is_image') + ->willReturn(false); + $filespec->expects($this->any()) + ->method('is_uploaded') + ->willReturn(true); + $filespec->expects($this->any()) + ->method('move_file') + ->willReturn(false); + $this->container->set('files.filespec', $filespec); + $factory_mock = $this->getMockBuilder('\phpbb\files\factory') + ->disableOriginalConstructor() + ->getMock(); + $factory_mock->expects($this->any()) + ->method('get') + ->willReturn($filespec); + $this->container->set('files.types.local', new \phpbb\files\types\local( + $factory_mock, + $this->language, + $this->php_ini, + $this->request + )); + + $plupload = $this->getMockBuilder('\phpbb\plupload\plupload') + ->disableOriginalConstructor() + ->getMock(); + $plupload->expects($this->any()) + ->method('is_active') + ->willReturn($plupload_active); + if ($plupload_active) + { + $plupload->expects($this->once()) + ->method('emit_error') + ->with(104, 'ATTACHED_IMAGE_NOT_IMAGE') + ->willReturn(false); + } + $this->upload = new \phpbb\attachment\upload( + $this->auth, + $this->cache, + $this->config, + $this->files_upload, + $this->language, + $this->mimetype_guesser, + $this->phpbb_dispatcher, + $plupload, + $this->user, + $this->phpbb_root_path + ); + + $filedata = $this->upload->upload('foobar', 1, true, '', false, array( + 'realname' => 'foobar.jpg', + 'type' => 'jpg', + 'size' => 100, + )); + $this->assertEquals(array( + 'error' => array('The image file you tried to attach is invalid.'), + 'post_attach' => false, + 'thumbnail' => 0, + ), $filedata); + } } -- cgit v1.2.1 From 1f1e708815369cc25f1c59c5ed69a49f80b64318 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 4 Oct 2015 12:28:12 +0200 Subject: [ticket/14168] Improve code coverage in upload class PHPBB3-14168 --- tests/attachment/upload_test.php | 109 ++++++++++++++++++++++++++++++++++----- 1 file changed, 96 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index d1007dbd77..295b6b15c9 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -12,6 +12,7 @@ */ require_once(dirname(__FILE__) . '/../../phpBB/includes/functions.php'); +require_once(dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php'); class phpbb_attachment_upload_test extends \phpbb_database_test_case { @@ -75,7 +76,8 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->auth = new \phpbb\auth\auth(); $this->config = new \phpbb\config\config(array( - 'upload_path' => '../attachment/fixtures/', + 'upload_path' => '', + 'img_create_thumbnail' => true, )); $config = $this->config; $this->db = $this->new_dbal(); @@ -176,7 +178,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case 'The image file you tried to attach is invalid.', ), 'post_attach' => false, - 'thumbnail' => 0, + 'thumbnail' => 1, ) ), array('foobar', 1, true, @@ -251,18 +253,89 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case ), $filedata); } - public function data_image_not_image() + public function data_image_upload() { return array( - array(false), - array(true), + array(false, false, array(), + array( + 'error' => array('The image file you tried to attach is invalid.'), + 'post_attach' => false, + 'thumbnail' => 1, + ) + ), + array(false, true, array(), + array( + 'error' => array('The image file you tried to attach is invalid.'), + 'post_attach' => false, + 'thumbnail' => 1, + ) + ), + array(true, false, array(), + array( + 'error' => array(), + 'post_attach' => true, + // thumbnail gets reset to 0 as creation was not possible + 'thumbnail' => 0, + 'filesize' => 100, + 'mimetype' => 'jpg', + 'extension' => 'jpg', + 'real_filename' => 'foobar.jpg', + ) + ), + array(true, false, + array( + 'check_attachment_content' => true, + 'mime_triggers' => '', + ), + array( + 'error' => array(), + 'post_attach' => true, + // thumbnail gets reset to 0 as creation was not possible + 'thumbnail' => 0, + 'filesize' => 100, + 'mimetype' => 'jpg', + 'extension' => 'jpg', + 'real_filename' => 'foobar.jpg', + ) + ), + array(true, false, + array( + 'attachment_quota' => 150, + ), + array( + 'error' => array(), + 'post_attach' => true, + // thumbnail gets reset to 0 as creation was not possible + 'thumbnail' => 0, + 'filesize' => 100, + 'mimetype' => 'jpg', + 'extension' => 'jpg', + 'real_filename' => 'foobar.jpg', + ) + ), + array(true, false, + array( + 'attachment_quota' => 50, + ), + array( + 'error' => array( + 'ATTACH_QUOTA_REACHED', + ), + 'post_attach' => false, + 'thumbnail' => 1, + 'filesize' => 100, + 'mimetype' => 'jpg', + 'extension' => 'jpg', + 'real_filename' => 'foobar.jpg', + ) + ), ); } /** - * @dataProvider data_image_not_image + * @dataProvider data_image_upload */ - public function test_image_not_image($plupload_active) + public function test_image_upload($is_image, $plupload_active, $config_data, $expected) { $filespec = $this->getMock('\phpbb\files\filespec', array( @@ -280,13 +353,17 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->mimetype_guesser, $this->plupload )); + foreach ($config_data as $key => $value) + { + $this->config[$key] = $value; + } $filespec->set_upload_namespace($this->files_upload); $filespec->expects($this->any()) ->method('init_error') ->willReturn(false); $filespec->expects($this->any()) ->method('is_image') - ->willReturn(false); + ->willReturn($is_image); $filespec->expects($this->any()) ->method('is_uploaded') ->willReturn(true); @@ -338,10 +415,16 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case 'type' => 'jpg', 'size' => 100, )); - $this->assertEquals(array( - 'error' => array('The image file you tried to attach is invalid.'), - 'post_attach' => false, - 'thumbnail' => 0, - ), $filedata); + + foreach ($expected as $key => $entry) + { + $this->assertEquals($entry, $filedata[$key]); + } + + // Reset config data + foreach ($config_data as $key => $value) + { + $this->config->delete($key); + } } } -- cgit v1.2.1 From 88033feb85f554936462b7652c80a7a815128d2b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Oct 2015 11:15:21 +0200 Subject: [ticket/14168] Fix tests after rebase PHPBB3-14168 --- tests/attachment/delete_test.php | 5 +++-- tests/content_visibility/delete_post_test.php | 2 +- tests/functions_user/delete_user_test.php | 2 +- tests/privmsgs/delete_user_pms_test.php | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php index 8db6487542..f1835dd37a 100644 --- a/tests/attachment/delete_test.php +++ b/tests/attachment/delete_test.php @@ -55,7 +55,8 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case ->method('exists') ->willReturn(true); $this->phpbb_root_path = $phpbb_root_path; - $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->filesystem, $this->resync, $phpbb_root_path); + $this->dispatcher = new \phpbb_mock_event_dispatcher(); + $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->filesystem, $this->resync, $phpbb_root_path); } public function data_attachment_delete() @@ -120,7 +121,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case ->method('exists') ->willReturn($exists_success); - $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->filesystem, $this->resync, $this->phpbb_root_path); + $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->filesystem, $this->resync, $this->phpbb_root_path); $this->assertSame($expected, $this->attachment_delete->unlink_attachment('foobar')); } } diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index c383ebfa2f..f174b99d51 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -312,7 +312,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path); + $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index f28c7286e3..1a5a4f672e 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -36,7 +36,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete($config, $db, new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); + $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); $phpbb_container->set( 'auth.provider.db', new phpbb_mock_auth_provider() diff --git a/tests/privmsgs/delete_user_pms_test.php b/tests/privmsgs/delete_user_pms_test.php index 1da4b76f9f..329c401316 100644 --- a/tests/privmsgs/delete_user_pms_test.php +++ b/tests/privmsgs/delete_user_pms_test.php @@ -91,7 +91,7 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); + $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); phpbb_delete_user_pms($delete_user); -- cgit v1.2.1 From 53008c87828746c316019e758641a2a4e37f522b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Oct 2015 12:14:19 +0200 Subject: [ticket/14168] Fix tabs in manager and add test file PHPBB3-14168 --- tests/attachment/manager_test.php | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/attachment/manager_test.php (limited to 'tests') diff --git a/tests/attachment/manager_test.php b/tests/attachment/manager_test.php new file mode 100644 index 0000000000..f71ccfbb6c --- /dev/null +++ b/tests/attachment/manager_test.php @@ -0,0 +1,69 @@ + + * @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_attachment_manager_test extends \phpbb_test_case +{ + protected $delete; + protected $resync; + protected $upload; + + public function setUp() + { + $this->delete = $this->getMockBuilder('\phpbb\attachment\delete') + ->disableOriginalConstructor() + ->setMethods(['delete', 'unlink']) + ->getMock(); + $this->resync = $this->getMockBuilder('\phpbb\attachment\resync') + ->disableOriginalConstructor() + ->setMethods(['resync']) + ->getMock(); + $this->upload = $this->getMockBuilder('\phpbb\attachment\upload') + ->disableOriginalConstructor() + ->setMethods(['upload']) + ->getMock(); + } + + protected function get_manager() + { + return new \phpbb\attachment\manager($this->delete, $this->resync, $this->upload); + } + + public function data_delete() + { + return array( + [ + ['foo', [1, 2, 3], false], + ['foo', [1, 2, 3], false], + true, + ], + [ + ['foo', [1, 2, 3], true], + ['foo', [1, 2, 3]], + true, + ], + ); + } + + /** + * @dataProvider data_delete + */ + public function test_delete($input, $input_manager, $output) + { + $mock = $this->delete->expects($this->atLeastOnce()) + ->method('delete'); + $mock = call_user_func_array([$mock, 'with'], $input); + $mock->willReturn($output); + $manager = $this->get_manager(); + $this->assertSame($output, call_user_func_array([$manager, 'delete'], $input_manager)); + } +} -- cgit v1.2.1 From b90783a296bc15427e9f29a5ed4d0912afcfa6b4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Oct 2015 12:29:00 +0200 Subject: [ticket/14168] Add new test method and more tests One test method to rule them all. PHPBB3-14168 --- tests/attachment/manager_test.php | 45 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/attachment/manager_test.php b/tests/attachment/manager_test.php index f71ccfbb6c..85a6465ab9 100644 --- a/tests/attachment/manager_test.php +++ b/tests/attachment/manager_test.php @@ -21,7 +21,7 @@ class phpbb_attachment_manager_test extends \phpbb_test_case { $this->delete = $this->getMockBuilder('\phpbb\attachment\delete') ->disableOriginalConstructor() - ->setMethods(['delete', 'unlink']) + ->setMethods(['delete', 'unlink_attachment']) ->getMock(); $this->resync = $this->getMockBuilder('\phpbb\attachment\resync') ->disableOriginalConstructor() @@ -66,4 +66,47 @@ class phpbb_attachment_manager_test extends \phpbb_test_case $manager = $this->get_manager(); $this->assertSame($output, call_user_func_array([$manager, 'delete'], $input_manager)); } + + public function data_manager() + { + return array( + array( + 'delete', + 'unlink_attachment', + 'unlink', + ['foo'], + ['foo', 'file', false], + true, + ), + array( + 'delete', + 'unlink_attachment', + 'unlink', + ['foo', 'bar'], + ['foo', 'bar', false], + true, + ), + array( + 'delete', + 'unlink_attachment', + 'unlink', + ['foo', 'bar', true], + ['foo', 'bar', true], + true, + ), + ); + } + + /** + * @dataProvider data_manager + */ + public function test_manager($class, $method_class, $method_manager, $input_manager, $input_method, $output) + { + $mock = call_user_func_array([$this->{$class}, 'expects'], [$this->atLeastOnce()]); + $mock = $mock->method($method_class); + $mock = call_user_func_array([$mock, 'with'], $input_method); + $mock->willReturn($output); + $manager = $this->get_manager(); + $this->assertSame($output, call_user_func_array([$manager, $method_manager], $input_manager)); + } } -- cgit v1.2.1 From 52dccd3dba0808e4e19aa8407da1d4c75fe241cd Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Oct 2015 14:33:12 +0200 Subject: [ticket/14168] Add more test cases for attachment manager PHPBB3-14168 --- tests/attachment/manager_test.php | 81 ++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/attachment/manager_test.php b/tests/attachment/manager_test.php index 85a6465ab9..01a6049602 100644 --- a/tests/attachment/manager_test.php +++ b/tests/attachment/manager_test.php @@ -38,35 +38,6 @@ class phpbb_attachment_manager_test extends \phpbb_test_case return new \phpbb\attachment\manager($this->delete, $this->resync, $this->upload); } - public function data_delete() - { - return array( - [ - ['foo', [1, 2, 3], false], - ['foo', [1, 2, 3], false], - true, - ], - [ - ['foo', [1, 2, 3], true], - ['foo', [1, 2, 3]], - true, - ], - ); - } - - /** - * @dataProvider data_delete - */ - public function test_delete($input, $input_manager, $output) - { - $mock = $this->delete->expects($this->atLeastOnce()) - ->method('delete'); - $mock = call_user_func_array([$mock, 'with'], $input); - $mock->willReturn($output); - $manager = $this->get_manager(); - $this->assertSame($output, call_user_func_array([$manager, 'delete'], $input_manager)); - } - public function data_manager() { return array( @@ -77,6 +48,7 @@ class phpbb_attachment_manager_test extends \phpbb_test_case ['foo'], ['foo', 'file', false], true, + true, ), array( 'delete', @@ -85,6 +57,7 @@ class phpbb_attachment_manager_test extends \phpbb_test_case ['foo', 'bar'], ['foo', 'bar', false], true, + true, ), array( 'delete', @@ -93,6 +66,52 @@ class phpbb_attachment_manager_test extends \phpbb_test_case ['foo', 'bar', true], ['foo', 'bar', true], true, + true, + ), + array( + 'delete', + 'delete', + 'delete', + ['foo', [1, 2, 3]], + ['foo', [1, 2, 3], true], + true, + true, + ), + array( + 'delete', + 'delete', + 'delete', + ['foo', [1, 2, 3], false], + ['foo', [1, 2, 3], false], + true, + true, + ), + array( + 'resync', + 'resync', + 'resync', + ['foo', [1, 2, 3]], + ['foo', [1, 2, 3]], + true, + null, + ), + array( + 'upload', + 'upload', + 'upload', + ['foo', 1], + ['foo', 1, false, '', false, []], + true, + true, + ), + array( + 'upload', + 'upload', + 'upload', + ['foo', 1, true, 'bar', true, ['filename' => 'foobar']], + ['foo', 1, true, 'bar', true, ['filename' => 'foobar']], + true, + true, ), ); } @@ -100,12 +119,12 @@ class phpbb_attachment_manager_test extends \phpbb_test_case /** * @dataProvider data_manager */ - public function test_manager($class, $method_class, $method_manager, $input_manager, $input_method, $output) + public function test_manager($class, $method_class, $method_manager, $input_manager, $input_method, $return, $output) { $mock = call_user_func_array([$this->{$class}, 'expects'], [$this->atLeastOnce()]); $mock = $mock->method($method_class); $mock = call_user_func_array([$mock, 'with'], $input_method); - $mock->willReturn($output); + $mock->willReturn($return); $manager = $this->get_manager(); $this->assertSame($output, call_user_func_array([$manager, $method_manager], $input_manager)); } -- cgit v1.2.1 From 49312f05f88ca58346cbb00c2f03f01fd2a3d56d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 12 Oct 2015 11:34:11 +0200 Subject: [ticket/14168] Use attachment manager instead of separate classes PHPBB3-14168 --- tests/attachment/manager_test.php | 8 ++++---- tests/content_visibility/delete_post_test.php | 3 ++- tests/functions_user/delete_user_test.php | 3 ++- tests/privmsgs/delete_user_pms_test.php | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/attachment/manager_test.php b/tests/attachment/manager_test.php index 01a6049602..47d7f38b1d 100644 --- a/tests/attachment/manager_test.php +++ b/tests/attachment/manager_test.php @@ -74,8 +74,8 @@ class phpbb_attachment_manager_test extends \phpbb_test_case 'delete', ['foo', [1, 2, 3]], ['foo', [1, 2, 3], true], - true, - true, + 5, + 5, ), array( 'delete', @@ -83,8 +83,8 @@ class phpbb_attachment_manager_test extends \phpbb_test_case 'delete', ['foo', [1, 2, 3], false], ['foo', [1, 2, 3], false], - true, - true, + 2, + 2, ), array( 'resync', diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index f174b99d51..ba0a21a1a4 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -319,7 +319,8 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); - $phpbb_container->set('attachment.delete', $attachment_delete); + // Works as a workaround for tests + $phpbb_container->set('attachment.manager', $attachment_delete); delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 1a5a4f672e..6d2e1fa20a 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -36,7 +36,8 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); + // Works as a workaround for tests + $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); $phpbb_container->set( 'auth.provider.db', new phpbb_mock_auth_provider() diff --git a/tests/privmsgs/delete_user_pms_test.php b/tests/privmsgs/delete_user_pms_test.php index 329c401316..9d6ba7a917 100644 --- a/tests/privmsgs/delete_user_pms_test.php +++ b/tests/privmsgs/delete_user_pms_test.php @@ -91,7 +91,8 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('attachment.delete', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); + // Works as a workaround for tests + $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); phpbb_delete_user_pms($delete_user); -- cgit v1.2.1 From b64a37d451132dcf7ef5fc3d6e700a6fb6decd90 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 13 Oct 2015 23:40:52 -0700 Subject: [ticket/14237] Use $language class for notifications PHPBB3-14237 --- tests/mock/notification_type_post.php | 3 ++- tests/notification/base.php | 2 ++ tests/notification/fixtures/services_notification.yml | 3 +++ tests/notification/submit_post_base.php | 10 +++++++--- tests/notification/user_list_trim_test.php | 4 ++-- 5 files changed, 16 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/mock/notification_type_post.php b/tests/mock/notification_type_post.php index fd2d1b63cd..4116fecf5e 100644 --- a/tests/mock/notification_type_post.php +++ b/tests/mock/notification_type_post.php @@ -21,11 +21,12 @@ if (!defined('IN_PHPBB')) class phpbb_mock_notification_type_post extends \phpbb\notification\type\post { - public function __construct($user_loader, $db, $cache, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $user_notifications_table) + public function __construct($user_loader, $db, $cache, $language, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $user_notifications_table) { $this->user_loader = $user_loader; $this->db = $db; $this->cache = $cache; + $this->language = $language; $this->user = $user; $this->auth = $auth; $this->config = $config; diff --git a/tests/notification/base.php b/tests/notification/base.php index 1295f099f0..b64e25cf8c 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -90,6 +90,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $loader->load('services_notification.yml'); $phpbb_container->set('user_loader', $this->user_loader); $phpbb_container->set('user', $user); + $phpbb_container->set('language', $lang); $phpbb_container->set('config', $this->config); $phpbb_container->set('dbal.conn', $this->db); $phpbb_container->set('auth', $auth); @@ -111,6 +112,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $this->phpbb_dispatcher, $this->db, $this->cache, + $lang, $this->user, 'phpbb_notification_types', 'phpbb_user_notifications' diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml index e0a404b12b..6e68cccff6 100644 --- a/tests/notification/fixtures/services_notification.yml +++ b/tests/notification/fixtures/services_notification.yml @@ -17,6 +17,9 @@ services: dbal.conn: synthetic: true + language: + synthetic: true + auth: synthetic: true diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 72b25abf0a..14ca4499d2 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -54,7 +54,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c { parent::setUp(); - global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path, $user_loader; + global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader; // Database $this->db = $this->new_dbal(); @@ -91,9 +91,12 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Event dispatcher $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + // Language + $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + // User $user = $this->getMock('\phpbb\user', array(), array( - new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + $lang, '\phpbb\datetime' )); $user->ip = ''; @@ -117,6 +120,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $loader->load('services_notification.yml'); $phpbb_container->set('user_loader', $user_loader); $phpbb_container->set('user', $user); + $phpbb_container->set('language', $lang); $phpbb_container->set('config', $config); $phpbb_container->set('dbal.conn', $db); $phpbb_container->set('auth', $auth); @@ -146,7 +150,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Notification Manager $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, $notification_methods_array, - $phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $user, + $phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $lang, $user, NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE); $phpbb_container->set('notification_manager', $phpbb_notifications); } diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index d57fbf0485..9f6eb492f6 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -55,13 +55,13 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->data = array('user_lang' => 'en'); - $user->add_lang('common'); + $lang->add_lang('common'); $user_loader = new phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE); $user_loader->load_users(array(2, 3, 4, 5, 6)); $this->notification = new phpbb_mock_notification_type_post( - $user_loader, null, null, $user, null, null, $phpbb_root_path, $phpEx, null, null + $user_loader, null, null, $lang, $user, null, null, $phpbb_root_path, $phpEx, null, null ); } -- cgit v1.2.1 From 8f5a0ad6f73e7b7757b02c827436384c96069b5a Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 09:20:50 +0200 Subject: [ticket/14039] Revamp updater PHPBB3-14039 --- .../di/fixtures/other_config/production/config.yml | 2 ++ .../production/container/environment.yml | 29 ++++++++++++++++++++++ tests/event/exception_listener_test.php | 4 +-- tests/installer/installer_config_test.php | 19 ++++++++------ 4 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 tests/di/fixtures/other_config/production/config.yml create mode 100644 tests/di/fixtures/other_config/production/container/environment.yml (limited to 'tests') diff --git a/tests/di/fixtures/other_config/production/config.yml b/tests/di/fixtures/other_config/production/config.yml new file mode 100644 index 0000000000..fcfa84f68b --- /dev/null +++ b/tests/di/fixtures/other_config/production/config.yml @@ -0,0 +1,2 @@ +core: + require_dev_dependencies: true diff --git a/tests/di/fixtures/other_config/production/container/environment.yml b/tests/di/fixtures/other_config/production/container/environment.yml new file mode 100644 index 0000000000..4960562a6c --- /dev/null +++ b/tests/di/fixtures/other_config/production/container/environment.yml @@ -0,0 +1,29 @@ +parameters: + other_config: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock + + ext.manager: + class: phpbb\extension\manager_mock + + template.twig.environment: + class: Exception + arguments: + - ~ + - ~ + - ~ + - ~ + - ~ + - ~ + - ~ + - [] diff --git a/tests/event/exception_listener_test.php b/tests/event/exception_listener_test.php index 608cde4f9b..e643fadf2c 100644 --- a/tests/event/exception_listener_test.php +++ b/tests/event/exception_listener_test.php @@ -83,10 +83,8 @@ class exception_listener extends phpbb_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); - $user = new \phpbb\user($lang, '\phpbb\datetime'); - $user->add_lang('common'); - $exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $user); + $exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $lang); $event = new \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, $exception); $exception_listener->on_kernel_exception($event); diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php index 7de23aea36..c8e482e260 100644 --- a/tests/installer/installer_config_test.php +++ b/tests/installer/installer_config_test.php @@ -62,13 +62,18 @@ class phpbb_installer_config_test extends phpbb_test_case $this->config->increment_current_task_progress(2); - $this->assertEquals(array( - 'last_task_module_name' => 'bar', - 'last_task_name' => 'foo', - 'max_task_progress' => 10, - 'current_task_progress' => 3, - ), - $this->config->get_progress_data() + // We only want to check these values + $result = $this->config->get_progress_data(); + $expected_result = array( + 'last_task_module_name' => 'bar', + 'last_task_name' => 'foo', + 'max_task_progress' => 10, + 'current_task_progress' => 3, ); + + foreach ($expected_result as $key => $value) + { + $this->assertEquals($value, $result[$key]); + } } } -- cgit v1.2.1 From 597297b169e2ae14684ad1f40c8e083be22b241d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 22:47:04 +0200 Subject: [ticket/14044] Deduplicate the installers PHPBB3-14044 --- tests/functional/search/base.php | 7 +- .../ignore_new_file_on_update_test.php | 45 ----- .../mock/phpbb_mock_null_installer_task.php | 30 ++++ .../phpbb_database_test_connection_manager.php | 8 +- .../test_framework/phpbb_functional_test_case.php | 189 +++++++++------------ tests/test_framework/phpbb_ui_test_case.php | 159 +++++++++-------- 6 files changed, 207 insertions(+), 231 deletions(-) delete mode 100644 tests/functions_install/ignore_new_file_on_update_test.php create mode 100644 tests/test_framework/mock/phpbb_mock_null_installer_task.php (limited to 'tests') diff --git a/tests/functional/search/base.php b/tests/functional/search/base.php index 1d37d748df..a3cac381d2 100644 --- a/tests/functional/search/base.php +++ b/tests/functional/search/base.php @@ -36,6 +36,8 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case $this->login(); $this->admin_login(); + $this->create_search_index('\phpbb\search\fulltext_native'); + $post = $this->create_topic(2, 'Test Topic 1 foosubject', 'This is a test topic posted by the barsearch testing framework.'); $crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=settings&sid=' . $this->sid); @@ -58,6 +60,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case $this->delete_topic($post['topic_id']); $this->markTestSkipped("Search backend is not supported/running"); } + $this->create_search_index(); } @@ -72,14 +75,14 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case $this->delete_topic($post['topic_id']); } - protected function create_search_index() + protected function create_search_index($backend = null) { $this->add_lang('acp/search'); $crawler = self::request( 'POST', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid, array( - 'search_type' => $this->search_backend, + 'search_type' => ( ($backend === null) ? $this->search_backend : $backend ), 'action' => 'create', 'submit' => true, ) diff --git a/tests/functions_install/ignore_new_file_on_update_test.php b/tests/functions_install/ignore_new_file_on_update_test.php deleted file mode 100644 index 822c5e6789..0000000000 --- a/tests/functions_install/ignore_new_file_on_update_test.php +++ /dev/null @@ -1,45 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php'; - -class phpbb_functions_install_ignore_new_file_on_update_test extends phpbb_test_case -{ - static public function ignore_new_file_on_update_data() - { - return array( - array('willneverexist.php', false), - array('includes/dirwillneverexist/newfile.php', false), - - array('language/en/email/short/bookmark.txt', false), - array('language/languagewillneverexist/email/short/bookmark.txt', true), - - array('styles/prosilver/template/bbcode.html', false), - array('styles/stylewillneverexist/template/bbcode.html', true), - - array('styles/prosilver/theme/en/icon_user_online.gif', false), - array('styles/prosilver/theme/languagewillneverexist/icon_user_online.gif', true), - - array('styles/prosilver/theme/imageset.css', false), - ); - } - - /** - * @dataProvider ignore_new_file_on_update_data - */ - public function test_ignore_new_file_on_update($file, $expected) - { - global $phpbb_root_path; - $this->assertEquals($expected, phpbb_ignore_new_file_on_update($phpbb_root_path, $file)); - } -} diff --git a/tests/test_framework/mock/phpbb_mock_null_installer_task.php b/tests/test_framework/mock/phpbb_mock_null_installer_task.php new file mode 100644 index 0000000000..c1b880d967 --- /dev/null +++ b/tests/test_framework/mock/phpbb_mock_null_installer_task.php @@ -0,0 +1,30 @@ + + * @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_mock_null_installer_task extends \phpbb\install\task_base +{ + public function run() + { + + } + + static public function get_step_count() + { + return 0; + } + + public function get_task_lang_name() + { + return ''; + } +} diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 5136af5ad1..fa50d89a70 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php'; require_once dirname(__FILE__) . '/phpbb_database_connection_odbc_pdo_wrapper.php'; class phpbb_database_test_connection_manager @@ -344,10 +343,13 @@ class phpbb_database_test_connection_manager if (file_exists($filename)) { + global $phpbb_root_path; + $queries = file_get_contents($filename); - $sql = phpbb_remove_comments($queries); - $sql = split_sql_file($sql, $this->dbms['DELIM']); + $db_helper = new \phpbb\install\helper\database(new \phpbb\filesystem\filesystem(), $phpbb_root_path); + $sql = $db_helper->remove_comments($queries); + $sql = $db_helper->split_sql_file($sql, $this->dbms['DELIM']); foreach ($sql as $query) { diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index bef1208609..9adbda9fc6 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -12,7 +12,7 @@ */ use Symfony\Component\BrowserKit\CookieJar; -require_once __DIR__ . '/../../phpBB/includes/functions_install.php'; +require_once __DIR__ . '/mock/phpbb_mock_null_installer_task.php'; class phpbb_functional_test_case extends phpbb_test_case { @@ -285,120 +285,97 @@ class phpbb_functional_test_case extends phpbb_test_case } } - self::$cookieJar = new CookieJar; - self::$client = new Goutte\Client(array(), null, self::$cookieJar); - // Set client manually so we can increase the cURL timeout - self::$client->setClient(new Guzzle\Http\Client('', array( - Guzzle\Http\Client::DISABLE_REDIRECTS => true, - 'curl.options' => array( - CURLOPT_TIMEOUT => 120, - ), - ))); - - // Reset the curl handle because it is 0 at this point and not a valid - // resource - self::$client->getClient()->getCurlMulti()->reset(true); + $container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); + $container = $container_builder + ->with_environment('installer') + ->without_extensions() + ->without_cache() + ->with_custom_parameters([ + 'core.disable_super_globals' => false, + 'installer.create_config_file.options' => [ + 'debug' => true, + 'environment' => 'test', + ] + ]) + ->without_compiled_container() + ->get_container(); + + $container->register('installer.install_finish.notify_user')->setSynthetic(true); + $container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task()); + $container->compile(); + + $language = $container->get('language'); + $language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); + + $iohandler_factory = $container->get('installer.helper.iohandler_factory'); + $iohandler_factory->set_environment('cli'); + $iohandler = $iohandler_factory->get(); $parseURL = parse_url(self::$config['phpbb_functional_url']); - $crawler = self::request('GET', 'install/index.php?mode=install&language=en'); - self::assertContains('Welcome to Installation', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - - // install/index.php?mode=install&sub=requirements - $crawler = self::submit($form); - self::assertContains('Installation compatibility', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - - // install/index.php?mode=install&sub=database - $crawler = self::submit($form); - self::assertContains('Database configuration', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(array( - // Installer uses 3.0-style dbms name - 'dbms' => str_replace('phpbb\db\driver\\', '', self::$config['dbms']), - 'dbhost' => self::$config['dbhost'], - 'dbport' => self::$config['dbport'], - 'dbname' => self::$config['dbname'], - 'dbuser' => self::$config['dbuser'], - 'dbpasswd' => self::$config['dbpasswd'], - 'table_prefix' => self::$config['table_prefix'], - )); - - // install/index.php?mode=install&sub=database - $crawler = self::submit($form); - self::assertContains('Successful connection', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - - // install/index.php?mode=install&sub=administrator - $crawler = self::submit($form); - self::assertContains('Administrator configuration', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(array( - 'default_lang' => 'en', - 'admin_name' => 'admin', - 'admin_pass1' => 'adminadmin', - 'admin_pass2' => 'adminadmin', - 'board_email' => 'nobody@example.com', - )); - - // install/index.php?mode=install&sub=administrator - $crawler = self::submit($form); - self::assertContains('Tests passed', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - - // We have to skip install/index.php?mode=install&sub=config_file - // because that step will create a config.php file if phpBB has the - // permission to do so. We have to create the config file on our own - // in order to get the DEBUG constants defined. - $config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, false, true); - $config_created = file_put_contents($config_file, $config_php_data) !== false; - if (!$config_created) + $output = new \Symfony\Component\Console\Output\NullOutput(); + $style = new \Symfony\Component\Console\Style\SymfonyStyle( + new \Symfony\Component\Console\Input\ArrayInput(array()), + $output + ); + $iohandler->set_style($style, $output); + + $installer = $container->get('installer.installer.install'); + $installer->set_iohandler($iohandler); + + // Set data + $iohandler->set_input('admin_name', 'admin'); + $iohandler->set_input('admin_pass1', 'adminadmin'); + $iohandler->set_input('admin_pass2', 'adminadmin'); + $iohandler->set_input('board_email', 'nobody@example.com'); + $iohandler->set_input('submit_admin', 'submit'); + + $iohandler->set_input('default_lang', 'en'); + $iohandler->set_input('board_name', 'yourdomain.com'); + $iohandler->set_input('board_description', 'A short text to describe your forum'); + $iohandler->set_input('submit_board', 'submit'); + + $iohandler->set_input('dbms', str_replace('phpbb\db\driver\\', '', self::$config['dbms'])); + $iohandler->set_input('dbhost', self::$config['dbhost']); + $iohandler->set_input('dbport', self::$config['dbport']); + $iohandler->set_input('dbuser', self::$config['dbuser']); + $iohandler->set_input('dbpasswd', self::$config['dbpasswd']); + $iohandler->set_input('dbname', self::$config['dbname']); + $iohandler->set_input('table_prefix', self::$config['table_prefix']); + $iohandler->set_input('submit_database', 'submit'); + + $iohandler->set_input('email_enable', true); + $iohandler->set_input('smtp_delivery', '1'); + $iohandler->set_input('smtp_host', 'nxdomain.phpbb.com'); + $iohandler->set_input('smtp_auth', 'PLAIN'); + $iohandler->set_input('smtp_user', 'nxuser'); + $iohandler->set_input('smtp_pass', 'nxpass'); + $iohandler->set_input('submit_email', 'submit'); + + $iohandler->set_input('cookie_secure', '0'); + $iohandler->set_input('server_protocol', '0'); + $iohandler->set_input('force_server_vars', $parseURL['scheme'] . '://'); + $iohandler->set_input('server_name', $parseURL['host']); + $iohandler->set_input('server_port', isset($parseURL['port']) ? (int) $parseURL['port'] : 80); + $iohandler->set_input('script_path', $parseURL['path']); + $iohandler->set_input('submit_server', 'submit'); + + do { - self::markTestSkipped("Could not write $config_file file."); + $installer->run(); } + while (file_exists($phpbb_root_path . 'store/install_config.php')); + + copy($config_file, $config_file_test); - // We also have to create a install lock that is normally created by - // the installer. The file will be removed by the final step of the - // installer. - $install_lock_file = $phpbb_root_path . 'cache/install_lock'; - $lock_created = file_put_contents($install_lock_file, '') !== false; - if (!$lock_created) + if (file_exists($phpbb_root_path . 'cache/install_lock')) { - self::markTestSkipped("Could not create $lock_created file."); + unlink($phpbb_root_path . 'cache/install_lock'); } - @chmod($install_lock_file, 0666); - - // install/index.php?mode=install&sub=advanced - $form_data = $form->getValues(); - unset($form_data['submit']); - - $crawler = self::request('POST', 'install/index.php?mode=install&sub=advanced', $form_data); - self::assertContains('The settings on this page are only necessary to set if you know that you require something different from the default.', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(array( - 'email_enable' => true, - 'smtp_delivery' => true, - 'smtp_host' => 'nxdomain.phpbb.com', - 'smtp_auth' => 'PLAIN', - 'smtp_user' => 'nxuser', - 'smtp_pass' => 'nxpass', - 'cookie_secure' => false, - 'force_server_vars' => false, - 'server_protocol' => $parseURL['scheme'] . '://', - 'server_name' => 'localhost', - 'server_port' => isset($parseURL['port']) ? (int) $parseURL['port'] : 80, - 'script_path' => $parseURL['path'], - )); - - // install/index.php?mode=install&sub=create_table - $crawler = self::submit($form); - self::assertContains('The database tables used by phpBB', $crawler->filter('#main')->text()); - self::assertContains('have been created and populated with some initial data.', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - // install/index.php?mode=install&sub=final - $crawler = self::submit($form); - self::assertContains('You have successfully installed', $crawler->text()); - - copy($config_file, $config_file_test); + global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; + $phpbb_container->reset(); + unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template); } public function install_ext($extension) diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index c8ac492e25..5da176e929 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -11,7 +11,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions_install.php'; +require_once __DIR__ . '/mock/phpbb_mock_null_installer_task.php'; class phpbb_ui_test_case extends phpbb_test_case { @@ -118,87 +118,96 @@ class phpbb_ui_test_case extends phpbb_test_case } } + $container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); + $container = $container_builder + ->with_environment('installer') + ->without_extensions() + ->without_cache() + ->with_custom_parameters([ + 'core.disable_super_globals' => false, + 'installer.create_config_file.options' => [ + 'debug' => true, + 'environment' => 'test', + ] + ]) + ->without_compiled_container() + ->get_container(); + + $container->register('installer.install_finish.notify_user')->setSynthetic(true); + $container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task()); + $container->compile(); + + $language = $container->get('language'); + $language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); + + $iohandler_factory = $container->get('installer.helper.iohandler_factory'); + $iohandler_factory->set_environment('cli'); + $iohandler = $iohandler_factory->get(); + $parseURL = parse_url(self::$config['phpbb_functional_url']); - self::visit('install/index.php?mode=install&language=en'); - self::assertContains('Welcome to Installation', self::find_element('id', 'main')->getText()); - - // install/index.php?mode=install&sub=requirements - self::submit(); - self::assertContains('Installation compatibility', self::find_element('id', 'main')->getText()); - - // install/index.php?mode=install&sub=database - self::submit(); - self::assertContains('Database configuration', self::find_element('id', 'main')->getText()); - - self::find_element('id','dbms')->sendKeys(str_replace('phpbb\db\driver\\', '', self::$config['dbms'])); - self::find_element('id','dbhost')->sendKeys(self::$config['dbhost']); - self::find_element('id','dbport')->sendKeys(self::$config['dbport']); - self::find_element('id','dbname')->sendKeys(self::$config['dbname']); - self::find_element('id','dbuser')->sendKeys(self::$config['dbuser']); - self::find_element('id','dbpasswd')->sendKeys(self::$config['dbpasswd']); - - // Need to clear default phpbb_ prefix - self::find_element('id','table_prefix')->clear(); - self::find_element('id','table_prefix')->sendKeys(self::$config['table_prefix']); - - // install/index.php?mode=install&sub=database - self::submit(); - self::assertContains('Successful connection', self::find_element('id','main')->getText()); - - // install/index.php?mode=install&sub=administrator - self::submit(); - self::assertContains('Administrator configuration', self::find_element('id','main')->getText()); - - self::find_element('id','admin_name')->sendKeys('admin'); - self::find_element('id','admin_pass1')->sendKeys('adminadmin'); - self::find_element('id','admin_pass2')->sendKeys('adminadmin'); - self::find_element('id','board_email')->sendKeys('nobody@example.com'); - - // install/index.php?mode=install&sub=administrator - self::submit(); - self::assertContains('Tests passed', self::find_element('id','main')->getText()); - - // install/index.php?mode=install&sub=config_file - self::submit(); - - // Installer has created a config.php file, we will overwrite it with a - // config file of our own in order to get the DEBUG constants defined - $config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, false, true); - $config_created = file_put_contents($config_file, $config_php_data) !== false; - if (!$config_created) + $output = new \Symfony\Component\Console\Output\NullOutput(); + $style = new \Symfony\Component\Console\Style\SymfonyStyle( + new \Symfony\Component\Console\Input\ArrayInput(array()), + $output + ); + $iohandler->set_style($style, $output); + + $installer = $container->get('installer.installer.install'); + $installer->set_iohandler($iohandler); + + // Set data + $iohandler->set_input('admin_name', 'admin'); + $iohandler->set_input('admin_pass1', 'adminadmin'); + $iohandler->set_input('admin_pass2', 'adminadmin'); + $iohandler->set_input('board_email', 'nobody@example.com'); + $iohandler->set_input('submit_admin', 'submit'); + + $iohandler->set_input('default_lang', 'en'); + $iohandler->set_input('board_name', 'yourdomain.com'); + $iohandler->set_input('board_description', 'A short text to describe your forum'); + $iohandler->set_input('submit_board', 'submit'); + + $iohandler->set_input('dbms', str_replace('phpbb\db\driver\\', '', self::$config['dbms'])); + $iohandler->set_input('dbhost', self::$config['dbhost']); + $iohandler->set_input('dbport', self::$config['dbport']); + $iohandler->set_input('dbuser', self::$config['dbuser']); + $iohandler->set_input('dbpasswd', self::$config['dbpasswd']); + $iohandler->set_input('dbname', self::$config['dbname']); + $iohandler->set_input('table_prefix', self::$config['table_prefix']); + $iohandler->set_input('submit_database', 'submit'); + + $iohandler->set_input('email_enable', true); + $iohandler->set_input('smtp_delivery', '1'); + $iohandler->set_input('smtp_host', 'nxdomain.phpbb.com'); + $iohandler->set_input('smtp_auth', 'PLAIN'); + $iohandler->set_input('smtp_user', 'nxuser'); + $iohandler->set_input('smtp_pass', 'nxpass'); + $iohandler->set_input('submit_email', 'submit'); + + $iohandler->set_input('cookie_secure', '0'); + $iohandler->set_input('server_protocol', '0'); + $iohandler->set_input('force_server_vars', $parseURL['scheme'] . '://'); + $iohandler->set_input('server_name', $parseURL['host']); + $iohandler->set_input('server_port', isset($parseURL['port']) ? (int) $parseURL['port'] : 80); + $iohandler->set_input('script_path', $parseURL['path']); + $iohandler->set_input('submit_server', 'submit'); + + do { - self::markTestSkipped("Could not write $config_file file."); + $installer->run(); } + while (file_exists($phpbb_root_path . 'store/install_config.php')); + + copy($config_file, $config_file_test); - if (strpos(self::find_element('id','main')->getText(), 'The configuration file has been written') === false) + if (file_exists($phpbb_root_path . 'cache/install_lock')) { - self::submit('id', 'dldone'); + unlink($phpbb_root_path . 'cache/install_lock'); } - self::assertContains('The configuration file has been written', self::find_element('id','main')->getText()); - - // install/index.php?mode=install&sub=advanced - self::submit(); - self::assertContains('The settings on this page are only necessary to set if you know that you require something different from the default.', self::find_element('id','main')->getText()); - - self::find_element('id','smtp_delivery')->sendKeys('1'); - self::find_element('id','smtp_host')->sendKeys('nxdomain.phpbb.com'); - self::find_element('id','smtp_user')->sendKeys('nxuser'); - self::find_element('id','smtp_pass')->sendKeys('nxpass'); - self::find_element('id','server_protocol')->sendKeys($parseURL['scheme'] . '://'); - self::find_element('id','server_name')->sendKeys('localhost'); - self::find_element('id','server_port')->sendKeys(isset($parseURL['port']) ? $parseURL['port'] : 80); - self::find_element('id','script_path')->sendKeys($parseURL['path']); - - // install/index.php?mode=install&sub=create_table - self::submit(); - self::assertContains('The database tables used by phpBB', self::find_element('id','main')->getText()); - self::assertContains('have been created and populated with some initial data.', self::find_element('id','main')->getText()); - - // install/index.php?mode=install&sub=final - self::submit(); - self::assertContains('You have successfully installed', self::find_element('id', 'main')->getText()); - copy($config_file, $config_file_test); + global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; + $phpbb_container->reset(); + unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template); } } -- cgit v1.2.1 From a910c8699761a40501d7e0b807e4282925c098b9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 30 Oct 2015 14:58:53 +0100 Subject: [ticket/14044] Fix tests PHPBB3-14044 --- tests/bootstrap.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ace48ea035..86e1e5314b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -16,6 +16,8 @@ define('PHPBB_ENVIRONMENT', 'test'); $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; + +global $table_prefix; require_once $phpbb_root_path . 'includes/startup.php'; $table_prefix = 'phpbb_'; -- cgit v1.2.1 From 3c43865a15f59f119e41a277d9053c4689b2652e Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Tue, 3 Nov 2015 16:45:57 +0100 Subject: [ticket/14264] Fix textreparser tests PHPBB3-14264 --- tests/text_reparser/plugins/forum_description_test.php | 2 +- tests/text_reparser/plugins/forum_rules_test.php | 2 +- tests/text_reparser/plugins/group_description_test.php | 2 +- tests/text_reparser/plugins/pm_text_test.php | 2 +- tests/text_reparser/plugins/poll_title_test.php | 2 +- tests/text_reparser/plugins/post_text_test.php | 2 +- tests/text_reparser/plugins/user_signature_test.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/text_reparser/plugins/forum_description_test.php b/tests/text_reparser/plugins/forum_description_test.php index 3b739353cd..57166e6a3c 100644 --- a/tests/text_reparser/plugins/forum_description_test.php +++ b/tests/text_reparser/plugins/forum_description_test.php @@ -21,6 +21,6 @@ class phpbb_textreparser_forum_description_test extends phpbb_textreparser_test_ protected function get_reparser() { - return new \phpbb\textreparser\plugins\forum_description($this->db); + return new \phpbb\textreparser\plugins\forum_description($this->db, FORUMS_TABLE); } } diff --git a/tests/text_reparser/plugins/forum_rules_test.php b/tests/text_reparser/plugins/forum_rules_test.php index 4c267c9014..72e4e98876 100644 --- a/tests/text_reparser/plugins/forum_rules_test.php +++ b/tests/text_reparser/plugins/forum_rules_test.php @@ -21,6 +21,6 @@ class phpbb_textreparser_forum_rules_test extends phpbb_textreparser_test_row_ba protected function get_reparser() { - return new \phpbb\textreparser\plugins\forum_rules($this->db); + return new \phpbb\textreparser\plugins\forum_rules($this->db, FORUMS_TABLE); } } diff --git a/tests/text_reparser/plugins/group_description_test.php b/tests/text_reparser/plugins/group_description_test.php index 51035903e1..babfc7e02f 100644 --- a/tests/text_reparser/plugins/group_description_test.php +++ b/tests/text_reparser/plugins/group_description_test.php @@ -21,6 +21,6 @@ class phpbb_textreparser_group_description_test extends phpbb_textreparser_test_ protected function get_reparser() { - return new \phpbb\textreparser\plugins\group_description($this->db); + return new \phpbb\textreparser\plugins\group_description($this->db, GROUPS_TABLE); } } diff --git a/tests/text_reparser/plugins/pm_text_test.php b/tests/text_reparser/plugins/pm_text_test.php index 3896a57e98..6dc1a9cb4c 100644 --- a/tests/text_reparser/plugins/pm_text_test.php +++ b/tests/text_reparser/plugins/pm_text_test.php @@ -21,6 +21,6 @@ class phpbb_textreparser_pm_text_test extends phpbb_textreparser_test_row_based_ protected function get_reparser() { - return new \phpbb\textreparser\plugins\pm_text($this->db); + return new \phpbb\textreparser\plugins\pm_text($this->db, PRIVMSGS_TABLE); } } diff --git a/tests/text_reparser/plugins/poll_title_test.php b/tests/text_reparser/plugins/poll_title_test.php index 76ca2ee228..046b6019c8 100644 --- a/tests/text_reparser/plugins/poll_title_test.php +++ b/tests/text_reparser/plugins/poll_title_test.php @@ -21,6 +21,6 @@ class phpbb_textreparser_poll_title_test extends phpbb_textreparser_test_row_bas protected function get_reparser() { - return new \phpbb\textreparser\plugins\poll_title($this->db); + return new \phpbb\textreparser\plugins\poll_title($this->db, TOPICS_TABLE); } } diff --git a/tests/text_reparser/plugins/post_text_test.php b/tests/text_reparser/plugins/post_text_test.php index 0f934a06ee..8ea71e65f5 100644 --- a/tests/text_reparser/plugins/post_text_test.php +++ b/tests/text_reparser/plugins/post_text_test.php @@ -21,6 +21,6 @@ class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_base protected function get_reparser() { - return new \phpbb\textreparser\plugins\post_text($this->db); + return new \phpbb\textreparser\plugins\post_text($this->db, POSTS_TABLE); } } diff --git a/tests/text_reparser/plugins/user_signature_test.php b/tests/text_reparser/plugins/user_signature_test.php index ab830a303d..5b66f2788a 100644 --- a/tests/text_reparser/plugins/user_signature_test.php +++ b/tests/text_reparser/plugins/user_signature_test.php @@ -21,6 +21,6 @@ class phpbb_textreparser_user_signature_test extends phpbb_textreparser_test_row protected function get_reparser() { - return new \phpbb\textreparser\plugins\user_signature($this->db); + return new \phpbb\textreparser\plugins\user_signature($this->db, USERS_TABLE); } } -- cgit v1.2.1 From ed02365868e832b7bb891386e07cb4a3c7644072 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 5 Nov 2015 20:52:37 +0100 Subject: [ticket/14264] Fix tests calling removed method PHPBB3-14264 --- tests/text_reparser/plugins/test_row_based_plugin.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_reparser/plugins/test_row_based_plugin.php b/tests/text_reparser/plugins/test_row_based_plugin.php index bbae44c8e0..e8218dfdd6 100644 --- a/tests/text_reparser/plugins/test_row_based_plugin.php +++ b/tests/text_reparser/plugins/test_row_based_plugin.php @@ -24,8 +24,13 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t { $reparser = $this->get_reparser(); $columns = $reparser->get_columns(); + + $reflection_reparser = new ReflectionClass(get_class($reparser)); + $table_property = $reflection_reparser->getProperty('table'); + $table_property->setAccessible(true); + $sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text - FROM ' . $reparser->get_table_name() . ' + FROM ' . $table_property->getValue($reparser) . ' WHERE ' . $this->db->sql_in_set($columns['id'], $ids) . ' ORDER BY id'; $result = $this->db->sql_query($sql); -- cgit v1.2.1 From 8d178f15f06e0f6b5e64447dc07157a796645572 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 4 Nov 2015 17:25:38 +0100 Subject: [ticket/14270] Purge cache when the installer is finished PHPBB3-14270 --- tests/test_framework/phpbb_functional_test_case.php | 3 ++- tests/test_framework/phpbb_ui_test_case.php | 3 ++- 2 files changed, 4 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 9adbda9fc6..323d97ff42 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -295,7 +295,8 @@ class phpbb_functional_test_case extends phpbb_test_case 'installer.create_config_file.options' => [ 'debug' => true, 'environment' => 'test', - ] + ], + 'cache.driver.class' => 'phpbb\cache\driver\file' ]) ->without_compiled_container() ->get_container(); diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 5da176e929..e118801972 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -128,7 +128,8 @@ class phpbb_ui_test_case extends phpbb_test_case 'installer.create_config_file.options' => [ 'debug' => true, 'environment' => 'test', - ] + ], + 'cache.driver.class' => 'phpbb\cache\driver\file' ]) ->without_compiled_container() ->get_container(); -- cgit v1.2.1 From 062352e312402820fd081a702c599a10c610e888 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 25 Oct 2015 17:22:40 +0000 Subject: [feature/sql-bool-builder] Changing syntax pt2. Fix tests PHPBB3-13652 --- tests/dbal/boolean_processor_test.php | 58 +++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 8662485ac8..226f5307b2 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -162,17 +162,25 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case ), ), 'WHERE' => array('AND', - array('OR', - array('AND', - array('ug.user_id', 'IN', array(1, 2, 3, 4)), - array('ug.group_id', '=', 2), - ), - array('AND', - array('ug.group_id', '=', 1), - array('b.ban_id', 'IS_NOT', NULL), + array( + array('OR', + array( + array('AND', + array( + array('ug.user_id', 'IN', array(1, 2, 3, 4)), + array('ug.group_id', '=', 2), + ), + ), + array('AND', + array( + array('ug.group_id', '=', 1), + array('b.ban_id', 'IS_NOT', NULL), + ), + ), + ), ), + array('u.user_id', '=', 'ug.user_id'), ), - array('u.user_id', '=', 'ug.user_id'), ), 'ORDER_BY' => 'u.user_id', ); @@ -204,9 +212,11 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case 'phpbb_user_group' => 'ug', ), 'WHERE' => array('AND', - array('ug.user_id', 'IN', array(1, 2, 3, 4)), - array('ug.group_id', '=', 1), - array('u.user_id', '=', 'ug.user_id'), + array( + array('ug.user_id', 'IN', array(1, 2, 3, 4)), + array('ug.group_id', '=', 1), + array('u.user_id', '=', 'ug.user_id'), + ), ), 'ORDER_BY' => 'u.user_id', ); @@ -240,13 +250,19 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case 'phpbb_user_group' => 'ug', ), 'WHERE' => array('AND', - array('NOT', - array('OR', - array('ug.group_id', '=', 1), - array('ug.group_id', '=', 2), + array( + array('NOT', + array( + array('OR', + array( + array('ug.group_id', '=', 1), + array('ug.group_id', '=', 2), + ), + ), + ), ), + array('u.user_id', '=', 'ug.user_id'), ), - array('u.user_id', '=', 'ug.user_id'), ), 'ORDER_BY' => 'u.user_id', ); @@ -283,9 +299,11 @@ class phpbb_boolean_processor_test extends phpbb_database_test_case ), ), 'WHERE' => array('AND', - array('ug.group_id', '=', 1), - array('u.user_id', '=', 'ug.user_id'), - array('b.ban_id', 'IS', NULL), + array( + array('ug.group_id', '=', 1), + array('u.user_id', '=', 'ug.user_id'), + array('b.ban_id', 'IS', NULL), + ), ), 'ORDER_BY' => 'u.username', ); -- cgit v1.2.1 From 762b383d2b7b6784d19fac888dab5798fdeacc7f Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 21 Nov 2015 04:04:50 +0100 Subject: [ticket/14257] Add tests for reparser manager PHPBB3-14257 --- tests/text_reparser/fixtures/config_text.xml | 7 ++ tests/text_reparser/manager_test.php | 117 +++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 tests/text_reparser/fixtures/config_text.xml create mode 100644 tests/text_reparser/manager_test.php (limited to 'tests') diff --git a/tests/text_reparser/fixtures/config_text.xml b/tests/text_reparser/fixtures/config_text.xml new file mode 100644 index 0000000000..ba8e1fcfcc --- /dev/null +++ b/tests/text_reparser/fixtures/config_text.xml @@ -0,0 +1,7 @@ + + +
            + config_name + config_value +
            + diff --git a/tests/text_reparser/manager_test.php b/tests/text_reparser/manager_test.php new file mode 100644 index 0000000000..df6adacb66 --- /dev/null +++ b/tests/text_reparser/manager_test.php @@ -0,0 +1,117 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once __DIR__ . '/../mock/container_builder.php'; +require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; + +class phpbb_text_reparser_manager_test extends phpbb_database_test_case +{ + /** @var \phpbb\config\config */ + protected $config; + + /** @var \phpbb\config\db_text */ + protected $config_text; + + /** @var \phpbb\textreparser\manager */ + protected $reparser_manager; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config_text.xml'); + } + + public function setUp() + { + parent::setUp(); + + $this->config = new \phpbb\config\config(array( + 'test_reparser_cron_interval' => 0, + 'my_reparser_cron_interval' => 100, + )); + + $db = $this->new_dbal(); + $this->config_text = new \phpbb\config\db_text($db, 'phpbb_config_text'); + + $service_collection = new \phpbb\di\service_collection(new phpbb_mock_container_builder()); + $service_collection->add('test_reparser'); + $service_collection->add('another_reparser'); + $service_collection->add('my_reparser'); + + $this->reparser_manager = new \phpbb\textreparser\manager($this->config, $this->config_text, $service_collection); + } + + public function test_get_resume_data() + { + $resume_data = array( + 'test_reparser' => array( + 'range-min' => 0, + 'range-max' => 100, + 'range-size' => 50, + ), + ); + $this->config_text->set('reparser_resume', serialize($resume_data)); + + $this->assert_array_content_equals($resume_data['test_reparser'], $this->reparser_manager->get_resume_data('test_reparser')); + $this->assertEmpty($this->reparser_manager->get_resume_data('another_reparser')); + } + + public function test_update_resume_data() + { + $resume_data = array( + 'test_reparser' => array( + 'range-min' => 0, + 'range-max' => 100, + 'range-size' => 50, + ), + ); + $this->config_text->set('reparser_resume', serialize($resume_data)); + + $this->reparser_manager->update_resume_data('another_reparser', 5, 20, 10, false); + $this->assert_array_content_equals($resume_data, unserialize($this->config_text->get('reparser_resume'))); + + $this->reparser_manager->update_resume_data('test_reparser', 0, 50, 50); + $resume_data = array( + 'test_reparser' => array( + 'range-min' => 0, + 'range-max' => 50, + 'range-size' => 50, + ), + 'another_reparser' => array( + 'range-min' => 5, + 'range-max' => 20, + 'range-size' => 10, + ), + ); + $this->assert_array_content_equals($resume_data, unserialize($this->config_text->get('reparser_resume'))); + } + + public function test_schedule() + { + $this->reparser_manager->schedule('no_reparser', 21); + $this->assertArrayNotHasKey('no_reparser_cron_interval', $this->config); + + $this->reparser_manager->schedule('another_reparser', 42); + $this->assertArrayNotHasKey('another_reparser_cron_interval', $this->config); + + $this->reparser_manager->schedule('test_reparser', 20); + $this->assertEquals(20, $this->config['test_reparser_cron_interval']); + } + + public function test_schedule_all() + { + $this->reparser_manager->schedule_all(180); + $this->assertEquals(180, $this->config['test_reparser_cron_interval']); + $this->assertEquals(180, $this->config['my_reparser_cron_interval']); + $this->assertArrayNotHasKey('another_reparser_cron_interval', $this->config); + } +} -- cgit v1.2.1 From 8916072a2abf0228a8795bd639c671769a2b86f3 Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 5 Dec 2015 00:01:27 +0700 Subject: [ticket/14340] Revert fix for segmentation fault error on phpBB 3.2 PHP7 tests The fix was introduces with #3826, now the PHP core bug has been fixed: https://bugs.php.net/bug.php?id=70249 PHPBB3-14340 --- tests/datetime/from_format_test.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php index 32b88ff588..7ecb546768 100644 --- a/tests/datetime/from_format_test.php +++ b/tests/datetime/from_format_test.php @@ -113,10 +113,6 @@ class phpbb_datetime_from_format_test extends phpbb_test_case { global $phpbb_root_path, $phpEx; - // This magically fixes the segmentation fault error on PHP7 tests - // while date_default_timezone_set('UTC') does not - date_default_timezone_set('Europe/Paris'); - $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); -- cgit v1.2.1 From ba8374579537345f7c592432739eea42467e845d Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 5 Dec 2015 08:05:43 +0100 Subject: [ticket/9791] Added regression test PHPBB3-9791 --- tests/text_processing/tickets_data/PHPBB3-9791.html | 1 + tests/text_processing/tickets_data/PHPBB3-9791.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-9791.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-9791.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-9791.html b/tests/text_processing/tickets_data/PHPBB3-9791.html new file mode 100644 index 0000000000..cabed5b12f --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-9791.html @@ -0,0 +1 @@ +http://www.phpbb.com/community/search.php?keywords=bogus&terms=all&author=&fid[]=46&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-9791.txt b/tests/text_processing/tickets_data/PHPBB3-9791.txt new file mode 100644 index 0000000000..e29b20086d --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-9791.txt @@ -0,0 +1 @@ +http://www.phpbb.com/community/search.php?keywords=bogus&terms=all&author=&fid[]=46&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search \ No newline at end of file -- cgit v1.2.1 From 4b8acefc6c3ed245778843ae7e52a7576eef6c28 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 5 Dec 2015 09:53:26 +0100 Subject: [ticket/13451] Added regression test PHPBB3-13451 --- tests/text_processing/tickets_data/PHPBB3-13451.html | 1 + tests/text_processing/tickets_data/PHPBB3-13451.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-13451.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-13451.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-13451.html b/tests/text_processing/tickets_data/PHPBB3-13451.html new file mode 100644 index 0000000000..e0892c18a9 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13451.html @@ -0,0 +1 @@ +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@example.org \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13451.txt b/tests/text_processing/tickets_data/PHPBB3-13451.txt new file mode 100644 index 0000000000..e0892c18a9 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13451.txt @@ -0,0 +1 @@ +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@example.org \ No newline at end of file -- cgit v1.2.1 From eb6ceb963ea7b32ef852b53d3da3a7e795291359 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 5 Dec 2015 07:55:52 +0100 Subject: [ticket/14323] Added support for truncating long URLs PHPBB3-14323 --- tests/text_formatter/s9e/default_formatting_test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 3047653d51..facffd5df1 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -225,6 +225,16 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '... www.example.org ...', '... www.example.org ...' ), + array( + // From make_clickable_test.php + 'www.phpbb.com/community/?', + 'www.phpbb.com/community/?' + ), + array( + // From make_clickable_test.php + 'http://www.phpbb.com/community/path/to/long/url/file.ext#section', + 'http://www.phpbb.com/community/path/to/ ... xt#section' + ), array( '[quote="[url=http://example.org]xxx[/url]"]...[/quote]', '
            xxx wrote:...
            ' -- cgit v1.2.1 From 8fe94a19b46c4e33a117c1a040415f2b1c397e7c Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 5 Dec 2015 19:48:01 +0100 Subject: [ticket/14323] Added support for truncating local URLs PHPBB3-14323 --- tests/test_framework/phpbb_test_case_helpers.php | 9 ++++++++- tests/text_formatter/s9e/default_formatting_test.php | 8 ++++++++ tests/text_processing/tickets_data/PHPBB3-10587.html | 4 ++-- tests/text_processing/tickets_data/PHPBB3-10587.txt | 4 ++-- 4 files changed, 20 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 0166b11d06..cb77c6829c 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -315,7 +315,7 @@ class phpbb_test_case_helpers public function set_s9e_services(ContainerInterface $container = null, $fixture = null, $styles_path = null) { static $first_run; - global $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $user; + global $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $request, $user; $cache_dir = __DIR__ . '/../tmp/'; @@ -490,6 +490,12 @@ class phpbb_test_case_helpers } } + // Create a fake request + if (!isset($request)) + { + $request = new phpbb_mock_request; + } + // Create and register the text_formatter.s9e.factory service $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, $cache_dir, $cache_key_parser, $cache_key_renderer); $container->set('text_formatter.s9e.factory', $factory); @@ -513,6 +519,7 @@ class phpbb_test_case_helpers ->will($this->test_case->returnCallback(__CLASS__ . '::format_date')); $user->date_format = 'Y-m-d H:i:s'; + $user->host = 'localhost'; $user->optionset('viewcensors', true); $user->optionset('viewflash', true); $user->optionset('viewimg', true); diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index facffd5df1..b5777a42d4 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -235,6 +235,14 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case 'http://www.phpbb.com/community/path/to/long/url/file.ext#section', 'http://www.phpbb.com/community/path/to/ ... xt#section' ), + array( + 'http://localhost/ http://localhost/viewforum.php?f=1', + 'http://localhost/ viewforum.php?f=1' + ), + array( + 'http://localhost/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + 'viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxx ... xxxxxxxxxx' + ), array( '[quote="[url=http://example.org]xxx[/url]"]...[/quote]', '
            xxx wrote:...
            ' diff --git a/tests/text_processing/tickets_data/PHPBB3-10587.html b/tests/text_processing/tickets_data/PHPBB3-10587.html index dd0a483244..4c2e536989 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10587.html +++ b/tests/text_processing/tickets_data/PHPBB3-10587.html @@ -1,2 +1,2 @@ -http://www.tx-gaming.net/warzone/tournament.php?tourney[id]=34&action=brackets
            -link \ No newline at end of file +http://example.org/?tourney[id]=34&action=brackets
            +link \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10587.txt b/tests/text_processing/tickets_data/PHPBB3-10587.txt index f81a35eb5f..84788b720d 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10587.txt +++ b/tests/text_processing/tickets_data/PHPBB3-10587.txt @@ -1,2 +1,2 @@ -[url]http://www.tx-gaming.net/warzone/tournament.php?tourney[id]=34&action=brackets[/url] -[url="http://www.tx-gaming.net/warzone/tournament.php?tourney[id]=34&action=brackets"]link[/url] \ No newline at end of file +[url]http://example.org/?tourney[id]=34&action=brackets[/url] +[url="http://example.org/?tourney[id]=34&action=brackets"]link[/url] \ No newline at end of file -- cgit v1.2.1 From f9d8866aee9bca746801ef0360a5ab350d04061d Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 6 Dec 2015 15:23:27 +0100 Subject: [ticket/14323] Set up global objects required during testing PHPBB3-14323 --- tests/test_framework/phpbb_test_case_helpers.php | 26 +++++++++++++--------- .../text_formatter/s9e/default_formatting_test.php | 8 +++---- tests/text_formatter/s9e/factory_test.php | 16 ++++++++++--- 3 files changed, 33 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index cb77c6829c..aa58b3974b 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -315,7 +315,7 @@ class phpbb_test_case_helpers public function set_s9e_services(ContainerInterface $container = null, $fixture = null, $styles_path = null) { static $first_run; - global $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $request, $user; + global $config, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $request, $user; $cache_dir = __DIR__ . '/../tmp/'; @@ -469,18 +469,25 @@ class phpbb_test_case_helpers } // Set up the a minimum config - if ($container->has('config')) + if (!isset($config)) { - $config = $container->get('config'); - } - else - { - $config = new \phpbb\config\config(array()); + if ($container->has('config')) + { + $config = $container->get('config'); + } + else + { + $config = new \phpbb\config\config(array()); + } } $default_config = array( - 'allow_nocensors' => false, + 'allow_nocensors' => false, 'allowed_schemes_links' => 'http,https,ftp', - 'smilies_path' => 'images/smilies', + 'script_path' => '/phpbb', + 'server_name' => 'localhost', + 'server_port' => 80, + 'server_protocol' => 'http://', + 'smilies_path' => 'images/smilies', ); foreach ($default_config as $config_name => $config_value) { @@ -519,7 +526,6 @@ class phpbb_test_case_helpers ->will($this->test_case->returnCallback(__CLASS__ . '::format_date')); $user->date_format = 'Y-m-d H:i:s'; - $user->host = 'localhost'; $user->optionset('viewcensors', true); $user->optionset('viewflash', true); $user->optionset('viewimg', true); diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index b5777a42d4..82c2e1f108 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -236,12 +236,12 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case 'http://www.phpbb.com/community/path/to/ ... xt#section' ), array( - 'http://localhost/ http://localhost/viewforum.php?f=1', - 'http://localhost/ viewforum.php?f=1' + 'http://localhost/ http://localhost/phpbb/ http://localhost/phpbb/viewforum.php?f=1', + 'http://localhost/ http://localhost/phpbb/ viewforum.php?f=1' ), array( - 'http://localhost/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - 'viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxx ... xxxxxxxxxx' + 'http://localhost/phpbb/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + 'viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxx ... xxxxxxxxxx' ), array( '[quote="[url=http://example.org]xxx[/url]"]...[/quote]', diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index c8bf595092..77f27d6547 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -35,7 +35,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case public function get_factory() { - global $phpbb_root_path; + global $config, $phpbb_root_path, $request, $user; $this->cache = new phpbb_mock_cache; $dal = new \phpbb\textformatter\data_access( $this->new_dbal(), @@ -55,6 +55,16 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case '_foo_renderer' ); + // Global objects required by generate_board_url() + $config = new \phpbb\config\config(array( + 'script_path' => '/phpbb', + 'server_name' => 'localhost', + 'server_port' => 80, + 'server_protocol' => 'http://', + )); + $request = new phpbb_mock_request; + $user = new phpbb_mock_user; + return $factory; } @@ -128,14 +138,14 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case public function test_local_url() { global $config, $user, $request; - $config = array( + $config = new \phpbb\config\config(array( 'force_server_vars' => true, 'server_protocol' => 'http://', 'server_name' => 'path', 'server_port' => 80, 'script_path' => '/to', 'cookie_secure' => false - ); + )); $user = new phpbb_mock_user; $request = new phpbb_mock_request; -- cgit v1.2.1 From ad2c032d3b748d177403fd495685977f7964f8d4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 6 Dec 2015 22:08:00 +0100 Subject: [ticket/14323] Moved autolink-related functions to a separate helper PHPBB3-14323 --- tests/test_framework/phpbb_test_case_helpers.php | 17 +++++++---------- tests/text_formatter/s9e/factory_test.php | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index aa58b3974b..dacf9d923f 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -469,16 +469,13 @@ class phpbb_test_case_helpers } // Set up the a minimum config - if (!isset($config)) + if ($container->has('config')) { - if ($container->has('config')) - { - $config = $container->get('config'); - } - else - { - $config = new \phpbb\config\config(array()); - } + $config = $container->get('config'); + } + elseif (!isset($config)) + { + $config = new \phpbb\config\config(array()); } $default_config = array( 'allow_nocensors' => false, @@ -504,7 +501,7 @@ class phpbb_test_case_helpers } // Create and register the text_formatter.s9e.factory service - $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, $cache_dir, $cache_key_parser, $cache_key_renderer); + $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, new \phpbb\textformatter\s9e\autolink_helper, $cache_dir, $cache_key_parser, $cache_key_renderer); $container->set('text_formatter.s9e.factory', $factory); // Create a user if none was provided, and add the common lang strings diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 77f27d6547..dbf28b1d38 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -50,6 +50,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $this->cache, $this->dispatcher, new \phpbb\config\config(array('allowed_schemes_links' => 'http,https,ftp')), + new \phpbb\textformatter\s9e\autolink_helper, $this->get_cache_dir(), '_foo_parser', '_foo_renderer' -- cgit v1.2.1 From 791c329e94283cc7fb5462c26e079a362cbd1810 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 26 Dec 2015 15:43:10 +0100 Subject: [ticket/14323] Fixed test data PHPBB3-14323 --- tests/text_processing/tickets_data/PHPBB3-9791.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-9791.html b/tests/text_processing/tickets_data/PHPBB3-9791.html index cabed5b12f..3d0108c8a6 100644 --- a/tests/text_processing/tickets_data/PHPBB3-9791.html +++ b/tests/text_processing/tickets_data/PHPBB3-9791.html @@ -1 +1 @@ -http://www.phpbb.com/community/search.php?keywords=bogus&terms=all&author=&fid[]=46&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search \ No newline at end of file +http://www.phpbb.com/community/search.p ... mit=Search \ No newline at end of file -- cgit v1.2.1 From 909f8653ec0bf2905ed8d8a9591486f7eefe4d56 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 27 Dec 2015 16:43:45 +0100 Subject: [ticket/14323] Renamed AUTOLINK_TEXT to LINK_TEXT Expanded link text shortening to [url] BBCodes with no parameters PHPBB3-14323 --- tests/test_framework/phpbb_test_case_helpers.php | 2 +- tests/text_formatter/s9e/factory_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index dacf9d923f..c4b653ec7c 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -501,7 +501,7 @@ class phpbb_test_case_helpers } // Create and register the text_formatter.s9e.factory service - $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, new \phpbb\textformatter\s9e\autolink_helper, $cache_dir, $cache_key_parser, $cache_key_renderer); + $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, new \phpbb\textformatter\s9e\link_helper, $cache_dir, $cache_key_parser, $cache_key_renderer); $container->set('text_formatter.s9e.factory', $factory); // Create a user if none was provided, and add the common lang strings diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index dbf28b1d38..8f8ec7ebc7 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -50,7 +50,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $this->cache, $this->dispatcher, new \phpbb\config\config(array('allowed_schemes_links' => 'http,https,ftp')), - new \phpbb\textformatter\s9e\autolink_helper, + new \phpbb\textformatter\s9e\link_helper, $this->get_cache_dir(), '_foo_parser', '_foo_renderer' -- cgit v1.2.1 From bcd5d8b5126e57e8c4c93a0d0c1be5e25f0185ff Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 27 Dec 2015 18:39:53 +0100 Subject: [ticket/14323] Added tests PHPBB3-14323 --- tests/text_formatter/s9e/default_formatting_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 82c2e1f108..fc6b0a65fa 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -243,6 +243,14 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case 'http://localhost/phpbb/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxx ... xxxxxxxxxx' ), + array( + '[url]http://example.org/0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0[/url]', + 'http://example.org/0xxxxxxxxxxxxxxxxxxx ... xxxxxxxxx0' + ), + array( + '[url=http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx[/url]', + 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' + ), array( '[quote="[url=http://example.org]xxx[/url]"]...[/quote]', '
            xxx wrote:...
            ' -- cgit v1.2.1 From bc5d976786d60d8d33cf77fccf81ce351b59fcdc Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 28 Dec 2015 04:19:21 +0100 Subject: [ticket/14323] Added should_shorten() Explicitly tests a tag's markup to determine whether a link should be shortened PHPBB3-14323 --- tests/text_formatter/s9e/default_formatting_test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index fc6b0a65fa..1f7df15434 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -247,6 +247,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '[url]http://example.org/0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0[/url]', 'http://example.org/0xxxxxxxxxxxxxxxxxxx ... xxxxxxxxx0' ), + array( + '[URL]http://example.org/0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0[/url]', + 'http://example.org/0xxxxxxxxxxxxxxxxxxx ... xxxxxxxxx0' + ), array( '[url=http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx[/url]', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' -- cgit v1.2.1 From 7273e24101e9cc5d244ddda4e6c674b8960ed0ba Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 28 Dec 2015 19:44:33 +0100 Subject: [ticket/10628] Added test Tests that the textarea's content is preserved, that no "http://" is added to the text or to the preview's HTML and that the www URL is linkified PHPBB3-10628 --- tests/functional/posting_test.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 724c42b289..bf9e3eb51a 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -205,4 +205,29 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler->filter('#preview .signature')->html() ); } + + /** + * @ticket PHPBB3-10628 + */ + public function test_www_links_preview() + { + $text = 'www.example.org'; + $url = 'http://' . $text; + + $this->add_lang('posting'); + $this->login(); + + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => $text + )); + $crawler = self::submit($form); + + // Test that the textarea remains unchanged + $this->assertEquals($text, $crawler->filter('#message')->text()); + + // Test that the preview contains the correct link + $this->assertEquals($url, $crawler->filter('#preview a')->attr('href')); + } } -- cgit v1.2.1 From 2eac5a0ddd14ddc6a2496b5526d84d2128ec15a4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 28 Dec 2015 20:10:42 +0100 Subject: [ticket/12221] Added test PHPBB3-12221 --- tests/text_processing/tickets_data/PHPBB3-12221.html | 1 + tests/text_processing/tickets_data/PHPBB3-12221.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-12221.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-12221.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-12221.html b/tests/text_processing/tickets_data/PHPBB3-12221.html new file mode 100644 index 0000000000..567f552e84 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-12221.html @@ -0,0 +1 @@ +https://example.com/test/#?javascript:lolhax \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-12221.txt b/tests/text_processing/tickets_data/PHPBB3-12221.txt new file mode 100644 index 0000000000..01a0bf8667 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-12221.txt @@ -0,0 +1 @@ +https://example.com/test/#?javascript:lolhax \ No newline at end of file -- cgit v1.2.1 From 8ed59fb82a9381914a4ccce91c0c5fac44616556 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 23 Oct 2015 02:44:41 +0200 Subject: [ticket/14250] Change token_storage class to fit changed interface PHPBB3-14250 --- tests/auth/provider_oauth_token_storage_test.php | 8 +++++--- tests/functions/user_delete_test.php | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php index 78b936ee8e..ae5de6aa7e 100644 --- a/tests/auth/provider_oauth_token_storage_test.php +++ b/tests/auth/provider_oauth_token_storage_test.php @@ -22,6 +22,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c protected $session_id; protected $token_storage; protected $token_storage_table; + protected $state_table; protected $user; protected function setup() @@ -36,6 +37,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $this->user = new \phpbb\user($lang, '\phpbb\datetime'); $this->service_name = 'auth.provider.oauth.service.testing'; $this->token_storage_table = 'phpbb_oauth_tokens'; + $this->state_table = 'phpbb_oauth_states'; // Give the user a session_id that we will remember $this->session_id = '12345'; @@ -44,7 +46,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c // Set the user id to anonymous $this->user->data['user_id'] = ANONYMOUS; - $this->token_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table); + $this->token_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table, $this->state_table); } public function getDataSet() @@ -98,7 +100,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $expected_token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES); // Store a token in the database - $temp_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table); + $temp_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table, $this->state_table); $temp_storage->storeAccessToken($this->service_name, $expected_token); unset($temp_storage); @@ -129,7 +131,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $expected_token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES); // Store a token in the database - $temp_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table); + $temp_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table, $this->state_table); $temp_storage->storeAccessToken($this->service_name, $expected_token); unset($temp_storage); diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index 21561492fd..bd6b53c59f 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -68,6 +68,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $request, $user, 'phpbb_oauth_tokens', + 'phpbb_oauth_states', 'phpbb_oauth_accounts', $oauth_provider_collection, 'phpbb_users', -- cgit v1.2.1 From e4dae8ed4b784d7a70a74a9ba74fb714c9eae750 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 12 Jan 2016 11:54:20 +0100 Subject: [ticket/14405] Force a lookahead check on [URL] BBCodes PHPBB3-14405 --- tests/text_processing/tickets_data/PHPBB3-14405.html | 1 + tests/text_processing/tickets_data/PHPBB3-14405.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-14405.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-14405.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-14405.html b/tests/text_processing/tickets_data/PHPBB3-14405.html new file mode 100644 index 0000000000..5e76e032ec --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14405.html @@ -0,0 +1 @@ +[url=http://example.org]... \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14405.txt b/tests/text_processing/tickets_data/PHPBB3-14405.txt new file mode 100644 index 0000000000..7005b36b23 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14405.txt @@ -0,0 +1 @@ +[url=http://example.org]... \ No newline at end of file -- cgit v1.2.1 From 0defce65c8ade296523cd9f5788c2abf43c73513 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 19 Jan 2016 23:32:07 +0100 Subject: [ticket/13733] Properly test setting validate_classes to false/true PHPBB3-13733 --- tests/extension/ext/vendor2/bar/migrations/bar.php | 7 +++ tests/extension/ext/vendor2/bar/migrations/foo.php | 54 ++++++++++++++++++++++ tests/extension/extension_base_test.php | 17 ++++++- 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 tests/extension/ext/vendor2/bar/migrations/bar.php create mode 100644 tests/extension/ext/vendor2/bar/migrations/foo.php (limited to 'tests') diff --git a/tests/extension/ext/vendor2/bar/migrations/bar.php b/tests/extension/ext/vendor2/bar/migrations/bar.php new file mode 100644 index 0000000000..ea5ddb6b8b --- /dev/null +++ b/tests/extension/ext/vendor2/bar/migrations/bar.php @@ -0,0 +1,7 @@ + '\vendor2\bar\migrations\migration', + ), + ), ); } /** * @dataProvider data_test_suffix_get_classes */ - public function test_suffix_get_classes($extension_name, $expected) + public function test_suffix_get_classes($extension_name, $validate_classes, $expected) { $extension = $this->extension_manager->get_extension($extension_name); - $this->assertEquals($expected, self::$reflection_method_get_migration_file_list->invoke($extension, false)); + $this->assertEquals($expected, self::$reflection_method_get_migration_file_list->invoke($extension, $validate_classes)); } } -- cgit v1.2.1 From a60935b99db712f8eec7b9ef3b9a00ac0d9a3d51 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 20 Jan 2016 11:16:06 +0100 Subject: [ticket/13733] Make sure migration classes always have same order in tests PHPBB3-13733 --- tests/extension/extension_base_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php index 1e74efc1fa..71b03a40ac 100644 --- a/tests/extension/extension_base_test.php +++ b/tests/extension/extension_base_test.php @@ -74,9 +74,7 @@ class phpbb_extension_extension_base_test extends phpbb_test_case array( 'vendor2/bar', true, - array( - 2 => '\vendor2\bar\migrations\migration', - ), + array('\vendor2\bar\migrations\migration'), ), ); } @@ -87,6 +85,8 @@ class phpbb_extension_extension_base_test extends phpbb_test_case public function test_suffix_get_classes($extension_name, $validate_classes, $expected) { $extension = $this->extension_manager->get_extension($extension_name); - $this->assertEquals($expected, self::$reflection_method_get_migration_file_list->invoke($extension, $validate_classes)); + $migration_classes = self::$reflection_method_get_migration_file_list->invoke($extension, $validate_classes); + sort($migration_classes); + $this->assertEquals($expected, $migration_classes); } } -- cgit v1.2.1 From 10bf5c1533501ed324627cb2a7f25de887322744 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 23 Jan 2016 13:46:18 +0100 Subject: [ticket/14428] Fix files types remote tests PHPBB3-14428 --- tests/files/types_remote_test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index a85844ee78..caed5c9e05 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -85,8 +85,8 @@ class phpbb_files_types_remote_test extends phpbb_test_case array('500k', 'http://example.com/foo/bar.png'), array('500M', 'http://example.com/foo/bar.png'), array('500m', 'http://example.com/foo/bar.png'), - array('500k', 'http://google.com/.png', 'DISALLOWED_CONTENT'), - array('1', 'http://google.com/.png', 'WRONG_FILESIZE'), + array('500k', 'http://google.com/?.png', array('DISALLOWED_EXTENSION', 'DISALLOWED_CONTENT')), + array('1', 'http://google.com/?.png', array('WRONG_FILESIZE')), array('500g', 'http://example.com/foo/bar.png'), array('foobar', 'http://example.com/foo/bar.png'), array('-5k', 'http://example.com/foo/bar.png'), @@ -96,7 +96,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case /** * @dataProvider data_get_max_file_size */ - public function test_get_max_file_size($max_file_size, $link, $expected = 'URL_NOT_FOUND') + public function test_get_max_file_size($max_file_size, $link, $expected = array('URL_NOT_FOUND')) { $php_ini = $this->getMock('\bantu\IniGetWrapper\IniGetWrapper', array('getString')); $php_ini->expects($this->any()) @@ -109,7 +109,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $file = $type_remote->upload($link); - $this->assertSame(array($expected), $file->error); + $this->assertSame($expected, $file->error); } public function test_upload_timeout() @@ -120,7 +120,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $type_remote->set_upload($upload); $upload->upload_timeout = -5; - $file = $type_remote->upload('http://google.com/.png'); + $file = $type_remote->upload('http://google.com/?.png'); $this->assertSame(array('REMOTE_UPLOAD_TIMEOUT'), $file->error); } @@ -133,7 +133,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $type_remote->set_upload($upload); $type_remote::$tempnam_path = $this->phpbb_root_path . 'cache/wrong/path'; - $file = $type_remote->upload('http://google.com/.png'); + $file = $type_remote->upload('http://google.com/?.png'); $this->assertSame(array('NOT_UPLOADED'), $file->error); $type_remote::$tempnam_path = ''; -- cgit v1.2.1 From fac4672f3f2def54fb65e325e77dea14cbc4aa6a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 24 Jan 2016 22:39:37 +0100 Subject: [ticket/13733] Remove validate_classes method argument PHPBB3-13733 --- tests/extension/extension_base_test.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php index 71b03a40ac..775a23e198 100644 --- a/tests/extension/extension_base_test.php +++ b/tests/extension/extension_base_test.php @@ -64,16 +64,6 @@ class phpbb_extension_extension_base_test extends phpbb_test_case return array( array( 'vendor2/bar', - false, - array( - '\vendor2\bar\migrations\bar', - '\vendor2\bar\migrations\foo', - '\vendor2\bar\migrations\migration', - ), - ), - array( - 'vendor2/bar', - true, array('\vendor2\bar\migrations\migration'), ), ); @@ -82,10 +72,10 @@ class phpbb_extension_extension_base_test extends phpbb_test_case /** * @dataProvider data_test_suffix_get_classes */ - public function test_suffix_get_classes($extension_name, $validate_classes, $expected) + public function test_suffix_get_classes($extension_name, $expected) { $extension = $this->extension_manager->get_extension($extension_name); - $migration_classes = self::$reflection_method_get_migration_file_list->invoke($extension, $validate_classes); + $migration_classes = self::$reflection_method_get_migration_file_list->invoke($extension); sort($migration_classes); $this->assertEquals($expected, $migration_classes); } -- cgit v1.2.1 From cc38bf550b6d044938532d96a98dd92767e69b61 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 25 Jan 2016 13:50:23 +0100 Subject: [ticket/14129] Caches extensions autoloaders PHPBB3-14129 --- tests/mock/phpbb_di_container_builder.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/mock/phpbb_di_container_builder.php b/tests/mock/phpbb_di_container_builder.php index 59cdf0bb2b..23dc3d1e8b 100644 --- a/tests/mock/phpbb_di_container_builder.php +++ b/tests/mock/phpbb_di_container_builder.php @@ -17,4 +17,14 @@ class phpbb_mock_phpbb_di_container_builder extends \phpbb\di\container_builder { return $this->phpbb_root_path . '../../tmp/container.' . $this->php_ext; } + + /** + * Get the filename under which the dumped extensions autoloader will be stored. + * + * @return string Path for dumped extensions autoloader + */ + protected function get_autoload_filename() + { + return $this->phpbb_root_path . '../../tmp/autoload.' . $this->php_ext; + } } -- cgit v1.2.1 From f5ca8c363bbd6776e9be8d2e05c3cf54685b0a59 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 26 Jan 2016 22:32:08 +0100 Subject: [ticket/14432] Adds a method to get raw language values PHPBB3-14432 --- tests/language/language_test.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/language/language_test.php b/tests/language/language_test.php index 6a814e39dc..29b4873dcb 100644 --- a/tests/language/language_test.php +++ b/tests/language/language_test.php @@ -53,6 +53,25 @@ class phpbb_language_test extends phpbb_test_case $this->assertFalse($this->lang->is_set(array('PHPBB', 'PHP'))); } + public function test_lang_raw() + { + $this->assertEquals($this->lang->lang_raw('FOO'), 'BAR'); + $this->assertEquals($this->lang->lang_raw('VOID'), 'VOID'); + $this->assertEquals($this->lang->lang_raw('ARRY'), array( + 0 => 'No posts', // 0 + 1 => '1 post', // 1 + 2 => '%d posts', // 2+ + )); + } + + public function test_lang_array() + { + $this->assertEquals($this->lang->lang_array('FOO'), 'BAR'); + $this->assertEquals($this->lang->lang_array('VOID'), 'VOID'); + $this->assertEquals($this->lang->lang_array('ARRY', [0]), 'No posts'); + $this->assertEquals($this->lang->lang_array('FOO', [2, 3, 'BARZ']), 'BAR'); + } + public function test_lang() { // No param -- cgit v1.2.1 From 27027deb9ce2076f64dbfdecba494efe1aa523dc Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 28 Jan 2016 11:22:30 -0800 Subject: [ticket/14434] Refactored to check migrations when setting them PHPBB3-14434 --- tests/mock/migrator.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/mock/migrator.php b/tests/mock/migrator.php index 293f115335..4d1aca0a0a 100644 --- a/tests/mock/migrator.php +++ b/tests/mock/migrator.php @@ -21,10 +21,6 @@ class phpbb_mock_migrator extends \phpbb\db\migrator { } - public function set_migrations($class_names) - { - } - public function update() { } -- cgit v1.2.1 From e4f562bdbaea5c9c04abbad7306a0fe24908e199 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 1 Feb 2016 15:25:31 +0100 Subject: [ticket/14442] Use Goutte 2.0 instead of outdated 1.0 PHPBB3-14442 --- tests/test_framework/phpbb_functional_test_case.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 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 a3864d3041..9135eee956 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -16,6 +16,7 @@ require_once __DIR__ . '/mock/phpbb_mock_null_installer_task.php'; class phpbb_functional_test_case extends phpbb_test_case { + /** @var \Goutte\Client */ static protected $client; static protected $cookieJar; static protected $root_url; @@ -81,9 +82,6 @@ class phpbb_functional_test_case extends phpbb_test_case self::$cookieJar = new CookieJar; self::$client = new Goutte\Client(array(), null, self::$cookieJar); - // Reset the curl handle because it is 0 at this point and not a valid - // resource - self::$client->getClient()->getCurlMulti()->reset(true); // Clear the language array so that things // that were added in other tests are gone @@ -169,7 +167,7 @@ class phpbb_functional_test_case extends phpbb_test_case */ static public function get_content() { - return self::$client->getResponse()->getContent(); + return (string) self::$client->getResponse()->getContent(); } // bootstrap, called after board is set up @@ -843,7 +841,7 @@ class phpbb_functional_test_case extends phpbb_test_case static public function assert_response_html($status_code = 200) { // Any output before the doc type means there was an error - $content = self::$client->getResponse()->getContent(); + $content = (string) self::$client->getResponse()->getContent(); self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith('getResponse()->getContent(); + $content = (string) self::$client->getResponse()->getContent(); self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith(' Date: Mon, 1 Feb 2016 17:00:56 +0100 Subject: [ticket/14442] Use get_content() in plupload functional tests PHPBB3-14442 --- tests/functional/plupload_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php index d358681ad1..7735d82ed4 100644 --- a/tests/functional/plupload_test.php +++ b/tests/functional/plupload_test.php @@ -107,11 +107,11 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case if ($i < self::CHUNKS - 1) { - $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::$client->getResponse()->getContent()); + $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::get_content()); } else { - $response = json_decode(self::$client->getResponse()->getContent(), true); + $response = json_decode(self::get_content(), true); $this->assertEquals('valid.jpg', $response['data'][0]['real_filename']); } @@ -148,7 +148,7 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case array('X-PHPBB-USING-PLUPLOAD' => '1') ); - $response = json_decode(self::$client->getResponse()->getContent(), true); + $response = json_decode((string) self::get_content(), true); $this->assertEquals('valid.jpg', $response['data'][0]['real_filename']); } } -- cgit v1.2.1 From 2353fe39c0a9ed05506fa13608d20b36bed5168f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 1 Feb 2016 19:31:09 +0100 Subject: [ticket/14442] Properly set plupload header PHPBB3-14442 --- tests/functional/plupload_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php index 7735d82ed4..9d284a7e57 100644 --- a/tests/functional/plupload_test.php +++ b/tests/functional/plupload_test.php @@ -134,7 +134,8 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case 'error' => UPLOAD_ERR_OK, ); - $crawler = self::$client->request( + self::$client->setServerParameter('HTTP_X_PHPBB_USING_PLUPLOAD', '1'); + self::$client->request( 'POST', $url . '&sid=' . $this->sid, array( @@ -144,11 +145,10 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case 'real_filename' => 'valid.jpg', 'add_file' => $this->lang('ADD_FILE'), ), - array('fileupload' => $file), - array('X-PHPBB-USING-PLUPLOAD' => '1') + array('fileupload' => $file) ); - $response = json_decode((string) self::get_content(), true); + $response = json_decode(self::get_content(), true); $this->assertEquals('valid.jpg', $response['data'][0]['real_filename']); } } -- cgit v1.2.1 From fdb16225889974a47d539079d0f42950b5dfc3f1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 1 Feb 2016 19:34:58 +0100 Subject: [ticket/14442] Use get_content() in functional test case PHPBB3-14442 --- 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 9135eee956..34fbcec0e2 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -841,7 +841,7 @@ class phpbb_functional_test_case extends phpbb_test_case static public function assert_response_html($status_code = 200) { // Any output before the doc type means there was an error - $content = (string) self::$client->getResponse()->getContent(); + $content = self::get_content(); self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith('getResponse()->getContent(); + $content = self::get_content(); self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith(' Date: Wed, 3 Feb 2016 14:06:10 +0100 Subject: [ticket/14448] Use GuzzleHttp and try to verify certs PHPBB3-14448 --- tests/files/types_remote_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index caed5c9e05..96103ad046 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -118,7 +118,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')); $type_remote->set_upload($upload); - $upload->upload_timeout = -5; + $upload->upload_timeout = 0.001; $file = $type_remote->upload('http://google.com/?.png'); -- cgit v1.2.1 From dacbc767f135cad5758b184ca501f529dc1b16b8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 3 Feb 2016 17:42:47 +0100 Subject: [ticket/14448] Do not try to test remote upload timeout PHPBB3-14448 --- tests/files/types_remote_test.php | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'tests') diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index 96103ad046..3f32f9ce75 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -112,19 +112,6 @@ class phpbb_files_types_remote_test extends phpbb_test_case $this->assertSame($expected, $file->error); } - public function test_upload_timeout() - { - $type_remote = new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); - $upload->set_allowed_extensions(array('png')); - $type_remote->set_upload($upload); - $upload->upload_timeout = 0.001; - - $file = $type_remote->upload('http://google.com/?.png'); - - $this->assertSame(array('REMOTE_UPLOAD_TIMEOUT'), $file->error); - } - public function test_upload_wrong_path() { $type_remote = new \phpbb\files\types\foo($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); -- cgit v1.2.1 From fd9c05309d186332728b533467aaecad5c543c52 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 4 Feb 2016 17:10:59 +0100 Subject: [ticket/14448] Let user decide if remote upload certs should be checked Also fixed some minor issues like coding style. PHPBB3-14448 --- tests/files/types_remote_test.php | 11 ++++++++--- tests/functional/fileupload_remote_test.php | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index 3f32f9ce75..476d8ed3ba 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -20,6 +20,9 @@ class phpbb_files_types_remote_test extends phpbb_test_case private $filesystem; + /** @var \phpbb\config\config */ + protected $config; + /** @var \Symfony\Component\DependencyInjection\ContainerInterface */ protected $container; @@ -43,6 +46,8 @@ class phpbb_files_types_remote_test extends phpbb_test_case global $config, $phpbb_root_path, $phpEx; $config = new \phpbb\config\config(array()); + $this->config = $config; + $this->config->set('remote_upload_verify', 0); $this->request = $this->getMock('\phpbb\request\request'); $this->filesystem = new \phpbb\filesystem\filesystem(); @@ -67,7 +72,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case public function test_upload_fsock_fail() { - $type_remote = new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')); $type_remote->set_upload($upload); @@ -102,7 +107,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $php_ini->expects($this->any()) ->method('getString') ->willReturn($max_file_size); - $type_remote = new \phpbb\files\types\remote($this->factory, $this->language, $php_ini, $this->request, $this->phpbb_root_path); + $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->language, $php_ini, $this->request, $this->phpbb_root_path); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')); $type_remote->set_upload($upload); @@ -114,7 +119,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case public function test_upload_wrong_path() { - $type_remote = new \phpbb\files\types\foo($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $type_remote = new \phpbb\files\types\foo($this->config, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')); $type_remote->set_upload($upload); diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 7e0f192b40..b70d49cddd 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -45,11 +45,12 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case if (!is_array($config)) { - $config = array(); + $config = new \phpbb\config\config(array()); } $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; + $config['remote_upload_verify'] = 0; $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); @@ -60,7 +61,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); - $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path)); + $container->set('files.types.remote', new \phpbb\files\types\remote($config, $this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path)); $this->phpbb_root_path = $phpbb_root_path; } -- cgit v1.2.1 From 20d85433fcba5dd892a7f82b8be2bac34546536f Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 7 Feb 2016 15:15:01 +0100 Subject: =?UTF-8?q?[ticket/14440]=C2=A0Add=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHPBB3-14440 --- tests/path_helper/path_helper_test.php | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests') diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index 007441bc92..49dd40fbec 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -135,6 +135,43 @@ class phpbb_path_helper_test extends phpbb_test_case '/phpbb3-fork/phpBB/app.php', './../', ), + + // No correction if the path is already prepend by the web root path + array( + './../' . $this->phpbb_root_path . 'test.php', + '//', + null, + null, + '', + ), + array( + './../' . $this->phpbb_root_path . 'test.php', + '//', + 'foo/bar.php', + 'bar.php', + '', + ), + array( + './../../' . $this->phpbb_root_path . 'test.php', + '/foo/template', + '/phpbb3-fork/phpBB/app.php/foo/template', + '/phpbb3-fork/phpBB/app.php', + '', + ), + array( + './../' . $this->phpbb_root_path . 'test.php', + '/foo/template', + '/phpbb3-fork/phpBB/foo/template', + '/phpbb3-fork/phpBB/app.php', + '', + ), + array( + './../'.$this->phpbb_root_path . 'test.php', + '/', + '/phpbb3-fork/phpBB/app.php/', + '/phpbb3-fork/phpBB/app.php', + '', + ), ); } -- cgit v1.2.1 From 955b9ede33c5696173a760ea271ec32d79e843b9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 11 Feb 2016 13:18:30 +0100 Subject: [ticket/14462] Further speed improvements - Cache the secondary container - Only initialize tasks/modules that are being used - Add timeout error message in the AJAX UI PHPBB3-14462 --- tests/installer/installer_config_test.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php index c8e482e260..13ac325a79 100644 --- a/tests/installer/installer_config_test.php +++ b/tests/installer/installer_config_test.php @@ -52,8 +52,8 @@ class phpbb_installer_config_test extends phpbb_test_case public function test_progress_tracking() { - $this->config->set_finished_task('foo'); - $this->config->set_active_module('bar'); + $this->config->set_finished_task(0); + $this->config->set_active_module('bar', 5); $this->config->set_task_progress_count(10); $this->config->increment_current_task_progress(); @@ -66,7 +66,8 @@ class phpbb_installer_config_test extends phpbb_test_case $result = $this->config->get_progress_data(); $expected_result = array( 'last_task_module_name' => 'bar', - 'last_task_name' => 'foo', + 'last_task_module_index' => 5, + 'last_task_index' => 0, 'max_task_progress' => 10, 'current_task_progress' => 3, ); -- cgit v1.2.1 From d63b5a1315ecf819a412db382c1adcfa39fd9813 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 12 Feb 2016 14:26:32 +0100 Subject: [ticket/14462] Fix installation in tests PHPBB3-14462 --- tests/test_framework/phpbb_functional_test_case.php | 18 ++++++++++++------ tests/test_framework/phpbb_ui_test_case.php | 21 +++++++++++++++------ tests/ui/quick_links_test.php | 1 - 3 files changed, 27 insertions(+), 13 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 34fbcec0e2..5083e7bdfa 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -20,6 +20,7 @@ class phpbb_functional_test_case extends phpbb_test_case static protected $client; static protected $cookieJar; static protected $root_url; + static protected $install_success = false; protected $cache = null; protected $db = null; @@ -78,6 +79,11 @@ class phpbb_functional_test_case extends phpbb_test_case { parent::setUp(); + if (!self::$install_success) + { + $this->fail('Installing phpBB has failed.'); + } + $this->bootstrap(); self::$cookieJar = new CookieJar; @@ -360,17 +366,17 @@ class phpbb_functional_test_case extends phpbb_test_case $iohandler->set_input('script_path', $parseURL['path']); $iohandler->set_input('submit_server', 'submit'); - do - { - $installer->run(); - } - while (file_exists($phpbb_root_path . 'store/install_config.php')); + $installer->run(); copy($config_file, $config_file_test); - if (file_exists($phpbb_root_path . 'cache/install_lock')) + self::$install_success = true; + + if (file_exists($phpbb_root_path . 'cache/install_lock') || file_exists($phpbb_root_path . 'store/install_config.php')) { + self::$install_success = false; unlink($phpbb_root_path . 'cache/install_lock'); + unlink($phpbb_root_path . 'store/install_config.php'); } global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index e118801972..59f3bdf242 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -26,6 +26,7 @@ class phpbb_ui_test_case extends phpbb_test_case static protected $config; static protected $root_url; static protected $already_installed = false; + static protected $install_success = false; static public function setUpBeforeClass() { @@ -74,6 +75,14 @@ class phpbb_ui_test_case extends phpbb_test_case } } + public function setUp() + { + if (!self::$install_success) + { + $this->fail('Installing phpBB has failed.'); + } + } + static public function visit($path) { self::$webDriver->get(self::$root_url . $path); @@ -194,17 +203,17 @@ class phpbb_ui_test_case extends phpbb_test_case $iohandler->set_input('script_path', $parseURL['path']); $iohandler->set_input('submit_server', 'submit'); - do - { - $installer->run(); - } - while (file_exists($phpbb_root_path . 'store/install_config.php')); + $installer->run(); copy($config_file, $config_file_test); - if (file_exists($phpbb_root_path . 'cache/install_lock')) + self::$install_success = true; + + if (file_exists($phpbb_root_path . 'cache/install_lock') || file_exists($phpbb_root_path . 'store/install_config.php')) { + self::$install_success = false; unlink($phpbb_root_path . 'cache/install_lock'); + unlink($phpbb_root_path . 'store/install_config.php'); } global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; diff --git a/tests/ui/quick_links_test.php b/tests/ui/quick_links_test.php index 5bddb44a8b..582aeafcae 100644 --- a/tests/ui/quick_links_test.php +++ b/tests/ui/quick_links_test.php @@ -16,7 +16,6 @@ */ class quick_links_test extends phpbb_ui_test_case { - public function test_quick_links() { $this->visit('index.php'); -- cgit v1.2.1 From 90710ffe9818fb45d177db4a8b07c70a43972776 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 12 Feb 2016 14:08:47 +0100 Subject: [ticket/14462] Set instance of db driver for database access using global PHPBB3-14462 --- tests/test_framework/phpbb_ui_test_case.php | 31 ++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 59f3bdf242..14e84b019d 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -27,6 +27,7 @@ class phpbb_ui_test_case extends phpbb_test_case static protected $root_url; static protected $already_installed = false; static protected $install_success = false; + static protected $db; static public function setUpBeforeClass() { @@ -83,6 +84,17 @@ class phpbb_ui_test_case extends phpbb_test_case } } + protected function tearDown() + { + parent::tearDown(); + + if (self::$db instanceof \phpbb\db\driver\driver_interface) + { + // Close the database connections again this test + self::$db->sql_close(); + } + } + static public function visit($path) { self::$webDriver->get(self::$root_url . $path); @@ -107,10 +119,12 @@ class phpbb_ui_test_case extends phpbb_test_case static public function install_board() { - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $db; self::recreate_database(self::$config); + $db = self::get_db(); + $config_file = $phpbb_root_path . "config.$phpEx"; $config_file_dev = $phpbb_root_path . "config_dev.$phpEx"; $config_file_test = $phpbb_root_path . "config_test.$phpEx"; @@ -220,4 +234,19 @@ class phpbb_ui_test_case extends phpbb_test_case $phpbb_container->reset(); unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template); } + + static protected function get_db() + { + global $phpbb_root_path, $phpEx; + // so we don't reopen an open connection + if (!(self::$db instanceof \phpbb\db\driver\driver_interface)) + { + $dbms = self::$config['dbms']; + /** @var \phpbb\db\driver\driver_interface $db */ + $db = new $dbms(); + $db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); + self::$db = $db; + } + return self::$db; + } } -- cgit v1.2.1 From 7c0fb563ec995d0d1fcb24d885a7d9d18838ed9c Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 12 Feb 2016 15:38:34 +0100 Subject: [ticket/14462] Fix CS and typo PHPBB3-14462 --- tests/test_framework/phpbb_ui_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 14e84b019d..9cbac0ce47 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -94,7 +94,7 @@ class phpbb_ui_test_case extends phpbb_test_case self::$db->sql_close(); } } - + static public function visit($path) { self::$webDriver->get(self::$root_url . $path); -- cgit v1.2.1 From 97d128a7e4702b5a28b223b177a0e182e3b79080 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 12 Feb 2016 15:53:36 +0100 Subject: [ticket/14462] Fix tests PHPBB3-14462 --- tests/test_framework/phpbb_functional_test_case.php | 10 +++++++--- tests/test_framework/phpbb_ui_test_case.php | 10 +++++++--- 2 files changed, 14 insertions(+), 6 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 5083e7bdfa..53519617b3 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -372,11 +372,15 @@ class phpbb_functional_test_case extends phpbb_test_case self::$install_success = true; - if (file_exists($phpbb_root_path . 'cache/install_lock') || file_exists($phpbb_root_path . 'store/install_config.php')) + if (file_exists($phpbb_root_path . 'store/install_config.php')) { self::$install_success = false; - unlink($phpbb_root_path . 'cache/install_lock'); - unlink($phpbb_root_path . 'store/install_config.php'); + @unlink($phpbb_root_path . 'store/install_config.php'); + } + + if (file_exists($phpbb_root_path . 'cache/install_lock')) + { + @unlink($phpbb_root_path . 'cache/install_lock'); } global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 9cbac0ce47..3aec2a19f4 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -223,11 +223,15 @@ class phpbb_ui_test_case extends phpbb_test_case self::$install_success = true; - if (file_exists($phpbb_root_path . 'cache/install_lock') || file_exists($phpbb_root_path . 'store/install_config.php')) + if (file_exists($phpbb_root_path . 'store/install_config.php')) { self::$install_success = false; - unlink($phpbb_root_path . 'cache/install_lock'); - unlink($phpbb_root_path . 'store/install_config.php'); + @unlink($phpbb_root_path . 'store/install_config.php'); + } + + if (file_exists($phpbb_root_path . 'cache/install_lock')) + { + @unlink($phpbb_root_path . 'cache/install_lock'); } global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; -- cgit v1.2.1 From d330ef8c1b52bb93e02de3992edb9041f2c99fb5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 14 Feb 2016 16:24:00 +0100 Subject: [ticket/14478] Move facebook/webdriver dependency to main composer file Also updated to latest version and now using proper version in composer.json. PHPBB3-14478 --- tests/composer.json | 5 --- tests/composer.lock | 66 ----------------------------- tests/test_framework/phpbb_ui_test_case.php | 11 +++-- 3 files changed, 8 insertions(+), 74 deletions(-) delete mode 100644 tests/composer.json delete mode 100644 tests/composer.lock (limited to 'tests') diff --git a/tests/composer.json b/tests/composer.json deleted file mode 100644 index 69512f30a6..0000000000 --- a/tests/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require-dev": { - "facebook/webdriver": "dev-master" - } -} diff --git a/tests/composer.lock b/tests/composer.lock deleted file mode 100644 index f714495d84..0000000000 --- a/tests/composer.lock +++ /dev/null @@ -1,66 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" - ], - "hash": "cf1d8a4841e5e669b148e0df6645a788", - "packages": [ - - ], - "packages-dev": [ - { - "name": "facebook/webdriver", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/facebook/php-webdriver.git", - "reference": "b6e002e5bf811a8edba393ce6872322c1b7cf796" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/b6e002e5bf811a8edba393ce6872322c1b7cf796", - "reference": "b6e002e5bf811a8edba393ce6872322c1b7cf796", - "shasum": "" - }, - "require": { - "php": ">=5.3.19" - }, - "require-dev": { - "phpdocumentor/phpdocumentor": "2.*", - "phpunit/phpunit": "3.7.*" - }, - "type": "library", - "autoload": { - "classmap": [ - "lib/" - ] - }, - "notification-url": "http://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "description": "A php client for WebDriver", - "homepage": "https://github.com/facebook/php-webdriver", - "keywords": [ - "facebook", - "php", - "selenium", - "webdriver" - ], - "time": "2014-08-05 02:55:46" - } - ], - "aliases": [ - - ], - "minimum-stability": "stable", - "stability-flags": { - "facebook/webdriver": 20 - }, - "platform": [ - - ], - "platform-dev": [ - - ] -} diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index e118801972..3c09ff96d1 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -11,6 +11,11 @@ * */ +use Facebook\WebDriver\WebDriverBy; +use Facebook\WebDriver\Exception\WebDriverCurlException; +use Facebook\WebDriver\Remote\RemoteWebDriver; +use Facebook\WebDriver\Remote\DesiredCapabilities; + require_once __DIR__ . '/mock/phpbb_mock_null_installer_task.php'; class phpbb_ui_test_case extends phpbb_test_case @@ -19,7 +24,7 @@ class phpbb_ui_test_case extends phpbb_test_case static protected $port = 8910; /** - * @var \RemoteWebDriver + * @var RemoteWebDriver */ static protected $webDriver; @@ -35,7 +40,7 @@ class phpbb_ui_test_case extends phpbb_test_case { self::markTestSkipped('UI test case requires at least PHP 5.3.19.'); } - else if (!class_exists('\RemoteWebDriver')) + else if (!class_exists('\Facebook\WebDriver\Remote\RemoteWebDriver')) { self::markTestSkipped( 'Could not find RemoteWebDriver class. ' . @@ -60,7 +65,7 @@ class phpbb_ui_test_case extends phpbb_test_case if (!self::$webDriver) { try { - $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox'); + $capabilities = DesiredCapabilities::firefox(); self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); } catch (WebDriverCurlException $e) { self::markTestSkipped('PhantomJS webserver is not running.'); -- cgit v1.2.1 From 845639ba371e0aacb60f760851c9c6b1cf6e9bd6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 16 Feb 2016 22:45:31 +0100 Subject: [ticket/14315] Add more functionality to ui test cases PHPBB3-14315 --- tests/test_framework/phpbb_ui_test_case.php | 208 ++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 8b60096081..f9f4c516e6 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -34,6 +34,18 @@ class phpbb_ui_test_case extends phpbb_test_case static protected $install_success = false; static protected $db; + /** + * Session ID for current test's session (each test makes its own) + * @var string + */ + protected $sid; + + /** + * Language array used by phpBB + * @var array + */ + protected $lang = array(); + static public function setUpBeforeClass() { parent::setUpBeforeClass(); @@ -87,6 +99,11 @@ class phpbb_ui_test_case extends phpbb_test_case { $this->fail('Installing phpBB has failed.'); } + + // Clear the language array so that things + // that were added in other tests are gone + $this->lang = array(); + $this->add_lang('common'); } protected function tearDown() @@ -258,4 +275,195 @@ class phpbb_ui_test_case extends phpbb_test_case } return self::$db; } + + /** + * Login to the ACP + * You must run login() before calling this. + */ + protected function admin_login($username = 'admin') + { + $this->add_lang('acp/common'); + + // Requires login first! + if (empty($this->sid)) + { + $this->fail('$this->sid is empty. Make sure you call login() before admin_login()'); + return; + } + + $this->visit('adm/index.php?sid=' . $this->sid); + $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), self::$webDriver->getPageSource()); + + self::find_element('cssSelector', 'input[name=username]')->clear()->sendKeys($username); + self::find_element('cssSelector', 'input[type=password]')->sendKeys($username . $username); + self::find_element('cssSelector', 'input[name=login]')->click(); + $this->assertContains($this->lang('ADMIN_PANEL'), $this->find_element('cssSelector', 'h1')->getText()); + + $cookies = self::$webDriver->manage()->getCookies(); + + // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie + foreach ($cookies as $cookie) + { + if (substr($cookie['name'], -4) == '_sid') + { + $this->sid = $cookie['value']; + } + } + } + + protected function add_lang($lang_file) + { + if (is_array($lang_file)) + { + foreach ($lang_file as $file) + { + $this->add_lang($file); + } + } + + $lang_path = __DIR__ . "/../../phpBB/language/en/$lang_file.php"; + + $lang = array(); + + if (file_exists($lang_path)) + { + include($lang_path); + } + + $this->lang = array_merge($this->lang, $lang); + } + + protected function add_lang_ext($ext_name, $lang_file) + { + if (is_array($lang_file)) + { + foreach ($lang_file as $file) + { + $this->add_lang_ext($ext_name, $file); + } + + return; + } + + $lang_path = __DIR__ . "/../../phpBB/ext/{$ext_name}/language/en/$lang_file.php"; + + $lang = array(); + + if (file_exists($lang_path)) + { + include($lang_path); + } + + $this->lang = array_merge($this->lang, $lang); + } + + protected function lang() + { + $args = func_get_args(); + $key = $args[0]; + + if (empty($this->lang[$key])) + { + throw new RuntimeException('Language key "' . $key . '" could not be found.'); + } + + $args[0] = $this->lang[$key]; + + return call_user_func_array('sprintf', $args); + } + + /** + * assertContains for language strings + * + * @param string $needle Search string + * @param string $haystack Search this + * @param string $message Optional failure message + */ + public function assertContainsLang($needle, $haystack, $message = null) + { + $this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); + } + + /** + * assertNotContains for language strings + * + * @param string $needle Search string + * @param string $haystack Search this + * @param string $message Optional failure message + */ + public function assertNotContainsLang($needle, $haystack, $message = null) + { + $this->assertNotContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); + } + + protected function login($username = 'admin') + { + $this->add_lang('ucp'); + + $this->visit('ucp.php'); + $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), self::$webDriver->getPageSource()); + + self::find_element('cssSelector', 'input[name=username]')->sendKeys($username); + self::find_element('cssSelector', 'input[name=password]')->sendKeys($username . $username); + self::find_element('cssSelector', 'input[name=login]')->click(); + $this->assertNotContains($this->lang('LOGIN'), $this->find_element('className', 'navbar')->getText()); + + $cookies = self::$webDriver->manage()->getCookies(); + + // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie + foreach ($cookies as $cookie) + { + if (substr($cookie['name'], -4) == '_sid') + { + $this->sid = $cookie['value']; + } + } + } + + /** + * Take screenshot. Can be used for debug purposes. + * + * @param \Facebook\WebDriver\Remote\RemoteWebElement $element + * @return string Element screenshot path + * @throws Exception When screenshot can't be created + */ + public function takeScreenshot($element = null) { + // Change the Path to your own settings + $screenshot = time() . ".png"; + + // Change the driver instance + self::$webDriver->takeScreenshot($screenshot); + if(!file_exists($screenshot)) { + throw new Exception('Could not save screenshot'); + } + + if( ! (bool) $element) { + return $screenshot; + } + + $element_screenshot = time() . ".png"; // Change the path here as well + + $element_width = $element->getSize()->getWidth(); + $element_height = $element->getSize()->getHeight(); + + $element_src_x = $element->getLocation()->getX(); + $element_src_y = $element->getLocation()->getY(); + + // Create image instances + $src = imagecreatefrompng($screenshot); + $dest = imagecreatetruecolor($element_width, $element_height); + + // Copy + imagecopy($dest, $src, 0, 0, $element_src_x, $element_src_y, $element_width, $element_height); + + imagepng($dest, $element_screenshot); + + // unlink($screenshot); // unlink function might be restricted in mac os x. + + if( ! file_exists($element_screenshot)) { + throw new Exception('Could not save element screenshot'); + } + + return $element_screenshot; + } } -- cgit v1.2.1 From d429fd03bfaf648a685519dfc7383152611a08e7 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 16 Feb 2016 22:46:03 +0100 Subject: [ticket/14315] Add tests for setting permission roles using javascript PHPBB3-14315 --- tests/ui/permission_roles_test.php | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 tests/ui/permission_roles_test.php (limited to 'tests') diff --git a/tests/ui/permission_roles_test.php b/tests/ui/permission_roles_test.php new file mode 100644 index 0000000000..a688680028 --- /dev/null +++ b/tests/ui/permission_roles_test.php @@ -0,0 +1,89 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +/** +* @group ui +*/ +class permission_roles_test extends phpbb_ui_test_case +{ + + public function test_quick_links() + { + $this->login(); + $this->admin_login(); + $this->add_lang('acp/permissions'); + $this->visit('adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid); + + // Select forums + $elements = self::find_element('cssSelector', 'select[id=forum]') + ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); + foreach ($elements as $element) + { + $element->click(); + } + self::find_element('cssSelector', 'form[id=select_victim]') + ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=submit]')) + ->click(); + + // Select administrators and guests + $groups_form = self::find_element('cssSelector', 'form[id=groups]'); + $elements = $groups_form + ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('select')) + ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); + + foreach ($elements as $element) + { + if ($element->getText() === 'Administrators' || $element->getText() === 'Guests') + { + $element->click(); + } + } + $groups_form->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[name=submit_edit_options]'))->click(); + + $first_fieldset = self::find_element('cssSelector', '#perm11'); + $this->assertEquals('none', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + $first_fieldset + ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle')) + ->click(); + $this->assertEquals('block', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + $lis = $first_fieldset + ->findElements(\Facebook\WebDriver\WebDriverBy::cssSelector('ul > li')); + + foreach ($lis as $li) + { + if ($li->getAttribute('data-id') == 18) + { + $li->click(); + + break; + } + } + $this->assertEquals('none', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + $this->assertEquals(18, $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); + $this->assertEquals($this->lang('ROLE_FORUM_LIMITED'), $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); + + // Check that admin settings didn't get changed + $second_fieldset = self::find_element('cssSelector', '#perm10'); + $this->assertEquals('none', $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + // Full access = 14 + $this->assertEquals(14, $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); + $this->assertEquals($this->lang('ROLE_FORUM_FULL'), $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); + + // Check that category settings were not modified + $category_fieldset = self::find_element('cssSelector', '#perm00'); + $this->assertEquals('none', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + // No settings + $this->assertEquals('', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); + $this->assertEquals($this->lang('NO_ROLE_ASSIGNED'), $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); + } +} -- cgit v1.2.1 From 620a8622660c5a00f56ce686e397ed09d9cd4039 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 17 Feb 2016 12:56:19 +0100 Subject: [ticket/14315] Add functional tests for permission roles and fix non-js Without JS the settings were not applied due to duplicate input names. PHPBB3-14315 --- tests/functional/permission_roles_test.php | 86 ++++++++++++++++++++++++++++++ tests/ui/permission_roles_test.php | 4 +- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 tests/functional/permission_roles_test.php (limited to 'tests') diff --git a/tests/functional/permission_roles_test.php b/tests/functional/permission_roles_test.php new file mode 100644 index 0000000000..82d5be68c3 --- /dev/null +++ b/tests/functional/permission_roles_test.php @@ -0,0 +1,86 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once __DIR__ . '/../../phpBB/includes/functions.php'; + +/** +* @group functional +*/ +class functional_permission_roles_test extends phpbb_functional_test_case +{ + public function data_permission_roles() + { + return array( + array( + array(0, 14), + array(17, 17), + array( + 'role[5][1]' => 14, + ) + ), + array( + array(14, 14), + array(17, 17), + array( + 'role[5][1]' => 0, + ) + ), + array( + array(0, 14), + array(17, 17) + ), + ); + } + /** + * @dataProvider data_permission_roles + */ + public function test_permission_roles($admin_roles, $guest_roles, $set_values = array()) + { + $this->login(); + $this->admin_login(); + $this->add_lang('acp/permissions'); + $crawler = self::request('GET', 'adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid); + + // Select forums + $form = $crawler->filter('form[id=select_victim]')->form(); + $form['forum_id']->setValue(array(1,2)); + $crawler = self::$client->submit($form); + + // Select administrators and guests + $groups_form = $crawler->filter('form[id=groups]')->form(); + $groups_form['group_id']->setValue(array(1,5)); + + $crawler = self::submit($groups_form); + $form = $crawler->filter('form')->form(); + $values = $form->getValues(); + + // Check default settings + $this->assertEquals($admin_roles[0], $values['role[5][1]']); + $this->assertEquals($admin_roles[1], $values['role[5][2]']); + $this->assertEquals($guest_roles[0], $values['role[1][1]']); + $this->assertEquals($guest_roles[1], $values['role[1][2]']); + + // Set admin to full access on category + foreach ($set_values as $key => $value) + { + $form[$key]->setValue($value); + } + + $form_values = $form->getValues(); + $form_values['action[apply_all_permissions]'] = true; + $crawler = self::request('POST', 'adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid, $form_values); + $this->assertContainsLang('AUTH_UPDATED', $crawler->text()); + + $this->logout(); + } +} diff --git a/tests/ui/permission_roles_test.php b/tests/ui/permission_roles_test.php index a688680028..fbd0750785 100644 --- a/tests/ui/permission_roles_test.php +++ b/tests/ui/permission_roles_test.php @@ -14,10 +14,10 @@ /** * @group ui */ -class permission_roles_test extends phpbb_ui_test_case +class ui_permission_roles_test extends phpbb_ui_test_case { - public function test_quick_links() + public function test_permission_roles() { $this->login(); $this->admin_login(); -- cgit v1.2.1 From a75885bd85d57401904055366c18733ac84b323a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 17 Feb 2016 13:26:35 +0100 Subject: [ticket/14315] Add logout to ui tests and use in permissions role test PHPBB3-14315 --- tests/test_framework/phpbb_ui_test_case.php | 10 ++++++++++ tests/ui/permission_roles_test.php | 1 + 2 files changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index f9f4c516e6..7e87b63b97 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -276,6 +276,16 @@ class phpbb_ui_test_case extends phpbb_test_case return self::$db; } + protected function logout() + { + $this->add_lang('ucp'); + + $this->visit('ucp.php?sid=' . $this->sid . '&mode=logout'); + $this->assertContains($this->lang('REGISTER'), self::$webDriver->getPageSource()); + unset($this->sid); + + } + /** * Login to the ACP * You must run login() before calling this. diff --git a/tests/ui/permission_roles_test.php b/tests/ui/permission_roles_test.php index fbd0750785..8d704606bf 100644 --- a/tests/ui/permission_roles_test.php +++ b/tests/ui/permission_roles_test.php @@ -19,6 +19,7 @@ class ui_permission_roles_test extends phpbb_ui_test_case public function test_permission_roles() { + $this->logout(); $this->login(); $this->admin_login(); $this->add_lang('acp/permissions'); -- cgit v1.2.1 From 7c96d0abcd2b41b0c76396a10da92dc94b5274bb Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 17 Feb 2016 13:47:51 +0100 Subject: [ticket/14315] Use proper ID selectors in ui test PHPBB3-14315 --- tests/ui/permission_roles_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/ui/permission_roles_test.php b/tests/ui/permission_roles_test.php index 8d704606bf..3bc35c5b68 100644 --- a/tests/ui/permission_roles_test.php +++ b/tests/ui/permission_roles_test.php @@ -26,18 +26,18 @@ class ui_permission_roles_test extends phpbb_ui_test_case $this->visit('adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid); // Select forums - $elements = self::find_element('cssSelector', 'select[id=forum]') + $elements = self::find_element('cssSelector', 'select#forum') ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); foreach ($elements as $element) { $element->click(); } - self::find_element('cssSelector', 'form[id=select_victim]') + self::find_element('cssSelector', 'form#select_victim') ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=submit]')) ->click(); // Select administrators and guests - $groups_form = self::find_element('cssSelector', 'form[id=groups]'); + $groups_form = self::find_element('cssSelector', 'form#groups'); $elements = $groups_form ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('select')) ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); -- cgit v1.2.1 From 7d41fe01362d7752ca64981791b56b5133d39848 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 17 Feb 2016 14:11:27 +0100 Subject: [ticket/14315] Properly get sid from cookies and simplify take_screenshot PHPBB3-14315 --- tests/test_framework/phpbb_ui_test_case.php | 51 +++++++++-------------------- tests/ui/permission_roles_test.php | 2 +- 2 files changed, 16 insertions(+), 37 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 7e87b63b97..9bb89781a1 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -280,6 +280,11 @@ class phpbb_ui_test_case extends phpbb_test_case { $this->add_lang('ucp'); + if (empty($this->sid)) + { + return; + } + $this->visit('ucp.php?sid=' . $this->sid . '&mode=logout'); $this->assertContains($this->lang('REGISTER'), self::$webDriver->getPageSource()); unset($this->sid); @@ -301,6 +306,8 @@ class phpbb_ui_test_case extends phpbb_test_case return; } + self::$webDriver->manage()->deleteAllCookies(); + $this->visit('adm/index.php?sid=' . $this->sid); $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), self::$webDriver->getPageSource()); @@ -317,8 +324,12 @@ class phpbb_ui_test_case extends phpbb_test_case if (substr($cookie['name'], -4) == '_sid') { $this->sid = $cookie['value']; + + break; } } + + $this->assertNotEmpty($this->sid); } protected function add_lang($lang_file) @@ -428,52 +439,20 @@ class phpbb_ui_test_case extends phpbb_test_case $this->sid = $cookie['value']; } } + + $this->assertNotEmpty($this->sid); } /** * Take screenshot. Can be used for debug purposes. * - * @param \Facebook\WebDriver\Remote\RemoteWebElement $element - * @return string Element screenshot path * @throws Exception When screenshot can't be created */ - public function takeScreenshot($element = null) { + public function take_screenshot() + { // Change the Path to your own settings $screenshot = time() . ".png"; - // Change the driver instance self::$webDriver->takeScreenshot($screenshot); - if(!file_exists($screenshot)) { - throw new Exception('Could not save screenshot'); - } - - if( ! (bool) $element) { - return $screenshot; - } - - $element_screenshot = time() . ".png"; // Change the path here as well - - $element_width = $element->getSize()->getWidth(); - $element_height = $element->getSize()->getHeight(); - - $element_src_x = $element->getLocation()->getX(); - $element_src_y = $element->getLocation()->getY(); - - // Create image instances - $src = imagecreatefrompng($screenshot); - $dest = imagecreatetruecolor($element_width, $element_height); - - // Copy - imagecopy($dest, $src, 0, 0, $element_src_x, $element_src_y, $element_width, $element_height); - - imagepng($dest, $element_screenshot); - - // unlink($screenshot); // unlink function might be restricted in mac os x. - - if( ! file_exists($element_screenshot)) { - throw new Exception('Could not save element screenshot'); - } - - return $element_screenshot; } } diff --git a/tests/ui/permission_roles_test.php b/tests/ui/permission_roles_test.php index 3bc35c5b68..3501124fc1 100644 --- a/tests/ui/permission_roles_test.php +++ b/tests/ui/permission_roles_test.php @@ -19,7 +19,6 @@ class ui_permission_roles_test extends phpbb_ui_test_case public function test_permission_roles() { - $this->logout(); $this->login(); $this->admin_login(); $this->add_lang('acp/permissions'); @@ -28,6 +27,7 @@ class ui_permission_roles_test extends phpbb_ui_test_case // Select forums $elements = self::find_element('cssSelector', 'select#forum') ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); + foreach ($elements as $element) { $element->click(); -- cgit v1.2.1 From 99ace63e62fddc934eded20afc6a7aebbc05e13b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 7 Feb 2016 12:49:00 +0100 Subject: [ticket/14457] Don't set CSS to JS and JS to CSS PHPBB3-14457 --- tests/template/template_test_case.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 62eea0d361..3c97d30edc 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -172,6 +172,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $expected = str_replace(array("\n", "\r", "\t"), '', $expected); $output = str_replace(array("\n", "\r", "\t"), '', $this->display('test')); + $this->assertEquals($expected, $output, "Testing $file"); } } -- cgit v1.2.1 From ae221602438b832968d307eba8baea4ce6358439 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 18 Feb 2016 23:53:40 +0100 Subject: [ticket/14488] Delete cookies to get correct session ID during login PHPBB3-14488 --- tests/test_framework/phpbb_ui_test_case.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 9bb89781a1..b5ac3a576b 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -424,6 +424,8 @@ class phpbb_ui_test_case extends phpbb_test_case $this->visit('ucp.php'); $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), self::$webDriver->getPageSource()); + self::$webDriver->manage()->deleteAllCookies(); + self::find_element('cssSelector', 'input[name=username]')->sendKeys($username); self::find_element('cssSelector', 'input[name=password]')->sendKeys($username . $username); self::find_element('cssSelector', 'input[name=login]')->click(); -- cgit v1.2.1 From 50761104ba6590de86ec651b5679983eaf2ff600 Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Fri, 13 Jun 2014 11:38:02 +0200 Subject: [ticket/12684] Add doc blocks and test file for user:add PHPBB3-12684 --- tests/console/user/add_test.php | 138 +++++++++++++++++++++++++++++++++ tests/console/user/fixtures/config.xml | 43 ++++++++++ 2 files changed, 181 insertions(+) create mode 100644 tests/console/user/add_test.php create mode 100644 tests/console/user/fixtures/config.xml (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php new file mode 100644 index 0000000000..6c28c46815 --- /dev/null +++ b/tests/console/user/add_test.php @@ -0,0 +1,138 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use phpbb\console\command\user\add; + +require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_user.php'; +require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../../phpBB/includes/utf/utf_tools.php'; + +class phpbb_console_command_user_add_test extends phpbb_database_test_case +{ + protected $db; + protected $config; + protected $user; + protected $passwords_manager; + protected $command_name; + protected $dialog; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + public function setUp() + { + global $db, $config, $phpbb_dispatcher, $phpbb_container; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('cache.driver', new phpbb_mock_cache()); + + $config = $this->config = new \phpbb\config\config(array( + 'board_timezone' => 'UTC', + 'default_lang' => 'en', + )); + set_config(null, null, null, $this->config); + set_config_count(null, null, null, $this->config); + + $db = $this->db = $this->new_dbal(); + + $this->user = $this->getMock('\phpbb\user'); + $this->user->method('lang')->will($this->returnArgument(0)); + + $driver_helper = new \phpbb\passwords\driver\helper($this->config); + $passwords_drivers = array( + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($this->config, $driver_helper), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($this->config, $driver_helper), + 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($this->config, $driver_helper), + 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($this->config, $driver_helper), + ); + + $passwords_helper = new \phpbb\passwords\helper; + $this->passwords_manager = new \phpbb\passwords\manager($this->config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); + + parent::setUp(); + } + + public function test_add_no_dialog() + { + $command_tester = $this->get_command_tester(); + + $this->assertEquals(2, $this->get_user_id('Admin')); + + $command_tester->execute(array( + 'command' => $this->command_name, + '--username' => 'foo', + '--password' => 'bar', + '--email' => 'foo@test.com' + )); + + $this->assertNotEquals(null, $this->get_user_id('foo')); + $this->assertContains('SUCCESS_ADD_USER', $command_tester->getDisplay()); + } + + public function test_add_dialog() + { + $command_tester = $this->get_command_tester(); + + $this->assertEquals(2, $this->get_user_id('Admin')); + + $this->dialog->setInputStream($this->getInputStream("bar\npass\npass\nbar@test.com\n")); + + $command_tester->execute(array( + 'command' => $this->command_name, + )); + + $this->assertNotEquals(null, $this->get_user_id('bar')); + $this->assertContains('SUCCESS_ADD_USER', $command_tester->getDisplay()); + + } + + public function get_command_tester() + { + $application = new Application(); + $application->add(new add($this->user, $this->db, $this->config, $this->passwords_manager)); + + $command = $application->find('user:add'); + $this->command_name = $command->getName(); + $this->dialog = $command->getHelper('dialog'); + return new CommandTester($command); + } + + public function get_user_id($username) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE ' . 'username = ' . "'" . $username . "'"; + + $result = $this->db->sql_query($sql); + + $row = $this->db->sql_fetchrow($result); + + $this->db->sql_freeresult($result); + + return $row['user_id']; + } + + public function getInputStream($input) + { + $stream = fopen('php://memory', 'r+', false); + fputs($stream, $input); + rewind($stream); + + return $stream; + } +} diff --git a/tests/console/user/fixtures/config.xml b/tests/console/user/fixtures/config.xml new file mode 100644 index 0000000000..fed30dc20d --- /dev/null +++ b/tests/console/user/fixtures/config.xml @@ -0,0 +1,43 @@ + + + + user_id + user_permissions + username + username_clean + user_sig + + 1 + + Guest + guest + + + + 2 + + Admin + admin + + + + 3 + + Test + test + + +
            + + group_id + group_name + group_type + group_desc + + 1 + REGISTERED + 3 + foobar + +
            +
            -- cgit v1.2.1 From df4a620ba146d895be4910761bc030045abbae93 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 27 Aug 2014 16:56:46 +0200 Subject: [ticket/12684] Fix tests PHPBB3-12684 --- tests/console/user/add_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index 6c28c46815..6f80a8658a 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -50,7 +50,7 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case $db = $this->db = $this->new_dbal(); - $this->user = $this->getMock('\phpbb\user'); + $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); $this->user->method('lang')->will($this->returnArgument(0)); $driver_helper = new \phpbb\passwords\driver\helper($this->config); @@ -90,7 +90,7 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case $this->assertEquals(2, $this->get_user_id('Admin')); - $this->dialog->setInputStream($this->getInputStream("bar\npass\npass\nbar@test.com\n")); + $this->dialog->setInputStream($this->getInputStream("bar\npassword\npassword\nbar@test.com\n")); $command_tester->execute(array( 'command' => $this->command_name, -- cgit v1.2.1 From 6fe084a2fd967c188bdca827a46647120a5ea58d Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 29 Feb 2016 11:38:49 -0800 Subject: [ticket/12684] Updates for 3.2 API PHPBB3-12684 --- tests/console/user/add_test.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index 6f80a8658a..5e4b76063e 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -27,6 +27,8 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case protected $passwords_manager; protected $command_name; protected $dialog; + protected $phpbb_root_path; + protected $php_ext; public function getDataSet() { @@ -35,22 +37,26 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case public function setUp() { - global $db, $config, $phpbb_dispatcher, $phpbb_container; + global $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('cache.driver', new phpbb_mock_cache()); + $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + + $cache = $phpbb_container->get('cache.driver'); $config = $this->config = new \phpbb\config\config(array( 'board_timezone' => 'UTC', 'default_lang' => 'en', )); - set_config(null, null, null, $this->config); - set_config_count(null, null, null, $this->config); $db = $this->db = $this->new_dbal(); - $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $user = $this->user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime') + ); $this->user->method('lang')->will($this->returnArgument(0)); $driver_helper = new \phpbb\passwords\driver\helper($this->config); @@ -64,6 +70,9 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case $passwords_helper = new \phpbb\passwords\helper; $this->passwords_manager = new \phpbb\passwords\manager($this->config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $phpEx; + parent::setUp(); } @@ -104,7 +113,7 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case public function get_command_tester() { $application = new Application(); - $application->add(new add($this->user, $this->db, $this->config, $this->passwords_manager)); + $application->add(new add($this->user, $this->db, $this->config, $this->passwords_manager, $this->phpbb_root_path, $this->php_ext)); $command = $application->find('user:add'); $this->command_name = $command->getName(); -- cgit v1.2.1 From d373428180e884f03a830aa69fe8ff2cd6a5140a Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 29 Feb 2016 11:41:47 -0800 Subject: [ticket/12684] Add input validation PHPBB3-12684 --- tests/console/user/add_test.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index 5e4b76063e..280adb101d 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -49,6 +49,11 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case $config = $this->config = new \phpbb\config\config(array( 'board_timezone' => 'UTC', 'default_lang' => 'en', + 'min_name_chars' => 3, + 'max_name_chars' => 10, + 'min_pass_chars' => 3, + 'max_pass_chars' => 10, + 'pass_complex' => 'PASS_TYPE_ANY', )); $db = $this->db = $this->new_dbal(); @@ -110,6 +115,24 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case } + public function test_add_no_dialog_invalid() + { + $command_tester = $this->get_command_tester(); + + $this->assertEquals(3, $this->get_user_id('Test')); + + $command_tester->execute(array( + 'command' => $this->command_name, + '--username' => 'Test', + '--password' => '1', + '--email' => 'foo' + )); + + $this->assertContains('USERNAME_TAKEN', $command_tester->getDisplay()); + $this->assertContains('TOO_SHORT', $command_tester->getDisplay()); + $this->assertContains('EMAIL_INVALID', $command_tester->getDisplay()); + } + public function get_command_tester() { $application = new Application(); -- cgit v1.2.1 From f32b4c0547a596fcdd935560b23ed660f3d3f87c Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 29 Feb 2016 11:42:23 -0800 Subject: [ticket/12684] Add send email option PHPBB3-12684 --- tests/console/user/add_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index 280adb101d..a673d5eb6c 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -49,6 +49,7 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case $config = $this->config = new \phpbb\config\config(array( 'board_timezone' => 'UTC', 'default_lang' => 'en', + 'email_enable' => false, 'min_name_chars' => 3, 'max_name_chars' => 10, 'min_pass_chars' => 3, -- cgit v1.2.1 From fe31060fca4a07696029c50af2c74c88ab5d85fe Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 29 Feb 2016 14:23:32 -0800 Subject: [ticket/12684] Fix tests PHPBB3-12684 --- tests/console/user/add_test.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index a673d5eb6c..8fc921babf 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -24,9 +24,10 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case protected $db; protected $config; protected $user; + protected $language; protected $passwords_manager; protected $command_name; - protected $dialog; + protected $question; protected $phpbb_root_path; protected $php_ext; @@ -59,11 +60,16 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case $db = $this->db = $this->new_dbal(); + $this->language = $this->getMockBuilder('\phpbb\language\language') + ->disableOriginalConstructor() + ->getMock(); + $this->language->expects($this->any()) + ->method('lang') + ->will($this->returnArgument(0)); $user = $this->user = $this->getMock('\phpbb\user', array(), array( - new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), - '\phpbb\datetime') - ); - $this->user->method('lang')->will($this->returnArgument(0)); + $this->language, + '\phpbb\datetime' + )); $driver_helper = new \phpbb\passwords\driver\helper($this->config); $passwords_drivers = array( @@ -105,7 +111,7 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case $this->assertEquals(2, $this->get_user_id('Admin')); - $this->dialog->setInputStream($this->getInputStream("bar\npassword\npassword\nbar@test.com\n")); + $this->question->setInputStream($this->getInputStream("bar\npassword\npassword\nbar@test.com\n")); $command_tester->execute(array( 'command' => $this->command_name, @@ -137,11 +143,11 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case public function get_command_tester() { $application = new Application(); - $application->add(new add($this->user, $this->db, $this->config, $this->passwords_manager, $this->phpbb_root_path, $this->php_ext)); + $application->add(new add($this->user, $this->db, $this->config, $this->language, $this->passwords_manager, $this->phpbb_root_path, $this->php_ext)); $command = $application->find('user:add'); $this->command_name = $command->getName(); - $this->dialog = $command->getHelper('dialog'); + $this->question = $command->getHelper('question'); return new CommandTester($command); } -- cgit v1.2.1 From 0ca4484525f69ea5e7c5cd28f671364604725e40 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 29 Feb 2016 21:03:32 -0800 Subject: [ticket/12684] Move all lang keys to cli PHPBB3-12684 --- tests/console/user/add_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index 8fc921babf..de146ef6ec 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -102,7 +102,7 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case )); $this->assertNotEquals(null, $this->get_user_id('foo')); - $this->assertContains('SUCCESS_ADD_USER', $command_tester->getDisplay()); + $this->assertContains('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay()); } public function test_add_dialog() @@ -118,7 +118,7 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case )); $this->assertNotEquals(null, $this->get_user_id('bar')); - $this->assertContains('SUCCESS_ADD_USER', $command_tester->getDisplay()); + $this->assertContains('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay()); } -- cgit v1.2.1 From 5fc3177395a6fb2981110fea4d39e422a8b318e3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 5 Mar 2016 21:23:24 +0100 Subject: [ticket/14497] Add test for visiting installer PHPBB3-14497 --- tests/functional/visit_installer_test.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/functional/visit_installer_test.php (limited to 'tests') diff --git a/tests/functional/visit_installer_test.php b/tests/functional/visit_installer_test.php new file mode 100644 index 0000000000..80336bd410 --- /dev/null +++ b/tests/functional/visit_installer_test.php @@ -0,0 +1,30 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_visit_installer_test extends phpbb_functional_test_case +{ + public function test_visit_installer() + { + self::request('GET', 'install/'); + $this->assertContains('installation system', $this->get_content()); + + self::request('GET', 'install/index.html'); + $this->assertContains('installation system', $this->get_content()); + + self::request('GET', 'install/app.php'); + $this->assertContains('installation system', $this->get_content()); + } +} -- cgit v1.2.1 From 4e717c1725474265a694bd300b024030769dbd85 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 5 Mar 2016 22:19:03 +0100 Subject: [ticket/14497] Do not check for doctype on index and use correct return PHPBB3-14497 --- tests/functional/visit_installer_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/functional/visit_installer_test.php b/tests/functional/visit_installer_test.php index 80336bd410..b4a75c0b51 100644 --- a/tests/functional/visit_installer_test.php +++ b/tests/functional/visit_installer_test.php @@ -18,11 +18,11 @@ class phpbb_functional_visit_installer_test extends phpbb_functional_test_case { public function test_visit_installer() { - self::request('GET', 'install/'); - $this->assertContains('installation system', $this->get_content()); + self::request('GET', 'install/', [], false); + $this->assertContains('', $this->get_content()); - self::request('GET', 'install/index.html'); - $this->assertContains('installation system', $this->get_content()); + self::request('GET', 'install/index.html', [], false); + $this->assertContains('', $this->get_content()); self::request('GET', 'install/app.php'); $this->assertContains('installation system', $this->get_content()); -- cgit v1.2.1 From dad531e4b2c19dd22b8dd6a15e410e187a67fe46 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Mar 2016 12:29:55 +0100 Subject: [ticket/14527] Add tests for reverted improper fix PHPBB3-14527 --- tests/text_processing/decode_message_test.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_processing/decode_message_test.php b/tests/text_processing/decode_message_test.php index 7de599f2b1..6ee5f91578 100644 --- a/tests/text_processing/decode_message_test.php +++ b/tests/text_processing/decode_message_test.php @@ -16,6 +16,15 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; class phpbb_text_processing_decode_message_test extends phpbb_test_case { + public function setUp() + { + parent::setUp(); + + global $phpbb_dispatcher; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + } + /** * @dataProvider get_legacy_tests */ @@ -40,12 +49,20 @@ class phpbb_text_processing_decode_message_test extends phpbb_test_case ), array( 'www.phpbb.com', - 'www.phpbb.com' + 'http://www.phpbb.com' ), array( 'http://www.phpbb.com', 'http://www.phpbb.com' ), + array( + 'this is just text', + 'http://www.phpbb.com' + ), + array( + 'http://www.phpbb.com/some/ ... /shortened', + 'http://www.phpbb.com/some/more/link/that/is/shortened' + ), /** * Fails as per PHPBB3-8420 * @link http://tracker.phpbb.com/browse/PHPBB3-8420 -- cgit v1.2.1 From 17b8e93a5350e297f9be0925120f0b6cf34f5ffe Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Mar 2016 14:48:21 +0100 Subject: [ticket/14527] Decode automatically generated postlink without prefix The http prefix gets automatically added and should be removed prior to outputting the post to the user. PHPBB3-14527 --- tests/text_processing/decode_message_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_processing/decode_message_test.php b/tests/text_processing/decode_message_test.php index 6ee5f91578..fd1719fedc 100644 --- a/tests/text_processing/decode_message_test.php +++ b/tests/text_processing/decode_message_test.php @@ -49,7 +49,7 @@ class phpbb_text_processing_decode_message_test extends phpbb_test_case ), array( 'www.phpbb.com', - 'http://www.phpbb.com' + 'www.phpbb.com' ), array( 'http://www.phpbb.com', -- cgit v1.2.1 From 00c2efca605b4dbd323221a3dab2110c81ae3dcd Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 21 Mar 2016 13:54:41 -0700 Subject: [ticket/12684] Refactor a test PHPBB3-12684 --- tests/console/user/add_test.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index de146ef6ec..00134c18cd 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -143,7 +143,15 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case public function get_command_tester() { $application = new Application(); - $application->add(new add($this->user, $this->db, $this->config, $this->language, $this->passwords_manager, $this->phpbb_root_path, $this->php_ext)); + $application->add(new add( + $this->user, + $this->db, + $this->config, + $this->language, + $this->passwords_manager, + $this->phpbb_root_path, + $this->php_ext + )); $command = $application->find('user:add'); $this->command_name = $command->getName(); -- cgit v1.2.1 From 56c2caf6c0778c0da48fe0ac688c893777b89ee4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 23 Mar 2016 22:48:58 +0100 Subject: [ticket/14555] Uniformize cache directory usages PHPBB3-14555 --- tests/controller/common_helper_route.php | 2 +- tests/controller/controller_test.php | 2 +- tests/pagination/pagination_test.php | 2 +- tests/session/testable_factory.php | 3 ++- tests/test_framework/phpbb_functional_test_case.php | 3 ++- 5 files changed, 7 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 72c5328b0b..808eb684f2 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -126,7 +126,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); - $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 431b26b2bc..e8af2f7485 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -47,7 +47,7 @@ class phpbb_controller_controller_test extends phpbb_test_case new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); - $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); $routes = $router->get_routes(); // This will need to be updated if any new routes are defined diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 6a3b46cdae..024b6fc02d 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -46,7 +46,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager); - $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); $request = new phpbb_mock_request(); $request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER); diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 7819063505..6f8b49122b 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -73,7 +73,7 @@ class phpbb_session_testable_factory public function get_session(\phpbb\db\driver\driver_interface $dbal) { // set up all the global variables used by session - global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container; + global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container, $phpbb_root_path; $request = $this->request = new phpbb_mock_request( array(), @@ -95,6 +95,7 @@ class phpbb_session_testable_factory new phpbb_mock_auth_provider() ); $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); $provider_collection->add('auth.provider.db'); $phpbb_container->set( diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 53519617b3..d234642898 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -209,10 +209,11 @@ class phpbb_functional_test_case extends phpbb_test_case { if (!$this->cache) { - global $phpbb_container; + global $phpbb_container, $phpbb_root_path; $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); $this->cache = new \phpbb\cache\driver\file; } -- cgit v1.2.1 From 0ff4a6b6a4151f25d94d7b4f651b069e21b036b2 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 24 Mar 2016 19:49:23 +0100 Subject: [ticket/14381] Set the mode in message parser to "reparse" The default mode is "post". By setting it to something else, all limits pertaining to posts (min/max length, etc...) should be disabled. PHPBB3-14381 --- tests/text_reparser/base_test.php | 70 +++++++++++++++++++++++++++++++++++ tests/text_reparser/fixtures/base.xml | 19 ++++++++++ 2 files changed, 89 insertions(+) create mode 100644 tests/text_reparser/base_test.php create mode 100644 tests/text_reparser/fixtures/base.xml (limited to 'tests') diff --git a/tests/text_reparser/base_test.php b/tests/text_reparser/base_test.php new file mode 100644 index 0000000000..2223ead9a6 --- /dev/null +++ b/tests/text_reparser/base_test.php @@ -0,0 +1,70 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; + +class phpbb_textreparser_base_test extends phpbb_database_test_case +{ + protected $db; + + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + $this->db = $this->new_dbal(); + parent::setUp(); + } + + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/base.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\post_text($this->db, POSTS_TABLE); + } + + protected function get_rows(array $ids) + { + $sql = 'SELECT post_id AS id, post_text AS text + FROM ' . POSTS_TABLE . ' + WHERE ' . $this->db->sql_in_set('post_id', $ids) . ' + ORDER BY id'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + return $rows; + } + + public function test_reparse_empty() + { + $this->get_reparser()->reparse_range(1, 1); + + $this->assertEquals( + array( + array( + 'id' => 1, + 'text' => '' + ) + ), + $this->get_rows(array(1)) + ); + } +} diff --git a/tests/text_reparser/fixtures/base.xml b/tests/text_reparser/fixtures/base.xml new file mode 100644 index 0000000000..a4921a8823 --- /dev/null +++ b/tests/text_reparser/fixtures/base.xml @@ -0,0 +1,19 @@ + + + + post_id + enable_bbcode + enable_smilies + enable_magic_url + post_text + bbcode_uid + + 1 + 1 + 1 + 1 + + abcd1234 + +
            +
            -- cgit v1.2.1 From a5f1ff85634eb8936afd109395fc1d305eaca61e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 27 Mar 2016 20:06:02 +0200 Subject: [ticket/13683] Fix merge into 3.2.x PHPBB3-13683 --- tests/controller/common_helper_route.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index f0dd5706f1..a26157c2b2 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -500,15 +500,14 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function helper_url_data_force_server_vars() { return array( - array(false, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/app.php/foo'), - array(true, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/foo'), - array(false, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/my/board/app.php/foo'), - array(true, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/my/board/foo'), - array(false, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/app.php/foo'), - array(true, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/foo'), - array(false, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::RELATIVE_PATH, 'app.php/foo'), - array(true, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::RELATIVE_PATH, 'foo'), - ); + array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/app.php/foo'), + array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::ABSOLUTE_URL, 'https://my_server:444/my/board/foo'), + array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/my/board/app.php/foo'), + array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:444/my/board/foo'), + array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/app.php/foo'), + array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/foo'), + array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'app.php/foo'), + array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'foo'), ); } /** -- cgit v1.2.1 From 14e8113fcf01be7dbdb080458fcbf4e75668cc1a Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 31 Mar 2016 11:06:47 -0700 Subject: [ticket/14576] Move common required files to bootstrap PHPBB3-14576 --- tests/attachment/upload_test.php | 1 - tests/auth/provider_apache_test.php | 3 --- tests/auth/provider_db_test.php | 3 --- tests/bbcode/parser_test.php | 2 -- tests/bbcode/url_bbcode_test.php | 2 -- tests/bootstrap.php | 5 ++++- tests/captcha/qa_test.php | 2 -- tests/compress/compress_test.php | 1 - tests/console/cron/run_test.php | 1 - tests/console/thumbnail_test.php | 3 --- tests/console/user/add_test.php | 2 -- tests/content_visibility/delete_post_test.php | 3 --- tests/content_visibility/set_post_visibility_test.php | 3 --- tests/content_visibility/set_topic_visibility_test.php | 3 --- tests/controller/common_helper_route.php | 2 -- tests/controller/controller_test.php | 2 -- tests/controller/helper_route_adm_subdir_test.php | 1 - tests/controller/helper_route_adm_test.php | 1 - tests/controller/helper_route_root_test.php | 1 - tests/controller/helper_route_slash_test.php | 1 - tests/controller/helper_route_unclean_path_test.php | 1 - tests/dbal/auto_increment_test.php | 2 -- tests/dbal/boolean_processor_test.php | 3 --- tests/dbal/connect_test.php | 2 -- tests/dbal/cross_join_test.php | 3 --- tests/dbal/db_tools_test.php | 2 -- tests/dbal/migrator_test.php | 1 - tests/dbal/migrator_tool_module_test.php | 2 -- tests/dbal/migrator_tool_permission_test.php | 2 -- tests/dbal/schema_test.php | 2 -- tests/dbal/select_test.php | 3 --- tests/dbal/write_sequence_test.php | 2 -- tests/dbal/write_test.php | 2 -- tests/di/create_container_test.php | 1 - tests/error_collector_test.php | 2 -- tests/event/exception_listener_test.php | 2 -- tests/event/md_exporter_test.php | 2 -- tests/extension/extension_base_test.php | 1 - tests/extension/finder_test.php | 1 - tests/files/types_form_test.php | 2 -- tests/files/types_local_test.php | 2 -- tests/files/types_remote_test.php | 1 - tests/functional/download_test.php | 3 --- tests/functional/feed_test.php | 2 -- tests/functional/notification_test.php | 2 -- tests/functional/permission_roles_test.php | 2 -- tests/functions/build_hidden_fields_for_query_params_test.php | 2 -- tests/functions/build_url_test.php | 2 -- tests/functions/convert_30_dbms_to_31_test.php | 2 -- tests/functions/generate_string_list.php | 3 --- tests/functions/get_formatted_filesize_test.php | 2 -- tests/functions/get_preg_expression_test.php | 2 -- tests/functions/get_remote_file_test.php | 3 --- tests/functions/language_select_test.php | 2 -- tests/functions/make_clickable_email_test.php | 3 --- tests/functions/make_clickable_test.php | 3 --- tests/functions/obtain_online_test.php | 3 --- tests/functions/parse_cfg_file_test.php | 2 -- tests/functions/quoteattr_test.php | 2 -- tests/functions/style_select_test.php | 2 -- tests/functions/user_delete_test.php | 1 - tests/functions/validate_email_test.php | 1 - tests/functions/validate_password_test.php | 1 - tests/functions/validate_string_test.php | 1 - tests/functions/validate_user_email_test.php | 1 - tests/functions/validate_username_test.php | 2 -- tests/functions_acp/validate_config_vars_test.php | 1 - tests/functions_acp/validate_range_test.php | 1 - tests/functions_content/get_username_string_test.php | 3 --- tests/functions_content/phpbb_clean_search_string_test.php | 2 -- tests/functions_user/delete_user_test.php | 2 -- tests/functions_user/group_user_attributes_test.php | 2 -- tests/groupposition/legend_test.php | 1 - tests/groupposition/teampage_test.php | 3 --- tests/lock/db_test.php | 2 -- tests/log/add_test.php | 2 -- tests/log/delete_test.php | 4 ---- tests/log/function_add_log_test.php | 2 -- tests/log/function_view_log_test.php | 3 --- tests/mock/session_testable.php | 2 -- tests/network/checkdnsrr_test.php | 2 -- tests/network/ftp_fsock_pasv_epsv_test.php | 1 - tests/network/inet_ntop_pton_test.php | 2 -- tests/network/ip_normalise_test.php | 2 -- tests/notification/group_request_test.php | 1 - tests/notification/submit_post_base.php | 3 --- tests/notification/user_list_trim_test.php | 3 --- tests/profilefields/type_googleplus_test.php | 2 -- tests/profilefields/type_string_test.php | 4 ---- tests/profilefields/type_url_test.php | 2 -- tests/random/gen_rand_string_test.php | 2 -- tests/regex/censor_test.php | 4 +--- tests/regex/email_test.php | 2 -- tests/regex/ipv4_test.php | 2 -- tests/regex/ipv6_test.php | 2 -- tests/regex/password_complexity_test.php | 1 - tests/regex/table_prefix_test.php | 2 -- tests/regex/url_test.php | 2 -- tests/request/request_var_test.php | 3 --- tests/request/type_cast_helper_test.php | 2 -- tests/security/extract_current_page_test.php | 1 - tests/security/hash_test.php | 2 -- tests/security/redirect_test.php | 1 - tests/session/append_sid_test.php | 2 -- tests/session/extract_page_test.php | 1 - tests/session/garbage_collection_test.php | 1 - tests/session/session_key_test.php | 1 - tests/template/template_parser_test.php | 1 - tests/template/template_test.php | 1 - tests/template/template_test_case.php | 2 -- tests/test_framework/phpbb_session_test_case.php | 1 - tests/text_formatter/s9e/default_formatting_test.php | 2 -- tests/text_formatter/s9e/factory_test.php | 3 +-- tests/text_formatter/s9e/parser_test.php | 2 -- tests/text_formatter/s9e/renderer_test.php | 2 -- tests/text_formatter/s9e/utils_test.php | 3 --- tests/text_processing/censor_text_test.php | 3 --- tests/text_processing/decode_message_test.php | 3 --- tests/text_processing/generate_text_for_display_test.php | 3 --- tests/text_processing/generate_text_for_edit_test.php | 3 --- tests/text_processing/generate_text_for_storage_test.php | 5 ----- tests/text_processing/make_clickable_test.php | 3 --- tests/text_processing/message_parser_test.php | 3 --- tests/text_processing/smilies_test.php | 3 --- tests/text_processing/strip_bbcode_test.php | 3 --- tests/text_processing/tickets_test.php | 4 ---- tests/text_reparser/base_test.php | 3 +-- tests/text_reparser/plugins/contact_admin_info_test.php | 3 +-- tests/text_reparser/plugins/poll_option_test.php | 3 +-- tests/text_reparser/plugins/test_row_based_plugin.php | 3 +-- tests/tree/nestedset_forum_base.php | 2 -- tests/upload/filespec_test.php | 3 --- tests/upload/fileupload_test.php | 2 -- tests/upload/imagesize_test.php | 2 -- tests/user/user_loader_test.php | 2 -- tests/utf/utf8_clean_string_test.php | 2 -- tests/utf/utf8_wordwrap_test.php | 2 -- tests/wrapper/gmgetdate_test.php | 2 -- tests/wrapper/mt_rand_test.php | 2 -- tests/wrapper/phpbb_php_ini_test.php | 1 - tests/wrapper/version_compare_test.php | 2 -- 141 files changed, 10 insertions(+), 289 deletions(-) (limited to 'tests') diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index 295b6b15c9..235ecd082a 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -11,7 +11,6 @@ * */ -require_once(dirname(__FILE__) . '/../../phpBB/includes/functions.php'); require_once(dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php'); class phpbb_attachment_upload_test extends \phpbb_database_test_case diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 60423acbc1..7d77d763fb 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_auth_provider_apache_test extends phpbb_database_test_case { protected $provider; diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php index 38dbfa1fcb..6ff77da564 100644 --- a/tests/auth/provider_db_test.php +++ b/tests/auth/provider_db_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_auth_provider_db_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 14736627f3..5677e49636 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php'; diff --git a/tests/bbcode/url_bbcode_test.php b/tests/bbcode/url_bbcode_test.php index 83176abe4c..3f8ad6022f 100644 --- a/tests/bbcode/url_bbcode_test.php +++ b/tests/bbcode/url_bbcode_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php'; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 86e1e5314b..18977bac88 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -23,7 +23,10 @@ require_once $phpbb_root_path . 'includes/startup.php'; $table_prefix = 'phpbb_'; require_once $phpbb_root_path . 'includes/constants.php'; require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; -require_once($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); +require_once $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx; +require_once $phpbb_root_path . 'includes/functions.' . $phpEx; +require_once $phpbb_root_path . 'includes/functions_content.' . $phpEx; +require_once $phpbb_root_path . 'includes/functions_compatibility.' . $phpEx; $phpbb_class_loader_mock = new \phpbb\class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', "php"); $phpbb_class_loader_mock->register(); diff --git a/tests/captcha/qa_test.php b/tests/captcha/qa_test.php index 4aa5e714f5..7ec4be69f5 100644 --- a/tests/captcha/qa_test.php +++ b/tests/captcha/qa_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_captcha_qa_test extends \phpbb_database_test_case { protected $request; diff --git a/tests/compress/compress_test.php b/tests/compress/compress_test.php index 56c406b206..c071a049a8 100644 --- a/tests/compress/compress_test.php +++ b/tests/compress/compress_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compress.php'; diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index d6c7b21781..b4a0203325 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -16,7 +16,6 @@ use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\cron\run; require_once dirname(__FILE__) . '/tasks/simple.php'; -require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php'; class phpbb_console_command_cron_run_test extends phpbb_database_test_case { diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php index 45d7adacb9..439e3623fa 100644 --- a/tests/console/thumbnail_test.php +++ b/tests/console/thumbnail_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\thumbnail\generate; diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index 00134c18cd..ee6eee8491 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -16,8 +16,6 @@ use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\user\add; require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_user.php'; -require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../../phpBB/includes/utf/utf_tools.php'; class phpbb_console_command_user_add_test extends phpbb_database_test_case { diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index ba0a21a1a4..4ea95b0a96 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -11,11 +11,8 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; require_once dirname(__FILE__) . '/../mock/search.php'; class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 6375ce8f6d..e33a1f30d5 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -11,11 +11,8 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_test_case { diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index f4d65f9ce3..78431396c3 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -11,11 +11,8 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_test_case { diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 808eb684f2..c23342bc57 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - use Symfony\Component\Routing\Generator\UrlGeneratorInterface; abstract class phpbb_controller_common_helper_route extends phpbb_test_case diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index e8af2f7485..abc1124a90 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/tests/controller/helper_route_adm_subdir_test.php b/tests/controller/helper_route_adm_subdir_test.php index f27ac81b04..a1bf1b8805 100644 --- a/tests/controller/helper_route_adm_subdir_test.php +++ b/tests/controller/helper_route_adm_subdir_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/common_helper_route.php'; class phpbb_controller_helper_route_adm_subdir_test extends phpbb_controller_common_helper_route diff --git a/tests/controller/helper_route_adm_test.php b/tests/controller/helper_route_adm_test.php index 86dc36ef1f..6ee394eaaa 100644 --- a/tests/controller/helper_route_adm_test.php +++ b/tests/controller/helper_route_adm_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/common_helper_route.php'; class phpbb_controller_helper_route_adm_test extends phpbb_controller_common_helper_route diff --git a/tests/controller/helper_route_root_test.php b/tests/controller/helper_route_root_test.php index 63a2f2f8f7..12462e076d 100644 --- a/tests/controller/helper_route_root_test.php +++ b/tests/controller/helper_route_root_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/common_helper_route.php'; class phpbb_controller_helper_route_test extends phpbb_controller_common_helper_route diff --git a/tests/controller/helper_route_slash_test.php b/tests/controller/helper_route_slash_test.php index 3db5ec19e5..c781a6943e 100644 --- a/tests/controller/helper_route_slash_test.php +++ b/tests/controller/helper_route_slash_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/common_helper_route.php'; class phpbb_controller_helper_route_slash_test extends phpbb_controller_common_helper_route diff --git a/tests/controller/helper_route_unclean_path_test.php b/tests/controller/helper_route_unclean_path_test.php index 9d8b62bc1c..80f1a99fff 100644 --- a/tests/controller/helper_route_unclean_path_test.php +++ b/tests/controller/helper_route_unclean_path_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/common_helper_route.php'; class phpbb_controller_helper_route_unclean_path_test extends phpbb_controller_common_helper_route diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php index 39eb6835ff..950a4fc8f7 100644 --- a/tests/dbal/auto_increment_test.php +++ b/tests/dbal/auto_increment_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_dbal_auto_increment_test extends phpbb_database_test_case { protected $db; diff --git a/tests/dbal/boolean_processor_test.php b/tests/dbal/boolean_processor_test.php index 226f5307b2..c69f60a1a8 100644 --- a/tests/dbal/boolean_processor_test.php +++ b/tests/dbal/boolean_processor_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_boolean_processor_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/dbal/connect_test.php b/tests/dbal/connect_test.php index edf57189cb..3933dab798 100644 --- a/tests/dbal/connect_test.php +++ b/tests/dbal/connect_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_dbal_connect_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/dbal/cross_join_test.php b/tests/dbal/cross_join_test.php index 7ba937ccc6..be9258c58b 100644 --- a/tests/dbal/cross_join_test.php +++ b/tests/dbal/cross_join_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_dbal_cross_join_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index aa0b6ccf48..b884b4ab95 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_dbal_db_tools_test extends phpbb_database_test_case { /** @var \phpbb\db\driver\driver_interface */ diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index f52e6ea63d..48c99ad1d0 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/migration/dummy.php'; require_once dirname(__FILE__) . '/migration/unfulfillable.php'; require_once dirname(__FILE__) . '/migration/if.php'; diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index a71334f23f..c2252c8d10 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php index bfb2e07080..d84f6a68ff 100644 --- a/tests/dbal/migrator_tool_permission_test.php +++ b/tests/dbal/migrator_tool_permission_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case { public $group_ids = array( diff --git a/tests/dbal/schema_test.php b/tests/dbal/schema_test.php index f13c7ce032..59965655ad 100644 --- a/tests/dbal/schema_test.php +++ b/tests/dbal/schema_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_dbal_schema_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php index b7074552ba..0dac66fc46 100644 --- a/tests/dbal/select_test.php +++ b/tests/dbal/select_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_dbal_select_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/dbal/write_sequence_test.php b/tests/dbal/write_sequence_test.php index a1b589c578..a2d5921797 100644 --- a/tests/dbal/write_sequence_test.php +++ b/tests/dbal/write_sequence_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_dbal_write_sequence_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php index 2426f2b0be..98709fb043 100644 --- a/tests/dbal/write_test.php +++ b/tests/dbal/write_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_dbal_write_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 2d94f1d778..4dd0583ebe 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -13,7 +13,6 @@ namespace { - require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/fixtures/ext/vendor/enabled_4/di/extension.php'; class phpbb_di_container_test extends \phpbb_test_case diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php index ddbe2e3af1..273284c8fc 100644 --- a/tests/error_collector_test.php +++ b/tests/error_collector_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../phpBB/includes/functions.php'; - class phpbb_error_collector_test extends phpbb_test_case { public function setUp() diff --git a/tests/event/exception_listener_test.php b/tests/event/exception_listener_test.php index e643fadf2c..08679a3ed8 100644 --- a/tests/event/exception_listener_test.php +++ b/tests/event/exception_listener_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class exception_listener extends phpbb_test_case { public function phpbb_exception_data() diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php index a6c1dc78de..607f442fdf 100644 --- a/tests/event/md_exporter_test.php +++ b/tests/event/md_exporter_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_event_md_exporter_test extends phpbb_test_case { static public function crawl_eventsmd_data() diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php index 775a23e198..e0c2e6d549 100644 --- a/tests/extension/extension_base_test.php +++ b/tests/extension/extension_base_test.php @@ -10,7 +10,6 @@ * the docs/CREDITS.txt file. * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/ext/vendor2/bar/migrations/bar.php'; require_once dirname(__FILE__) . '/ext/vendor2/bar/migrations/foo.php'; require_once dirname(__FILE__) . '/ext/vendor2/bar/migrations/migration.php'; diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 463b69e9a9..71de2c2fc5 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -10,7 +10,6 @@ * the docs/CREDITS.txt file. * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_extension_finder_test extends phpbb_test_case { diff --git a/tests/files/types_form_test.php b/tests/files/types_form_test.php index efcece49d1..925babb47f 100644 --- a/tests/files/types_form_test.php +++ b/tests/files/types_form_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_files_types_form_test extends phpbb_test_case { private $path; diff --git a/tests/files/types_local_test.php b/tests/files/types_local_test.php index f4fa7fad3f..31070de107 100644 --- a/tests/files/types_local_test.php +++ b/tests/files/types_local_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_files_types_local_test extends phpbb_test_case { private $path; diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index 476d8ed3ba..d103771c04 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/type_foo.php'; class phpbb_files_types_remote_test extends phpbb_test_case diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php index 1e863210e6..e2f1d065be 100644 --- a/tests/functional/download_test.php +++ b/tests/functional/download_test.php @@ -11,10 +11,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; /** * @group functional diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index dad5ca7e1a..3792b0a23c 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - /** * @group functional */ diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index 87c36dd4d1..5c6b87d50b 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - /** * @group functional */ diff --git a/tests/functional/permission_roles_test.php b/tests/functional/permission_roles_test.php index 82d5be68c3..e6506fb37c 100644 --- a/tests/functional/permission_roles_test.php +++ b/tests/functional/permission_roles_test.php @@ -11,8 +11,6 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; - /** * @group functional */ diff --git a/tests/functions/build_hidden_fields_for_query_params_test.php b/tests/functions/build_hidden_fields_for_query_params_test.php index 14cb4b9a94..aee7a569d4 100644 --- a/tests/functions/build_hidden_fields_for_query_params_test.php +++ b/tests/functions/build_hidden_fields_for_query_params_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_build_hidden_fields_for_query_params_test extends phpbb_test_case { public function build_hidden_fields_for_query_params_test_data() diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 3e19b51f02..91a4a9ec66 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_build_url_test extends phpbb_test_case { protected function setUp() diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php index 729c0a82f0..1405d81eb3 100644 --- a/tests/functions/convert_30_dbms_to_31_test.php +++ b/tests/functions/convert_30_dbms_to_31_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case { public function convert_30_dbms_to_31_data() diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php index bcf0c09fe4..6eddb1395e 100644 --- a/tests/functions/generate_string_list.php +++ b/tests/functions/generate_string_list.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_generate_string_list_test extends phpbb_test_case { public $user; diff --git a/tests/functions/get_formatted_filesize_test.php b/tests/functions/get_formatted_filesize_test.php index 635753d737..290515b64f 100644 --- a/tests/functions/get_formatted_filesize_test.php +++ b/tests/functions/get_formatted_filesize_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_get_formatted_filesize_test extends phpbb_test_case { public function get_formatted_filesize_test_data() diff --git a/tests/functions/get_preg_expression_test.php b/tests/functions/get_preg_expression_test.php index e74017d315..b8254b03ea 100644 --- a/tests/functions/get_preg_expression_test.php +++ b/tests/functions/get_preg_expression_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_functions_get_preg_expression_test extends phpbb_test_case { public function data_path_remove_dot_trailing_slash() diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php index 781a73a462..1550aa37e6 100644 --- a/tests/functions/get_remote_file_test.php +++ b/tests/functions/get_remote_file_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; - /** * @group slow */ diff --git a/tests/functions/language_select_test.php b/tests/functions/language_select_test.php index 6762ead5a1..2d1296d72f 100644 --- a/tests/functions/language_select_test.php +++ b/tests/functions/language_select_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_functions_language_select_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/functions/make_clickable_email_test.php b/tests/functions/make_clickable_email_test.php index 4c802d0487..f32b4339a8 100644 --- a/tests/functions/make_clickable_email_test.php +++ b/tests/functions/make_clickable_email_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_functions_make_clickable_email_test extends phpbb_test_case { protected function setUp() diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php index 63beeb06b2..48fc2c19fb 100644 --- a/tests/functions/make_clickable_test.php +++ b/tests/functions/make_clickable_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_functions_make_clickable_test extends phpbb_test_case { /** diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index e793a4eb82..778753e5d2 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_functions_obtain_online_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/functions/parse_cfg_file_test.php b/tests/functions/parse_cfg_file_test.php index b47e25fbc1..017a931f28 100644 --- a/tests/functions/parse_cfg_file_test.php +++ b/tests/functions/parse_cfg_file_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_functions_parse_cfg_file extends phpbb_test_case { public function parse_cfg_file_data() diff --git a/tests/functions/quoteattr_test.php b/tests/functions/quoteattr_test.php index 6e191f9610..dbad7a99d8 100644 --- a/tests/functions/quoteattr_test.php +++ b/tests/functions/quoteattr_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_quoteattr_test extends phpbb_test_case { public function quoteattr_test_data() diff --git a/tests/functions/style_select_test.php b/tests/functions/style_select_test.php index a918f83155..27f0e68c88 100644 --- a/tests/functions/style_select_test.php +++ b/tests/functions/style_select_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_functions_style_select_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index bd6b53c59f..480b5fc5e1 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; class phpbb_functions_user_delete_test extends phpbb_database_test_case diff --git a/tests/functions/validate_email_test.php b/tests/functions/validate_email_test.php index b46509fda7..7f8b2679d4 100644 --- a/tests/functions/validate_email_test.php +++ b/tests/functions/validate_email_test.php @@ -7,7 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; require_once dirname(__FILE__) . '/../mock/user.php'; require_once dirname(__FILE__) . '/validate_data_helper.php'; diff --git a/tests/functions/validate_password_test.php b/tests/functions/validate_password_test.php index c5942e79bf..5e34c8baba 100644 --- a/tests/functions/validate_password_test.php +++ b/tests/functions/validate_password_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; require_once dirname(__FILE__) . '/validate_data_helper.php'; diff --git a/tests/functions/validate_string_test.php b/tests/functions/validate_string_test.php index 24026e4c9f..7aca14c334 100644 --- a/tests/functions/validate_string_test.php +++ b/tests/functions/validate_string_test.php @@ -12,7 +12,6 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; require_once dirname(__FILE__) . '/validate_data_helper.php'; class phpbb_functions_validate_string_test extends phpbb_test_case diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php index 951d5794e6..8dcec88103 100644 --- a/tests/functions/validate_user_email_test.php +++ b/tests/functions/validate_user_email_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; require_once dirname(__FILE__) . '/../mock/user.php'; require_once dirname(__FILE__) . '/validate_data_helper.php'; diff --git a/tests/functions/validate_username_test.php b/tests/functions/validate_username_test.php index 4fa5af7ff3..d310f58036 100644 --- a/tests/functions/validate_username_test.php +++ b/tests/functions/validate_username_test.php @@ -11,9 +11,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; require_once dirname(__FILE__) . '/../mock/cache.php'; require_once dirname(__FILE__) . '/validate_data_helper.php'; diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php index 32738e4351..5c31888291 100644 --- a/tests/functions_acp/validate_config_vars_test.php +++ b/tests/functions_acp/validate_config_vars_test.php @@ -12,7 +12,6 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case { diff --git a/tests/functions_acp/validate_range_test.php b/tests/functions_acp/validate_range_test.php index 6408e29a26..9e9154a43c 100644 --- a/tests/functions_acp/validate_range_test.php +++ b/tests/functions_acp/validate_range_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; class phpbb_functions_acp_validate_range_test extends phpbb_test_case diff --git a/tests/functions_content/get_username_string_test.php b/tests/functions_content/get_username_string_test.php index 01ec97f6a4..e79342d05d 100644 --- a/tests/functions_content/get_username_string_test.php +++ b/tests/functions_content/get_username_string_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_functions_content_get_username_string_test extends phpbb_test_case { public function setUp() diff --git a/tests/functions_content/phpbb_clean_search_string_test.php b/tests/functions_content/phpbb_clean_search_string_test.php index abd107097c..34ae0575c5 100644 --- a/tests/functions_content/phpbb_clean_search_string_test.php +++ b/tests/functions_content/phpbb_clean_search_string_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_functions_content_phpbb_clean_search_string_test extends phpbb_test_case { public function phpbb_clean_search_string_data() diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 6d2e1fa20a..25042d9f1b 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -7,9 +7,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_functions_user_delete_user_test extends phpbb_database_test_case { diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index 6ccada44f8..3124d57ba0 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -11,9 +11,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_functions_user_group_user_attributes_test extends phpbb_database_test_case { diff --git a/tests/groupposition/legend_test.php b/tests/groupposition/legend_test.php index 566a8a2935..02ddb7cbce 100644 --- a/tests/groupposition/legend_test.php +++ b/tests/groupposition/legend_test.php @@ -11,7 +11,6 @@ * */ - class phpbb_groupposition_legend_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/groupposition/teampage_test.php b/tests/groupposition/teampage_test.php index dff52f7a43..3b916670f7 100644 --- a/tests/groupposition/teampage_test.php +++ b/tests/groupposition/teampage_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_groupposition_teampage_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php index 389eab4152..5fbfa26554 100644 --- a/tests/lock/db_test.php +++ b/tests/lock/db_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_lock_db_test extends phpbb_database_test_case { private $db; diff --git a/tests/log/add_test.php b/tests/log/add_test.php index ea1ae74d53..604c8364dc 100644 --- a/tests/log/add_test.php +++ b/tests/log/add_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_log_add_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/log/delete_test.php b/tests/log/delete_test.php index fe4c3835cb..e8b75d01d9 100644 --- a/tests/log/delete_test.php +++ b/tests/log/delete_test.php @@ -11,10 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_log_delete_test extends phpbb_database_test_case { protected $log; diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php index cdfeb52996..3b5537fc13 100644 --- a/tests/log/function_add_log_test.php +++ b/tests/log/function_add_log_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; - class phpbb_log_function_add_log_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 81b1f4a78c..ee9c3e5893 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -11,10 +11,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; require_once dirname(__FILE__) . '/../mock/user.php'; require_once dirname(__FILE__) . '/../mock/cache.php'; diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php index 29dd2a5bff..2f24978ba8 100644 --- a/tests/mock/session_testable.php +++ b/tests/mock/session_testable.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - /** * Extends the session class to overwrite the setting of cookies. * diff --git a/tests/network/checkdnsrr_test.php b/tests/network/checkdnsrr_test.php index a3852b2656..6503a4c40b 100644 --- a/tests/network/checkdnsrr_test.php +++ b/tests/network/checkdnsrr_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - /** * @group slow */ diff --git a/tests/network/ftp_fsock_pasv_epsv_test.php b/tests/network/ftp_fsock_pasv_epsv_test.php index 6ed9d61dc0..4ec21b6f75 100644 --- a/tests/network/ftp_fsock_pasv_epsv_test.php +++ b/tests/network/ftp_fsock_pasv_epsv_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_transfer.php'; /** diff --git a/tests/network/inet_ntop_pton_test.php b/tests/network/inet_ntop_pton_test.php index fae40ad74e..dbd58ce783 100644 --- a/tests/network/inet_ntop_pton_test.php +++ b/tests/network/inet_ntop_pton_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_network_inet_ntop_pton_test extends phpbb_test_case { public function data_provider() diff --git a/tests/network/ip_normalise_test.php b/tests/network/ip_normalise_test.php index 1acfd4521d..52e594e115 100644 --- a/tests/network/ip_normalise_test.php +++ b/tests/network/ip_normalise_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_network_ip_normalise_test extends phpbb_test_case { public function data_provider() diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index d16e198861..92e758a336 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -12,7 +12,6 @@ */ require_once dirname(__FILE__) . '/base.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_notification_group_request_test extends phpbb_tests_notification_base { diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 14ca4499d2..21559c42a5 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -15,10 +15,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; abstract class phpbb_notification_submit_post_base extends phpbb_database_test_case { diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index 9f6eb492f6..7d4dff6024 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_notification_user_list_trim_test extends phpbb_database_test_case { protected $notification; diff --git a/tests/profilefields/type_googleplus_test.php b/tests/profilefields/type_googleplus_test.php index 6faf939231..9222362214 100644 --- a/tests/profilefields/type_googleplus_test.php +++ b/tests/profilefields/type_googleplus_test.php @@ -11,8 +11,6 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_profilefield_type_googleplus_test extends phpbb_test_case { protected $field; diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php index 447ab32a00..7c7fa3f3e6 100644 --- a/tests/profilefields/type_string_test.php +++ b/tests/profilefields/type_string_test.php @@ -11,10 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_profilefield_type_string_test extends phpbb_test_case { protected $cp; diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php index a0f93fe1f6..1d90e2c34c 100644 --- a/tests/profilefields/type_url_test.php +++ b/tests/profilefields/type_url_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_profilefield_type_url_test extends phpbb_test_case { protected $cp; diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php index 1d12d0622c..a9d1ea20de 100644 --- a/tests/random/gen_rand_string_test.php +++ b/tests/random/gen_rand_string_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_random_gen_rand_string_test extends phpbb_test_case { const TEST_COUNT = 100; diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php index 5625b0020b..5a516b71de 100644 --- a/tests/regex/censor_test.php +++ b/tests/regex/censor_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_regex_censor_test extends phpbb_test_case { public function censor_test_data() @@ -41,4 +39,4 @@ class phpbb_regex_censor_test extends phpbb_test_case $this->assertRegExp($regex, $subject); } -} \ No newline at end of file +} diff --git a/tests/regex/email_test.php b/tests/regex/email_test.php index ede35c49bc..5187b8bda6 100644 --- a/tests/regex/email_test.php +++ b/tests/regex/email_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_regex_email_test extends phpbb_test_case { protected $regex; diff --git a/tests/regex/ipv4_test.php b/tests/regex/ipv4_test.php index 62c2567517..e21a2d77fa 100644 --- a/tests/regex/ipv4_test.php +++ b/tests/regex/ipv4_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_regex_ipv4_test extends phpbb_test_case { protected $regex; diff --git a/tests/regex/ipv6_test.php b/tests/regex/ipv6_test.php index 41039c819d..223161df7f 100644 --- a/tests/regex/ipv6_test.php +++ b/tests/regex/ipv6_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_regex_ipv6_test extends phpbb_test_case { protected $regex; diff --git a/tests/regex/password_complexity_test.php b/tests/regex/password_complexity_test.php index 8a1a9edd41..933dc1ac91 100644 --- a/tests/regex/password_complexity_test.php +++ b/tests/regex/password_complexity_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; class phpbb_password_complexity_test extends phpbb_test_case diff --git a/tests/regex/table_prefix_test.php b/tests/regex/table_prefix_test.php index c593085b25..bf7b59ccc6 100644 --- a/tests/regex/table_prefix_test.php +++ b/tests/regex/table_prefix_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_regex_table_prefix_test extends phpbb_test_case { public function table_prefix_test_data() diff --git a/tests/regex/url_test.php b/tests/regex/url_test.php index e5d7c3256a..5e2a22bf73 100644 --- a/tests/regex/url_test.php +++ b/tests/regex/url_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_regex_url_test extends phpbb_test_case { public function url_test_data() diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php index b409e5ef25..84c81c4e84 100644 --- a/tests/request/request_var_test.php +++ b/tests/request/request_var_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_request_var_test extends phpbb_test_case { /** diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php index d6ee1dc728..143c05aa9c 100644 --- a/tests/request/type_cast_helper_test.php +++ b/tests/request/type_cast_helper_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_type_cast_helper_test extends phpbb_test_case { private $type_cast_helper; diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php index 767b901a43..f764449eca 100644 --- a/tests/security/extract_current_page_test.php +++ b/tests/security/extract_current_page_test.php @@ -13,7 +13,6 @@ require_once dirname(__FILE__) . '/base.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_security_extract_current_page_test extends phpbb_security_test_base { diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php index 0494c55c6d..84d4fcf479 100644 --- a/tests/security/hash_test.php +++ b/tests/security/hash_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; - class phpbb_security_hash_test extends phpbb_test_case { public function setUp() diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index 62781f3ee6..40cb7d2f04 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -13,7 +13,6 @@ require_once dirname(__FILE__) . '/base.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_security_redirect_test extends phpbb_security_test_base { diff --git a/tests/session/append_sid_test.php b/tests/session/append_sid_test.php index 2a1d94514f..4e5a238644 100644 --- a/tests/session/append_sid_test.php +++ b/tests/session/append_sid_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_session_append_sid_test extends phpbb_test_case { diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index 96445ef9b3..88eb7b2c1a 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -12,7 +12,6 @@ */ require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_session_extract_page_test extends phpbb_session_test_case { diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php index 3fad81c68b..3dc591a328 100644 --- a/tests/session/garbage_collection_test.php +++ b/tests/session/garbage_collection_test.php @@ -12,7 +12,6 @@ */ require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_session_garbage_collection_test extends phpbb_session_test_case { diff --git a/tests/session/session_key_test.php b/tests/session/session_key_test.php index bf3dfcaa3c..2499ea1d55 100644 --- a/tests/session/session_key_test.php +++ b/tests/session/session_key_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php'; class phpbb_session_login_keys_test extends phpbb_session_test_case diff --git a/tests/template/template_parser_test.php b/tests/template/template_parser_test.php index d32fe78391..938b1bc8b8 100644 --- a/tests/template/template_parser_test.php +++ b/tests/template/template_parser_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/template_test_case.php'; class phpbb_template_template_parser_test extends phpbb_template_template_test_case diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 33dc4ca551..63e7cb869a 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/template_test_case.php'; class phpbb_template_template_test extends phpbb_template_template_test_case diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 3c97d30edc..cda0623dcb 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_template_template_test_case extends phpbb_test_case { protected $lang; diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php index 1c1930e88d..b3d7780d14 100644 --- a/tests/test_framework/phpbb_session_test_case.php +++ b/tests/test_framework/phpbb_session_test_case.php @@ -11,7 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../session/testable_factory.php'; require_once dirname(__FILE__) . '/../session/testable_facade.php'; diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 1f7df15434..a41e5da507 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -10,8 +10,6 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case { diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 8f8ec7ebc7..e74337decc 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -10,8 +10,7 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; + require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 3b72e713e1..4b9bbf9bb2 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -10,8 +10,6 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; class phpbb_textformatter_s9e_parser_test extends phpbb_test_case { diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index ad5bfa78fc..2b034259c9 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -10,8 +10,6 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case { diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index dade259790..719d3cda88 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -11,9 +11,6 @@ * */ -require_once __DIR__ . '/../../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; - class phpbb_textformatter_s9e_utils_test extends phpbb_test_case { /** diff --git a/tests/text_processing/censor_text_test.php b/tests/text_processing/censor_text_test.php index 983a5ba2d3..eda2bbb1b3 100644 --- a/tests/text_processing/censor_text_test.php +++ b/tests/text_processing/censor_text_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_text_processing_censor_text_test extends phpbb_test_case { public function censor_text_data() diff --git a/tests/text_processing/decode_message_test.php b/tests/text_processing/decode_message_test.php index fd1719fedc..e2402e721a 100644 --- a/tests/text_processing/decode_message_test.php +++ b/tests/text_processing/decode_message_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_text_processing_decode_message_test extends phpbb_test_case { public function setUp() diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index dba3713447..dfbd0977a0 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -11,9 +11,6 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; - class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_case { public function setUp() diff --git a/tests/text_processing/generate_text_for_edit_test.php b/tests/text_processing/generate_text_for_edit_test.php index 105e8da86b..8258a196f5 100644 --- a/tests/text_processing/generate_text_for_edit_test.php +++ b/tests/text_processing/generate_text_for_edit_test.php @@ -11,9 +11,6 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; - class phpbb_text_processing_generate_text_for_edit_test extends phpbb_test_case { /** diff --git a/tests/text_processing/generate_text_for_storage_test.php b/tests/text_processing/generate_text_for_storage_test.php index 474f6d8f0f..f0588fec4f 100644 --- a/tests/text_processing/generate_text_for_storage_test.php +++ b/tests/text_processing/generate_text_for_storage_test.php @@ -11,11 +11,6 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_compatibility.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_case { public function setUp() diff --git a/tests/text_processing/make_clickable_test.php b/tests/text_processing/make_clickable_test.php index 95e304dd97..3c8539c612 100644 --- a/tests/text_processing/make_clickable_test.php +++ b/tests/text_processing/make_clickable_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_text_processing_make_clickable_test extends phpbb_test_case { public function make_clickable_data() diff --git a/tests/text_processing/message_parser_test.php b/tests/text_processing/message_parser_test.php index bee1b3fca3..a3dbf644f6 100644 --- a/tests/text_processing/message_parser_test.php +++ b/tests/text_processing/message_parser_test.php @@ -12,10 +12,7 @@ */ require_once __DIR__ . '/../../phpBB/includes/bbcode.php'; -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; require_once __DIR__ . '/../../phpBB/includes/message_parser.php'; -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_text_processing_message_parser_test extends phpbb_test_case { diff --git a/tests/text_processing/smilies_test.php b/tests/text_processing/smilies_test.php index 3bbe065d36..ebdbe7dadc 100644 --- a/tests/text_processing/smilies_test.php +++ b/tests/text_processing/smilies_test.php @@ -11,9 +11,6 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; - class phpbb_text_processing_smilies_test extends phpbb_test_case { /** diff --git a/tests/text_processing/strip_bbcode_test.php b/tests/text_processing/strip_bbcode_test.php index 827d8d4a52..9acedc2872 100644 --- a/tests/text_processing/strip_bbcode_test.php +++ b/tests/text_processing/strip_bbcode_test.php @@ -11,9 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; - class phpbb_text_processing_strip_bbcode_test extends phpbb_test_case { public function test_legacy() diff --git a/tests/text_processing/tickets_test.php b/tests/text_processing/tickets_test.php index 8c48a3f4a9..6230191a69 100644 --- a/tests/text_processing/tickets_test.php +++ b/tests/text_processing/tickets_test.php @@ -11,10 +11,6 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_text_processing_tickets_test extends phpbb_test_case { /** diff --git a/tests/text_reparser/base_test.php b/tests/text_reparser/base_test.php index 2223ead9a6..af2d56ea51 100644 --- a/tests/text_reparser/base_test.php +++ b/tests/text_reparser/base_test.php @@ -10,8 +10,7 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; + require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; class phpbb_textreparser_base_test extends phpbb_database_test_case diff --git a/tests/text_reparser/plugins/contact_admin_info_test.php b/tests/text_reparser/plugins/contact_admin_info_test.php index 1dc03834b6..757b02be39 100644 --- a/tests/text_reparser/plugins/contact_admin_info_test.php +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -10,8 +10,7 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; + require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_case diff --git a/tests/text_reparser/plugins/poll_option_test.php b/tests/text_reparser/plugins/poll_option_test.php index dfa3a030ed..177faac51d 100644 --- a/tests/text_reparser/plugins/poll_option_test.php +++ b/tests/text_reparser/plugins/poll_option_test.php @@ -10,8 +10,7 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; + require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; class phpbb_textreparser_poll_option_test extends phpbb_database_test_case diff --git a/tests/text_reparser/plugins/test_row_based_plugin.php b/tests/text_reparser/plugins/test_row_based_plugin.php index e8218dfdd6..3e9ff09448 100644 --- a/tests/text_reparser/plugins/test_row_based_plugin.php +++ b/tests/text_reparser/plugins/test_row_based_plugin.php @@ -10,8 +10,7 @@ * the docs/CREDITS.txt file. * */ -require_once __DIR__ . '/../../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; + require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_test_case diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php index 647fcef2af..3daa75b2e4 100644 --- a/tests/tree/nestedset_forum_base.php +++ b/tests/tree/nestedset_forum_base.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 1351b46002..18b6deed1f 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -11,9 +11,6 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_filespec_test extends phpbb_test_case { const TEST_COUNT = 100; diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 05cb8dcf93..fb72823f08 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -11,8 +11,6 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; require_once __DIR__ . '/../mock/filespec.php'; class phpbb_fileupload_test extends phpbb_test_case diff --git a/tests/upload/imagesize_test.php b/tests/upload/imagesize_test.php index d20e866dab..5429bb5c5e 100644 --- a/tests/upload/imagesize_test.php +++ b/tests/upload/imagesize_test.php @@ -12,8 +12,6 @@ * */ -require_once(__DIR__ . '/../../phpBB/includes/functions.php'); - class phpbb_upload_imagesize_test extends \phpbb_test_case { /** @var \FastImageSize\FastImageSize */ diff --git a/tests/user/user_loader_test.php b/tests/user/user_loader_test.php index 8d1f43707b..f871f324ca 100644 --- a/tests/user/user_loader_test.php +++ b/tests/user/user_loader_test.php @@ -11,8 +11,6 @@ * */ -include_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php'); - class phpbb_user_loader_test extends phpbb_database_test_case { protected $db; diff --git a/tests/utf/utf8_clean_string_test.php b/tests/utf/utf8_clean_string_test.php index 2bb65387e0..4b3c8a5a25 100644 --- a/tests/utf/utf8_clean_string_test.php +++ b/tests/utf/utf8_clean_string_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_utf_utf8_clean_string_test extends phpbb_test_case { public function cleanable_strings() diff --git a/tests/utf/utf8_wordwrap_test.php b/tests/utf/utf8_wordwrap_test.php index ab053e2911..8906595d33 100644 --- a/tests/utf/utf8_wordwrap_test.php +++ b/tests/utf/utf8_wordwrap_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_utf_utf8_wordwrap_test extends phpbb_test_case { public function test_utf8_wordwrap_ascii() diff --git a/tests/wrapper/gmgetdate_test.php b/tests/wrapper/gmgetdate_test.php index 2e55a78d21..08ee491c0f 100644 --- a/tests/wrapper/gmgetdate_test.php +++ b/tests/wrapper/gmgetdate_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_wrapper_gmgetdate_test extends phpbb_test_case { public static function phpbb_gmgetdate_data() diff --git a/tests/wrapper/mt_rand_test.php b/tests/wrapper/mt_rand_test.php index d190182286..8d370dee2a 100644 --- a/tests/wrapper/mt_rand_test.php +++ b/tests/wrapper/mt_rand_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_wrapper_mt_rand_test extends phpbb_test_case { public function test_max_equals_min() diff --git a/tests/wrapper/phpbb_php_ini_test.php b/tests/wrapper/phpbb_php_ini_test.php index 9f46a78d5b..5827744702 100644 --- a/tests/wrapper/phpbb_php_ini_test.php +++ b/tests/wrapper/phpbb_php_ini_test.php @@ -12,7 +12,6 @@ */ require_once dirname(__FILE__) . '/phpbb_php_ini_fake.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case { diff --git a/tests/wrapper/version_compare_test.php b/tests/wrapper/version_compare_test.php index 93d9e0117d..8260d99504 100644 --- a/tests/wrapper/version_compare_test.php +++ b/tests/wrapper/version_compare_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - class phpbb_wrapper_version_compare_test extends phpbb_test_case { public function test_two_parameters() -- cgit v1.2.1 From 8a9429efa4b0a459a657a44b41a596969878ad65 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 26 Mar 2016 12:35:38 -0700 Subject: [ticket/14561] User delete command PHPBB3-14561 --- tests/console/user/delete_test.php | 169 +++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 tests/console/user/delete_test.php (limited to 'tests') diff --git a/tests/console/user/delete_test.php b/tests/console/user/delete_test.php new file mode 100644 index 0000000000..5162358713 --- /dev/null +++ b/tests/console/user/delete_test.php @@ -0,0 +1,169 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use phpbb\console\command\user\delete; + +class phpbb_console_command_user_delete_test extends phpbb_database_test_case +{ + protected $db; + protected $user; + protected $language; + protected $log; + protected $command_name; + protected $question; + protected $phpbb_root_path; + protected $php_ext; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + public function setUp() + { + global $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('cache.driver', new phpbb_mock_cache()); + $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + + $cache = $phpbb_container->get('cache.driver'); + + $config = new \phpbb\config\config(array()); + + $db = $this->db = $this->new_dbal(); + + $this->language = $this->getMockBuilder('\phpbb\language\language') + ->disableOriginalConstructor() + ->getMock(); + $this->language->expects($this->any()) + ->method('lang') + ->will($this->returnArgument(0)); + $user = $this->user = $this->getMock('\phpbb\user', array(), array( + $this->language, + '\phpbb\datetime' + )); + + $this->log = $this->getMockBuilder('\phpbb\log\log') + ->disableOriginalConstructor() + ->getMock(); + + $phpbb_container->set('auth.provider.db', new phpbb_mock_auth_provider()); + $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); + $provider_collection->add('auth.provider.db'); + $phpbb_container->set( + 'auth.provider_collection', + $provider_collection + ); + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $phpEx; + + parent::setUp(); + } + + public function test_delete() + { + $command_tester = $this->get_command_tester(); + + $this->assertEquals(3, $this->get_user_id('Test')); + + $this->question->setInputStream($this->getInputStream("yes\n")); + + $command_tester->execute(array( + 'command' => $this->command_name, + 'username' => 'Test', + '--delete-posts' => false, + )); + + $this->assertNull($this->get_user_id('Test')); + $this->assertContains('USER_DELETED', $command_tester->getDisplay()); + } + + public function test_delete_non_user() + { + $command_tester = $this->get_command_tester(); + + $this->assertNull($this->get_user_id('Foo')); + + $this->question->setInputStream($this->getInputStream("yes\n")); + + $command_tester->execute(array( + 'command' => $this->command_name, + 'username' => 'Foo', + '--delete-posts' => false, + )); + + $this->assertContains('NO_USER', $command_tester->getDisplay()); + } + + public function test_delete_cancel() + { + $command_tester = $this->get_command_tester(); + + $this->assertEquals(3, $this->get_user_id('Test')); + + $this->question->setInputStream($this->getInputStream("no\n")); + + $command_tester->execute(array( + 'command' => $this->command_name, + 'username' => 'Test', + '--delete-posts' => false, + )); + + $this->assertNotNull($this->get_user_id('Test')); + } + + public function get_command_tester() + { + $application = new Application(); + $application->add(new delete( + $this->user, + $this->db, + $this->language, + $this->log, + $this->phpbb_root_path, + $this->php_ext + )); + + $command = $application->find('user:delete'); + $this->command_name = $command->getName(); + $this->question = $command->getHelper('question'); + + return new CommandTester($command); + } + + public function get_user_id($username) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE ' . 'username = ' . "'" . $username . "'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row['user_id']; + } + + public function getInputStream($input) + { + $stream = fopen('php://memory', 'r+', false); + fputs($stream, $input); + rewind($stream); + + return $stream; + } +} -- cgit v1.2.1 From 91f1116e046818fb49a19ff59652f684c6f5f736 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 26 Mar 2016 12:37:27 -0700 Subject: [ticket/14561] User activate command PHPBB3-14561 --- tests/console/user/activate_test.php | 124 +++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 tests/console/user/activate_test.php (limited to 'tests') diff --git a/tests/console/user/activate_test.php b/tests/console/user/activate_test.php new file mode 100644 index 0000000000..90a4d74a26 --- /dev/null +++ b/tests/console/user/activate_test.php @@ -0,0 +1,124 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use phpbb\console\command\user\activate; + +class phpbb_console_command_user_activate_test extends phpbb_database_test_case +{ + protected $db; + protected $config; + protected $user; + protected $language; + protected $log; + protected $notifications; + protected $command_name; + protected $phpbb_root_path; + protected $php_ext; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + public function setUp() + { + global $config, $db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, $phpEx; + + $auth = $this->getMock('\phpbb\auth\auth'); + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + + $config = $this->config = new \phpbb\config\config(array()); + + $db = $this->db = $this->new_dbal(); + + $this->language = $this->getMockBuilder('\phpbb\language\language') + ->disableOriginalConstructor() + ->getMock(); + $this->language->expects($this->any()) + ->method('lang') + ->will($this->returnArgument(0)); + $user = $this->user = $this->getMock('\phpbb\user', array(), array( + $this->language, + '\phpbb\datetime' + )); + + $this->log = $this->getMockBuilder('\phpbb\log\log') + ->disableOriginalConstructor() + ->getMock(); + + $this->notifications = $this->getMockBuilder('\phpbb\notification\manager') + ->disableOriginalConstructor() + ->getMock(); + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $phpEx; + + parent::setUp(); + } + + public function activate_test_data() + { + return array( + // Test an inactive user + array('Test', false, 'USER_ADMIN_ACTIVATED'), + array('Test', true, 'CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE'), + + // Test an active user + array('Test 2', false, 'CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE'), + array('Test 2', true, 'USER_ADMIN_DEACTIVED'), + + // Test a non existent user + array('Foo', false, 'NO_USER'), + array('Foo', true, 'NO_USER'), + ); + } + + /** + * @dataProvider activate_test_data + */ + public function test_activate($username, $deactivate, $expected) + { + $command_tester = $this->get_command_tester(); + + $command_tester->execute(array( + 'command' => $this->command_name, + 'username' => $username, + '--deactivate' => $deactivate, + )); + + $this->assertContains($expected, $command_tester->getDisplay()); + } + + public function get_command_tester() + { + $application = new Application(); + $application->add(new activate( + $this->user, + $this->db, + $this->config, + $this->language, + $this->log, + $this->notifications, + $this->phpbb_root_path, + $this->php_ext + )); + + $command = $application->find('user:activate'); + $this->command_name = $command->getName(); + + return new CommandTester($command); + } +} -- cgit v1.2.1 From 16f9b4630cfc3c6247894ac82ac6b95577075753 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 26 Mar 2016 12:38:07 -0700 Subject: [ticket/14561] Reclean usernames command PHPBB3-14561 --- tests/console/user/reclean_test.php | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 tests/console/user/reclean_test.php (limited to 'tests') diff --git a/tests/console/user/reclean_test.php b/tests/console/user/reclean_test.php new file mode 100644 index 0000000000..ac464bdf82 --- /dev/null +++ b/tests/console/user/reclean_test.php @@ -0,0 +1,78 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use phpbb\console\command\user\reclean; + +class phpbb_console_command_user_reclean_test extends phpbb_database_test_case +{ + protected $db; + protected $user; + protected $language; + protected $command_name; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + public function setUp() + { + $this->db = $this->new_dbal(); + + $this->language = $this->getMockBuilder('\phpbb\language\language') + ->disableOriginalConstructor() + ->getMock(); + $this->language->expects($this->any()) + ->method('lang') + ->will($this->returnArgument(0)); + $this->user = $this->getMock('\phpbb\user', array(), array( + $this->language, + '\phpbb\datetime' + )); + + parent::setUp(); + } + + public function test_reclean() + { + $command_tester = $this->get_command_tester(); + + $command_tester->execute(array( + 'command' => $this->command_name, + )); + + $this->assertContains('CLI_USER_RECLEAN_SUCCESS', $command_tester->getDisplay()); + + $result = $this->db->sql_query('SELECT user_id FROM ' . USERS_TABLE . " WHERE username_clean = 'test unclean'"); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + $this->assertNotNull($row['user_id']); + } + + public function get_command_tester() + { + $application = new Application(); + $application->add(new reclean( + $this->user, + $this->db, + $this->language + )); + + $command = $application->find('user:reclean'); + $this->command_name = $command->getName(); + + return new CommandTester($command); + } +} -- cgit v1.2.1 From 6291bfaca94d104f1c85a0b139cab908e0793b3a Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 26 Mar 2016 12:59:23 -0700 Subject: [ticket/14561] Refactor tests PHPBB3-14561 --- tests/console/user/activate_test.php | 81 ++++++---------------- tests/console/user/add_test.php | 121 ++++---------------------------- tests/console/user/base.php | 122 +++++++++++++++++++++++++++++++++ tests/console/user/delete_test.php | 107 ++++------------------------- tests/console/user/fixtures/config.xml | 20 ++++++ tests/console/user/reclean_test.php | 52 ++++---------- 6 files changed, 206 insertions(+), 297 deletions(-) create mode 100644 tests/console/user/base.php (limited to 'tests') diff --git a/tests/console/user/activate_test.php b/tests/console/user/activate_test.php index 90a4d74a26..08b25c6c95 100644 --- a/tests/console/user/activate_test.php +++ b/tests/console/user/activate_test.php @@ -15,58 +15,39 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\user\activate; -class phpbb_console_command_user_activate_test extends phpbb_database_test_case +require_once dirname(__FILE__) . '/base.php'; + +class phpbb_console_user_activate_test extends phpbb_console_user_base { - protected $db; - protected $config; - protected $user; - protected $language; - protected $log; protected $notifications; - protected $command_name; - protected $phpbb_root_path; - protected $php_ext; - - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); - } public function setUp() { - global $config, $db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, $phpEx; - - $auth = $this->getMock('\phpbb\auth\auth'); - - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - - $config = $this->config = new \phpbb\config\config(array()); - - $db = $this->db = $this->new_dbal(); + parent::setUp(); - $this->language = $this->getMockBuilder('\phpbb\language\language') + $this->notifications = $this->getMockBuilder('\phpbb\notification\manager') ->disableOriginalConstructor() ->getMock(); - $this->language->expects($this->any()) - ->method('lang') - ->will($this->returnArgument(0)); - $user = $this->user = $this->getMock('\phpbb\user', array(), array( + } + + public function get_command_tester() + { + $application = new Application(); + $application->add(new activate( + $this->user, + $this->db, + $this->config, $this->language, - '\phpbb\datetime' + $this->log, + $this->notifications, + $this->phpbb_root_path, + $this->php_ext )); - $this->log = $this->getMockBuilder('\phpbb\log\log') - ->disableOriginalConstructor() - ->getMock(); - - $this->notifications = $this->getMockBuilder('\phpbb\notification\manager') - ->disableOriginalConstructor() - ->getMock(); - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; + $command = $application->find('user:activate'); + $this->command_name = $command->getName(); - parent::setUp(); + return new CommandTester($command); } public function activate_test_data() @@ -101,24 +82,4 @@ class phpbb_console_command_user_activate_test extends phpbb_database_test_case $this->assertContains($expected, $command_tester->getDisplay()); } - - public function get_command_tester() - { - $application = new Application(); - $application->add(new activate( - $this->user, - $this->db, - $this->config, - $this->language, - $this->log, - $this->notifications, - $this->phpbb_root_path, - $this->php_ext - )); - - $command = $application->find('user:activate'); - $this->command_name = $command->getName(); - - return new CommandTester($command); - } } diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index ee6eee8491..8641bf87b6 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -15,75 +15,27 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\user\add; -require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_user.php'; +require_once dirname(__FILE__) . '/base.php'; -class phpbb_console_command_user_add_test extends phpbb_database_test_case +class phpbb_console_user_add_test extends phpbb_console_user_base { - protected $db; - protected $config; - protected $user; - protected $language; - protected $passwords_manager; - protected $command_name; - protected $question; - protected $phpbb_root_path; - protected $php_ext; - - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); - } - - public function setUp() + public function get_command_tester() { - global $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; - - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $phpbb_container = new phpbb_mock_container_builder(); - $phpbb_container->set('cache.driver', new phpbb_mock_cache()); - $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - - $cache = $phpbb_container->get('cache.driver'); - - $config = $this->config = new \phpbb\config\config(array( - 'board_timezone' => 'UTC', - 'default_lang' => 'en', - 'email_enable' => false, - 'min_name_chars' => 3, - 'max_name_chars' => 10, - 'min_pass_chars' => 3, - 'max_pass_chars' => 10, - 'pass_complex' => 'PASS_TYPE_ANY', - )); - - $db = $this->db = $this->new_dbal(); - - $this->language = $this->getMockBuilder('\phpbb\language\language') - ->disableOriginalConstructor() - ->getMock(); - $this->language->expects($this->any()) - ->method('lang') - ->will($this->returnArgument(0)); - $user = $this->user = $this->getMock('\phpbb\user', array(), array( + $application = new Application(); + $application->add(new add( + $this->user, + $this->db, + $this->config, $this->language, - '\phpbb\datetime' + $this->passwords_manager, + $this->phpbb_root_path, + $this->php_ext )); - $driver_helper = new \phpbb\passwords\driver\helper($this->config); - $passwords_drivers = array( - 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($this->config, $driver_helper), - 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($this->config, $driver_helper), - 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($this->config, $driver_helper), - 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($this->config, $driver_helper), - ); - - $passwords_helper = new \phpbb\passwords\helper; - $this->passwords_manager = new \phpbb\passwords\manager($this->config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; - - parent::setUp(); + $command = $application->find('user:add'); + $this->command_name = $command->getName(); + $this->question = $command->getHelper('question'); + return new CommandTester($command); } public function test_add_no_dialog() @@ -137,47 +89,4 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case $this->assertContains('TOO_SHORT', $command_tester->getDisplay()); $this->assertContains('EMAIL_INVALID', $command_tester->getDisplay()); } - - public function get_command_tester() - { - $application = new Application(); - $application->add(new add( - $this->user, - $this->db, - $this->config, - $this->language, - $this->passwords_manager, - $this->phpbb_root_path, - $this->php_ext - )); - - $command = $application->find('user:add'); - $this->command_name = $command->getName(); - $this->question = $command->getHelper('question'); - return new CommandTester($command); - } - - public function get_user_id($username) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE ' . 'username = ' . "'" . $username . "'"; - - $result = $this->db->sql_query($sql); - - $row = $this->db->sql_fetchrow($result); - - $this->db->sql_freeresult($result); - - return $row['user_id']; - } - - public function getInputStream($input) - { - $stream = fopen('php://memory', 'r+', false); - fputs($stream, $input); - rewind($stream); - - return $stream; - } } diff --git a/tests/console/user/base.php b/tests/console/user/base.php new file mode 100644 index 0000000000..c6ffc428ed --- /dev/null +++ b/tests/console/user/base.php @@ -0,0 +1,122 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_user.php'; +require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../../phpBB/includes/utf/utf_tools.php'; + +abstract class phpbb_console_user_base extends phpbb_database_test_case +{ + protected $db; + protected $config; + protected $user; + protected $language; + protected $log; + protected $passwords_manager; + protected $command_name; + protected $question; + protected $phpbb_root_path; + protected $php_ext; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + public function setUp() + { + global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('cache.driver', new phpbb_mock_cache()); + $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + + $auth = $this->getMock('\phpbb\auth\auth'); + + $cache = $phpbb_container->get('cache.driver'); + + $config = $this->config = new \phpbb\config\config(array( + 'board_timezone' => 'UTC', + 'default_lang' => 'en', + 'email_enable' => false, + 'min_name_chars' => 3, + 'max_name_chars' => 10, + 'min_pass_chars' => 3, + 'max_pass_chars' => 10, + 'pass_complex' => 'PASS_TYPE_ANY', + )); + + $db = $this->db = $this->new_dbal(); + + $this->language = $this->getMockBuilder('\phpbb\language\language') + ->disableOriginalConstructor() + ->getMock(); + $this->language->expects($this->any()) + ->method('lang') + ->will($this->returnArgument(0)); + $user = $this->user = $this->getMock('\phpbb\user', array(), array( + $this->language, + '\phpbb\datetime' + )); + + $driver_helper = new \phpbb\passwords\driver\helper($this->config); + $passwords_drivers = array( + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($this->config, $driver_helper), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($this->config, $driver_helper), + 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($this->config, $driver_helper), + 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($this->config, $driver_helper), + ); + + $passwords_helper = new \phpbb\passwords\helper; + $this->passwords_manager = new \phpbb\passwords\manager($this->config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $phpEx; + + $this->log = $this->getMockBuilder('\phpbb\log\log') + ->disableOriginalConstructor() + ->getMock(); + + $phpbb_container->set('auth.provider.db', new phpbb_mock_auth_provider()); + $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); + $provider_collection->add('auth.provider.db'); + $phpbb_container->set( + 'auth.provider_collection', + $provider_collection + ); + + parent::setUp(); + } + + public function get_user_id($username) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE ' . 'username = ' . "'" . $username . "'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row['user_id']; + } + + public function getInputStream($input) + { + $stream = fopen('php://memory', 'r+', false); + fputs($stream, $input); + rewind($stream); + + return $stream; + } +} diff --git a/tests/console/user/delete_test.php b/tests/console/user/delete_test.php index 5162358713..dc4c07e8b8 100644 --- a/tests/console/user/delete_test.php +++ b/tests/console/user/delete_test.php @@ -15,64 +15,27 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\user\delete; -class phpbb_console_command_user_delete_test extends phpbb_database_test_case -{ - protected $db; - protected $user; - protected $language; - protected $log; - protected $command_name; - protected $question; - protected $phpbb_root_path; - protected $php_ext; - - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); - } +require_once dirname(__FILE__) . '/base.php'; - public function setUp() +class phpbb_console_user_delete_test extends phpbb_console_user_base +{ + public function get_command_tester() { - global $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; - - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $phpbb_container = new phpbb_mock_container_builder(); - $phpbb_container->set('cache.driver', new phpbb_mock_cache()); - $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - - $cache = $phpbb_container->get('cache.driver'); - - $config = new \phpbb\config\config(array()); - - $db = $this->db = $this->new_dbal(); - - $this->language = $this->getMockBuilder('\phpbb\language\language') - ->disableOriginalConstructor() - ->getMock(); - $this->language->expects($this->any()) - ->method('lang') - ->will($this->returnArgument(0)); - $user = $this->user = $this->getMock('\phpbb\user', array(), array( + $application = new Application(); + $application->add(new delete( + $this->user, + $this->db, $this->language, - '\phpbb\datetime' + $this->log, + $this->phpbb_root_path, + $this->php_ext )); - $this->log = $this->getMockBuilder('\phpbb\log\log') - ->disableOriginalConstructor() - ->getMock(); - - $phpbb_container->set('auth.provider.db', new phpbb_mock_auth_provider()); - $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); - $provider_collection->add('auth.provider.db'); - $phpbb_container->set( - 'auth.provider_collection', - $provider_collection - ); - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; + $command = $application->find('user:delete'); + $this->command_name = $command->getName(); + $this->question = $command->getHelper('question'); - parent::setUp(); + return new CommandTester($command); } public function test_delete() @@ -126,44 +89,4 @@ class phpbb_console_command_user_delete_test extends phpbb_database_test_case $this->assertNotNull($this->get_user_id('Test')); } - - public function get_command_tester() - { - $application = new Application(); - $application->add(new delete( - $this->user, - $this->db, - $this->language, - $this->log, - $this->phpbb_root_path, - $this->php_ext - )); - - $command = $application->find('user:delete'); - $this->command_name = $command->getName(); - $this->question = $command->getHelper('question'); - - return new CommandTester($command); - } - - public function get_user_id($username) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE ' . 'username = ' . "'" . $username . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - return $row['user_id']; - } - - public function getInputStream($input) - { - $stream = fopen('php://memory', 'r+', false); - fputs($stream, $input); - rewind($stream); - - return $stream; - } } diff --git a/tests/console/user/fixtures/config.xml b/tests/console/user/fixtures/config.xml index fed30dc20d..a988ba463f 100644 --- a/tests/console/user/fixtures/config.xml +++ b/tests/console/user/fixtures/config.xml @@ -6,12 +6,14 @@ username username_clean user_sig + user_type 1 Guest guest + 0 2 @@ -19,6 +21,7 @@ Admin admin + 3 3 @@ -26,6 +29,23 @@ Test test + 1 + + + 4 + + Test 2 + test 2 + + 0 + + + 5 + + Test Unclean + Test Unclean + + 0 diff --git a/tests/console/user/reclean_test.php b/tests/console/user/reclean_test.php index ac464bdf82..2b28484084 100644 --- a/tests/console/user/reclean_test.php +++ b/tests/console/user/reclean_test.php @@ -15,34 +15,23 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\user\reclean; -class phpbb_console_command_user_reclean_test extends phpbb_database_test_case -{ - protected $db; - protected $user; - protected $language; - protected $command_name; - - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); - } +require_once dirname(__FILE__) . '/base.php'; - public function setUp() +class phpbb_console_user_reclean_test extends phpbb_console_user_base +{ + public function get_command_tester() { - $this->db = $this->new_dbal(); - - $this->language = $this->getMockBuilder('\phpbb\language\language') - ->disableOriginalConstructor() - ->getMock(); - $this->language->expects($this->any()) - ->method('lang') - ->will($this->returnArgument(0)); - $this->user = $this->getMock('\phpbb\user', array(), array( - $this->language, - '\phpbb\datetime' + $application = new Application(); + $application->add(new reclean( + $this->user, + $this->db, + $this->language )); - parent::setUp(); + $command = $application->find('user:reclean'); + $this->command_name = $command->getName(); + + return new CommandTester($command); } public function test_reclean() @@ -60,19 +49,4 @@ class phpbb_console_command_user_reclean_test extends phpbb_database_test_case $this->db->sql_freeresult($result); $this->assertNotNull($row['user_id']); } - - public function get_command_tester() - { - $application = new Application(); - $application->add(new reclean( - $this->user, - $this->db, - $this->language - )); - - $command = $application->find('user:reclean'); - $this->command_name = $command->getName(); - - return new CommandTester($command); - } } -- cgit v1.2.1 From 4b789c041844396f3a5e6a51142c45c13d2edd59 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 27 Mar 2016 10:24:12 -0700 Subject: [ticket/14561] Use the user loader where appropriate PHPBB3-14561 --- tests/console/user/activate_test.php | 1 + tests/console/user/base.php | 3 +++ tests/console/user/delete_test.php | 1 + 3 files changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/console/user/activate_test.php b/tests/console/user/activate_test.php index 08b25c6c95..1588a76e47 100644 --- a/tests/console/user/activate_test.php +++ b/tests/console/user/activate_test.php @@ -40,6 +40,7 @@ class phpbb_console_user_activate_test extends phpbb_console_user_base $this->language, $this->log, $this->notifications, + $this->user_loader, $this->phpbb_root_path, $this->php_ext )); diff --git a/tests/console/user/base.php b/tests/console/user/base.php index c6ffc428ed..7ff11af1ae 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -25,6 +25,7 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case protected $passwords_manager; protected $command_name; protected $question; + protected $user_loader; protected $phpbb_root_path; protected $php_ext; @@ -70,6 +71,8 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case '\phpbb\datetime' )); + $this->user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE); + $driver_helper = new \phpbb\passwords\driver\helper($this->config); $passwords_drivers = array( 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($this->config, $driver_helper), diff --git a/tests/console/user/delete_test.php b/tests/console/user/delete_test.php index dc4c07e8b8..88f91afab1 100644 --- a/tests/console/user/delete_test.php +++ b/tests/console/user/delete_test.php @@ -27,6 +27,7 @@ class phpbb_console_user_delete_test extends phpbb_console_user_base $this->db, $this->language, $this->log, + $this->user_loader, $this->phpbb_root_path, $this->php_ext )); -- cgit v1.2.1 From afb69d7cd280df65b22b1a338d3023aebf2e3f0c Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 27 Mar 2016 11:25:19 -0700 Subject: [ticket/14561] Add a progress bar to reclean command PHPBB3-14561 --- tests/console/user/reclean_test.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/console/user/reclean_test.php b/tests/console/user/reclean_test.php index 2b28484084..1bf0b8ef5a 100644 --- a/tests/console/user/reclean_test.php +++ b/tests/console/user/reclean_test.php @@ -38,11 +38,8 @@ class phpbb_console_user_reclean_test extends phpbb_console_user_base { $command_tester = $this->get_command_tester(); - $command_tester->execute(array( - 'command' => $this->command_name, - )); - - $this->assertContains('CLI_USER_RECLEAN_SUCCESS', $command_tester->getDisplay()); + $exit_status = $command_tester->execute(array('command' => $this->command_name)); + $this->assertSame(0, $exit_status); $result = $this->db->sql_query('SELECT user_id FROM ' . USERS_TABLE . " WHERE username_clean = 'test unclean'"); $row = $this->db->sql_fetchrow($result); -- cgit v1.2.1 From 1641fd18c142ede0df8d7486a33bf0b7bd449f2c Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 31 Mar 2016 15:14:41 -0700 Subject: [ticket/14561] Remove requires for functions in tests PHPBB3-14561 --- tests/console/user/base.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/console/user/base.php b/tests/console/user/base.php index 7ff11af1ae..b84c0bb267 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -11,10 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_user.php'; -require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../../phpBB/includes/utf/utf_tools.php'; - abstract class phpbb_console_user_base extends phpbb_database_test_case { protected $db; -- cgit v1.2.1 From 91045879df2ee9918c7a03a58c64a74335ac67c1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 30 Mar 2016 17:44:38 +0200 Subject: [ticket/13502] Test getArguments() method of controller resolver PHPBB3-13502 --- tests/controller/controller_test.php | 57 ++++++++++++++++++++----- tests/controller/ext/vendor2/foo/controller.php | 12 +++++- 2 files changed, 57 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index abc1124a90..8bd7bf678c 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -11,6 +11,9 @@ * */ +include_once(__DIR__ . '/ext/vendor2/foo/controller.php'); +include_once(__DIR__.'/phpbb/controller/foo.php'); + use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -64,7 +67,7 @@ class phpbb_controller_controller_test extends phpbb_test_case $this->assertNull($routes->get('controller_noroute')); } - public function test_controller_resolver() + protected function get_foo_container() { $container = new ContainerBuilder(); // YamlFileLoader only uses one path at a time, so we need to loop @@ -75,26 +78,58 @@ class phpbb_controller_controller_test extends phpbb_test_case $loader->load('services.yml'); } - // Autoloading classes within the tests folder does not work - // so I'll include them manually. - if (!class_exists('vendor2\\foo\\controller')) - { - include(__DIR__ . '/ext/vendor2/foo/controller.php'); - } - if (!class_exists('phpbb\\controller\\foo')) - { - include(__DIR__.'/phpbb/controller/foo.php'); - } + return $container; + } + + public function test_controller_resolver() + { + $container = $this->get_foo_container(); $resolver = new \phpbb\controller\resolver($container, dirname(__FILE__) . '/'); $symfony_request = new Request(); $symfony_request->attributes->set('_controller', 'foo.controller:handle'); $this->assertEquals($resolver->getController($symfony_request), array(new foo\controller, 'handle')); + $this->assertEquals(array('foo'), $resolver->getArguments($symfony_request, $resolver->getController($symfony_request))); $symfony_request = new Request(); $symfony_request->attributes->set('_controller', 'core_foo.controller:bar'); $this->assertEquals($resolver->getController($symfony_request), array(new phpbb\controller\foo, 'bar')); + $this->assertEquals(array(), $resolver->getArguments($symfony_request, $resolver->getController($symfony_request))); + } + + public function data_get_arguments() + { + return array( + array(array(new foo\controller(), 'handle2'), array('foo', 0)), + array(array(new foo\controller(), 'handle_fail'), array('default'), array('no_default' => 'default')), + array(array(new foo\controller(), 'handle_fail'), array(), array(), '\phpbb\controller\exception', 'CONTROLLER_ARGUMENT_VALUE_MISSING'), + array('', array(), array(), '\ReflectionException', 'Function () does not exist'), + array(new foo\controller(), array(), array(), '\ReflectionException', 'Method __invoke does not exist'), + ); + } + + /** + * @dataProvider data_get_arguments + */ + public function test_get_arguments($input, $expected, $set_attributes = array(), $exception = '', $exception_message = '') + { + $container = $this->get_foo_container(); + + $resolver = new \phpbb\controller\resolver($container, dirname(__FILE__) . '/'); + $symfony_request = new Request(); + + foreach ($set_attributes as $name => $value) + { + $symfony_request->attributes->set($name, $value); + } + + if (!empty($exception)) + { + $this->setExpectedException($exception, $exception_message); + } + + $this->assertEquals($expected, $resolver->getArguments($symfony_request, $input)); } } diff --git a/tests/controller/ext/vendor2/foo/controller.php b/tests/controller/ext/vendor2/foo/controller.php index ce2233b3c9..b2c3df616c 100644 --- a/tests/controller/ext/vendor2/foo/controller.php +++ b/tests/controller/ext/vendor2/foo/controller.php @@ -11,8 +11,18 @@ class controller * * @return null */ - public function handle() + public function handle($optional = 'foo') { return new Response('Test', 200); } + + public function handle2($foo = 'foo', $very_optional = 0) + { + return new Response('Test2', 200); + } + + public function handle_fail($no_default) + { + return new Response('Test_fail', 200); + } } -- cgit v1.2.1 From 01d56673889cb12a11fca24b62f6e93e1c9f8dd8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 30 Mar 2016 17:49:10 +0200 Subject: [ticket/13502] Also cover passing object to resolver in tests PHPBB3-13502 --- tests/controller/controller_test.php | 3 ++- tests/controller/ext/vendor2/foo/controller.php | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 8bd7bf678c..d921d0eade 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -104,9 +104,10 @@ class phpbb_controller_controller_test extends phpbb_test_case return array( array(array(new foo\controller(), 'handle2'), array('foo', 0)), array(array(new foo\controller(), 'handle_fail'), array('default'), array('no_default' => 'default')), + array(new foo\controller(), array(), array()), array(array(new foo\controller(), 'handle_fail'), array(), array(), '\phpbb\controller\exception', 'CONTROLLER_ARGUMENT_VALUE_MISSING'), array('', array(), array(), '\ReflectionException', 'Function () does not exist'), - array(new foo\controller(), array(), array(), '\ReflectionException', 'Method __invoke does not exist'), + array(new phpbb\controller\foo, array(), array(), '\ReflectionException', 'Method __invoke does not exist'), ); } diff --git a/tests/controller/ext/vendor2/foo/controller.php b/tests/controller/ext/vendor2/foo/controller.php index b2c3df616c..cabcae042b 100644 --- a/tests/controller/ext/vendor2/foo/controller.php +++ b/tests/controller/ext/vendor2/foo/controller.php @@ -25,4 +25,9 @@ class controller { return new Response('Test_fail', 200); } + + public function __invoke() + { + $this->handle(); + } } -- cgit v1.2.1 From 753d6dfcae95c5099078ac3134a2a56f00472d71 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 3 Apr 2016 09:26:03 +0200 Subject: [ticket/14260] Added regression test PHPBB3-14260 --- tests/text_processing/tickets_data/PHPBB3-14260.html | 1 + tests/text_processing/tickets_data/PHPBB3-14260.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-14260.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-14260.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-14260.html b/tests/text_processing/tickets_data/PHPBB3-14260.html new file mode 100644 index 0000000000..c7e7cad237 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14260.html @@ -0,0 +1 @@ +http://example.org/article/S0883-9441(11)0483-7/pdf \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14260.txt b/tests/text_processing/tickets_data/PHPBB3-14260.txt new file mode 100644 index 0000000000..f95523c00e --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14260.txt @@ -0,0 +1 @@ +http://example.org/article/S0883-9441(11)0483-7/pdf \ No newline at end of file -- cgit v1.2.1 From 663e3bc64238668ec139b53ccfb2f82a1d306601 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 23 Mar 2016 21:59:40 +0100 Subject: [ticket/13616] Updates direct call to twig environment constructor PHPBB3-13616 --- tests/controller/common_helper_route.php | 3 +-- tests/extension/metadata_manager_test.php | 3 +-- tests/template/template_allfolder_test.php | 3 +-- tests/template/template_events_test.php | 3 +-- tests/template/template_includecss_test.php | 3 +-- tests/template/template_test_case.php | 3 +-- tests/template/template_test_case_with_tree.php | 3 +-- 7 files changed, 7 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index c23342bc57..21397d0f77 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -95,7 +95,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config, $this->filesystem, $this->phpbb_path_helper, - $container, $cache_path, null, $loader, @@ -107,7 +106,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 53bd3d109b..19b99ee0ce 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -65,7 +65,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->config, $filesystem, $phpbb_path_helper, - $container, $cache_path, null, $loader, @@ -112,7 +111,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->user = new \phpbb\user($lang, '\phpbb\datetime'); $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); } // Should fail from missing composer.json diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php index 9a0f1f512e..9a0a42fabd 100644 --- a/tests/template/template_allfolder_test.php +++ b/tests/template/template_allfolder_test.php @@ -64,7 +64,6 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case $config, $filesystem, $path_helper, - $container, $cache_path, $this->extension_manager, $loader, @@ -76,7 +75,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case ) ); $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template_path = $this->test_path . '/templates'; $this->ext_template_path = 'tests/extension/ext/vendor4/bar/styles/all/template'; diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index 54e08652a1..e245c90aee 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -158,7 +158,6 @@ Zeta test event in all', $config, $filesystem, $path_helper, - $container, $cache_path, $this->extension_manager, $loader, @@ -170,7 +169,7 @@ Zeta test event in all', ) ); $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path)); } diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index ac62e820ae..764652c9c2 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -50,7 +50,6 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te $config, $filesystem, $this->phpbb_path_helper, - $container, $cache_path, null, $loader, @@ -80,7 +79,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te ) ) ); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index cda0623dcb..e52d3b76dd 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -102,7 +102,6 @@ class phpbb_template_template_test_case extends phpbb_test_case $config, $filesystem, $path_helper, - $container, $cache_path, null, $loader, @@ -114,7 +113,7 @@ class phpbb_template_template_test_case extends phpbb_test_case ) ); $this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', $this->template_path); } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index bf5de6b85e..ff35d16120 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -45,7 +45,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $config, $filesystem, $this->phpbb_path_helper, - $container, $cache_path, null, $loader, @@ -57,7 +56,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat ) ); $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } } -- cgit v1.2.1 From bffd963c5033cfa49c016b7c4f163bf58d065e2b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 24 Mar 2016 10:57:23 +0100 Subject: [ticket/13616] Cleanup globals after installing the board in func tests PHPBB3-13616 --- tests/test_framework/phpbb_functional_test_case.php | 12 ++++++++++-- 1 file changed, 10 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 d234642898..829f64b780 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -384,9 +384,17 @@ class phpbb_functional_test_case extends phpbb_test_case @unlink($phpbb_root_path . 'cache/install_lock'); } - global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; + global $phpbb_container; $phpbb_container->reset(); - unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template); + + $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; + + foreach (array_keys($GLOBALS) as $key) { + if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true)) + { + unset($GLOBALS[$key]); + } + } } public function install_ext($extension) -- cgit v1.2.1 From 6d2acb5ba3fbd22b345b312e704021eab1375941 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 24 Mar 2016 13:01:52 +0100 Subject: [ticket/13616] Fix UI tests PHPBB3-13616 --- tests/test_framework/phpbb_ui_test_case.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index b5ac3a576b..e79c78db29 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -256,9 +256,17 @@ class phpbb_ui_test_case extends phpbb_test_case @unlink($phpbb_root_path . 'cache/install_lock'); } - global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; + global $phpbb_container; $phpbb_container->reset(); - unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template); + + $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; + + foreach (array_keys($GLOBALS) as $key) { + if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true)) + { + unset($GLOBALS[$key]); + } + } } static protected function get_db() -- cgit v1.2.1 From 5754cbfec445919dd8b7f261de33d75cbdc78fdd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 3 Apr 2016 16:14:50 +0200 Subject: [ticket/13616] Fix CS + constant in the core extension PHPBB3-13616 --- tests/test_framework/phpbb_functional_test_case.php | 3 ++- tests/test_framework/phpbb_ui_test_case.php | 3 ++- 2 files changed, 4 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 829f64b780..20b89aba4e 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -389,7 +389,8 @@ class phpbb_functional_test_case extends phpbb_test_case $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; - foreach (array_keys($GLOBALS) as $key) { + foreach (array_keys($GLOBALS) as $key) + { if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true)) { unset($GLOBALS[$key]); diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index e79c78db29..c8ca2a9003 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -261,7 +261,8 @@ class phpbb_ui_test_case extends phpbb_test_case $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; - foreach (array_keys($GLOBALS) as $key) { + foreach (array_keys($GLOBALS) as $key) + { if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true)) { unset($GLOBALS[$key]); -- cgit v1.2.1 From 6a48cad4a261fdf84d30c2002e14d2f0f049315b Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 19 Jun 2016 23:09:36 +0700 Subject: [ticket/14660] Add test case. PHPBB3-14660 --- tests/email/email_parsing_test.php | 138 +++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 tests/email/email_parsing_test.php (limited to 'tests') diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php new file mode 100644 index 0000000000..8def27c945 --- /dev/null +++ b/tests/email/email_parsing_test.php @@ -0,0 +1,138 @@ + + * @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_email_parsing_test extends phpbb_test_case +{ + static protected $reflection; + protected $messenger; + protected $reflection_template_property; + + public function setUp() + { + global $phpbb_container, $config, $phpbb_root_path, $phpEx, $request, $user; + + $phpbb_container = new phpbb_mock_container_builder; + + $config = new \phpbb\config\config(array()); + $default_config = array( + 'board_email_sig' => '-- Thanks, The Management', + 'sitename' => 'yourdomain.com', + 'default_lang' => 'en', + ); + foreach ($default_config as $config_name => $config_value) + { + if (!isset($config[$config_name])) + { + $config[$config_name] = $config_value; + } + } + $phpbb_container->set('config', $config, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + + $request = new phpbb_mock_request; + $symfony_request = new \phpbb\symfony_request( + $request + ); + $filesystem = new \phpbb\filesystem\filesystem(); + $phpbb_path_helper = new \phpbb\path_helper( + $symfony_request, + $filesystem, + $request, + $phpbb_root_path, + $phpEx + ); + $phpbb_container->set('path_helper', $phpbb_path_helper, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $phpbb_container->set('filesystem', $filesystem, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + + $cache_path = 'cache/' . PHPBB_ENVIRONMENT . '/twig'; + $phpbb_container->setParameter('core.template.cache_path', $cache_path, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $phpbb_container->set('user', $user, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $extension_manager = new phpbb_mock_extension_manager( + dirname(__FILE__) . '/', + array( + 'vendor2/foo' => array( + 'ext_name' => 'vendor2/foo', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor2/foo/', + ), + ) + ); + $phpbb_container->set('ext.manager', $extension_manager, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + + $context = new \phpbb\template\context(); + $phpbb_container->set('template.twig.extensions.collection', array(new \phpbb\template\twig\extension($context, $user)), phpbb_mock_container_builder::SCOPE_PROTOTYPE); + + $twig = new \phpbb\template\twig\environment( + $config, + $filesystem, + $phpbb_path_helper, + $cache_path, + null, + new \phpbb\template\twig\loader($filesystem, ''), + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig), phpbb_mock_container_builder::SCOPE_PROTOTYPE); + + if (!class_exists('messenger')) + { + include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + } + + $this->messenger = new \messenger(); + + $reflection = new ReflectionObject($this->messenger); + $this->reflection_template_property = $reflection->getProperty('template'); + $this->reflection_template_property->setAccessible(true); + } + + public function test_email_parsing() + { + global $phpbb_container, $config, $phpbb_root_path, $phpEx, $user, $request; + + $this->messenger->set_addresses($user->data); + + $this->messenger->assign_vars(array( + 'EMAIL_SIG' => str_replace('
            ', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), + 'SITENAME' => htmlspecialchars_decode($config['sitename']), + + 'AUTHOR_NAME' => 'Author username', + 'FORUM_NAME' => 'Any forum', + 'TOPIC_TITLE' => 'The topic title', + 'USERNAME' => 'Dear user', + + 'U_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?f=1", + 'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?uid=2&f=1&unwatch=forum", + )); + $this->messenger->template('newtopic_notify', $user->data['user_lang'], '', ''); + + $reflection_template = $this->reflection_template_property->getValue($this->messenger); + $msg = trim($reflection_template->assign_display('body')); + + $this->assertContains('Author username', $msg); + $this->assertContains('Any forum', $msg); + $this->assertContains('The topic title', $msg); + $this->assertContains('Dear user', $msg); + $this->assertContains(htmlspecialchars_decode($config['sitename']), $msg); + $this->assertContains(str_replace('
            ', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), $msg); + $this->assertNotContains('EMAIL_SIG', $msg); + $this->assertNotContains('U_STOP_WATCHING_FORUM', $msg); + } +} -- cgit v1.2.1 From 471a773bcf73d95c8c875070de459397292113bd Mon Sep 17 00:00:00 2001 From: lavigor Date: Sun, 26 Jun 2016 14:29:45 +0300 Subject: [ticket/14696] Fix email template test for '0' username PHPBB3-14696 --- tests/email/email_parsing_test.php | 39 +++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php index 8def27c945..4f962c9c29 100644 --- a/tests/email/email_parsing_test.php +++ b/tests/email/email_parsing_test.php @@ -19,7 +19,7 @@ class phpbb_email_parsing_test extends phpbb_test_case public function setUp() { - global $phpbb_container, $config, $phpbb_root_path, $phpEx, $request, $user; + global $phpbb_container, $config, $phpbb_root_path, $phpEx, $request, $user; $phpbb_container = new phpbb_mock_container_builder; @@ -73,7 +73,8 @@ class phpbb_email_parsing_test extends phpbb_test_case $phpbb_container->set('ext.manager', $extension_manager, phpbb_mock_container_builder::SCOPE_PROTOTYPE); $context = new \phpbb\template\context(); - $phpbb_container->set('template.twig.extensions.collection', array(new \phpbb\template\twig\extension($context, $user)), phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $twig_extension = new \phpbb\template\twig\extension($context, $user); + $phpbb_container->set('template.twig.extensions.collection', array($twig_extension), phpbb_mock_container_builder::SCOPE_PROTOTYPE); $twig = new \phpbb\template\twig\environment( $config, @@ -89,13 +90,14 @@ class phpbb_email_parsing_test extends phpbb_test_case 'autoescape' => false, ) ); + $twig->addExtension($twig_extension); $phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig), phpbb_mock_container_builder::SCOPE_PROTOTYPE); if (!class_exists('messenger')) { include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); } - + $this->messenger = new \messenger(); $reflection = new ReflectionObject($this->messenger); @@ -103,9 +105,20 @@ class phpbb_email_parsing_test extends phpbb_test_case $this->reflection_template_property->setAccessible(true); } - public function test_email_parsing() + public function email_parsing_data() + { + return array( + array('Author username', 'Any forum', 'The topic title', 'Dear user'), + array('0', 'Any forum', 'The topic title', 'Dear user'), + ); + } + + /** + * @dataProvider email_parsing_data + */ + public function test_email_parsing($author_name, $forum_name, $topic_title, $username) { - global $phpbb_container, $config, $phpbb_root_path, $phpEx, $user, $request; + global $config, $phpEx, $user; $this->messenger->set_addresses($user->data); @@ -113,10 +126,10 @@ class phpbb_email_parsing_test extends phpbb_test_case 'EMAIL_SIG' => str_replace('
            ', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), 'SITENAME' => htmlspecialchars_decode($config['sitename']), - 'AUTHOR_NAME' => 'Author username', - 'FORUM_NAME' => 'Any forum', - 'TOPIC_TITLE' => 'The topic title', - 'USERNAME' => 'Dear user', + 'AUTHOR_NAME' => $author_name, + 'FORUM_NAME' => $forum_name, + 'TOPIC_TITLE' => $topic_title, + 'USERNAME' => $username, 'U_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?f=1", 'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?uid=2&f=1&unwatch=forum", @@ -126,10 +139,10 @@ class phpbb_email_parsing_test extends phpbb_test_case $reflection_template = $this->reflection_template_property->getValue($this->messenger); $msg = trim($reflection_template->assign_display('body')); - $this->assertContains('Author username', $msg); - $this->assertContains('Any forum', $msg); - $this->assertContains('The topic title', $msg); - $this->assertContains('Dear user', $msg); + $this->assertContains($author_name, $msg); + $this->assertContains($forum_name, $msg); + $this->assertContains($topic_title, $msg); + $this->assertContains($username, $msg); $this->assertContains(htmlspecialchars_decode($config['sitename']), $msg); $this->assertContains(str_replace('
            ', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), $msg); $this->assertNotContains('EMAIL_SIG', $msg); -- cgit v1.2.1 From 27f16a195ec1c83860cbf0b8c9fa1e6f9f3d3f5e Mon Sep 17 00:00:00 2001 From: lavigor Date: Sun, 26 Jun 2016 16:05:08 +0300 Subject: [ticket/14696] Be perfect PHPBB3-14696 --- tests/email/email_parsing_test.php | 40 ++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php index 4f962c9c29..351a38514f 100644 --- a/tests/email/email_parsing_test.php +++ b/tests/email/email_parsing_test.php @@ -13,8 +13,10 @@ class phpbb_email_parsing_test extends phpbb_test_case { - static protected $reflection; + /** @var \messenger */ protected $messenger; + + /** @var \ReflectionProperty */ protected $reflection_template_property; public function setUp() @@ -23,20 +25,12 @@ class phpbb_email_parsing_test extends phpbb_test_case $phpbb_container = new phpbb_mock_container_builder; - $config = new \phpbb\config\config(array()); - $default_config = array( + $config = new \phpbb\config\config(array( 'board_email_sig' => '-- Thanks, The Management', 'sitename' => 'yourdomain.com', 'default_lang' => 'en', - ); - foreach ($default_config as $config_name => $config_value) - { - if (!isset($config[$config_name])) - { - $config[$config_name] = $config_value; - } - } - $phpbb_container->set('config', $config, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + )); + $phpbb_container->set('config', $config); $request = new phpbb_mock_request; $symfony_request = new \phpbb\symfony_request( @@ -50,16 +44,16 @@ class phpbb_email_parsing_test extends phpbb_test_case $phpbb_root_path, $phpEx ); - $phpbb_container->set('path_helper', $phpbb_path_helper, phpbb_mock_container_builder::SCOPE_PROTOTYPE); - $phpbb_container->set('filesystem', $filesystem, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $phpbb_container->set('path_helper', $phpbb_path_helper); + $phpbb_container->set('filesystem', $filesystem); - $cache_path = 'cache/' . PHPBB_ENVIRONMENT . '/twig'; - $phpbb_container->setParameter('core.template.cache_path', $cache_path, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $cache_path = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/twig'; + $phpbb_container->setParameter('core.template.cache_path', $cache_path); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $phpbb_container->set('user', $user, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $phpbb_container->set('user', $user); $extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', array( @@ -70,11 +64,15 @@ class phpbb_email_parsing_test extends phpbb_test_case ), ) ); - $phpbb_container->set('ext.manager', $extension_manager, phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $phpbb_container->set('ext.manager', $extension_manager); $context = new \phpbb\template\context(); - $twig_extension = new \phpbb\template\twig\extension($context, $user); - $phpbb_container->set('template.twig.extensions.collection', array($twig_extension), phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $twig_extension = new \phpbb\template\twig\extension($context, $lang); + $phpbb_container->set('template.twig.extensions.phpbb', $twig_extension); + + $twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container); + $twig_extensions_collection->add('template.twig.extensions.phpbb'); + $phpbb_container->set('template.twig.extensions.collection', $twig_extensions_collection); $twig = new \phpbb\template\twig\environment( $config, @@ -91,7 +89,7 @@ class phpbb_email_parsing_test extends phpbb_test_case ) ); $twig->addExtension($twig_extension); - $phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig), phpbb_mock_container_builder::SCOPE_PROTOTYPE); + $phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); if (!class_exists('messenger')) { -- cgit v1.2.1 From 24da2db987c895c474b1d0a59344a7094133f278 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 8 Jul 2016 07:46:53 +0200 Subject: [ticket/14706] Updated [list] BBCode to automatically create a list item Fixes issues with missing list items. Produces valid HTML. PHPBB3-14706 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- tests/text_processing/tickets_data/PHPBB3-14706.html | 1 + tests/text_processing/tickets_data/PHPBB3-14706.txt | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 tests/text_processing/tickets_data/PHPBB3-14706.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-14706.txt (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index a41e5da507..5bd1123bba 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -86,7 +86,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( '[list]no item[/list]', - '
              no item
            ' + '
            • no item
            ' ), array( '[*]unparsed', diff --git a/tests/text_processing/tickets_data/PHPBB3-14706.html b/tests/text_processing/tickets_data/PHPBB3-14706.html new file mode 100644 index 0000000000..b8f74c9e93 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14706.html @@ -0,0 +1 @@ +
              1. a
              2. b
              3. c
              4. d
              5. e
            • outer
            \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14706.txt b/tests/text_processing/tickets_data/PHPBB3-14706.txt new file mode 100644 index 0000000000..8ec2e9cd35 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14706.txt @@ -0,0 +1 @@ +[list][list=a][*]a[*]b[*]c[*]d[*]e[/list][*]outer[/list] \ No newline at end of file -- cgit v1.2.1 From e9e6847803f6c99aeb4a7dffbacd12dc57c9d9e9 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 18 Jul 2016 19:06:29 +0200 Subject: [ticket/14663] Added regression test for Unicode in custom BBCodes PHPBB3-14663 --- .../text_processing/tickets_data/PHPBB3-14663.html | 1 + .../text_processing/tickets_data/PHPBB3-14663.txt | 1 + .../text_processing/tickets_data/PHPBB3-14663.xml | 28 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-14663.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-14663.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-14663.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-14663.html b/tests/text_processing/tickets_data/PHPBB3-14663.html new file mode 100644 index 0000000000..b18bcfd52b --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14663.html @@ -0,0 +1 @@ + Тест \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14663.txt b/tests/text_processing/tickets_data/PHPBB3-14663.txt new file mode 100644 index 0000000000..5443ae3046 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14663.txt @@ -0,0 +1 @@ +[test]Тест[/test] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14663.xml b/tests/text_processing/tickets_data/PHPBB3-14663.xml new file mode 100644 index 0000000000..423d01e242 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14663.xml @@ -0,0 +1,28 @@ + + +
            + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + test + + 1 + [test]{TEXT}[/test] + {TEXT}]]> + + + + ${1}]]> + +
            + -- cgit v1.2.1 From 13a756bfb7f73bdbd89e178617345afa18210b69 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 21 Jul 2016 03:37:44 +0200 Subject: [ticket/14700] Prevent an exception on duplicate smilies in text_formatter PHPBB3-14700 --- tests/text_formatter/s9e/factory_test.php | 11 ++++++++ .../s9e/fixtures/smilies_duplicate.xml | 33 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/text_formatter/s9e/fixtures/smilies_duplicate.xml (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index e74337decc..368b8a4f4b 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -170,6 +170,17 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case ); } + public function test_duplicate_smilies() + { + $fixture = __DIR__ . '/fixtures/smilies_duplicate.xml'; + $parser = $this->get_test_case_helpers()->set_s9e_services(null, $fixture)->get('text_formatter.parser'); + + $this->assertSame( + ':)', + $parser->parse(':)') + ); + } + /** * @testdox {INTTEXT} is supported in custom BBCodes */ diff --git a/tests/text_formatter/s9e/fixtures/smilies_duplicate.xml b/tests/text_formatter/s9e/fixtures/smilies_duplicate.xml new file mode 100644 index 0000000000..9645f3e516 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/smilies_duplicate.xml @@ -0,0 +1,33 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 1 + :) + :) + foo.png + 15 + 17 + 2 + 1 + + + 2 + :) + :) + bar.png + 15 + 17 + 2 + 2 + +
            +
            -- cgit v1.2.1 From 89461d982c3356f5389caaae7bec1fa76fbe6beb Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 23 Jul 2016 16:23:42 +0200 Subject: [ticket/14717] Quote strings beginning with @ or % in yaml definitions This type of use was deprecated in symfony 2.8 and will be dropped in 3.x. Also see: https://github.com/symfony/symfony/pull/16285 PHPBB3-14717 --- .../fixtures/config/production/container/environment.yml | 2 +- tests/di/fixtures/config/test/container/environment.yml | 2 +- .../other_config/production/container/environment.yml | 2 +- .../fixtures/other_config/test/container/environment.yml | 2 +- tests/functional/fixtures/ext/foo/bar/config/services.yml | 14 +++++++------- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/di/fixtures/config/production/container/environment.yml b/tests/di/fixtures/config/production/container/environment.yml index 9dcf11d865..4216b187cc 100644 --- a/tests/di/fixtures/config/production/container/environment.yml +++ b/tests/di/fixtures/config/production/container/environment.yml @@ -8,7 +8,7 @@ services: dbal.conn: class: phpbb\db\driver\factory arguments: - - @service_container + - '@service_container' dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/config/test/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml index 14c986d123..7d528fed19 100644 --- a/tests/di/fixtures/config/test/container/environment.yml +++ b/tests/di/fixtures/config/test/container/environment.yml @@ -8,7 +8,7 @@ services: dbal.conn: class: phpbb\db\driver\factory arguments: - - @service_container + - '@service_container' dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/production/container/environment.yml b/tests/di/fixtures/other_config/production/container/environment.yml index 4960562a6c..1170145b66 100644 --- a/tests/di/fixtures/other_config/production/container/environment.yml +++ b/tests/di/fixtures/other_config/production/container/environment.yml @@ -8,7 +8,7 @@ services: dbal.conn: class: phpbb\db\driver\factory arguments: - - @service_container + - '@service_container' dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/test/container/environment.yml b/tests/di/fixtures/other_config/test/container/environment.yml index e285b1b781..6c36977d4d 100644 --- a/tests/di/fixtures/other_config/test/container/environment.yml +++ b/tests/di/fixtures/other_config/test/container/environment.yml @@ -8,7 +8,7 @@ services: dbal.conn: class: phpbb\db\driver\factory arguments: - - @service_container + - '@service_container' dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/functional/fixtures/ext/foo/bar/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml index d35be7955a..495c775a1f 100644 --- a/tests/functional/fixtures/ext/foo/bar/config/services.yml +++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml @@ -2,13 +2,13 @@ services: foo_bar.controller: class: foo\bar\controller\controller arguments: - - @controller.helper - - @path_helper - - @template - - @config - - @user - - %core.root_path% - - %core.php_ext% + - '@controller.helper' + - '@path_helper' + - '@template' + - '@config' + - '@user' + - '%core.root_path%' + - '%core.php_ext%' foo_bar.listener.permission: class: foo\bar\event\permission -- cgit v1.2.1 From c64b8102b7c5dc5bd0be9d8085d01a66e90dde73 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Tue, 29 Mar 2016 21:21:35 +0200 Subject: [ticket/10809] Remove MSSQL support PHPBB3-10809 --- tests/functions/convert_30_dbms_to_31_test.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests') diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php index 1405d81eb3..e46a569565 100644 --- a/tests/functions/convert_30_dbms_to_31_test.php +++ b/tests/functions/convert_30_dbms_to_31_test.php @@ -16,7 +16,6 @@ class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case public function convert_30_dbms_to_31_data() { return array( - array('mssql'), array('mssql_odbc'), array('mssqlnative'), array('mysql'), -- cgit v1.2.1 From 9225a0fdffdd5830e2f87ec964a90d26576b812b Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 5 Aug 2016 16:27:13 +0200 Subject: [ticket/14734] Use SVG emoji PHPBB3-14734 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 5bd1123bba..a70528aba3 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -298,7 +298,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "Emoji: \xF0\x9F\x98\x80", - 'Emoji: ' . ' + 'Emoji: ' . ' ), array( "Emoji: \xF0\x9F\x98\x80", -- cgit v1.2.1 From 260a0a29add1d318c27e998cfa3602333c74adcb Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 10 Aug 2016 03:19:38 +0200 Subject: [ticket/14740] Added support for quoted attributes in BBCode definitions PHPBB3-14740 --- .../text_processing/tickets_data/PHPBB3-14740.html | 2 ++ .../text_processing/tickets_data/PHPBB3-14740.txt | 2 ++ .../text_processing/tickets_data/PHPBB3-14740.xml | 40 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-14740.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-14740.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-14740.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-14740.html b/tests/text_processing/tickets_data/PHPBB3-14740.html new file mode 100644 index 0000000000..a1986a0901 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14740.html @@ -0,0 +1,2 @@ +
            !
            Moderatoropmerking from: neufke
            Mod Remark
            +
            !
            Moderatoropmerking from: neufke
            Mod Remark
            \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14740.txt b/tests/text_processing/tickets_data/PHPBB3-14740.txt new file mode 100644 index 0000000000..c5b2e74513 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14740.txt @@ -0,0 +1,2 @@ +[mod=neufke]Mod Remark[/mod] +[mod="neufke"]Mod Remark[/mod] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14740.xml b/tests/text_processing/tickets_data/PHPBB3-14740.xml new file mode 100644 index 0000000000..9e7dc9760c --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14740.xml @@ -0,0 +1,40 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + mod= + + 1 + [mod="{TEXT1}"]{TEXT2}[/mod] + +
            !
            +
            +
            Moderatoropmerking {L_FROM}{L_COLON} {TEXT1}
            +
            {TEXT2}
            +
            +]]>
            + !\[mod\="(.*?)"\](.*?)\[/mod\]!ies + '[mod="'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', ''', '(', ')'), trim('${1}')).'":$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', ''', '(', ')'), trim('${2}')).'[/mod:$uid]' + !\[mod\="(.*?)":$uid\](.*?)\[/mod:$uid\]!s + +
            !
            +
            +
            Moderatoropmerking {L_FROM}{L_COLON} ${1}
            +
            ${2}
            +
            +]]>
            +
            +
            +
            -- cgit v1.2.1 From d2750b650fb3600ef2cf7b7139998e1a71c7d5ef Mon Sep 17 00:00:00 2001 From: Dan Villiom Podlaski Christiansen Date: Wed, 7 Sep 2016 03:58:33 +0200 Subject: [ticket/14774] Support partial downloads of attachments phpBB already had limited support for partial downloads, but only for resuming downloads, disregarding any range ending before EOF. WebKit on iOS and OS X uses partial downloads when fetching media files. Previously, only MP3 attachments could play directly in the browser, reported as a live stream, but with this change, all supported media formats should render as expected. Tested using cURL by verifying that partial downloads give exactly the same results compared to Apache. PHPBB3-14774 --- tests/download/http_byte_range_test.php | 62 +++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/download/http_byte_range_test.php b/tests/download/http_byte_range_test.php index f920299048..8975ec1799 100644 --- a/tests/download/http_byte_range_test.php +++ b/tests/download/http_byte_range_test.php @@ -45,24 +45,72 @@ class phpbb_download_http_byte_range_test extends phpbb_test_case public function parse_range_request_data() { return array( - // Does not read until the end of file. + // Valid request array( array('3-4'), 10, - false, + array( + 'byte_pos_start' => 3, + 'byte_pos_end' => 4, + 'bytes_requested' => 2, + 'bytes_total' => 10, + ), ), - // Valid request, handle second range. + // Get the beginning array( - array('0-0', '120-125'), - 125, + array('-5'), + 10, array( - 'byte_pos_start' => 120, - 'byte_pos_end' => 124, + 'byte_pos_start' => 0, + 'byte_pos_end' => 5, + 'bytes_requested' => 6, + 'bytes_total' => 10, + ), + ), + + // Get the end + array( + array('5-'), + 10, + array( + 'byte_pos_start' => 5, + 'byte_pos_end' => 9, 'bytes_requested' => 5, + 'bytes_total' => 10, + ), + ), + + // Overlong request + array( + array('3-20'), + 10, + array( + 'byte_pos_start' => 3, + 'byte_pos_end' => 9, + 'bytes_requested' => 7, + 'bytes_total' => 10, + ), + ), + + // Multiple, contiguous range + array( + array('10-20', '21-30'), + 125, + array( + 'byte_pos_start' => 10, + 'byte_pos_end' => 30, + 'bytes_requested' => 21, 'bytes_total' => 125, ) ), + + // We don't do multiple, non-contiguous range + array( + array('0-0', '120-125'), + 125, + false, + ), ); } } -- cgit v1.2.1 From 53ead1e926de81c9437767c067d01f6e6ebe68b0 Mon Sep 17 00:00:00 2001 From: Crizzo Date: Thu, 15 Sep 2016 21:58:21 +0200 Subject: [ticket/14780] Fixes array with exspected results in test-function PHPBB3-14780 --- tests/functions_privmsgs/get_max_setting_from_group_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/functions_privmsgs/get_max_setting_from_group_test.php b/tests/functions_privmsgs/get_max_setting_from_group_test.php index 3eb7866802..fbabf1222a 100644 --- a/tests/functions_privmsgs/get_max_setting_from_group_test.php +++ b/tests/functions_privmsgs/get_max_setting_from_group_test.php @@ -33,12 +33,12 @@ class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_dat static public function get_max_setting_from_group_data() { return array( - array(1, 0, 'message_limit'), + array(1, 2, 'message_limit'), array(2, 2, 'message_limit'), array(3, 0, 'message_limit'), array(4, 0, 'message_limit'), array(5, 2, 'message_limit'), - array(1, 0, 'max_recipients'), + array(1, 4, 'max_recipients'), array(2, 4, 'max_recipients'), array(3, 0, 'max_recipients'), array(4, 5, 'max_recipients'), -- cgit v1.2.1 From 6242698a84dfc00bc5a09705eeed2db1a539996c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 18 Sep 2016 21:52:11 +0200 Subject: [ticket/14484] Remove invalid code caused by merge conflict PHPBB3-14484 --- tests/test_framework/phpbb_ui_test_case.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index bc761aff69..1d6dda0ba6 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -340,10 +340,6 @@ class phpbb_ui_test_case extends phpbb_test_case $this->assertContains($this->lang('ADMIN_PANEL'), $this->find_element('cssSelector', 'h1')->getText()); $cookies = self::$webDriver->manage()->getCookies(); - - copy($config_file, $config_file_test); - - self::$install_success = true; } public function install_ext($extension) -- cgit v1.2.1 From 2b22adbcacf469998b2490073c29a6188125f94d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Sep 2016 21:09:55 +0200 Subject: [ticket/14484] Remove duplicate methods and no longer needed calls PHPBB3-14484 --- tests/test_framework/phpbb_ui_test_case.php | 101 +++++++++++++++------------- 1 file changed, 56 insertions(+), 45 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 1d6dda0ba6..e3f636679c 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -174,8 +174,6 @@ class phpbb_ui_test_case extends phpbb_test_case self::recreate_database(self::$config); - $db = self::get_db(); - $config_file = $phpbb_root_path . "config.$phpEx"; $config_file_dev = $phpbb_root_path . "config_dev.$phpEx"; $config_file_test = $phpbb_root_path . "config_test.$phpEx"; @@ -299,49 +297,6 @@ class phpbb_ui_test_case extends phpbb_test_case } } - protected function logout() - { - $this->add_lang('ucp'); - - if (empty($this->sid)) - { - return; - } - - $this->visit('ucp.php?sid=' . $this->sid . '&mode=logout'); - $this->assertContains($this->lang('REGISTER'), self::$webDriver->getPageSource()); - unset($this->sid); - - } - - /** - * Login to the ACP - * You must run login() before calling this. - */ - protected function admin_login($username = 'admin') - { - $this->add_lang('acp/common'); - - // Requires login first! - if (empty($this->sid)) - { - $this->fail('$this->sid is empty. Make sure you call login() before admin_login()'); - return; - } - - self::$webDriver->manage()->deleteAllCookies(); - - $this->visit('adm/index.php?sid=' . $this->sid); - $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), self::$webDriver->getPageSource()); - - self::find_element('cssSelector', 'input[name=username]')->clear()->sendKeys($username); - self::find_element('cssSelector', 'input[type=password]')->sendKeys($username . $username); - self::find_element('cssSelector', 'input[name=login]')->click(); - $this->assertContains($this->lang('ADMIN_PANEL'), $this->find_element('cssSelector', 'h1')->getText()); - - $cookies = self::$webDriver->manage()->getCookies(); - } - public function install_ext($extension) { $this->login(); @@ -450,6 +405,62 @@ class phpbb_ui_test_case extends phpbb_test_case return $this->db; } + protected function logout() + { + $this->add_lang('ucp'); + + if (empty($this->sid)) + { + return; + } + + $this->visit('ucp.php?sid=' . $this->sid . '&mode=logout'); + $this->assertContains($this->lang('REGISTER'), self::$webDriver->getPageSource()); + unset($this->sid); + + } + + /** + * Login to the ACP + * You must run login() before calling this. + */ + protected function admin_login($username = 'admin') + { + $this->add_lang('acp/common'); + + // Requires login first! + if (empty($this->sid)) + { + $this->fail('$this->sid is empty. Make sure you call login() before admin_login()'); + return; + } + + self::$webDriver->manage()->deleteAllCookies(); + + $this->visit('adm/index.php?sid=' . $this->sid); + $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), self::$webDriver->getPageSource()); + + self::find_element('cssSelector', 'input[name=username]')->clear()->sendKeys($username); + self::find_element('cssSelector', 'input[type=password]')->sendKeys($username . $username); + self::find_element('cssSelector', 'input[name=login]')->click(); + $this->assertContains($this->lang('ADMIN_PANEL'), $this->find_element('cssSelector', 'h1')->getText()); + + $cookies = self::$webDriver->manage()->getCookies(); + + // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie + foreach ($cookies as $cookie) + { + if (substr($cookie['name'], -4) == '_sid') + { + $this->sid = $cookie['value']; + + break; + } + } + + $this->assertNotEmpty($this->sid); + } + protected function add_lang($lang_file) { if (is_array($lang_file)) -- cgit v1.2.1 From 65ef56ed715c3a5f1a8ae30d5aa1a75538cb4f69 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Sep 2016 21:36:03 +0200 Subject: [ticket/14791] Get form tokens from correct button in search test base PHPBB3-14791 --- tests/functional/search/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/search/base.php b/tests/functional/search/base.php index f77ef70ecc..fc6f4c0a0b 100644 --- a/tests/functional/search/base.php +++ b/tests/functional/search/base.php @@ -79,7 +79,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case { $this->add_lang('acp/search'); $crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid); - $form_values = $crawler->selectButton('Delete index')->form()->getValues(); + $form_values = $crawler->selectButton('Create index')->form()->getValues(); $crawler = self::request( 'POST', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid, -- cgit v1.2.1 From 1d40c0f43b366638de16a99a874ce1475249ade0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 9 Aug 2016 21:07:49 +0200 Subject: [ticket/14733] Support increasing hashing cost factor PHPBB3-14733 --- tests/passwords/drivers_test.php | 23 +++++++++++++++++++++-- tests/passwords/manager_test.php | 4 ++-- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 5f9fd523c9..01c69a38bb 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -23,8 +23,8 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $php_ext = 'php'; $this->passwords_drivers = array( - 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper), - 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper), + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper, 10), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper, 10), 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $this->driver_helper), 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $this->driver_helper), 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), @@ -413,4 +413,23 @@ class phpbb_passwords_helper_test extends \phpbb_test_case ); return strtr($string, $transform); } + + public function data_needs_rehash() + { + return array( + array('passwords.driver.bcrypt_2y', '$2y$10$somerandomhash', false), + array('passwords.driver.bcrypt', '$2a$10$somerandomhash', false), + array('passwords.driver.salted_md5', 'foobar', false), + array('passwords.driver.bcrypt_2y', '$2y$9$somerandomhash', true), + array('passwords.driver.bcrypt', '$2a$04$somerandomhash', true), + ); + } + + /** + * @dataProvider data_needs_rehash + */ + public function test_needs_rehash($driver, $hash, $expected) + { + $this->assertSame($this->passwords_drivers[$driver]->needs_rehash($hash), $expected); + } } diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 333834ee07..dbe0341664 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -29,8 +29,8 @@ class phpbb_passwords_manager_test extends \phpbb_test_case $php_ext = 'php'; $this->passwords_drivers = array( - 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper), - 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper), + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper, 10), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper, 10), 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $this->driver_helper), 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $this->driver_helper), 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), -- cgit v1.2.1 From 380be9f1fd713dbcee91f12f18060d6b3ff4819e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Sep 2016 20:33:10 +0200 Subject: [ticket/14733] Make sure detect_algorithm() works correctly and add tests detect_algorithm() returned array() if an algorithm prefix was more than 2 characters long. This might have been invalid for other prefixes. In order to correctly cope with other prefixes, another check for a backslash in the prefix definitino has been added. This was discovered while writing the tests for the newly added interface. PHPBB3-14733 --- tests/passwords/manager_test.php | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'tests') diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index dbe0341664..0410d7035f 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -344,4 +344,54 @@ class phpbb_passwords_manager_test extends \phpbb_test_case { $this->assertSame($expected, $this->driver_helper->string_compare($a, $b)); } + + public function data_driver_interface_driver() + { + return array( + array(false, false, false), + array(true, false, false), + array(true, true, true), + ); + } + + /** + * @dataProvider data_driver_interface_driver + */ + public function test_driver_interface_driver($use_new_interface, $needs_rehash, $expected) + { + if ($use_new_interface) + { + $test_driver = $this->getMock('\phpbb\passwords\driver\rehashable_driver_interface', array('needs_rehash', 'get_prefix', 'check', 'is_supported', 'is_legacy', 'hash', 'get_settings_only')); + $test_driver->method('needs_rehash') + ->willReturn($needs_rehash); + } + else + { + $test_driver = $this->getMock('\phpbb\passwords\driver\driver_interface', array('get_prefix', 'check', 'is_supported', 'is_legacy', 'hash', 'get_settings_only')); + } + $config = new \phpbb\config\config(array()); + + $test_driver->method('is_supported') + ->willReturn(true); + $test_driver->method('get_prefix') + ->willReturn('$test$'); + $test_driver->method('check') + ->with($this->anything()) + ->willReturn(true); + $passwords_drivers = array( + 'passwords.driver.foobar' => $test_driver, + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper, 10), + ); + // Set up another manager + $foobar_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $this->helper, array('passwords.driver.foobar')); + + $this->assertTrue($foobar_manager->check('foobar', '$test$somerandomstuff')); + $this->assertEquals($expected, $foobar_manager->convert_flag); + + // Should always return true in case a different driver is default + $foobar_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $this->helper, array('passwords.driver.bcrypt_2y', 'passwords.driver.foobar')); + + $this->assertTrue($foobar_manager->check('foobar', '$test$somerandomstuff')); + $this->assertTrue($foobar_manager->convert_flag); + } } -- cgit v1.2.1 From 82105070ad2e3886d5fbe9d7483f787806e58cfc Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 9 Oct 2016 22:10:16 +0200 Subject: [ticket/14807] Updates s9e textformatter again PHPBB3-14807 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index a70528aba3..e25c3246b5 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -298,7 +298,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "Emoji: \xF0\x9F\x98\x80", - 'Emoji: ' . ' + 'Emoji: ' . ' ), array( "Emoji: \xF0\x9F\x98\x80", -- cgit v1.2.1 From 35ad0f124933495c8282342679048860d057c362 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 9 Oct 2016 22:13:58 +0200 Subject: [ticket/14807] Fix tests after symfony upgrade PHPBB3-14807 --- tests/di/create_container_test.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 4dd0583ebe..aba7a3560b 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -73,8 +73,6 @@ namespace // Checks the construction of a dumped container $container = $this->builder->get_container(); $this->assertInstanceOf('phpbb_cache_container', $container); - $this->assertFalse($container->isFrozen()); - $container->getParameterBag(); // needed, otherwise the container is not marked as frozen $this->assertTrue($container->isFrozen()); } -- cgit v1.2.1 From 33f1934b727ce71e272447356941de18f999d53f Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 2 Nov 2016 09:19:35 +0100 Subject: [ticket/14846] Updated s9e\TextFormatter PHPBB3-14846 --- .../text_processing/tickets_data/PHPBB3-14846.html | 1 + .../text_processing/tickets_data/PHPBB3-14846.txt | 1 + .../text_processing/tickets_data/PHPBB3-14846.xml | 28 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-14846.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-14846.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-14846.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-14846.html b/tests/text_processing/tickets_data/PHPBB3-14846.html new file mode 100644 index 0000000000..461ca25bc6 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14846.html @@ -0,0 +1 @@ +
            moderator text
            - Mickroz
            \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14846.txt b/tests/text_processing/tickets_data/PHPBB3-14846.txt new file mode 100644 index 0000000000..ded7b3f1fe --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14846.txt @@ -0,0 +1 @@ +[mod=Mickroz]moderator text[/mod] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14846.xml b/tests/text_processing/tickets_data/PHPBB3-14846.xml new file mode 100644 index 0000000000..94b094f0e3 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14846.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + mod= + + 1 + [mod={TEXT1}]{TEXT2}[/mod] + {TEXT2}
            - {TEXT1}
            ]]>
            + + + + ${2}
            - ${1}
            ]]>
            +
            +
            +
            -- cgit v1.2.1 From e974f338afb86c065e9b160363bc2e6156f8566d Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Sun, 13 Nov 2016 18:08:35 +0100 Subject: [ticket/14739] Remove SQLite 2.8.x database driver PHPBB3-14739 --- tests/functions/convert_30_dbms_to_31_test.php | 1 - tests/migrator/schema_generator_test.php | 2 +- tests/test_framework/phpbb_database_test_case.php | 2 +- .../phpbb_database_test_connection_manager.php | 15 +-------------- tests/test_framework/phpbb_test_case_helpers.php | 11 ----------- 5 files changed, 3 insertions(+), 28 deletions(-) (limited to 'tests') diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php index e46a569565..456eb64461 100644 --- a/tests/functions/convert_30_dbms_to_31_test.php +++ b/tests/functions/convert_30_dbms_to_31_test.php @@ -22,7 +22,6 @@ class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case array('mysqli'), array('oracle'), array('postgres'), - array('sqlite'), ); } diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php index 40a8343e22..1996d207ea 100644 --- a/tests/migrator/schema_generator_test.php +++ b/tests/migrator/schema_generator_test.php @@ -29,7 +29,7 @@ class schema_generator_test extends phpbb_test_case parent::setUp(); $this->config = new \phpbb\config\config(array()); - $this->db = new \phpbb\db\driver\sqlite(); + $this->db = new \phpbb\db\driver\sqlite3(); $factory = new \phpbb\db\tools\factory(); $this->db_tools = $factory->get($this->db); $this->table_prefix = 'phpbb_'; diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 4d0460ebeb..b7386e9a3e 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -76,7 +76,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test global $table_prefix; - $db = new \phpbb\db\driver\sqlite(); + $db = new \phpbb\db\driver\sqlite3(); $factory = new \phpbb\db\tools\factory(); $db_tools = $factory->get($db, true); diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 27ac64e21d..147029d699 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -55,7 +55,6 @@ class phpbb_database_test_connection_manager switch ($this->dbms['PDO']) { - case 'sqlite2': case 'sqlite': // SQLite3 driver $dsn .= $this->config['dbhost']; break; @@ -193,7 +192,6 @@ class phpbb_database_test_connection_manager { switch ($this->config['dbms']) { - case 'phpbb\db\driver\sqlite': case 'phpbb\db\driver\sqlite3': $this->connect(); // Drop all of the tables @@ -269,12 +267,6 @@ class phpbb_database_test_connection_manager $sql = 'SHOW TABLES'; break; - case 'phpbb\db\driver\sqlite': - $sql = 'SELECT name - FROM sqlite_master - WHERE type = "table"'; - break; - case 'phpbb\db\driver\sqlite3': $sql = 'SELECT name FROM sqlite_master @@ -378,7 +370,7 @@ class phpbb_database_test_connection_manager $classes = $finder->core_path('phpbb/db/migration/data/') ->get_classes(); - $db = new \phpbb\db\driver\sqlite(); + $db = new \phpbb\db\driver\sqlite3(); $factory = new \phpbb\db\tools\factory(); $db_tools = $factory->get($db, true); @@ -454,11 +446,6 @@ class phpbb_database_test_connection_manager 'DELIM' => ';', 'PDO' => 'pgsql', ), - 'phpbb\db\driver\sqlite' => array( - 'SCHEMA' => 'sqlite', - 'DELIM' => ';', - 'PDO' => 'sqlite2', - ), 'phpbb\db\driver\sqlite3' => array( 'SCHEMA' => 'sqlite', 'DELIM' => ';', diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index c4b653ec7c..7fb9a740b8 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -122,17 +122,6 @@ class phpbb_test_case_helpers 'dbpasswd' => '', )); } - else if (extension_loaded('sqlite')) - { - $config = array_merge($config, array( - 'dbms' => 'phpbb\db\driver\sqlite', - 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename - 'dbport' => '', - 'dbname' => '', - 'dbuser' => '', - 'dbpasswd' => '', - )); - } if (isset($_SERVER['PHPBB_TEST_CONFIG'])) { -- cgit v1.2.1 From 88c921be23a2cddbfb3ac7272eb14305664b6542 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 27 Nov 2016 13:30:15 +0100 Subject: [ticket/14873] Added width/height attributes to smilies PHPBB3-14873 --- tests/text_formatter/s9e/factory_test.php | 2 +- tests/text_formatter/s9e/renderer_test.php | 4 ++-- tests/text_processing/generate_text_for_display_test.php | 2 +- tests/text_processing/smilies_test.php | 8 ++++---- tests/text_processing/tickets_data/PHPBB3-13425.html | 2 +- tests/text_processing/tickets_data/PHPBB3-7187.html | 2 +- tests/text_processing/tickets_data/PHPBB3-7275.html | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 368b8a4f4b..3d3ea8b794 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -165,7 +165,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $renderer = $this->get_test_case_helpers()->set_s9e_services(null, $fixture)->get('text_formatter.renderer'); $this->assertSame( - '"\'<&>', + '"\'<&>', $renderer->render('"\'<&>') ); } diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 2b034259c9..175b90fdc7 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -115,7 +115,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ), array( ':)', - ':)', + ':)', array('set_viewsmilies' => true) ), array( @@ -248,7 +248,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ), array( ':)', - ':)' + ':)' ), array( ':)', diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index dfbd0977a0..b8b5b18561 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -190,7 +190,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca ), array( ':)', - ':)' + ':)' ), array( ':)', diff --git a/tests/text_processing/smilies_test.php b/tests/text_processing/smilies_test.php index ebdbe7dadc..3778e5f58c 100644 --- a/tests/text_processing/smilies_test.php +++ b/tests/text_processing/smilies_test.php @@ -30,19 +30,19 @@ class phpbb_text_processing_smilies_test extends phpbb_test_case return array( array( ':) beginning', - ':) beginning' + ':) beginning' ), array( 'end :)', - 'end :)' + 'end :)' ), array( ':)', - ':)' + ':)' ), array( 'xx (18) 8) xx', - 'xx (18) 8) xx' + 'xx (18) 8) xx' ), ); } diff --git a/tests/text_processing/tickets_data/PHPBB3-13425.html b/tests/text_processing/tickets_data/PHPBB3-13425.html index 9a042dc558..a3b6d21f40 100644 --- a/tests/text_processing/tickets_data/PHPBB3-13425.html +++ b/tests/text_processing/tickets_data/PHPBB3-13425.html @@ -1 +1 @@ -
            :lol: starts with a smiley
            \ No newline at end of file +
            :lol: starts with a smiley
            \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-7187.html b/tests/text_processing/tickets_data/PHPBB3-7187.html index 9138779d29..a37cdf038e 100644 --- a/tests/text_processing/tickets_data/PHPBB3-7187.html +++ b/tests/text_processing/tickets_data/PHPBB3-7187.html @@ -1 +1 @@ -
            :geek: :ugeek:
            \ No newline at end of file +
            :geek: :ugeek:
            \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-7275.html b/tests/text_processing/tickets_data/PHPBB3-7275.html index 12502833fd..470aebb5d0 100644 --- a/tests/text_processing/tickets_data/PHPBB3-7275.html +++ b/tests/text_processing/tickets_data/PHPBB3-7275.html @@ -1 +1 @@ -
            :)
            \ No newline at end of file +
            :)
            \ No newline at end of file -- cgit v1.2.1 From d817f3cc674433bfe3217b58fce887c48677b382 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 2 Dec 2016 12:53:17 +0100 Subject: [ticket/14875] Add raw_variable() to request mock PHPBB3-14875 --- tests/mock/request.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/mock/request.php b/tests/mock/request.php index e7217a94a9..6a32ba0cf1 100644 --- a/tests/mock/request.php +++ b/tests/mock/request.php @@ -34,6 +34,11 @@ class phpbb_mock_request implements \phpbb\request\request_interface $this->data[$super_global][$var_name] = $value; } + public function raw_variable($var_name, $default, $super_global = \phpbb\request\request_interface::REQUEST) + { + return $this->variable($var_name, $default, true, $super_global); + } + public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST) { return isset($this->data[$super_global][$var_name]) ? $this->data[$super_global][$var_name] : $default; -- cgit v1.2.1 From eb1ade67681ee7c88845978eade07ad3ac96357a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 24 Feb 2016 13:49:20 +0100 Subject: [ticket/14492] Set install extensions to synthetic and fix step count PHPBB3-14492 --- tests/test_framework/phpbb_functional_test_case.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 20b89aba4e..2a37ca0e53 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -309,6 +309,8 @@ class phpbb_functional_test_case extends phpbb_test_case $container->register('installer.install_finish.notify_user')->setSynthetic(true); $container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task()); + $container->register('installer.install_finish.install_extensions')->setSynthetic(true); + $container->set('installer.install_finish.install_extensions', new phpbb_mock_null_installer_task()); $container->compile(); $language = $container->get('language'); -- cgit v1.2.1 From 346f31a03156839d1b1931d2fc69cd2ab5656bc0 Mon Sep 17 00:00:00 2001 From: Etienne Baroux Date: Mon, 2 Jun 2014 10:12:18 +0200 Subject: [ticket/12610] Add command to check if the board is up to date. PHPBB3-12610 --- tests/console/update/check_test.php | 99 ++++++++++++++++++++++ tests/extension/manager_test.php | 2 +- tests/extension/metadata_manager_test.php | 5 +- tests/pagination/pagination_test.php | 3 +- .../test_framework/phpbb_functional_test_case.php | 2 +- 5 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 tests/console/update/check_test.php (limited to 'tests') diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php new file mode 100644 index 0000000000..d257ef6c0a --- /dev/null +++ b/tests/console/update/check_test.php @@ -0,0 +1,99 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use phpbb\console\command\update\check; + +require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_admin.php'; +require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../../phpBB/includes/utf/utf_tools.php'; + +/** +* @slow +*/ +class phpbb_console_command_check_test extends phpbb_test_case +{ + protected $command_name; + + protected $version_helper; + + public function test_up_to_date() + { + $command_tester = $this->get_command_tester('100000'); + $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); + $this->assertSame('', $command_tester->getDisplay()); + $this->assertSame($status, 0); + } + + public function test_up_to_date_verbose() + { + $command_tester = $this->get_command_tester('100000'); + $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true)); + $this->assertContains('UPDATE_NOT_NEEDED', $command_tester->getDisplay()); + $this->assertSame($status, 0); + } + + + public function test_not_up_to_date() + { + $command_tester = $this->get_command_tester('0'); + $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); + $this->assertContains('UPDATE_NEEDED', $command_tester->getDisplay()); + $this->assertSame($status, 1); + } + + public function test_not_up_to_date_verbose() + { + $command_tester = $this->get_command_tester('0'); + $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true)); + $this->assertContains('UPDATE_NEEDED', $command_tester->getDisplay()); + $this->assertContains('UPDATES_AVAILABLE', $command_tester->getDisplay()); + $this->assertSame($status, 1); + } + + public function test_error() + { + $command_tester = $this->get_command_tester('1'); + $this->version_helper->set_file_location('acme.corp','foo', 'bar.json'); + + $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); + $this->assertContains('VERSIONCHECK_FAIL', $command_tester->getDisplay()); + $this->assertSame($status, 2); + } + + public function get_command_tester($current_version) + { + global $user; + + $user = $this->getMock('\phpbb\user'); + $user->method('lang')->will($this->returnArgument(0)); + + $cache = $this->getMockBuilder('\phpbb\cache\service') + ->disableOriginalConstructor() + ->getMock(); + + $config = new \phpbb\config\config(array('version' => $current_version)); + $this->version_helper = new \phpbb\version_helper($cache, $config, $user); + + $container = new phpbb_mock_container_builder; + $container->set('version_helper', $this->version_helper); + + $application = new Application(); + $application->add(new check($user, $config, $container)); + + $command = $application->find('update:check'); + $this->command_name = $command->getName(); + return new CommandTester($command); + } +} diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index a24b0cf178..f619d4c19d 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -180,7 +180,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case 'phpbb_ext', dirname(__FILE__) . '/', $php_ext, - ($with_cache) ? new phpbb_mock_cache() : null + ($with_cache) ? new \phpbb\cache\service(new phpbb_mock_cache(), $config, $db, $phpbb_root_path, $php_ext) : null ); } } diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 19b99ee0ce..ce675f0d36 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -36,7 +36,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case { parent::setUp(); - $this->cache = new phpbb_mock_cache(); $this->config = new \phpbb\config\config(array( 'version' => '3.1.0', )); @@ -45,6 +44,9 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->db_tools = $factory->get($this->db); $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->phpEx = 'php'; + + $this->cache = new \phpbb\cache\service(new phpbb_mock_cache(), $this->config, $this->db, $this->phpbb_root_path, $this->phpEx); + $this->table_prefix = 'phpbb_'; $container = new phpbb_mock_container_builder(); @@ -364,7 +366,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $ext_name, $this->config, $this->extension_manager, - $this->template, $this->phpbb_root_path ); } diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 024b6fc02d..30b25913f7 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -37,10 +37,11 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); + $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); + $filesystem = new \phpbb\filesystem\filesystem(); $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); - $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 2a37ca0e53..d5e78d1d60 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -263,7 +263,7 @@ class phpbb_functional_test_case extends phpbb_test_case self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', $phpEx, - $this->get_cache_driver() + new \phpbb\cache\service($this->get_cache_driver(), $config, $this->db, $phpbb_root_path, $phpEx) ); return $extension_manager; -- cgit v1.2.1 From 376042d845a18058d93d289a1227096794da06d2 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 24 Aug 2015 10:26:05 +0200 Subject: [ticket/12610] Fix tests PHPBB3-12610 --- tests/console/update/check_test.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php index d257ef6c0a..2101a3f33a 100644 --- a/tests/console/update/check_test.php +++ b/tests/console/update/check_test.php @@ -76,7 +76,10 @@ class phpbb_console_command_check_test extends phpbb_test_case { global $user; - $user = $this->getMock('\phpbb\user'); + $user = $this->getMock('\phpbb\user', array(), array( + new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + '\phpbb\datetime' + )); $user->method('lang')->will($this->returnArgument(0)); $cache = $this->getMockBuilder('\phpbb\cache\service') @@ -84,7 +87,7 @@ class phpbb_console_command_check_test extends phpbb_test_case ->getMock(); $config = new \phpbb\config\config(array('version' => $current_version)); - $this->version_helper = new \phpbb\version_helper($cache, $config, $user); + $this->version_helper = new \phpbb\version_helper($cache, $config, new \phpbb\file_downloader(), $user); $container = new phpbb_mock_container_builder; $container->set('version_helper', $this->version_helper); -- cgit v1.2.1 From 8481bd4e1831e3f9911263957637f4095fb088b0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 24 Aug 2015 12:33:32 +0200 Subject: [ticket/12610] Use exception_interface PHPBB3-12610 --- tests/console/update/check_test.php | 5 ++++- tests/version/version_fetch_test.php | 5 +---- tests/version/version_helper_remote_test.php | 7 +++---- tests/version/version_test.php | 5 +---- 4 files changed, 9 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php index 2101a3f33a..de57e4df08 100644 --- a/tests/console/update/check_test.php +++ b/tests/console/update/check_test.php @@ -62,6 +62,9 @@ class phpbb_console_command_check_test extends phpbb_test_case $this->assertSame($status, 1); } + /** + * @expectedException phpbb\exception\runtime_exception + */ public function test_error() { $command_tester = $this->get_command_tester('1'); @@ -87,7 +90,7 @@ class phpbb_console_command_check_test extends phpbb_test_case ->getMock(); $config = new \phpbb\config\config(array('version' => $current_version)); - $this->version_helper = new \phpbb\version_helper($cache, $config, new \phpbb\file_downloader(), $user); + $this->version_helper = new \phpbb\version_helper($cache, $config, new \phpbb\file_downloader()); $container = new phpbb_mock_container_builder; $container->set('version_helper', $this->version_helper); diff --git a/tests/version/version_fetch_test.php b/tests/version/version_fetch_test.php index 6ecc9b7223..c44bd5514a 100644 --- a/tests/version/version_fetch_test.php +++ b/tests/version/version_fetch_test.php @@ -28,15 +28,12 @@ class phpbb_version_helper_fetch_test extends phpbb_test_case ->disableOriginalConstructor() ->getMock(); - $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); - $this->version_helper = new \phpbb\version_helper( $this->cache, new \phpbb\config\config(array( 'version' => '3.1.0', )), - new \phpbb\file_downloader(), - new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime') + new \phpbb\file_downloader() ); } diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php index 724c4c970c..fa383d487f 100644 --- a/tests/version/version_helper_remote_test.php +++ b/tests/version/version_helper_remote_test.php @@ -42,8 +42,7 @@ class version_helper_remote_test extends \phpbb_test_case $this->version_helper = new \phpbb\version_helper( $this->cache, $config, - $this->file_downloader, - new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime') + $this->file_downloader ); $this->user = new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime'); $this->user->add_lang('acp/common'); @@ -161,8 +160,8 @@ class version_helper_remote_test extends \phpbb_test_case { try { $return = $this->version_helper->get_versions(); - } catch (\RuntimeException $e) { - $this->assertEquals((string)$e->getMessage(), $this->user->lang('VERSIONCHECK_FAIL')); + } catch (\phpbb\exception\runtime_exception $e) { + $this->assertEquals((string)$e->getMessage(), 'VERSIONCHECK_FAIL'); } } else diff --git a/tests/version/version_test.php b/tests/version/version_test.php index 05577f6a18..93d47a40a6 100644 --- a/tests/version/version_test.php +++ b/tests/version/version_test.php @@ -25,15 +25,12 @@ class phpbb_version_helper_test extends phpbb_test_case ->disableOriginalConstructor() ->getMock(); - $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); - $this->version_helper = new \phpbb\version_helper( $this->cache, new \phpbb\config\config(array( 'version' => '3.1.0', )), - new \phpbb\file_downloader(), - new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime') + new \phpbb\file_downloader() ); } -- cgit v1.2.1 From 103d344cd4476b452e42cd7ba0007b5a85caeaaf Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 5 Dec 2016 15:46:05 +0100 Subject: [ticket/12610] Fix tests and use getOption() for console PHPBB3-12610 --- tests/console/update/check_test.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php index de57e4df08..5cadc5cc97 100644 --- a/tests/console/update/check_test.php +++ b/tests/console/update/check_test.php @@ -28,6 +28,9 @@ class phpbb_console_command_check_test extends phpbb_test_case protected $version_helper; + /** @var \phpbb\language\language */ + protected $language; + public function test_up_to_date() { $command_tester = $this->get_command_tester('100000'); @@ -40,7 +43,7 @@ class phpbb_console_command_check_test extends phpbb_test_case { $command_tester = $this->get_command_tester('100000'); $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true)); - $this->assertContains('UPDATE_NOT_NEEDED', $command_tester->getDisplay()); + $this->assertContains($this->language->lang('UPDATE_NOT_NEEDED'), $command_tester->getDisplay()); $this->assertSame($status, 0); } @@ -49,7 +52,7 @@ class phpbb_console_command_check_test extends phpbb_test_case { $command_tester = $this->get_command_tester('0'); $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertContains('UPDATE_NEEDED', $command_tester->getDisplay()); + $this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay()); $this->assertSame($status, 1); } @@ -57,8 +60,8 @@ class phpbb_console_command_check_test extends phpbb_test_case { $command_tester = $this->get_command_tester('0'); $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true)); - $this->assertContains('UPDATE_NEEDED', $command_tester->getDisplay()); - $this->assertContains('UPDATES_AVAILABLE', $command_tester->getDisplay()); + $this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay()); + $this->assertContains($this->language->lang('UPDATES_AVAILABLE'), $command_tester->getDisplay()); $this->assertSame($status, 1); } @@ -77,10 +80,12 @@ class phpbb_console_command_check_test extends phpbb_test_case public function get_command_tester($current_version) { - global $user; + global $user, $phpbb_root_path, $phpEx; + + $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $user = $this->getMock('\phpbb\user', array(), array( - new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), + $this->language, '\phpbb\datetime' )); $user->method('lang')->will($this->returnArgument(0)); @@ -96,7 +101,7 @@ class phpbb_console_command_check_test extends phpbb_test_case $container->set('version_helper', $this->version_helper); $application = new Application(); - $application->add(new check($user, $config, $container)); + $application->add(new check($user, $config, $container, $this->language)); $command = $application->find('update:check'); $this->command_name = $command->getName(); -- cgit v1.2.1 From 6a5b99b12b1812202843613994480cc6caf93354 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 8 Dec 2016 16:49:50 -0800 Subject: [ticket/14895] Fix broken tests PHPBB3-14895 --- tests/console/cron/cron_list_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index 3bbe2078ba..fdc9a05cb2 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -50,19 +50,19 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case public function test_only_ready() { $this->initiate_test(2, 0); - $this->assertContains('TASKS_READY command1 command2', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); + $this->assertContains('TASKS_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_only_not_ready() { $this->initiate_test(0, 2); - $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); + $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_both_ready() { $this->initiate_test(2, 2); - $this->assertSame('TASKS_READY command1 command2 TASKS_NOT_READY command3 command4', preg_replace('/\s+/', ' ', trim($this->command_tester->getDisplay()))); + $this->assertSame('TASKS_READY command1 command2 TASKS_NOT_READY command3 command4', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); } public function get_cron_manager(array $tasks) -- cgit v1.2.1 From de6942e117d4e1b27a62fd1a3bebcad53052140c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 17 Dec 2016 23:29:19 +0100 Subject: [ticket/14921] Use phpbb.com URL to prevent test failures for remote URLs PHPBB3-14921 --- tests/files/types_remote_test.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index d103771c04..1a7d63d790 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -84,16 +84,16 @@ class phpbb_files_types_remote_test extends phpbb_test_case public function data_get_max_file_size() { return array( - array('', 'http://example.com/foo/bar.png'), - array('2k', 'http://example.com/foo/bar.png'), - array('500k', 'http://example.com/foo/bar.png'), - array('500M', 'http://example.com/foo/bar.png'), - array('500m', 'http://example.com/foo/bar.png'), + array('', 'http://phpbb.com/foo/bar.png'), + array('2k', 'http://phpbb.com/foo/bar.png'), + array('500k', 'http://phpbb.com/foo/bar.png'), + array('500M', 'http://phpbb.com/foo/bar.png'), + array('500m', 'http://phpbb.com/foo/bar.png'), array('500k', 'http://google.com/?.png', array('DISALLOWED_EXTENSION', 'DISALLOWED_CONTENT')), array('1', 'http://google.com/?.png', array('WRONG_FILESIZE')), - array('500g', 'http://example.com/foo/bar.png'), - array('foobar', 'http://example.com/foo/bar.png'), - array('-5k', 'http://example.com/foo/bar.png'), + array('500g', 'http://phpbb.com/foo/bar.png'), + array('foobar', 'http://phpbb.com/foo/bar.png'), + array('-5k', 'http://phpbb.com/foo/bar.png'), ); } -- cgit v1.2.1 From f111e70fc3959d979e61e8134fcaefb670b32603 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 27 Dec 2016 21:48:01 +0100 Subject: [ticket/14914] Made emoji scale in size with text PHPBB3-14914 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index e25c3246b5..a0c57214e4 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -298,7 +298,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "Emoji: \xF0\x9F\x98\x80", - 'Emoji: ' . ' + 'Emoji: ' . ' ), array( "Emoji: \xF0\x9F\x98\x80", -- cgit v1.2.1 From 429225027ecf53a359dafcfcc3b03ce40f40fa1b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 2 Jan 2017 20:39:41 +0100 Subject: [ticket/14947] Create new webdriver instance for every test PHPUnit seems to have emptied the webdriver between every test, which causes curl errors. A new webdriver instance will now be created for every test file. This does not cause a lot of overhead for ui tests. PHPBB3-14947 --- tests/test_framework/phpbb_ui_test_case.php | 72 +++++++++++++++-------------- tests/ui/permission_roles_test.php | 12 ++--- tests/ui/quick_links_test.php | 6 +-- 3 files changed, 46 insertions(+), 44 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index e3f636679c..b875d3212b 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -78,14 +78,11 @@ class phpbb_ui_test_case extends phpbb_test_case self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); } - if (!self::$webDriver) - { - try { - $capabilities = DesiredCapabilities::firefox(); - self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); - } catch (WebDriverCurlException $e) { - self::markTestSkipped('PhantomJS webserver is not running.'); - } + try { + $capabilities = DesiredCapabilities::firefox(); + self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); + } catch (WebDriverCurlException $e) { + self::markTestSkipped('PhantomJS webserver is not running.'); } if (!self::$already_installed) @@ -146,9 +143,14 @@ class phpbb_ui_test_case extends phpbb_test_case } } - static public function visit($path) + public function getDriver() + { + return self::$webDriver; + } + + public function visit($path) { - self::$webDriver->get(self::$root_url . $path); + $this->getDriver()->get(self::$root_url . $path); } static protected function recreate_database($config) @@ -157,14 +159,14 @@ class phpbb_ui_test_case extends phpbb_test_case $db_conn_mgr->recreate_db(); } - static public function find_element($type, $value) + public function find_element($type, $value) { - return self::$webDriver->findElement(WebDriverBy::$type($value)); + return $this->getDriver()->findElement(WebDriverBy::$type($value)); } - static public function submit($type = 'id', $value = 'submit') + public function submit($type = 'id', $value = 'submit') { - $element = self::find_element($type, $value); + $element = $this->find_element($type, $value); $element->click(); } @@ -305,21 +307,21 @@ class phpbb_ui_test_case extends phpbb_test_case $ext_path = str_replace('/', '%2F', $extension); $this->visit('adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid); - $this->assertNotEmpty(count(self::find_element('cssSelector', '.submit-buttons'))); + $this->assertNotEmpty(count($this->find_element('cssSelector', '.submit-buttons'))); - self::find_element('cssSelector', "input[value='Enable']")->submit(); + $this->find_element('cssSelector', "input[value='Enable']")->submit(); $this->add_lang('acp/extensions'); try { - $meta_refresh = self::find_element('cssSelector', 'meta[http-equiv="refresh"]'); + $meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]'); // Wait for extension to be fully enabled while (sizeof($meta_refresh)) { preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match); - self::$webDriver->execute(array('method' => 'post', 'url' => $match[1])); - $meta_refresh = self::find_element('cssSelector', 'meta[http-equiv="refresh"]'); + $this->getDriver()->execute(array('method' => 'post', 'url' => $match[1])); + $meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]'); } } catch (\Facebook\WebDriver\Exception\NoSuchElementException $e) @@ -327,7 +329,7 @@ class phpbb_ui_test_case extends phpbb_test_case // Probably no refresh triggered } - $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', self::find_element('cssSelector', 'div.successbox')->getText()); + $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $this->find_element('cssSelector', 'div.successbox')->getText()); $this->logout(); } @@ -415,7 +417,7 @@ class phpbb_ui_test_case extends phpbb_test_case } $this->visit('ucp.php?sid=' . $this->sid . '&mode=logout'); - $this->assertContains($this->lang('REGISTER'), self::$webDriver->getPageSource()); + $this->assertContains($this->lang('REGISTER'), $this->getDriver()->getPageSource()); unset($this->sid); } @@ -435,17 +437,17 @@ class phpbb_ui_test_case extends phpbb_test_case return; } - self::$webDriver->manage()->deleteAllCookies(); + $this->getDriver()->manage()->deleteAllCookies(); $this->visit('adm/index.php?sid=' . $this->sid); - $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), self::$webDriver->getPageSource()); + $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $this->getDriver()->getPageSource()); - self::find_element('cssSelector', 'input[name=username]')->clear()->sendKeys($username); - self::find_element('cssSelector', 'input[type=password]')->sendKeys($username . $username); - self::find_element('cssSelector', 'input[name=login]')->click(); + $this->find_element('cssSelector', 'input[name=username]')->clear()->sendKeys($username); + $this->find_element('cssSelector', 'input[type=password]')->sendKeys($username . $username); + $this->find_element('cssSelector', 'input[name=login]')->click(); $this->assertContains($this->lang('ADMIN_PANEL'), $this->find_element('cssSelector', 'h1')->getText()); - $cookies = self::$webDriver->manage()->getCookies(); + $cookies = $this->getDriver()->manage()->getCookies(); // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie foreach ($cookies as $cookie) @@ -550,19 +552,19 @@ class phpbb_ui_test_case extends phpbb_test_case { $this->add_lang('ucp'); - self::$webDriver->manage()->deleteAllCookies(); + $this->getDriver()->manage()->deleteAllCookies(); $this->visit('ucp.php'); - $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), self::$webDriver->getPageSource()); + $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $this->getDriver()->getPageSource()); - self::$webDriver->manage()->deleteAllCookies(); + $this->getDriver()->manage()->deleteAllCookies(); - self::find_element('cssSelector', 'input[name=username]')->sendKeys($username); - self::find_element('cssSelector', 'input[name=password]')->sendKeys($username . $username); - self::find_element('cssSelector', 'input[name=login]')->click(); + $this->find_element('cssSelector', 'input[name=username]')->sendKeys($username); + $this->find_element('cssSelector', 'input[name=password]')->sendKeys($username . $username); + $this->find_element('cssSelector', 'input[name=login]')->click(); $this->assertNotContains($this->lang('LOGIN'), $this->find_element('className', 'navbar')->getText()); - $cookies = self::$webDriver->manage()->getCookies(); + $cookies = $this->getDriver()->manage()->getCookies(); // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie foreach ($cookies as $cookie) @@ -586,6 +588,6 @@ class phpbb_ui_test_case extends phpbb_test_case // Change the Path to your own settings $screenshot = time() . ".png"; - self::$webDriver->takeScreenshot($screenshot); + $this->getDriver()->takeScreenshot($screenshot); } } diff --git a/tests/ui/permission_roles_test.php b/tests/ui/permission_roles_test.php index 3501124fc1..de54cc788d 100644 --- a/tests/ui/permission_roles_test.php +++ b/tests/ui/permission_roles_test.php @@ -25,19 +25,19 @@ class ui_permission_roles_test extends phpbb_ui_test_case $this->visit('adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid); // Select forums - $elements = self::find_element('cssSelector', 'select#forum') + $elements = $this->find_element('cssSelector', 'select#forum') ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); foreach ($elements as $element) { $element->click(); } - self::find_element('cssSelector', 'form#select_victim') + $this->find_element('cssSelector', 'form#select_victim') ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=submit]')) ->click(); // Select administrators and guests - $groups_form = self::find_element('cssSelector', 'form#groups'); + $groups_form = $this->find_element('cssSelector', 'form#groups'); $elements = $groups_form ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('select')) ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); @@ -51,7 +51,7 @@ class ui_permission_roles_test extends phpbb_ui_test_case } $groups_form->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[name=submit_edit_options]'))->click(); - $first_fieldset = self::find_element('cssSelector', '#perm11'); + $first_fieldset = $this->find_element('cssSelector', '#perm11'); $this->assertEquals('none', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); $first_fieldset ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle')) @@ -74,14 +74,14 @@ class ui_permission_roles_test extends phpbb_ui_test_case $this->assertEquals($this->lang('ROLE_FORUM_LIMITED'), $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); // Check that admin settings didn't get changed - $second_fieldset = self::find_element('cssSelector', '#perm10'); + $second_fieldset = $this->find_element('cssSelector', '#perm10'); $this->assertEquals('none', $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); // Full access = 14 $this->assertEquals(14, $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); $this->assertEquals($this->lang('ROLE_FORUM_FULL'), $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); // Check that category settings were not modified - $category_fieldset = self::find_element('cssSelector', '#perm00'); + $category_fieldset = $this->find_element('cssSelector', '#perm00'); $this->assertEquals('none', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); // No settings $this->assertEquals('', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); diff --git a/tests/ui/quick_links_test.php b/tests/ui/quick_links_test.php index 582aeafcae..171ef3ca53 100644 --- a/tests/ui/quick_links_test.php +++ b/tests/ui/quick_links_test.php @@ -19,8 +19,8 @@ class quick_links_test extends phpbb_ui_test_case public function test_quick_links() { $this->visit('index.php'); - $this->assertEmpty(self::find_element('className', 'dropdown')->getText()); - self::find_element('className', 'dropdown-toggle')->click(); - $this->assertNotNull(self::find_element('className', 'dropdown')->getText()); + $this->assertEmpty($this->find_element('className', 'dropdown')->getText()); + $this->find_element('className', 'dropdown-toggle')->click(); + $this->assertNotNull($this->find_element('className', 'dropdown')->getText()); } } -- cgit v1.2.1 From 1db7aa712af0521f1a64e90c6fcf4972ac5b08c2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 4 Jan 2017 19:19:02 +0100 Subject: [ticket/14838] Add missing method to mock'ed feed PHPBB3-14838 --- tests/feed/attachments_mock_feed.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/feed/attachments_mock_feed.php b/tests/feed/attachments_mock_feed.php index 0e623fed24..fb67a48f7c 100644 --- a/tests/feed/attachments_mock_feed.php +++ b/tests/feed/attachments_mock_feed.php @@ -28,4 +28,9 @@ class phpbb_feed_attachments_mock_feed extends \phpbb\feed\attachments_base return true; } + + public function adjust_item(&$item_row, &$row) + { + return array(); + } } -- cgit v1.2.1 From b582a19039acb004d38927cde29f459f8bf4039f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 4 Jan 2017 19:47:10 +0100 Subject: [ticket/14838] Correctly instantiate language object PHPBB3-14838 --- tests/feed/attachments_base_test.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php index c980dfd3d7..dd432d13f5 100644 --- a/tests/feed/attachments_base_test.php +++ b/tests/feed/attachments_base_test.php @@ -31,7 +31,12 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case $this->filesystem = new \phpbb\filesystem(); $config = new \phpbb\config\config(array()); - $user = new \phpbb\user('\phpbb\datetime'); + $user = new \phpbb\user( + new \phpbb\language\language( + new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx) + ), + '\phpbb\datetime' + ); $feed_helper = new \phpbb\feed\helper($config, $user, $phpbb_root_path, $phpEx); $db = $this->new_dbal(); $cache = new \phpbb_mock_cache(); -- cgit v1.2.1 From f82299b8e445cccfc8bad8cbe6505f3fb50d0f8f Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 6 Jan 2017 19:52:17 +0100 Subject: [ticket/14962] Introduces a new helper to check emptyness of bbcode texts PHPBB3-14962 --- tests/functional/posting_test.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 9dd8a1dc91..4ed34eca31 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -86,6 +86,21 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $this->assertRegexp($expected, $crawler->filter('textarea#message')->text()); } + /** + * @see https://tracker.phpbb.com/browse/PHPBB3-14962 + */ + public function test_edit() + { + $this->login(); + $this->create_topic(2, 'Test Topic 1', 'Test topic'); + + $url = self::$client->getCrawler()->selectLink('Edit')->link()->getUri(); + $post_id = $this->get_parameter_from_link($url, 'p'); + $this->submit_post("posting.php?mode=edit&f=2&p={$post_id}", 'EDIT_POST', array('message' => 'Edited post')); + + $this->assertContains('Edited post', self::$client->getCrawler()->filter("#post_content{$post_id} .content")->text()); + } + /** * @testdox max_quote_depth is applied to the text populating the posting form */ -- cgit v1.2.1 From 538f03efb058c84daf3e677a3137be8900678f2b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 6 Jan 2017 23:46:34 +0100 Subject: [ticket/14962] Fix functional test for editing post PHPBB3-14962 --- tests/functional/posting_test.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 4ed34eca31..83acefd2f3 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -92,13 +92,16 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case public function test_edit() { $this->login(); - $this->create_topic(2, 'Test Topic 1', 'Test topic'); + $this->create_topic(2, 'Test Topic post', 'Test topic post'); $url = self::$client->getCrawler()->selectLink('Edit')->link()->getUri(); $post_id = $this->get_parameter_from_link($url, 'p'); - $this->submit_post("posting.php?mode=edit&f=2&p={$post_id}", 'EDIT_POST', array('message' => 'Edited post')); + $crawler = self::request('GET', "posting.php?mode=edit&f=2&p={$post_id}&sid={$this->sid}"); + $form = $crawler->selectButton('Submit')->form(); + $form->setValues(array('message' => 'Edited post')); + $crawler = self::submit($form); - $this->assertContains('Edited post', self::$client->getCrawler()->filter("#post_content{$post_id} .content")->text()); + $this->assertContains('Edited post', $crawler->filter("#post_content{$post_id} .content")->text()); } /** -- cgit v1.2.1 From 9b2b9dd9de8d413f3f3b947b53e1a2a1e33dc477 Mon Sep 17 00:00:00 2001 From: javiexin Date: Sat, 7 Jan 2017 22:47:26 +0100 Subject: [ticket/14950] Add possibility to delete a template block Adds a new mode to alter_block_array to allow for the deletion of a certain block of template variables. The selection method is the same as for the other modes for alter_block_array. The passed in vararray is ignored, and an out of bounds index is considered an error. Added tests for the new function. PHPBB3-14950 --- tests/template/template_test.php | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 0bbfe3848d..d253651564 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -603,6 +603,48 @@ EOT $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification'); } + public function test_delete_alter_block_array() + { + $this->template->set_filenames(array('test' => 'loop_nested.html')); + + $this->template->assign_var('TEST_MORE', true); + + // @todo Change this + $this->template->assign_block_vars('outer', array('VARIABLE' => 'zero')); + $this->template->assign_block_vars('outer', array('VARIABLE' => 'one')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '1A')); + $this->template->assign_block_vars('outer', array('VARIABLE' => 'two')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '2A')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '2B')); + $this->template->assign_block_vars('outer', array('VARIABLE' => 'three')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3A')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3B')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3C')); + + $expect = 'outer - 0 - zero[outer|4]outer - 1 - one[outer|4]middle - 0 - 1A[middle|1]outer - 2 - two[outer|4]middle - 0 - 2A[middle|2]middle - 1 - 2B[middle|2]outer - 3 - three[outer|4]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification'); + + $this->template->alter_block_array('outer', array(), true, 'delete'); + + $expect = 'outer - 0 - one[outer|3]middle - 0 - 1A[middle|1]outer - 1 - two[outer|3]middle - 0 - 2A[middle|2]middle - 1 - 2B[middle|2]outer - 2 - three[outer|3]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting at the beginning of outer loop'); + + $this->template->alter_block_array('outer[0].middle', array(), false, 'delete'); + + $expect = 'outer - 0 - one[outer|3]outer - 1 - two[outer|3]middle - 0 - 2A[middle|2]middle - 1 - 2B[middle|2]outer - 2 - three[outer|3]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting at the end of first middle loop, delete complete loop'); + + $this->template->alter_block_array('outer', array(), 1, 'delete'); + + $expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|2]middle - 0 - 3A[middle|2]middle - 1 - 3C[middle|2]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting by index at top level'); + + $this->template->alter_block_array('outer', array(), 4, 'delete'); + + $expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|2]middle - 0 - 3A[middle|2]middle - 1 - 3C[middle|2]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting by index out of bounds, ignored'); + } + public function assign_block_vars_array_data() { return array( -- cgit v1.2.1 From 696724ac1b102d67aa765ebba7c898b0da3e8ba8 Mon Sep 17 00:00:00 2001 From: javiexin Date: Sun, 8 Jan 2017 00:59:26 +0100 Subject: [ticket/14950] Add possibility to delete a template block Adds a new mode to alter_block_array to allow for the deletion of a certain block of template variables. The selection method is the same as for the other modes for alter_block_array. The passed in vararray is ignored, and an out of bounds index is considered an error. Added tests for the new function, fixed. PHPBB3-14950 --- tests/template/template_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index d253651564..2d27a5b56a 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -624,12 +624,12 @@ EOT $expect = 'outer - 0 - zero[outer|4]outer - 1 - one[outer|4]middle - 0 - 1A[middle|1]outer - 2 - two[outer|4]middle - 0 - 2A[middle|2]middle - 1 - 2B[middle|2]outer - 3 - three[outer|4]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification'); - $this->template->alter_block_array('outer', array(), true, 'delete'); + $this->template->alter_block_array('outer', array(), false, 'delete'); $expect = 'outer - 0 - one[outer|3]middle - 0 - 1A[middle|1]outer - 1 - two[outer|3]middle - 0 - 2A[middle|2]middle - 1 - 2B[middle|2]outer - 2 - three[outer|3]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting at the beginning of outer loop'); - $this->template->alter_block_array('outer[0].middle', array(), false, 'delete'); + $this->template->alter_block_array('outer[0].middle', array(), true, 'delete'); $expect = 'outer - 0 - one[outer|3]outer - 1 - two[outer|3]middle - 0 - 2A[middle|2]middle - 1 - 2B[middle|2]outer - 2 - three[outer|3]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting at the end of first middle loop, delete complete loop'); -- cgit v1.2.1 From 7f8dd6b007393482b7f9e3316a6756d0c3953e11 Mon Sep 17 00:00:00 2001 From: javiexin Date: Sun, 8 Jan 2017 01:19:22 +0100 Subject: [ticket/14950] Add possibility to delete a template block Adds a new mode to alter_block_array to allow for the deletion of a certain block of template variables. The selection method is the same as for the other modes for alter_block_array. The passed in vararray is ignored, and an out of bounds index is considered an error. Added tests for the new function, fixed. PHPBB3-14950 --- tests/template/template_test.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 2d27a5b56a..3bc2f66ef0 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -636,9 +636,14 @@ EOT $this->template->alter_block_array('outer', array(), 1, 'delete'); - $expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|2]middle - 0 - 3A[middle|2]middle - 1 - 3C[middle|2]'; + $expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|3]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting by index at top level'); + $this->template->alter_block_array('outer.middle', array(), 1, 'delete'); + + $expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|2]middle - 0 - 3A[middle|2]middle - 1 - 3C[middle|2]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting by index at middle level'); + $this->template->alter_block_array('outer', array(), 4, 'delete'); $expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|2]middle - 0 - 3A[middle|2]middle - 1 - 3C[middle|2]'; -- cgit v1.2.1 From 988865fd0a1d213a441777b3c613265365fe651a Mon Sep 17 00:00:00 2001 From: javiexin Date: Sun, 8 Jan 2017 01:35:18 +0100 Subject: [ticket/14950] Add possibility to delete a template block Adds a new mode to alter_block_array to allow for the deletion of a certain block of template variables. The selection method is the same as for the other modes for alter_block_array. The passed in vararray is ignored, and an out of bounds index is considered an error. Added tests for the new function, fixed. PHPBB3-14950 --- tests/template/template_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 3bc2f66ef0..c03da6e646 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -636,7 +636,7 @@ EOT $this->template->alter_block_array('outer', array(), 1, 'delete'); - $expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|3]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; + $expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|2]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting by index at top level'); $this->template->alter_block_array('outer.middle', array(), 1, 'delete'); -- cgit v1.2.1 From 06b402bdecee8145639d50d17e1350971a5ec017 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 8 Jan 2017 23:07:08 +0700 Subject: [ticket/14971] Add on_page test with the string arguments PHPBB3-14971 --- tests/pagination/pagination_test.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 30b25913f7..2d7d1671a8 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -219,6 +219,12 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case 0, 'PAGE_OF-1-1', ), + array( + '10', + '10', + '0', + 'PAGE_OF-1-1', + ), ); } -- cgit v1.2.1 From a3accfaf461bc963f0661bdab1befbc9ef50a514 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 11 Jan 2017 01:54:14 -0800 Subject: [ticket/14989] Allow more admin-configurable schemes in post links PHPBB3-14989 --- tests/functional/posting_test.php | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 9dd8a1dc91..f3b222b388 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -246,4 +246,45 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case // Test that the preview contains the correct link $this->assertEquals($url, $crawler->filter('#preview a')->attr('href')); } + + public function test_allowed_schemes_links() + { + $text = 'http://example.org/ tcp://localhost:22/ServiceName'; + + $this->login(); + $this->admin_login(); + + // Post with default settings + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => $text, + )); + $crawler = self::submit($form); + $this->assertContains( + 'http://example.org/ tcp://localhost:22/ServiceName', + $crawler->filter('#preview .content')->html() + ); + + // Update allowed schemes + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + $values['config[allowed_schemes_links]'] = 'https,tcp'; + $form->setValues($values); + $crawler = self::submit($form); + $this->assertEquals(1, $crawler->filter('.successbox')->count()); + + // Post with new settings + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => $text, + )); + $crawler = self::submit($form); + $this->assertContains( + 'http://example.org/ tcp://localhost:22/ServiceName', + $crawler->filter('#preview .content')->html() + ); + } } -- cgit v1.2.1 From 499fcbcca96c154298b355a945897aba4164ab8d Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 12 Jan 2017 09:27:00 +0100 Subject: [ticket/14985] Added functional tests for BBCodes and smilies PHPBB3-14985 --- tests/functional/acp_bbcodes_test.php | 46 +++++++++++++++++++++++++++++++++++ tests/functional/acp_smilies_test.php | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 tests/functional/acp_bbcodes_test.php create mode 100644 tests/functional/acp_smilies_test.php (limited to 'tests') diff --git a/tests/functional/acp_bbcodes_test.php b/tests/functional/acp_bbcodes_test.php new file mode 100644 index 0000000000..58681dfa07 --- /dev/null +++ b/tests/functional/acp_bbcodes_test.php @@ -0,0 +1,46 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +/** + * @group functional + */ +class phpbb_functional_acp_bbcodes_test extends phpbb_functional_test_case +{ + public function test_htmlspecialchars() + { + $this->login(); + $this->admin_login(); + + // Create the BBCode + $crawler = self::request('GET', 'adm/index.php?i=acp_bbcodes&sid=' . $this->sid . '&mode=bbcodes&action=add'); + $form = $crawler->selectButton('Submit')->form(array( + 'bbcode_match' => '[mod="{TEXT1}"]{TEXT2}[/mod]', + 'bbcode_tpl' => '
            {TEXT1}
            {TEXT2}
            ' + )); + self::submit($form); + + // Test it in the "new topic" preview + $crawler = self::request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'subject', + 'message' => '[mod=a]b[/mod][mod="c"]d[/mod]' + )); + $crawler = self::submit($form); + + $html = $crawler->filter('#preview')->html(); + $this->assertContains('
            a
            ', $html); + $this->assertContains('
            b
            ', $html); + $this->assertContains('
            c
            ', $html); + $this->assertContains('
            d
            ', $html); + } +} diff --git a/tests/functional/acp_smilies_test.php b/tests/functional/acp_smilies_test.php new file mode 100644 index 0000000000..ebe8717fa7 --- /dev/null +++ b/tests/functional/acp_smilies_test.php @@ -0,0 +1,43 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +/** + * @group functional + */ +class phpbb_functional_acp_smilies_test extends phpbb_functional_test_case +{ + public function test_htmlspecialchars() + { + $this->login(); + $this->admin_login(); + + // Create the BBCode + $crawler = self::request('GET', 'adm/index.php?i=acp_icons&sid=' . $this->sid . '&mode=smilies&action=edit&id=1'); + $form = $crawler->selectButton('Submit')->form(array( + 'code[icon_e_biggrin.gif]' => '>:D', + 'emotion[icon_e_biggrin.gif]' => '>:D' + )); + self::submit($form); + + // Test it in the "new topic" preview + $crawler = self::request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'subject', + 'message' => '>:D' + )); + $crawler = self::submit($form); + + $html = $crawler->filter('#preview')->html(); + $this->assertRegexp('(]+ alt=">:D" title=">:D"[^>]*>)', $html); + } +} -- cgit v1.2.1 From 15315ac87a68834e2d560acf62756f628a26da45 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 14 Jan 2017 14:27:38 +0100 Subject: [ticket/15008] Disable emoji when smilies are disabled Will effectively disable emoji shortname and won't replace emoji with images but will not prevent a browser or OS from displaying emoji as images. PHPBB3-15008 --- .../tickets_data/PHPBB3-15008.before.php | 18 ++++++++++++++++++ tests/text_processing/tickets_data/PHPBB3-15008.html | 1 + tests/text_processing/tickets_data/PHPBB3-15008.txt | 1 + 3 files changed, 20 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-15008.before.php create mode 100644 tests/text_processing/tickets_data/PHPBB3-15008.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-15008.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-15008.before.php b/tests/text_processing/tickets_data/PHPBB3-15008.before.php new file mode 100644 index 0000000000..a3243e74cd --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15008.before.php @@ -0,0 +1,18 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +function before_assert_phpbb3_15008($vars) +{ + extract($vars); + $parser->disable_smilies(); +} diff --git a/tests/text_processing/tickets_data/PHPBB3-15008.html b/tests/text_processing/tickets_data/PHPBB3-15008.html new file mode 100644 index 0000000000..7642eb63ee --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15008.html @@ -0,0 +1 @@ +No smilies :) or shortnames :strawberry: \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15008.txt b/tests/text_processing/tickets_data/PHPBB3-15008.txt new file mode 100644 index 0000000000..7642eb63ee --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15008.txt @@ -0,0 +1 @@ +No smilies :) or shortnames :strawberry: \ No newline at end of file -- cgit v1.2.1 From 52d53ef3de93f1d840f82520848a8d6b113da64a Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 15 Jan 2017 11:24:15 +0100 Subject: [ticket/15016] Fixed an issue with some parentheses in smilies PHPBB3-15016 --- .../text_processing/tickets_data/PHPBB3-15016.html | 1 + .../text_processing/tickets_data/PHPBB3-15016.txt | 1 + .../text_processing/tickets_data/PHPBB3-15016.xml | 43 ++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-15016.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-15016.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-15016.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-15016.html b/tests/text_processing/tickets_data/PHPBB3-15016.html new file mode 100644 index 0000000000..47b66ad771 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15016.html @@ -0,0 +1 @@ +)--( )-( )-- \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15016.txt b/tests/text_processing/tickets_data/PHPBB3-15016.txt new file mode 100644 index 0000000000..081d9e3dc9 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15016.txt @@ -0,0 +1 @@ +)--( )-( )-- \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15016.xml b/tests/text_processing/tickets_data/PHPBB3-15016.xml new file mode 100644 index 0000000000..644481861e --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15016.xml @@ -0,0 +1,43 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 1 + )--( + )--( + icon_lol.gif + 15 + 17 + 22 + 1 + + + 2 + )-- + )-- + icon_lol.gif + 15 + 17 + 22 + 1 + + + 3 + )-( + )-( + icon_lol.gif + 15 + 17 + 22 + 1 + +
            +
            -- cgit v1.2.1 From 4b2a5a41a70a6c5745df8459d3c3de37af5249d2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 21 Jan 2017 10:28:08 +0100 Subject: [ticket/15036] Unlink install_config during functional testing PHPBB3-15036 --- tests/test_framework/phpbb_functional_test_case.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index e678bfbaef..eb56049515 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -291,6 +291,13 @@ class phpbb_functional_test_case extends phpbb_test_case } } + $install_config_file = $phpbb_root_path . 'store/install_config.php'; + + if (file_exists($install_config_file)) + { + unlink($install_config_file); + } + $container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $container = $container_builder ->with_environment('installer') -- cgit v1.2.1 From 9aa8dc26b7a389f2c1d9622f8d3ef564b0abcbcd Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 22 Jan 2017 19:19:12 +0100 Subject: [ticket/14790] Added test case PHPBB3-14790 --- tests/text_processing/tickets_data/PHPBB3-14790.html | 4 ++++ tests/text_processing/tickets_data/PHPBB3-14790.txt | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-14790.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-14790.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-14790.html b/tests/text_processing/tickets_data/PHPBB3-14790.html new file mode 100644 index 0000000000..7624b2d36c --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14790.html @@ -0,0 +1,4 @@ +
            • text
            • +
            • text
            • +
            • text
            • +
            • text
            \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14790.txt b/tests/text_processing/tickets_data/PHPBB3-14790.txt new file mode 100644 index 0000000000..1cd83d97d8 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14790.txt @@ -0,0 +1,4 @@ +[color=#0000FF][list][*]text +[*]text +[*]text +[*]text[/list][/color] \ No newline at end of file -- cgit v1.2.1 From 3e73413982dfa247c039f4c8a82b34d2c7483c2c Mon Sep 17 00:00:00 2001 From: hanakin Date: Mon, 23 Jan 2017 21:59:00 -0500 Subject: [ticket/15037]a attempt to fix stupid test issue PHPBB3-15037 --- tests/functional/fileupload_remote_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index b70d49cddd..3dc8986948 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -101,7 +101,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(1000); - $file = $upload->handle_upload('files.types.remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->get('filename'))); $this->assertTrue($file->is_uploaded()); @@ -113,8 +113,8 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) - ->set_max_filesize(100); - $file = $upload->handle_upload('files.types.remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); + ->set_max_filesize(1); + $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); $this->assertEquals(1, sizeof($file->error)); $this->assertEquals('WRONG_FILESIZE', $file->error[0]); } -- cgit v1.2.1 From 6f7b92ae1023f958e4b9894950a412fadc52b802 Mon Sep 17 00:00:00 2001 From: hanakin Date: Mon, 23 Jan 2017 22:41:08 -0500 Subject: [ticket/15307] fix for good! PHPBB3-15037 --- tests/functional/fileupload_remote_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 3dc8986948..09c123fa7b 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -100,7 +100,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) - ->set_max_filesize(1000); + ->set_max_filesize(1100); $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->get('filename'))); @@ -113,7 +113,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) - ->set_max_filesize(1); + ->set_max_filesize(100); $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); $this->assertEquals(1, sizeof($file->error)); $this->assertEquals('WRONG_FILESIZE', $file->error[0]); -- cgit v1.2.1 From 8b6d043ca6b415be94e9e1517676e2e507e954c5 Mon Sep 17 00:00:00 2001 From: hanakin Date: Mon, 23 Jan 2017 23:08:52 -0500 Subject: [ticket/15037] try larger size limit PHPBB3-15037 --- tests/functional/fileupload_remote_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 09c123fa7b..88f8999005 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -100,7 +100,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) - ->set_max_filesize(1100); + ->set_max_filesize(2000); $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->get('filename'))); -- cgit v1.2.1 From e8f41a0dcc4320c7ce9f739766a8a1cfc5b3c5f9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 24 Jan 2017 22:50:10 +0100 Subject: [ticket/15045] Fix user object instantiation in version_test PHPBB3-15045 --- tests/version/version_test.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/version/version_test.php b/tests/version/version_test.php index 698975bc72..abe51ef539 100644 --- a/tests/version/version_test.php +++ b/tests/version/version_test.php @@ -519,6 +519,11 @@ class phpbb_version_helper_test extends phpbb_test_case */ public function test_get_update_on_branch($current_version, $versions, $expected) { + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $version_helper = $this ->getMockBuilder('\phpbb\version_helper') ->setMethods(array( @@ -530,7 +535,7 @@ class phpbb_version_helper_test extends phpbb_test_case 'version' => $current_version, )), new \phpbb\file_downloader(), - new \phpbb\user('\phpbb\datetime'), + new \phpbb\user($lang, '\phpbb\datetime'), )) ->getMock() ; -- cgit v1.2.1 From 7000db304995ae575d14f84d4f4f3c874d09c3e0 Mon Sep 17 00:00:00 2001 From: javiexin Date: Sun, 12 Feb 2017 19:25:42 +0100 Subject: [ticket/15087] Optimize creation of metadata objects by caching Fix constructor in test cases. PHPBB3-15087 --- tests/extension/metadata_manager_test.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index ce675f0d36..8ef41f3673 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -364,9 +364,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case { return new phpbb_mock_metadata_manager( $ext_name, - $this->config, - $this->extension_manager, - $this->phpbb_root_path + $this->extension_manager->get_extension_path($ext_name, true) ); } } -- cgit v1.2.1 From 51a55cee5dd52687054c548e3b893de0a9ba2cd9 Mon Sep 17 00:00:00 2001 From: Vinny Date: Tue, 28 Feb 2017 05:59:22 -0300 Subject: [ticket/14732] Remove references from tests PHPBB3-14732 --- tests/bbcode/parser_test.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests') diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 5677e49636..4e85737c4f 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -65,11 +65,6 @@ class phpbb_bbcode_parser_test extends \phpbb_test_case '[code]unparsed code[/code]', '[code:]unparsed code[/code:]', ), - array( - 'Test default bbcodes: simple php code', - '[code=php]unparsed code[/code]', - '[code=php:]unparsed code[/code:]', - ), array( 'Test default bbcodes: simple list', '[list]no item[/list]', -- cgit v1.2.1 From f39e5424f1f8585a7ffad9ad068f3ae14fcd2375 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 16 Apr 2017 16:36:13 +0200 Subject: [ticket/14938] Add missing language class to extension manager mock PHPBB3-14938 --- tests/mock/extension_manager.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php index 4e48278bbd..0d6d110647 100644 --- a/tests/mock/extension_manager.php +++ b/tests/mock/extension_manager.php @@ -15,12 +15,15 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager { public function __construct($phpbb_root_path, $extensions = array(), $container = null) { + global $phpEx; + + $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = 'php'; $this->extensions = $extensions; $this->filesystem = new \phpbb\filesystem\filesystem(); $this->container = $container; $this->config = new \phpbb\config\config(array()); - $this->user = new \phpbb\user('\phpbb\datetime'); + $this->user = new \phpbb\user($lang,'\phpbb\datetime'); } } -- cgit v1.2.1 From 1ea114ca20bd4613420284d7bfc4c92ab0a817b4 Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 11 Jan 2017 23:53:12 +0700 Subject: [ticket/14990] Fix event name, email parsing, installer and dispatcher calls PHPBB3-14990 --- tests/email/email_parsing_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php index 351a38514f..a8366cf076 100644 --- a/tests/email/email_parsing_test.php +++ b/tests/email/email_parsing_test.php @@ -86,7 +86,8 @@ class phpbb_email_parsing_test extends phpbb_test_case 'debug' => false, 'auto_reload' => true, 'autoescape' => false, - ) + ), + new \phpbb\event\dispatcher($phpbb_container) ); $twig->addExtension($twig_extension); $phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); -- cgit v1.2.1 From fcc8e155ec309669bebbf6e0370cecfe64c95193 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 16 Apr 2017 20:53:59 +0700 Subject: [ticket/14990] Move dispatcher object to the front of the options array PHPBB3-14990 --- tests/controller/common_helper_route.php | 1 + tests/email/email_parsing_test.php | 4 ++-- tests/extension/metadata_manager_test.php | 3 +-- tests/template/template_allfolder_test.php | 1 + tests/template/template_events_test.php | 1 + tests/template/template_includecss_test.php | 1 + tests/template/template_test_case.php | 1 + tests/template/template_test_case_with_tree.php | 1 + 8 files changed, 9 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 367c15a667..ea2bc042b1 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -114,6 +114,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $cache_path, null, $loader, + new \phpbb\event\dispatcher($container), array( 'cache' => false, 'debug' => false, diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php index a8366cf076..8fdfe3035e 100644 --- a/tests/email/email_parsing_test.php +++ b/tests/email/email_parsing_test.php @@ -81,13 +81,13 @@ class phpbb_email_parsing_test extends phpbb_test_case $cache_path, null, new \phpbb\template\twig\loader($filesystem, ''), + new \phpbb\event\dispatcher($phpbb_container), array( 'cache' => false, 'debug' => false, 'auto_reload' => true, 'autoescape' => false, - ), - new \phpbb\event\dispatcher($phpbb_container) + ) ); $twig->addExtension($twig_extension); $phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 8ef41f3673..533da68c57 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -70,6 +70,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $cache_path, null, $loader, + new \phpbb\event\dispatcher($container), array( 'cache' => false, 'debug' => false, @@ -78,8 +79,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case ) ); - $container = new phpbb_mock_container_builder(); - $this->migrator = new \phpbb\db\migrator( $container, $this->config, diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php index 9a0a42fabd..63a6ef08ea 100644 --- a/tests/template/template_allfolder_test.php +++ b/tests/template/template_allfolder_test.php @@ -67,6 +67,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case $cache_path, $this->extension_manager, $loader, + new \phpbb\event\dispatcher($container), array( 'cache' => false, 'debug' => false, diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index e245c90aee..3a93c91e11 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -161,6 +161,7 @@ Zeta test event in all', $cache_path, $this->extension_manager, $loader, + new \phpbb\event\dispatcher($container), array( 'cache' => false, 'debug' => false, diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index 764652c9c2..bc871aa612 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -53,6 +53,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te $cache_path, null, $loader, + new \phpbb\event\dispatcher($container), array( 'cache' => false, 'debug' => false, diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index e52d3b76dd..8adbafb1b2 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -105,6 +105,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $cache_path, null, $loader, + new \phpbb\event\dispatcher($container), array( 'cache' => false, 'debug' => false, diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index ff35d16120..75e3918f44 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -48,6 +48,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $cache_path, null, $loader, + new \phpbb\event\dispatcher($container), array( 'cache' => false, 'debug' => false, -- cgit v1.2.1 From ddcd0f243791ea64373b53f077689df0c46c713a Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 7 Apr 2017 08:49:56 +0200 Subject: [ticket/15163] Escape curly braces in smilies HTML attributes PHPBB3-15163 --- .../text_processing/tickets_data/PHPBB3-15163.html | 1 + .../text_processing/tickets_data/PHPBB3-15163.txt | 1 + .../text_processing/tickets_data/PHPBB3-15163.xml | 23 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-15163.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-15163.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-15163.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-15163.html b/tests/text_processing/tickets_data/PHPBB3-15163.html new file mode 100644 index 0000000000..a1af10187c --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15163.html @@ -0,0 +1 @@ +--{E \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15163.txt b/tests/text_processing/tickets_data/PHPBB3-15163.txt new file mode 100644 index 0000000000..126402d66a --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15163.txt @@ -0,0 +1 @@ +--{E \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15163.xml b/tests/text_processing/tickets_data/PHPBB3-15163.xml new file mode 100644 index 0000000000..f3e04c230f --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15163.xml @@ -0,0 +1,23 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 1 + --{E + --{E + icon_lol.gif + 15 + 17 + 22 + 1 + +
            +
            -- cgit v1.2.1 From 9a5714071e18322f5842c48bb30c850c49abacc9 Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 8 May 2017 17:29:24 +0700 Subject: [ticket/15222] Fix a typo in generate_text_for_display_test.php PHPBB3-15222 --- tests/text_processing/generate_text_for_display_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index b8b5b18561..9c7152a008 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -100,7 +100,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $renderer->set_viewcensors(false); $this->assertSame('apple', $renderer->render($original)); - $this->assertSame('banana', generate_text_for_display($original, '', '', 0, truee)); + $this->assertSame('banana', generate_text_for_display($original, '', '', 0, true)); $this->assertSame('apple', $renderer->render($original), 'The original setting was not restored'); } -- cgit v1.2.1 From 60d6667eb4c5ad8a02d67dea62bc2d5b9553f958 Mon Sep 17 00:00:00 2001 From: javiexin Date: Sun, 21 May 2017 18:18:59 +0200 Subject: [ticket/15068] Add template vars retrieval from the template object Added tests. PHPBB3-15068 --- tests/template/template_test.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 0bbfe3848d..ad36954049 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -445,6 +445,37 @@ class phpbb_template_template_test extends phpbb_template_template_test_case $this->assertEquals($expecting, $this->display('append_var')); } + public function test_retrieve_data() + { + $this->template->set_filenames(array('test' => 'loop_nested.html')); + + $this->template->assign_var('TEST_MORE', false); + + // @todo Change this + $this->template->assign_vars(array('ONE' => true, 'TWO' => 'two', 'THREE' => 3)); + $this->template->assign_block_vars('outer', array('POSITION' => 'O1')); + $this->template->assign_block_vars('outer.middle', array('POSITION' => 'O1M1')); + $this->template->assign_block_vars('outer', array('POSITION' => 'O2')); + $this->template->assign_block_vars('outer.middle', array('POSITION' => 'O2M1')); + $this->template->assign_block_vars('outer.middle', array('POSITION' => 'O2M2')); + $this->template->assign_block_vars('outer', array('POSITION' => 'O3')); + $this->template->assign_block_vars('outer.middle', array('POSITION' => 'O3M1')); + $this->template->assign_block_vars('outer.middle', array('POSITION' => 'O3M2', 'ONE' => true, 'TWO' => 'two', 'THREE' => 3)); + $this->template->assign_block_vars('outer.middle', array('POSITION' => 'O3M3')); + + $expect = 'outer - 0middle - 0outer - 1middle - 0middle - 1outer - 2middle - 0middle - 1middle - 2'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification'); + + $this->assertEquals(true, $this->template->retrieve_var('ONE'), 'Retrieve a single value from the template'); + $this->assertEquals(null, $this->template->retrieve_var('FOUR'), 'Retrieve a non_existent value from the template'); + $this->assertEquals(array('TWO' => 'two', 'THREE' => 3, 'FOUR' => null), $this->template->retrieve_vars(array('TWO','THREE', 'FOUR')), 'Retrieve several variables from the template'); + + $this->assertEquals(array('POSITION' => 'O3', 'SIZE' => null), $this->template->retrieve_block_vars('outer', array('POSITION', 'SIZE')), 'Retrieve vars from a block in the template'); + $this->assertEquals(array('POSITION' => 'O2M1'), $this->template->retrieve_block_vars('outer[1].middle[0]', array('POSITION')), 'Retrieve single var from a nested indexed block in the template'); + $this->assertEquals(array('S_ROW_NUM' => 2), $this->template->retrieve_block_vars('outer.middle', array('S_ROW_NUM')), 'Retrieve automatic var from a block in the template'); + $this->assertEquals(array('POSITION' => 'O3M2', 'ONE' => true, 'TWO' => 'two', 'THREE' => 3), $this->template->retrieve_block_vars('outer[2].middle[1]', array()), 'Retrieve all vars from a block in the template'); + } + public function test_php() { global $phpbb_root_path; -- cgit v1.2.1 From 7f408e4b4184e4c850156090e648fc120985c975 Mon Sep 17 00:00:00 2001 From: v12mike Date: Mon, 26 Jun 2017 12:43:23 +0100 Subject: [PHPBB3-15247] Add support for php v7 APCu cache API Add new cache driver apcu.php (based closely on existing APC cache driver) Add new unit test apcu_driver_test.php for the new driver Update RUNNING_TESTS.md to clarify requirements for apc, apcu and apc_bc extensions and add a couple of general hints to RUNNING_TESTS.md PHPBB3-15247 --- tests/RUNNING_TESTS.md | 12 ++++++++- tests/cache/apcu_driver_test.php | 58 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/cache/apcu_driver_test.php (limited to 'tests') diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md index b082197166..c9941d61e5 100644 --- a/tests/RUNNING_TESTS.md +++ b/tests/RUNNING_TESTS.md @@ -30,7 +30,9 @@ Some of the functionality in phpBB and/or the test suite uses additional PHP extensions. If these extensions are not loaded, respective tests will be skipped: -- apc (APC cache driver) +- apc (APC cache driver, php5 only) +- apcu (APCu cache driver - native API, php7+) +- apcu_bc, apcu (APCu cache driver - APC API, php7+) - bz2 (compress tests) - mysql, pdo_mysql (MySQL database driver) - mysqli, pdo_mysql (MySQLi database driver) @@ -117,6 +119,14 @@ directory (above phpBB): $ phpBB/vendor/bin/phpunit +To generate an xml log file, run: + + $ phpBB/vendor/bin/phpunit --log-junit tests/tmp/log/log.xml + +If you are getting a memory exhausted error after running a few tests, you can try running: + + $ phpBB/vendor/bin/phpunit -d memory_limit=2048M + Slow tests -------------- diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php new file mode 100644 index 0000000000..9de1d82a15 --- /dev/null +++ b/tests/cache/apcu_driver_test.php @@ -0,0 +1,58 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +// Important: apc.enable_cli=1 must be in php.ini. +// http://forums.devshed.com/php-development-5/apc-problem-561290.html +// http://php.net/manual/en/apc.configuration.php + +require_once dirname(__FILE__) . '/common_test_case.php'; + +class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case +{ + protected static $config; + protected $driver; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + static public function setUpBeforeClass() + { + if (!extension_loaded('apcu')) + { + self::markTestSkipped('APCu extension is not loaded'); + } + + $php_ini = new \bantu\IniGetWrapper\IniGetWrapper; + + if (!$php_ini->getBool('apc.enabled')) + { + self::markTestSkipped('APCu is not enabled. Make sure apc.enabled=1 in php.ini'); + } + + if (PHP_SAPI == 'cli' && !$php_ini->getBool('apc.enable_cli')) + { + self::markTestSkipped('APCu is not enabled for CLI. Set apc.enable_cli=1 in php.ini'); + } + } + + protected function setUp() + { + parent::setUp(); + + $this->driver = new \phpbb\cache\driver\apcu; + + $this->driver->purge(); + } +} -- cgit v1.2.1 From 329e5c5e052588b0f22c9046b9fbc19c9e551c81 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 3 Jul 2017 16:06:50 +0200 Subject: [ticket/15261] Fix censoring HTML tags PHPBB3-15261 --- tests/text_processing/tickets_data/PHPBB3-15261.html | 1 + tests/text_processing/tickets_data/PHPBB3-15261.txt | 1 + tests/text_processing/tickets_data/PHPBB3-15261.xml | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-15261.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-15261.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-15261.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-15261.html b/tests/text_processing/tickets_data/PHPBB3-15261.html new file mode 100644 index 0000000000..b563052b47 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15261.html @@ -0,0 +1 @@ +foo **** baz \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15261.txt b/tests/text_processing/tickets_data/PHPBB3-15261.txt new file mode 100644 index 0000000000..a8c4a05c10 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15261.txt @@ -0,0 +1 @@ +foo baz \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15261.xml b/tests/text_processing/tickets_data/PHPBB3-15261.xml new file mode 100644 index 0000000000..c0d0f395a1 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15261.xml @@ -0,0 +1,14 @@ + + + + word_id + word + replacement + + + 1 + <*> + **** + +
            +
            -- cgit v1.2.1 From 24bde10028a1a7d8d479e2a381bec047485b4273 Mon Sep 17 00:00:00 2001 From: lavigor Date: Thu, 6 Jul 2017 02:37:35 +0300 Subject: [ticket/15259] Fatal error on SQLite/Oracle database update Add a test. PHPBB3-15259 --- tests/dbal/db_tools_test.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests') diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index b884b4ab95..f9243e7266 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -421,4 +421,41 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2'))); $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282')); } + + public function test_create_index_with_long_name() + { + // This constant is being used for checking table prefix. + $table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config) + + if (strlen($table_prefix) > 20) + { + $this->markTestIncomplete('The table prefix length is too long for proper testing of index shortening function.'); + } + + $table_suffix = str_repeat('a', 25 - strlen($table_prefix)); + $table_name = $table_prefix . $table_suffix; + + $this->tools->sql_create_table($table_name, $this->table_data); + + // Index name and table suffix and table prefix have > 30 chars in total. + // Index name and table suffix have <= 30 chars in total. + $long_index_name = str_repeat('i', 30 - strlen($table_suffix)); + $this->assertFalse($this->tools->sql_index_exists($table_name, $long_index_name)); + $this->assertTrue($this->tools->sql_create_index($table_name, $long_index_name, array('c_timestamp'))); + $this->assertTrue($this->tools->sql_index_exists($table_name, $long_index_name)); + + // Index name and table suffix have > 30 chars in total. + $very_long_index_name = str_repeat('i', 30); + $this->assertFalse($this->tools->sql_index_exists($table_name, $very_long_index_name)); + $this->assertTrue($this->tools->sql_create_index($table_name, $very_long_index_name, array('c_timestamp'))); + $this->assertTrue($this->tools->sql_index_exists($table_name, $very_long_index_name)); + + $this->tools->sql_table_drop($table_name); + + // Index name has > 30 chars - that should not be possible. + $too_long_index_name = str_repeat('i', 31); + $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', $too_long_index_name)); + $this->setExpectedTriggerError(E_USER_ERROR); + $this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp')); + } } -- cgit v1.2.1 From 5b21903e66731d85e12632fe38651301a34a8240 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 16 Jul 2017 17:09:06 +0200 Subject: [ticket/security/210] Fix tests for 3.2.x SECURITY-210 --- tests/avatar/manager_test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 3c872a7683..9e826a3a59 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -424,11 +424,10 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case 'avatar_remote_height' => $height, )); - $user = new \phpbb\user('\phpbb\datetime'); $row = array(); $error = array(); - $return = $remote_avatar->process_form($request, null, $user, $row, $error); + $return = $remote_avatar->process_form($request, null, $this->user, $row, $error); if (count($expected_error) > 0) { $this->assertFalse($return); -- cgit v1.2.1 From 882a3c383103802c491404032c5d267e4f5271a0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 22 Jul 2017 17:26:41 +0200 Subject: [ticket/security/211] Make sure website URL only uses http & https schemes SECURITY-211 --- tests/profilefields/type_url_test.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php index cc37f04f30..aaba227348 100644 --- a/tests/profilefields/type_url_test.php +++ b/tests/profilefields/type_url_test.php @@ -89,6 +89,19 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case 'FIELD_INVALID_URL-field', 'Field should reject invalid URL having multi value parameters', ), + // Not allowed schemes + array( + 'ftp://example.com/', + array(), + 'FIELD_INVALID_URL-field', + 'Field should reject invalid URL having multi value parameters', + ), + array( + 'javascript://alert.com', + array(), + 'FIELD_INVALID_URL-field', + 'Field should reject invalid URL having multi value parameters', + ), // IDN url type profilefields array( -- cgit v1.2.1 From 91f9050a70d95a472daf9f6fa15187c195f05909 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 23 Jul 2017 11:18:07 +0200 Subject: [ticket/security/211] Extend tests for profile field values SECURITY-211 --- tests/profilefields/type_string_test.php | 12 +++++++ tests/profilefields/type_url_test.php | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) (limited to 'tests') diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php index 0417afbfab..43f88c01ae 100644 --- a/tests/profilefields/type_string_test.php +++ b/tests/profilefields/type_string_test.php @@ -270,6 +270,18 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case null, 'Field should simply output null for empty vlaue', ), + array( + 'http://foobar.com', + array('field_show_novalue' => false), + 'http://foobar.com', + 'Field should output the given value but not make it clickable', + ), + array( + 'javascript://foobar.com', + array('field_show_novalue' => true), + 'javascript://foobar.com', + 'Field should output the given value but not make it clickable', + ), ); } diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php index aaba227348..af17cc125a 100644 --- a/tests/profilefields/type_url_test.php +++ b/tests/profilefields/type_url_test.php @@ -12,6 +12,8 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_profilefield_type_url_test extends phpbb_test_case { @@ -26,6 +28,9 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case */ public function setUp() { + global $request, $user, $cache; + + $cache = new phpbb_mock_cache; $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); $user->expects($this->any()) ->method('lang') @@ -175,6 +180,55 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case ); } + public function profile_value_data() + { + return array( + array( + 'http://foobar.com', + array('field_show_novalue' => true), + 'foobar.com', + 'Field should output the given value', + ), + array( + 'http://foobar.com', + array('field_show_novalue' => false), + 'foobar.com', + 'Field should output the given value', + ), + array( + 'test', + array('field_show_novalue' => true), + null, + 'Field should output nothing for empty value', + ), + array( + 'test', + array('field_show_novalue' => false), + null, + 'Field should simply output null for empty value', + ), + array( + 'javascript://foobar.com', + array('field_show_novalue' => true), + null, + 'Field should output nothing for empty value', + ), + ); + } + + + /** + * @dataProvider profile_value_data + */ + public function test_get_profile_value($value, $field_options, $expected, $description) + { + $field_options = array_merge($this->field_options, $field_options); + + $result = $this->cp->get_profile_value($value, $field_options); + + $this->assertSame($expected, $result, $description); + } + /** * @dataProvider profile_value_raw_data */ -- cgit v1.2.1 From 0aba1faa0803af6013c9ac2071e87f117e9c4835 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 26 Jul 2017 21:14:05 +0200 Subject: [ticket/security/211] Do not match javascript URIs with URL regexes SECURITY-211 --- tests/functions/make_clickable_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php index 63beeb06b2..2cdefe689d 100644 --- a/tests/functions/make_clickable_test.php +++ b/tests/functions/make_clickable_test.php @@ -55,6 +55,10 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case 'http://testhost/viewtopic.php?t=1', 'viewtopic.php?t=1' ), + array( + 'javascript://testhost/viewtopic.php?t=1', + 'javascript://testhost/viewtopic.php?t=1' + ), array( 'email@domain.com', 'email@domain.com' @@ -92,6 +96,10 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case 'ftp://ftp.täst.de/', 'ftp://ftp.täst.de/' ), + array( + 'javascript://täst.de/', + 'javascript://täst.de/' + ), array( 'sip://bantu@täst.de', 'sip://bantu@täst.de' -- cgit v1.2.1 From f7d387f93c421e93ef13375bd5e0fb408e921598 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 27 Jul 2017 18:23:43 +0200 Subject: [ticket/security/211] Add test for line breaks in URL SECURITY-211 --- tests/functions/make_clickable_test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php index 2cdefe689d..2bb7721d21 100644 --- a/tests/functions/make_clickable_test.php +++ b/tests/functions/make_clickable_test.php @@ -59,6 +59,10 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case 'javascript://testhost/viewtopic.php?t=1', 'javascript://testhost/viewtopic.php?t=1' ), + array( + "java\nscri\npt://testhost/viewtopic.php?t=1", + "java\nscri\npt://testhost/viewtopic.php?t=1" + ), array( 'email@domain.com', 'email@domain.com' -- cgit v1.2.1 From 342a7cbd55829283663ad6ba29f924eeb53fca38 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Aug 2017 22:20:33 +0200 Subject: [ticket/security/211] Allow make_clickable() again after change to regex SECURITY-211 --- tests/profilefields/type_string_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php index 43f88c01ae..9709b48470 100644 --- a/tests/profilefields/type_string_test.php +++ b/tests/profilefields/type_string_test.php @@ -273,8 +273,8 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case array( 'http://foobar.com', array('field_show_novalue' => false), - 'http://foobar.com', - 'Field should output the given value but not make it clickable', + 'foobar.com', + 'Field should output the given value and make it clickable', ), array( 'javascript://foobar.com', -- cgit v1.2.1 From a86cff313fd573745c96d822ce6ac0b83d01a8bb Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 12 Aug 2017 17:48:47 +0700 Subject: [ticket/15318] Fix tests PHPBB3-15318 --- tests/text_processing/generate_text_for_display_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index 9c7152a008..468c902347 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -29,7 +29,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca */ public function test_legacy($original, $expected, $uid = '', $bitfield = '', $flags = 0, $censor_text = true) { - global $cache, $user; + global $auth, $cache, $config, $user; global $phpbb_root_path, $phpEx; @@ -63,7 +63,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca public function test_censor_is_restored() { - global $phpbb_container; + global $auth, $user, $config, $phpbb_container; $phpbb_container = new phpbb_mock_container_builder; @@ -109,7 +109,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca */ public function test_text_formatter($original, $expected, $censor_text = true, $setup = null) { - global $phpbb_container; + global $auth, $user, $config, $phpbb_container; $phpbb_container = new phpbb_mock_container_builder; -- cgit v1.2.1 From de6a0a7dc1e0e52f05e7b5ced085ef8f17650ff1 Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 12 Aug 2017 19:46:02 +0700 Subject: [ticket/15318] Add UCP censoring switch testing PHPBB3-15318 --- tests/text_processing/generate_text_for_display_test.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index 468c902347..86bc803c98 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -72,7 +72,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $user->optionset('viewcensors', false); + // Do not ignore word censoring by user (switch censoring on in UCP) + $user->optionset('viewcensors', true); $config = new \phpbb\config\config(array('allow_nocensors' => true)); @@ -102,6 +103,14 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $this->assertSame('apple', $renderer->render($original)); $this->assertSame('banana', generate_text_for_display($original, '', '', 0, true)); $this->assertSame('apple', $renderer->render($original), 'The original setting was not restored'); + + // Test user option switch to ignore censoring + $renderer->set_viewcensors(true); + // 1st: censoring is still on in UCP + $this->assertSame('banana', generate_text_for_display($original, '', '', 0, true)); + // 2nd: switch censoring off in UCP + $user->optionset('viewcensors', false); + $this->assertSame('apple', generate_text_for_display($original, '', '', 0, true)); } /** -- cgit v1.2.1 From e67d2ae3b9d71bfd9aa82ec250c13d1186b1e280 Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 15 Aug 2017 16:57:30 +0700 Subject: [ticket/15323] Run s9e configurator tests on twigified bbcode.html PHPBB3-15323 --- tests/text_formatter/s9e/factory_test.php | 25 ++++++-- .../fixtures/styles/prosilver/template/bbcode.html | 75 ++++++++++++++++++++++ 2 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 tests/text_formatter/s9e/fixtures/styles/prosilver/template/bbcode.html (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 3d3ea8b794..82b1b0043b 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -32,9 +32,15 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case return __DIR__ . '/../../tmp/'; } - public function get_factory() + public function get_factory($styles_path = null) { global $config, $phpbb_root_path, $request, $user; + + if (!isset($styles_path)) + { + $styles_path = $phpbb_root_path . 'styles/'; + } + $this->cache = new phpbb_mock_cache; $dal = new \phpbb\textformatter\data_access( $this->new_dbal(), @@ -42,7 +48,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case 'phpbb_smilies', 'phpbb_styles', 'phpbb_words', - $phpbb_root_path . 'styles/' + $styles_path ); $factory = new \phpbb\textformatter\s9e\factory( $dal, @@ -68,10 +74,8 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case return $factory; } - public function test_get_configurator() + public function run_configurator_assertions($configurator) { - $configurator = $this->get_factory()->get_configurator(); - $this->assertInstanceOf('s9e\\TextFormatter\\Configurator', $configurator); $this->assertTrue(isset($configurator->plugins['Autoemail'])); @@ -97,6 +101,17 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $this->assertTrue(isset($configurator->Emoticons[':D'])); } + public function test_get_configurator() + { + $configurator = $this->get_factory()->get_configurator(); + $this->run_configurator_assertions($configurator); + + // Test with twigified bbcode.html + $configurator = $this->get_factory(__DIR__ . '/fixtures/styles/')->get_configurator(); + $this->run_configurator_assertions($configurator); + + } + public function test_regenerate() { extract($this->get_factory()->regenerate()); diff --git a/tests/text_formatter/s9e/fixtures/styles/prosilver/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/prosilver/template/bbcode.html new file mode 100644 index 0000000000..22be395499 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/styles/prosilver/template/bbcode.html @@ -0,0 +1,75 @@ +{% for ulist_open in loops.ulist_open %}
              {% endfor %} +{% for ulist_open_default in loops.ulist_open_default %}
                {% endfor %} +{% for ulist_close in loops.ulist_close %}
              {% endfor %} + +{% for olist_open in loops.olist_open %}
                {% endfor %} +{% for olist_close in loops.olist_close %}
              {% endfor %} + +{% for listitem in loops.listitem %}
            • {% endfor %} +{% for listitem_close in loops.listitem_close %}
            • {% endfor %} + +{% for quote_username_open in loops.quote_username_open %}
              {{ USERNAME }} {{ lang('WROTE') }}{{ lang('COLON') }}{% endfor %} +{% for quote_open in loops.quote_open %}
              {% endfor %} +{% for quote_close in loops.quote_close %}
              {% endfor %} +{% for quote_extended in loops.quote_extended %} +
              + + uncited + +
              + + + + + + + + + + + + + + + + + + + + + +
              +
              +
              +
              + +
              +
              +{% endfor %} + +{% for code_open in loops.code_open %}

              {{ lang('CODE') }}{{ lang('COLON') }} {{ lang('SELECT_ALL_CODE') }}

              {% endfor %}
              +{% for code_close in loops.code_close %}
              {% endfor %} + +{% for inline_attachment_open in loops.inline_attachment_open %}
              {% endfor %} +{% for inline_attachment_close in loops.inline_attachment_close %}
              {% endfor %} + +{% for b_open in loops.b_open %}{% endfor %} +{% for b_close in loops.b_close %}{% endfor %} + +{% for u_open in loops.u_open %}{% endfor %} +{% for u_close in loops.u_close %}{% endfor %} + +{% for i_open in loops.i_open %}{% endfor %} +{% for i_close in loops.i_close %}{% endfor %} + +{% for color in loops.color %}{{ TEXT }}{% endfor %} + +{% for size in loops.size %}{{ TEXT }}{% endfor %} + +{% for img in loops.img %}{{ lang('IMAGE') }}{% endfor %} + +{% for url in loops.url %}{{ DESCRIPTION }}{% endfor %} + +{% for email in loops.email %}{{ DESCRIPTION }}{% endfor %} + +{% for flash in loops.flash %}{% endfor %} -- cgit v1.2.1 From 837dc9b3a737e68d12eef033572894a81a2c0de7 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 6 Sep 2017 03:35:26 +0200 Subject: [ticket/15348] Ignore smilies that are immediately followed by a word PHPBB3-15348 --- .../text_processing/tickets_data/PHPBB3-15348.html | 1 + .../text_processing/tickets_data/PHPBB3-15348.txt | 1 + .../text_processing/tickets_data/PHPBB3-15348.xml | 33 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-15348.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-15348.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-15348.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.html b/tests/text_processing/tickets_data/PHPBB3-15348.html new file mode 100644 index 0000000000..e65925ec28 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15348.html @@ -0,0 +1 @@ +:o k: :ok: \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.txt b/tests/text_processing/tickets_data/PHPBB3-15348.txt new file mode 100644 index 0000000000..d6b971702c --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15348.txt @@ -0,0 +1 @@ +:o k: :ok: \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.xml b/tests/text_processing/tickets_data/PHPBB3-15348.xml new file mode 100644 index 0000000000..0c88c8824f --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15348.xml @@ -0,0 +1,33 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 13 + :o + First half of :ok: + icon_e_surprised.gif + 15 + 17 + 14 + 1 + + + 99 + k: + Second half of :ok: + icon_lol.gif + 15 + 17 + 22 + 1 + +
              +
              -- cgit v1.2.1 From 4b1ec6abb7b2d2daa320ac5e2872e055bc5b07d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Fri, 8 Sep 2017 10:59:47 +0200 Subject: [ticket/15201] Fix tests PHPBB3-15201 --- tests/test_framework/phpbb_functional_test_case.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index eb56049515..c9943c4302 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -572,6 +572,9 @@ class phpbb_functional_test_case extends phpbb_test_case $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; + // Prevent new user to have an invalid style + $config['default_style'] = 1; + // Required by user_add global $db, $cache, $phpbb_dispatcher, $phpbb_container; $db = $this->get_db(); -- cgit v1.2.1 From c368d170cf09d06ff63249d4405323e6108d90bb Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 8 Sep 2017 10:45:22 +0200 Subject: [ticket/15351] Makes confirm_works in a router context (app.php) PHPBB3-15351 --- tests/session/extract_page_test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index 88eb7b2c1a..f8aa3d27a5 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -136,6 +136,22 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case 'forum' => 0, ), ), + array( + './community', + '/app.php', + '', + '/', + '/kb', + array( + 'page_name' => 'app.php/kb', + 'page_dir' => '..', + 'query_string' => '', + 'script_path' => '/', + 'root_script_path' => '/community/', + 'page' => '../app.php/kb', + 'forum' => 0, + ), + ), ); } -- cgit v1.2.1 From f6b8f69e7ec51841785bc598a5e0533d946c1def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 10 Sep 2017 11:19:40 +0200 Subject: [ticket/15172] Add symfony_request to some tests PHPBB3-15172 --- tests/bbcode/parser_test.php | 3 ++- tests/bbcode/url_bbcode_test.php | 3 ++- tests/functions/make_clickable_email_test.php | 5 +++-- tests/functions/make_clickable_test.php | 3 ++- tests/text_formatter/s9e/factory_test.php | 6 ++++-- 5 files changed, 13 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 4e85737c4f..b569d371f1 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -249,9 +249,10 @@ class phpbb_bbcode_parser_test extends \phpbb_test_case $this->markTestIncomplete($incomplete); } - global $user, $request; + global $user, $request, $symfony_request; $user = new phpbb_mock_user; $request = new phpbb_mock_request; + $symfony_request = new \phpbb\symfony_request($request); $bbcode = new bbcode_firstpass(); $bbcode->message = $message; diff --git a/tests/bbcode/url_bbcode_test.php b/tests/bbcode/url_bbcode_test.php index 3f8ad6022f..f95970a6bb 100644 --- a/tests/bbcode/url_bbcode_test.php +++ b/tests/bbcode/url_bbcode_test.php @@ -52,9 +52,10 @@ class phpbb_url_bbcode_test extends phpbb_test_case */ public function test_url($description, $message, $expected) { - global $user, $request; + global $user, $request, $symfony_request; $user = new phpbb_mock_user; $request = new phpbb_mock_request; + $symfony_request = new \phpbb\symfony_request($request); $bbcode = new bbcode_firstpass(); $bbcode->message = $message; diff --git a/tests/functions/make_clickable_email_test.php b/tests/functions/make_clickable_email_test.php index f32b4339a8..d481bde80d 100644 --- a/tests/functions/make_clickable_email_test.php +++ b/tests/functions/make_clickable_email_test.php @@ -17,9 +17,10 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case { parent::setUp(); - global $config, $user, $request; + global $config, $user, $request, $symfony_request; $user = new phpbb_mock_user(); $request = new phpbb_mock_request(); + $symfony_request = new \phpbb\symfony_request($request); } /** @@ -168,7 +169,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case array('abc,def@example.com'), // invalid character , array('abcdef@example.com', 'abc>def@example.com'), // invalid character > - + // http://fightingforalostcause.net/misc/2006/compare-email-regex.php array('missingDomain@.com'), array('@missingLocal.org'), diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php index 48fc2c19fb..a351a6d527 100644 --- a/tests/functions/make_clickable_test.php +++ b/tests/functions/make_clickable_test.php @@ -146,9 +146,10 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case { parent::setUp(); - global $config, $user, $request; + global $config, $user, $request, $symfony_request; $user = new phpbb_mock_user(); $request = new phpbb_mock_request(); + $symfony_request = new \phpbb\symfony_request($request); } /** diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 82b1b0043b..fd9b4e4c09 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -34,7 +34,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case public function get_factory($styles_path = null) { - global $config, $phpbb_root_path, $request, $user; + global $config, $phpbb_root_path, $request, $symfony_request, $user; if (!isset($styles_path)) { @@ -69,6 +69,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case 'server_protocol' => 'http://', )); $request = new phpbb_mock_request; + $symfony_request = new \phpbb\symfony_request($request); $user = new phpbb_mock_user; return $factory; @@ -152,7 +153,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case public function test_local_url() { - global $config, $user, $request; + global $config, $user, $request, $symfony_request; $config = new \phpbb\config\config(array( 'force_server_vars' => true, 'server_protocol' => 'http://', @@ -163,6 +164,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case )); $user = new phpbb_mock_user; $request = new phpbb_mock_request; + $symfony_request = new \phpbb\symfony_request($request); $fixture = __DIR__ . '/fixtures/local_url.xml'; $renderer = $this->get_test_case_helpers()->set_s9e_services(null, $fixture)->get('text_formatter.renderer'); -- cgit v1.2.1 From 27ae01c27a99b0f0674ad4f0e82f1b018365926d Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 22 Sep 2017 13:03:14 +0200 Subject: [ticket/15245] Fix images in feeds when accessing via app.php PHPBB3-15245 --- tests/feed/attachments_base_test.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php index dd432d13f5..f5c79bd6b4 100644 --- a/tests/feed/attachments_base_test.php +++ b/tests/feed/attachments_base_test.php @@ -31,13 +31,22 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case $this->filesystem = new \phpbb\filesystem(); $config = new \phpbb\config\config(array()); + $path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem\filesystem(), + $this->getMock('\phpbb\request\request'), + $phpbb_root_path, + 'php' + ); $user = new \phpbb\user( new \phpbb\language\language( new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx) ), '\phpbb\datetime' ); - $feed_helper = new \phpbb\feed\helper($config, $user, $phpbb_root_path, $phpEx); + $feed_helper = new \phpbb\feed\helper($config, $path_helper, $user, $phpbb_root_path, $phpEx); $db = $this->new_dbal(); $cache = new \phpbb_mock_cache(); $auth = new \phpbb\auth\auth(); -- cgit v1.2.1 From 4a7ead0239179d4257c074b755cd4a5f765a513b Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 22 Sep 2017 13:33:42 +0200 Subject: [ticket/15245] Remove unnecessary arguments and fix whitespace PHPBB3-15245 --- tests/feed/attachments_base_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php index f5c79bd6b4..2ee1cc16e7 100644 --- a/tests/feed/attachments_base_test.php +++ b/tests/feed/attachments_base_test.php @@ -35,7 +35,7 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), + $this->filesystem, $this->getMock('\phpbb\request\request'), $phpbb_root_path, 'php' @@ -46,7 +46,7 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case ), '\phpbb\datetime' ); - $feed_helper = new \phpbb\feed\helper($config, $path_helper, $user, $phpbb_root_path, $phpEx); + $feed_helper = new \phpbb\feed\helper($config, $path_helper, $user); $db = $this->new_dbal(); $cache = new \phpbb_mock_cache(); $auth = new \phpbb\auth\auth(); -- cgit v1.2.1 From 886089d28e45eab8003a7e9ba2ac0132e186cc29 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 1 Oct 2017 19:14:12 +0200 Subject: [ticket/15245] Fix tests PHPBB3-15245 --- tests/feed/attachments_base_test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php index 2ee1cc16e7..573218be42 100644 --- a/tests/feed/attachments_base_test.php +++ b/tests/feed/attachments_base_test.php @@ -46,7 +46,10 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case ), '\phpbb\datetime' ); - $feed_helper = new \phpbb\feed\helper($config, $path_helper, $user); + $container = new phpbb_mock_container_builder(); + $this->get_test_case_helpers()->set_s9e_services($container); + $container->set('feed.quote_helper', new \phpbb\feed\quote_helper($user, $phpbb_root_path, 'php')); + $feed_helper = new \phpbb\feed\helper($config, $container, $path_helper, $container->get('text_formatter.renderer'), $user); $db = $this->new_dbal(); $cache = new \phpbb_mock_cache(); $auth = new \phpbb\auth\auth(); -- cgit v1.2.1 From 6c04a6715c08c1e224aeea8c4889c0258a832524 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 4 Oct 2017 20:12:34 +0200 Subject: [ticket/15389] Match multiple events in dispatcher in php_exporter I've also improved some regular expressions PHPBB3-15389 --- tests/event/dispatcher_test.php | 16 ++++++++++++++++ tests/event/fixtures/event_migration.test | 30 ++++++++++++++++++++++++++++++ tests/event/php_exporter_test.php | 19 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 tests/event/fixtures/event_migration.test (limited to 'tests') diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php index 7bba5bf337..da28d24daa 100644 --- a/tests/event/dispatcher_test.php +++ b/tests/event/dispatcher_test.php @@ -29,5 +29,21 @@ class phpbb_event_dispatcher_test extends phpbb_test_case $result = $dispatcher->trigger_event('core.test_event', compact($vars)); $this->assertSame(array('foo' => 'foo2', 'bar' => 'bar2'), $result); + + // Test migrating events + $dispatcher->addListener('core.foo_br', function(\phpbb\event\data $event) { + $event['pi'] = '3.14159'; + }); + $dispatcher->addListener('core.foo_bar', function(\phpbb\event\data $event) { + $event['pi'] = '3.1'; + }); + + + $pi = '3'; + + $vars = array('pi'); + $result = $dispatcher->trigger_event(['core.foo_bar', 'core.foo_br'], compact($vars)); + + $this->assertSame(array('pi' => '3.14159'), $result); } } diff --git a/tests/event/fixtures/event_migration.test b/tests/event/fixtures/event_migration.test new file mode 100644 index 0000000000..b2df9f95df --- /dev/null +++ b/tests/event/fixtures/event_migration.test @@ -0,0 +1,30 @@ +trigger_event(['core.ucp_pm_view_message', 'core.ucp_pm_view_messsage'], compact($vars))); diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 692a57f93c..21dbb1e1d4 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -37,6 +37,18 @@ class phpbb_event_php_exporter_test extends phpbb_test_case ), ), ), + array( + 'event_migration.test', + array( + 'core.ucp_pm_view_message' => array( + 'event' => 'core.ucp_pm_view_message', + 'file' => 'event_migration.test', + 'arguments' => array('cp_row', 'folder', 'folder_id', 'id', 'message_row', 'mode', 'msg_data', 'msg_id', 'user_info'), + 'since' => '3.1.0-a1', + 'description' => 'Modify pm and sender data before it is assigned to the template', + ), + ), + ), array( 'extra_description.test', array( @@ -240,6 +252,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array("\t\$phpbb_dispatcher->dispatch('dispatch.one2.thr_ee4');", 'dispatch.one2.thr_ee4'), array("\$this->dispatcher->dispatch('dispatch.one2');", 'dispatch.one2'), array("\$phpbb_dispatcher->dispatch('dis_patch.one');", 'dis_patch.one'), + array("\$phpbb_dispatcher->dispatch(['dis_patch.one', 'dis_patch.one2']);", 'dis_patch.one'), + array("\$phpbb_dispatcher->dispatch(['dis_patch.one', 'dis_patch.one2', 'dis_patch.two3']);", 'dis_patch.one'), ); } @@ -259,6 +273,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array("\$phpbb_dispatcher->dispatch('');"), array("\$phpbb_dispatcher->dispatch('dispatch.2one');"), array("\$phpbb_dispatcher->dispatch('dispatch');"), + array("\$phpbb_dispatcher->dispatch(['dispatch.one']);"), + array("\$phpbb_dispatcher->dispatch(array('dispatch.one', 'dispatch.one2'));"), ); } @@ -279,6 +295,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array("\textract(\$phpbb_dispatcher->trigger_event('dispatch.one2.thr_ee4', compact(\$vars)));", 'dispatch.one2.thr_ee4'), array("extract(\$this->dispatcher->trigger_event('dispatch.one2', compact(\$vars)));", 'dispatch.one2'), array("extract(\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars)));", 'dis_patch.one'), + array("extract(\$phpbb_dispatcher->trigger_event(['dis_patch.one', 'dis_patch.one2'], compact(\$vars)));", 'dis_patch.one'), + array("extract(\$phpbb_dispatcher->trigger_event(['dis_patch.one', 'dis_patch.one2', 'dis_patch.two3'], compact(\$vars)));", 'dis_patch.one'), ); } @@ -301,6 +319,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', \$vars));"), array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$var)));"), array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$array)));"), + array("extract(\$phpbb_dispatcher->trigger_event(['dispatch.one'], compact(\$vars)));"), array("\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars));", 'dis_patch.one'), ); } -- cgit v1.2.1 From 490626d985b50a5f4bbb7d31931c68c5a28898ac Mon Sep 17 00:00:00 2001 From: kasimi Date: Sat, 14 Oct 2017 15:59:42 +0200 Subject: [ticket/15396] Added test for correct order of revert_schema() steps PHPBB3-15396 --- tests/dbal/migration/revert_table.php | 39 ++++++++++++++++ .../migration/revert_table_with_dependency.php | 52 ++++++++++++++++++++++ tests/dbal/migrator_test.php | 45 +++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 tests/dbal/migration/revert_table.php create mode 100644 tests/dbal/migration/revert_table_with_dependency.php (limited to 'tests') diff --git a/tests/dbal/migration/revert_table.php b/tests/dbal/migration/revert_table.php new file mode 100644 index 0000000000..162421be85 --- /dev/null +++ b/tests/dbal/migration/revert_table.php @@ -0,0 +1,39 @@ + +* @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_dbal_migration_revert_table extends \phpbb\db\migration\migration +{ + function update_schema() + { + return array( + 'add_tables' => array( + 'phpbb_foobar' => array( + 'COLUMNS' => array( + 'module_id' => array('UINT:3', NULL, 'auto_increment'), + 'bar_column' => array('UINT', 1), + ), + 'PRIMARY_KEY' => 'module_id', + ), + ), + ); + } + + function revert_schema() + { + return array( + 'drop_tables' => array( + 'phpbb_foobar', + ), + ); + } +} diff --git a/tests/dbal/migration/revert_table_with_dependency.php b/tests/dbal/migration/revert_table_with_dependency.php new file mode 100644 index 0000000000..f26ad076e6 --- /dev/null +++ b/tests/dbal/migration/revert_table_with_dependency.php @@ -0,0 +1,52 @@ + +* @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_dbal_migration_revert_table_with_dependency extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array('phpbb_dbal_migration_revert_table'); + } + + function update_schema() + { + return array( + 'add_columns' => array( + 'phpbb_foobar' => array( + 'baz_column' => array('UINT', 1), + ), + ), + 'drop_columns' => array( + 'phpbb_foobar' => array( + 'bar_column', + ), + ), + ); + } + + function revert_schema() + { + return array( + 'add_columns' => array( + 'phpbb_foobar' => array( + 'bar_column' => array('UINT', 1), + ), + ), + 'drop_columns' => array( + 'phpbb_foobar' => array( + 'baz_column', + ), + ), + ); + } +} diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index f7275a4bbe..372b2dbe1e 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -17,16 +17,26 @@ require_once dirname(__FILE__) . '/migration/if.php'; require_once dirname(__FILE__) . '/migration/recall.php'; require_once dirname(__FILE__) . '/migration/revert.php'; require_once dirname(__FILE__) . '/migration/revert_with_dependency.php'; +require_once dirname(__FILE__) . '/migration/revert_table.php'; +require_once dirname(__FILE__) . '/migration/revert_table_with_dependency.php'; require_once dirname(__FILE__) . '/migration/fail.php'; require_once dirname(__FILE__) . '/migration/installed.php'; require_once dirname(__FILE__) . '/migration/schema.php'; class phpbb_dbal_migrator_test extends phpbb_database_test_case { + /** @var \phpbb\db\driver\driver_interface */ protected $db; + + /** @var \phpbb\db\tools\tools_interface */ protected $db_tools; + + /** @var \phpbb\db\migrator */ protected $migrator; + /** @var \phpbb\config\config */ + protected $config; + public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator.xml'); @@ -241,6 +251,41 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->assertEquals(1, $migrator_test_revert_counter, 'Revert did call custom function again'); } + public function test_revert_table() + { + // Make sure there are no other migrations in the db, this could cause issues + $this->db->sql_query("DELETE FROM phpbb_migrations"); + $this->migrator->load_migration_state(); + + $this->migrator->set_migrations(array('phpbb_dbal_migration_revert_table', 'phpbb_dbal_migration_revert_table_with_dependency')); + + $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_table')); + $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_table_with_dependency')); + + // Install the migration first + while (!$this->migrator->finished()) + { + $this->migrator->update(); + } + + $this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_revert_table') !== false); + $this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_revert_table_with_dependency') !== false); + + $this->assertTrue($this->db_tools->sql_column_exists('phpbb_foobar', 'baz_column')); + $this->assertFalse($this->db_tools->sql_column_exists('phpbb_foobar', 'bar_column')); + + // Revert migrations + while ($this->migrator->migration_state('phpbb_dbal_migration_revert_table') !== false) + { + $this->migrator->revert('phpbb_dbal_migration_revert_table'); + } + + $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_table')); + $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_table_with_dependency')); + + $this->assertFalse($this->db_tools->sql_table_exists('phpbb_foobar')); + } + public function test_fail() { $this->migrator->set_migrations(array('phpbb_dbal_migration_fail')); -- cgit v1.2.1 From a0ba57dc4f39804cd52f69b6342c1e2f5f1acea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Mon, 2 Oct 2017 16:29:53 +0200 Subject: [ticket/15171] Fix test PHPBB3-15171 --- tests/functional/posting_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 8e6328d1d3..764376a945 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -235,7 +235,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case )); $crawler = self::submit($form); $this->assertContains( - 'My signature', + 'My signature', $crawler->filter('#preview .signature')->html() ); } -- cgit v1.2.1 From bf882826e48d4f29ca4c48ecb7d65cbdf459d5fb Mon Sep 17 00:00:00 2001 From: javiexin Date: Sun, 21 May 2017 14:57:40 +0200 Subject: [ticket/14994] Refactor template->assign_block_var Refactor assign_block_var to use the same block selection mechanism as is used in alter_block_array. This allows creating new blocks at any position in the template structure, not only on the last block. Allows selecting a block as outer[2].middle. Added tests. PHPBB3-14994 --- tests/template/template_test.php | 40 +++++++++++++++++++++++++++++++ tests/template/templates/loop_nested.html | 3 +++ 2 files changed, 43 insertions(+) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 9f2124418d..0f761abc76 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -998,6 +998,46 @@ EOT $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting by index out of bounds, ignored'); } + public function test_indexed_assign_block_vars() + { + $this->template->set_filenames(array('test' => 'loop_nested.html')); + + $this->template->assign_var('TEST_MORE', true); + + // @todo Change this + $this->template->assign_block_vars('outer', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + + $expect = 'outer - 0[outer|3]middle - 0[middle|1]outer - 1[outer|3]middle - 0[middle|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification'); + + $this->template->assign_block_vars('outer[0].middle', array('VARIABLE' => 'test')); + + $expect = 'outer - 0[outer|3]middle - 0[middle|2]middle - 1 - test[middle|2]outer - 1[outer|3]middle - 0[middle|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Inserting at the first outer block'); + + $this->template->assign_block_vars('outer[1].middle[0].inner', array()); + + $expect = 'outer - 0[outer|3]middle - 0[middle|2]middle - 1 - test[middle|2]outer - 1[outer|3]middle - 0[middle|2]inner - 0[inner|1]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Creating an inner block at the first middle block in the second outer block'); + + $this->template->assign_block_vars('outer[1].middle[0].inner', array()); + + $expect = 'outer - 0[outer|3]middle - 0[middle|2]middle - 1 - test[middle|2]outer - 1[outer|3]middle - 0[middle|2]inner - 0[inner|2]inner - 1[inner|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Inserting another inner block in the same place'); + + $this->template->assign_block_vars('outer.middle[1].inner', array('VARIABLE' => 'test')); + + $expect = 'outer - 0[outer|3]middle - 0[middle|2]middle - 1 - test[middle|2]outer - 1[outer|3]middle - 0[middle|2]inner - 0[inner|2]inner - 1[inner|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]inner - 0 - test[inner|1]middle - 2[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Inserting another inner block in the same place'); + } public function assign_block_vars_array_data() { diff --git a/tests/template/templates/loop_nested.html b/tests/template/templates/loop_nested.html index cf099ecc15..5763262781 100644 --- a/tests/template/templates/loop_nested.html +++ b/tests/template/templates/loop_nested.html @@ -2,5 +2,8 @@ outer - {outer.S_ROW_COUNT} - {outer.VARIABLE}[{outer.S_BLOCK_NAME}|{outer.S_NUM_ROWS}] middle - {outer.middle.S_ROW_COUNT} - {outer.middle.VARIABLE}[{outer.middle.S_BLOCK_NAME}|{outer.middle.S_NUM_ROWS}] + +inner - {outer.middle.inner.S_ROW_COUNT} - {outer.middle.inner.VARIABLE}[{outer.middle.inner.S_BLOCK_NAME}|{outer.middle.inner.S_NUM_ROWS}] + -- cgit v1.2.1 From 288def143cb8f594fd5c58d6a6dab07263a6c60e Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 7 Nov 2017 10:34:11 +0100 Subject: [ticket/15442] Allow unsafe HTML in bbcode.html PHPBB3-15442 --- tests/text_formatter/s9e/factory_test.php | 16 +++++++++ .../fixtures/styles/unsafe/template/bbcode.html | 40 ++++++++++++++++++++++ .../s9e/fixtures/unsafe_default_bbcodes.xml | 24 +++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html create mode 100644 tests/text_formatter/s9e/fixtures/unsafe_default_bbcodes.xml (limited to 'tests') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index fd9b4e4c09..d35330a975 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -247,6 +247,22 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $this->assertSame($expected, $renderer->render($parser->parse($original))); } + /** + * @testdox Accepts unsafe default BBCodes + */ + public function test_unsafe_default_bbcodes() + { + $fixture = __DIR__ . '/fixtures/unsafe_default_bbcodes.xml'; + $style_dir = __DIR__ . '/fixtures/styles/'; + $container = $this->get_test_case_helpers()->set_s9e_services(null, $fixture, $style_dir); + $parser = $container->get('text_formatter.parser'); + $renderer = $container->get('text_formatter.renderer'); + + $original = '[b]alert(1)[/b]'; + $expected = ''; + $this->assertSame($expected, $renderer->render($parser->parse($original))); + } + /** * @testdox get_configurator() triggers events before and after configuration */ diff --git a/tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html new file mode 100644 index 0000000000..f3932f9b78 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html @@ -0,0 +1,40 @@ +
                +
                  +
                + +
                  +
                + +
              • +
              • + +
                {USERNAME} {L_WROTE}{L_COLON} +
                +
                + +

                {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}

                +
                + +
                +
                + + + + + + + + + +{TEXT} + +{TEXT} + +{L_IMAGE} + +{DESCRIPTION} + +{DESCRIPTION} + + diff --git a/tests/text_formatter/s9e/fixtures/unsafe_default_bbcodes.xml b/tests/text_formatter/s9e/fixtures/unsafe_default_bbcodes.xml new file mode 100644 index 0000000000..06524a13cc --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/unsafe_default_bbcodes.xml @@ -0,0 +1,24 @@ + + + + style_id + style_name + style_copyright + style_active + style_path + bbcode_bitfield + style_parent_id + style_parent_tree + + + 1 + unsafe + + 1 + unsafe + QA== + 0 + + +
                +
                -- cgit v1.2.1 From a7664811dd3696e17a78fd98fec49f9beaf4579d Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 23 Nov 2017 16:25:48 +0100 Subject: [ticket/15464] Detect BBCodes in uppercase when reparsing PHPBB3-15464 --- tests/text_reparser/base_test.php | 15 +++++++++++++++ tests/text_reparser/fixtures/base.xml | 8 ++++++++ 2 files changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/text_reparser/base_test.php b/tests/text_reparser/base_test.php index af2d56ea51..2c6844b063 100644 --- a/tests/text_reparser/base_test.php +++ b/tests/text_reparser/base_test.php @@ -66,4 +66,19 @@ class phpbb_textreparser_base_test extends phpbb_database_test_case $this->get_rows(array(1)) ); } + + public function test_reparse_case_insensitive() + { + $this->get_reparser()->reparse_range(2, 2); + + $this->assertEquals( + [ + [ + 'id' => '2', + 'text' => '[IMG]img.png[/IMG]' + ] + ], + $this->get_rows([2]) + ); + } } diff --git a/tests/text_reparser/fixtures/base.xml b/tests/text_reparser/fixtures/base.xml index a4921a8823..532a19a8a9 100644 --- a/tests/text_reparser/fixtures/base.xml +++ b/tests/text_reparser/fixtures/base.xml @@ -15,5 +15,13 @@ abcd1234 + + 2 + 1 + 1 + 1 + [IMG]img.png[/IMG]]]> + + -- cgit v1.2.1 From b9dce3fa65a508baa02bc66e86e68b931e0ba670 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 10 Dec 2017 02:54:38 +0100 Subject: [ticket/15457] Updated s9e/text-formatter dependency PHPBB3-15457 --- .../text_formatter/s9e/default_formatting_test.php | 36 +++++++++++----------- .../text_processing/tickets_data/PHPBB3-10122.html | 2 +- .../text_processing/tickets_data/PHPBB3-10268.html | 4 +-- .../text_processing/tickets_data/PHPBB3-13641.html | 2 +- .../text_processing/tickets_data/PHPBB3-13921.html | 2 +- .../text_processing/tickets_data/PHPBB3-14706.html | 2 +- .../text_processing/tickets_data/PHPBB3-14790.html | 8 ++--- .../text_processing/tickets_data/PHPBB3-14846.html | 2 +- .../text_processing/tickets_data/PHPBB3-15348.html | 2 +- .../text_processing/tickets_data/PHPBB3-8419.html | 2 +- 10 files changed, 31 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index a0c57214e4..8887b9daee 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -50,27 +50,27 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case return array( array( '[b]bold[/b]', - 'bold' + 'bold' ), array( '[u]underlined[/u]', - 'underlined' + 'underlined' ), array( '[i]italic[/i]', - 'italic' + 'italic' ), array( '[color=#FF0000]colored[/color]', - 'colored' + 'colored' ), array( '[color=red]colored[/color]', - 'colored' + 'colored' ), array( '[size=75]smaller[/size]', - 'smaller' + 'smaller' ), array( '[quote]quoted[/quote]', @@ -102,31 +102,31 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( '[list=1][*]item[/list]', - '
                1. item
                ' + '
                1. item
                ' ), array( '[list=a][*]item[/list]', - '
                1. item
                ' + '
                1. item
                ' ), array( '[list=i][*]item[/list]', - '
                1. item
                ' + '
                1. item
                ' ), array( '[list=I][*]item[/list]', - '
                1. item
                ' + '
                1. item
                ' ), array( '[list=disc][*]item[/list]', - '
                • item
                ' + '
                • item
                ' ), array( '[list=circle][*]item[/list]', - '
                • item
                ' + '
                • item
                ' ), array( '[list=square][*]item[/list]', - '
                • item
                ' + '
                • item
                ' ), array( '[img]https://area51.phpbb.com/images/area51.png[/img]', @@ -180,17 +180,17 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case array( // Allow textual bbcodes in textual bbcodes '[b]bold [i]bold + italic[/i][/b]', - 'bold bold + italic' + 'bold bold + italic' ), array( // Allow textual bbcodes in url with description '[url=https://area51.phpbb.com/]Area51 [i]italic[/i][/url]', - 'Area51 italic' + 'Area51 italic' ), array( // Allow url with description in textual bbcodes '[i]italic [url=https://area51.phpbb.com/]Area51[/url][/i]', - 'italic Area51' + 'italic Area51' ), array( // Do not parse textual bbcodes in code @@ -205,7 +205,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case array( // Textual bbcode nesting into textual bbcode '[b]bold [i]bold + italic[/b] italic[/i]', - 'bold bold + italic italic' + 'bold bold + italic italic' ), array( "[code]\tline1\n line2[/code]", @@ -298,7 +298,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "Emoji: \xF0\x9F\x98\x80", - 'Emoji: ' . ' + 'Emoji: ' . ' ), array( "Emoji: \xF0\x9F\x98\x80", diff --git a/tests/text_processing/tickets_data/PHPBB3-10122.html b/tests/text_processing/tickets_data/PHPBB3-10122.html index f0fb6115b2..0803c895a8 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10122.html +++ b/tests/text_processing/tickets_data/PHPBB3-10122.html @@ -1 +1 @@ -
                • This is my indented text
                \ No newline at end of file +
                • This is my indented text
                \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-10268.html b/tests/text_processing/tickets_data/PHPBB3-10268.html index c89e63f9a3..13b71b4823 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10268.html +++ b/tests/text_processing/tickets_data/PHPBB3-10268.html @@ -1,4 +1,4 @@
                -http://phpbb.com
                - http://phpbb.com
                +http://phpbb.com
                + http://phpbb.com
                diff --git a/tests/text_processing/tickets_data/PHPBB3-13641.html b/tests/text_processing/tickets_data/PHPBB3-13641.html index 1bd1c06dbb..2646bc0ea5 100644 --- a/tests/text_processing/tickets_data/PHPBB3-13641.html +++ b/tests/text_processing/tickets_data/PHPBB3-13641.html @@ -1 +1 @@ -[color=#FF0000] - red \ No newline at end of file +[color=#FF0000] - red \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13921.html b/tests/text_processing/tickets_data/PHPBB3-13921.html index 6a9dc7f504..690668ef28 100644 --- a/tests/text_processing/tickets_data/PHPBB3-13921.html +++ b/tests/text_processing/tickets_data/PHPBB3-13921.html @@ -1 +1 @@ -
                xxx
                \ No newline at end of file +
                xxx
                \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14706.html b/tests/text_processing/tickets_data/PHPBB3-14706.html index b8f74c9e93..23b3304485 100644 --- a/tests/text_processing/tickets_data/PHPBB3-14706.html +++ b/tests/text_processing/tickets_data/PHPBB3-14706.html @@ -1 +1 @@ -
                  1. a
                  2. b
                  3. c
                  4. d
                  5. e
                • outer
                \ No newline at end of file +
                  1. a
                  2. b
                  3. c
                  4. d
                  5. e
                • outer
                \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14790.html b/tests/text_processing/tickets_data/PHPBB3-14790.html index 7624b2d36c..5384098e1b 100644 --- a/tests/text_processing/tickets_data/PHPBB3-14790.html +++ b/tests/text_processing/tickets_data/PHPBB3-14790.html @@ -1,4 +1,4 @@ -
                • text
                • -
                • text
                • -
                • text
                • -
                • text
                \ No newline at end of file +
                • text
                • +
                • text
                • +
                • text
                • +
                • text
                \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14846.html b/tests/text_processing/tickets_data/PHPBB3-14846.html index 461ca25bc6..bd4455781b 100644 --- a/tests/text_processing/tickets_data/PHPBB3-14846.html +++ b/tests/text_processing/tickets_data/PHPBB3-14846.html @@ -1 +1 @@ -
                moderator text
                - Mickroz
                \ No newline at end of file +
                moderator text
                - Mickroz
                \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.html b/tests/text_processing/tickets_data/PHPBB3-15348.html index e65925ec28..5d44c07899 100644 --- a/tests/text_processing/tickets_data/PHPBB3-15348.html +++ b/tests/text_processing/tickets_data/PHPBB3-15348.html @@ -1 +1 @@ -:o k: :ok: \ No newline at end of file +:o k: :ok: \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-8419.html b/tests/text_processing/tickets_data/PHPBB3-8419.html index 38df626a94..df91e9df50 100644 --- a/tests/text_processing/tickets_data/PHPBB3-8419.html +++ b/tests/text_processing/tickets_data/PHPBB3-8419.html @@ -1 +1 @@ -przykład \ No newline at end of file +przykład \ No newline at end of file -- cgit v1.2.1 From 75e7e7b293c812645942427fd8156a160225d0d5 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 27 Nov 2017 21:12:19 +0100 Subject: [ticket/15468] Add a service to merge duplicate BBCodes PHPBB3-15468 --- tests/text_formatter/s9e/bbcode_merger_test.php | 280 ++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 tests/text_formatter/s9e/bbcode_merger_test.php (limited to 'tests') diff --git a/tests/text_formatter/s9e/bbcode_merger_test.php b/tests/text_formatter/s9e/bbcode_merger_test.php new file mode 100644 index 0000000000..815539056b --- /dev/null +++ b/tests/text_formatter/s9e/bbcode_merger_test.php @@ -0,0 +1,280 @@ + +* @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_textformatter_s9e_bbcode_merger_test extends phpbb_test_case +{ + /** + * @dataProvider get_merge_bbcodes_tests + */ + public function test_merge_bbcodes($usage_without, $template_without, $usage_with, $template_with, $expected_usage, $expected_template) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $factory = $container->get('text_formatter.s9e.factory'); + $bbcode_merger = new \phpbb\textformatter\s9e\bbcode_merger($factory); + + $without = ['usage' => $usage_without, 'template' => $template_without]; + $with = ['usage' => $usage_with, 'template' => $template_with]; + $merged = $bbcode_merger->merge_bbcodes($without, $with); + + // Normalize the expected template's whitespace to match the default indentation + $expected_template = str_replace("\n\t\t\t\t", "\n", $expected_template); + $expected_template = str_replace("\t", ' ', $expected_template); + + $this->assertSame($expected_usage, $merged['usage']); + $this->assertSame($expected_template, $merged['template']); + } + + public function get_merge_bbcodes_tests() + { + return [ + [ + '[x]{TEXT}[/x]', + '{TEXT}', + + '[x={TEXT1}]{TEXT}[/x]', + '{TEXT}', + + '[x={TEXT1?}]{TEXT}[/x]', + ' + + + + + + + ' + ], + [ + // The tokens' numbering differs between versions + '[x]{TEXT}[/x]', + '{TEXT}', + + '[x={TEXT1}]{TEXT2}[/x]', + '{TEXT2}', + + '[x={TEXT1?}]{TEXT2}[/x]', + ' + + + + + + + ' + ], + [ + '[x]{URL}[/x]', + '{URL}', + + '[x={URL}]{TEXT}[/x]', + '{TEXT}', + + '[x={URL;useContent}]{TEXT}[/x]', + ' + + ' + ], + [ + '[x]{URL}[/x]', + '{L_GO_TO}: {URL}', + + '[x={URL}]{TEXT}[/x]', + '{L_GO_TO}: {TEXT}', + + '[x={URL;useContent}]{TEXT}[/x]', + '{L_GO_TO}: ' + ], + [ + // Test that unsafe BBCodes can still be merged + '[script]{TEXT}[/script]', + '', + + '[script={TEXT1}]{TEXT2}[/script]', + '', + + '[script={TEXT1?}]{TEXT2}[/script]', + '' + ], + [ + // https://www.phpbb.com/community/viewtopic.php?p=14848281#p14848281 + '[note]{TEXT}[/note]', + '{TEXT}', + + '[note={TEXT1}]{TEXT2}[/note]', + '{TEXT1}{TEXT2}', + + '[note={TEXT1?}]{TEXT2}[/note]', + ' + + + + + + + + ' + ], + [ + // https://www.phpbb.com/community/viewtopic.php?p=14768441#p14768441 + '[MI]{TEXT}[/MI]', + 'MI: {TEXT}', + + '[MI={TEXT2}]{TEXT1}[/MI]', + 'MI for: "{TEXT2}": {TEXT1}', + + '[MI={TEXT2?}]{TEXT1}[/MI]', + 'MI for: "": + + + + ' + ], + [ + // https://www.phpbb.com/community/viewtopic.php?p=14700506#p14700506 + '[spoiler]{TEXT}[/spoiler]', + ' {TEXT}', + + '[spoiler={TEXT1}]{TEXT2}[/spoiler]', + '
                {TEXT1}{TEXT2}
                ', + + '[spoiler={TEXT1?}]{TEXT2}[/spoiler]', + ' + +
                + + + + + +
                +
                + + + + + + +
                ' + ], + [ + // https://www.phpbb.com/community/viewtopic.php?p=14859676#p14859676 + '[AE]{TEXT}[/AE]', + ' + +
                + + + + +
                + + + + + + + + +
                +  ACTIVE EFFECTS & CONDITIONS  
                + + + + +
                + {TEXT} +
                +
                +
                +
                +

                 

                ', + + '[AE={TEXT1}]{TEXT2}[/AE]', + ' + +
                + + + + +
                + + + + + + + + +
                +   {TEXT1}  
                + + + + +
                + {TEXT2} +
                +
                +
                +
                +

                 

                ', + + '[AE={TEXT1?}]{TEXT2}[/AE]', + ' + + + +
                + + + + +
                + + + + + + + + +
                + + +   ACTIVE EFFECTS & CONDITIONS  + + +  
                + + + + +
                + +
                +
                +
                +
                +

                 

                ' + ], + ]; + } +} -- cgit v1.2.1 From 2b16b7cada85492b6312d126afa71a8a2e50a2a3 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 24 Dec 2017 19:55:03 +0100 Subject: [ticket/15339] Fix tests PHPBB3-15339 --- tests/dbal/migrator_tool_module_test.php | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'tests') diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 29b21166b6..c625b93ded 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -193,25 +193,6 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case } $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE')); - // Test adding module when plural parent module_langname exists - // PHPBB3-14703 - // Adding fail - try - { - $this->tool->add('acp', 'ACP_FORUM_BASED_PERMISSIONS', array( - 'module_basename' => 'acp_new_permissions_module', - 'module_langname' => 'ACP_NEW_PERMISSIONS_MODULE', - 'module_mode' => 'test', - 'module_auth' => '', - )); - $this->fail('Exception not thrown'); - } - catch (Exception $e) - { - $this->assertEquals('phpbb\db\migration\exception', get_class($e)); - $this->assertEquals('MODULE_EXIST_MULTIPLE', $e->getMessage()); - } - // Test adding module when plural parent module_langname exists // PHPBB3-14703 // Adding success -- cgit v1.2.1 From 6e6195c303c23e66419ffed9fbc3b19856614afc Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 7 May 2017 03:26:01 +0700 Subject: [ticket/14972] Avoid using self as constant in tests PHPBB3-14972 --- tests/functional/extension_acp_test.php | 2 +- tests/functional/extension_controller_test.php | 2 +- tests/functional/extension_global_lang_test.php | 2 +- tests/functional/extension_module_test.php | 2 +- tests/functional/extension_permission_lang_test.php | 2 +- tests/functional/metadata_manager_test.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 8a71a5ce04..e980c5a04b 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -26,7 +26,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/../extension/ext/', self::$fixtures); } diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 18eb9ad4c6..58c3878b8b 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -34,7 +34,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php index f615114c08..a1e2547745 100644 --- a/tests/functional/extension_global_lang_test.php +++ b/tests/functional/extension_global_lang_test.php @@ -30,7 +30,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index 95107665cd..d3a66b9b35 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -29,7 +29,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 92d8d596c7..f570d45215 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -30,7 +30,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php index 0d2fdf082e..8456c40f00 100644 --- a/tests/functional/metadata_manager_test.php +++ b/tests/functional/metadata_manager_test.php @@ -35,7 +35,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case { parent::setUpBeforeClass(); - self::$helper = new phpbb_test_case_helpers(self); + self::$helper = new phpbb_test_case_helpers(__CLASS__); self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } -- cgit v1.2.1 From 11e09f1b3c943695ff688f7a86fdebff88649cef Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 9 May 2017 02:13:24 +0700 Subject: [ticket/14972] Fix test_collection_with_mask test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In PHP 7.2, the severity of the message “Use of undefined constant” was raised from E_NOTICE to E_WARNING, so calling $array[ITEM] causes warning caught by error collector. Use undefined offset notice to get an empty message as such. PHPBB3-14972 --- tests/error_collector_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php index 273284c8fc..8ed89bbe52 100644 --- a/tests/error_collector_test.php +++ b/tests/error_collector_test.php @@ -52,8 +52,8 @@ class phpbb_error_collector_test extends phpbb_test_case 1/0; $line = __LINE__; // Cause a notice - $array = array('ITEM' => 'value'); - $value = $array[ITEM]; $line2 = __LINE__; + $array = array(0 => 'value'); + $value = $array[1]; $line2 = __LINE__; $collector->uninstall(); -- cgit v1.2.1 From f8fbe3793680af1dae2db2829cfc84068831c52f Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 28 Jun 2017 00:58:03 +0700 Subject: [ticket/14972] replace all occurrences of sizeof() with the count() PHPBB3-14972 --- tests/cache/cache_memory_test.php | 2 +- tests/cron/manager_test.php | 2 +- tests/dbal/write_test.php | 2 +- tests/event/md_exporter_test.php | 4 ++-- tests/functional/fileupload_remote_test.php | 4 ++-- tests/functions/get_remote_file_test.php | 2 +- tests/mock/sql_insert_buffer.php | 2 +- tests/notification/base.php | 2 +- tests/test_framework/phpbb_database_test_case.php | 2 +- .../phpbb_database_test_connection_manager.php | 2 +- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- tests/test_framework/phpbb_ui_test_case.php | 2 +- tests/upload/fileupload_test.php | 12 ++++++------ tests/wrapper/version_compare_test.php | 2 +- 14 files changed, 22 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/cache/cache_memory_test.php b/tests/cache/cache_memory_test.php index 9f92e8d8dc..ba1010bcf3 100644 --- a/tests/cache/cache_memory_test.php +++ b/tests/cache/cache_memory_test.php @@ -116,7 +116,7 @@ class phpbb_cache_memory_test extends phpbb_database_test_case $results[] = $row; } $this->cache->sql_freeresult($query_id); - $this->assertEquals($query[1], sizeof($results)); + $this->assertEquals($query[1], count($results)); } $this->cache->destroy('sql', $table); diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php index f4dd69b19b..76f8c753bf 100644 --- a/tests/cron/manager_test.php +++ b/tests/cron/manager_test.php @@ -40,7 +40,7 @@ class phpbb_cron_manager_test extends \phpbb_test_case public function test_manager_finds_all_ready_tasks() { $tasks = $this->manager->find_all_ready_tasks(); - $this->assertEquals(3, sizeof($tasks)); + $this->assertEquals(3, count($tasks)); } public function test_manager_finds_one_ready_task() diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php index 98709fb043..4fa5cc37a2 100644 --- a/tests/dbal/write_test.php +++ b/tests/dbal/write_test.php @@ -67,7 +67,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case $result = $db->sql_query($sql); $rows = $db->sql_fetchrowset($result); - $this->assertEquals(1, sizeof($rows)); + $this->assertEquals(1, count($rows)); $this->assertEquals('config2', $rows[0]['config_name']); $db->sql_freeresult($result); diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php index 607f442fdf..2eeb48ea05 100644 --- a/tests/event/md_exporter_test.php +++ b/tests/event/md_exporter_test.php @@ -92,7 +92,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case public function test_crawl_eventsmd($file, $min_version, $max_version, $events) { $exporter = new \phpbb\event\md_exporter(dirname(__FILE__) . '/fixtures/', null, $min_version, $max_version); - $this->assertSame(sizeof($events), $exporter->crawl_eventsmd($file, 'adm')); + $this->assertSame(count($events), $exporter->crawl_eventsmd($file, 'adm')); $this->assertEquals($events, $exporter->get_events()); } @@ -146,7 +146,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case $exporter->crawl_eventsmd('docs/events.md', $filter); $events = $exporter->crawl_file_for_events($file); - $this->assertGreaterThanOrEqual(0, sizeof($events)); + $this->assertGreaterThanOrEqual(0, count($events)); $this->assertTrue($exporter->validate_events_from_file($file, $events)); } } diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 88f8999005..426ebcee53 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -102,7 +102,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case ->set_allowed_extensions(array('gif')) ->set_max_filesize(2000); $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); - $this->assertEquals(0, sizeof($file->error)); + $this->assertEquals(0, count($file->error)); $this->assertTrue(file_exists($file->get('filename'))); $this->assertTrue($file->is_uploaded()); } @@ -115,7 +115,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); - $this->assertEquals(1, sizeof($file->error)); + $this->assertEquals(1, count($file->error)); $this->assertEquals('WRONG_FILESIZE', $file->error[0]); } } diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php index 1550aa37e6..75e5a6dc61 100644 --- a/tests/functions/get_remote_file_test.php +++ b/tests/functions/get_remote_file_test.php @@ -58,7 +58,7 @@ class phpbb_functions_get_remote_file extends phpbb_test_case $this->assertGreaterThanOrEqual( 2, - sizeof($lines), + count($lines), 'Failed asserting that the version file has at least two lines.' ); diff --git a/tests/mock/sql_insert_buffer.php b/tests/mock/sql_insert_buffer.php index c751764d45..e57983684d 100644 --- a/tests/mock/sql_insert_buffer.php +++ b/tests/mock/sql_insert_buffer.php @@ -15,7 +15,7 @@ class phpbb_mock_sql_insert_buffer extends \phpbb\db\sql_insert_buffer { public function flush() { - return (sizeof($this->buffer)) ? true : false; + return (count($this->buffer)) ? true : false; } public function get_buffer() diff --git a/tests/notification/base.php b/tests/notification/base.php index b64e25cf8c..80b9a0d777 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -163,7 +163,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case 'order_dir' => 'ASC', ), $options)); - $this->assertEquals(sizeof($expected), $notifications['unread_count']); + $this->assertEquals(count($expected), $notifications['unread_count']); $i = 0; foreach ($notifications['notifications'] as $notification) diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index b7386e9a3e..df7c669865 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -229,7 +229,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test { // http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important // but one array_diff is not enough! - if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one))) + if (count(array_diff($one, $two)) || count(array_diff($two, $one))) { // get a nice error message $this->assertEquals($one, $two); diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 147029d699..b58e9c752b 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -621,7 +621,7 @@ class phpbb_database_test_connection_manager } // Combine all of the SETVALs into one query - if (sizeof($setval_queries)) + if (count($setval_queries)) { $queries[] = 'SELECT ' . implode(', ', $setval_queries); } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index c9943c4302..2d8224f7dc 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -425,7 +425,7 @@ class phpbb_functional_test_case extends phpbb_test_case $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); // Wait for extension to be fully enabled - while (sizeof($meta_refresh)) + while (count($meta_refresh)) { preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match); $url = $match[1]; @@ -990,7 +990,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->assertEquals( 1, - sizeof($result), + count($result), $message ?: 'Failed asserting that exactly one checkbox with name' . " $name exists in crawler scope." ); diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index b875d3212b..d38d14f45c 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -317,7 +317,7 @@ class phpbb_ui_test_case extends phpbb_test_case $meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]'); // Wait for extension to be fully enabled - while (sizeof($meta_refresh)) + while (count($meta_refresh)) { preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match); $this->getDriver()->execute(array('method' => 'post', 'url' => $match[1])); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index fb72823f08..5b3357237d 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -173,7 +173,7 @@ class phpbb_fileupload_test extends phpbb_test_case ->set_max_filesize(1000); $file = $this->gen_valid_filespec(); $upload->common_checks($file); - $this->assertEquals(0, sizeof($file->error)); + $this->assertEquals(0, count($file->error)); } public function test_local_upload() @@ -184,7 +184,7 @@ class phpbb_fileupload_test extends phpbb_test_case copy($this->path . 'jpg', $this->path . 'jpg.jpg'); $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); - $this->assertEquals(0, sizeof($file->error)); + $this->assertEquals(0, count($file->error)); $this->assertFalse($file->additional_checks()); $this->assertTrue($file->move_file('../tests/upload/fixture/copies', true)); $file->remove(); @@ -198,10 +198,10 @@ class phpbb_fileupload_test extends phpbb_test_case copy($this->path . 'jpg', $this->path . 'jpg.jpg'); $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); - $this->assertEquals(0, sizeof($file->error)); + $this->assertEquals(0, count($file->error)); $this->assertFalse($file->move_file('../tests/upload/fixture')); $this->assertFalse($file->get('file_moved')); - $this->assertEquals(1, sizeof($file->error)); + $this->assertEquals(1, count($file->error)); } public function test_move_existent_file_overwrite() @@ -213,9 +213,9 @@ class phpbb_fileupload_test extends phpbb_test_case copy($this->path . 'jpg', $this->path . 'jpg.jpg'); copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg'); $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); - $this->assertEquals(0, sizeof($file->error)); + $this->assertEquals(0, count($file->error)); $file->move_file('../tests/upload/fixture/copies', true); - $this->assertEquals(0, sizeof($file->error)); + $this->assertEquals(0, count($file->error)); unlink($this->path . 'copies/jpg.jpg'); } diff --git a/tests/wrapper/version_compare_test.php b/tests/wrapper/version_compare_test.php index 8260d99504..ee23fe779c 100644 --- a/tests/wrapper/version_compare_test.php +++ b/tests/wrapper/version_compare_test.php @@ -66,7 +66,7 @@ class phpbb_wrapper_version_compare_test extends phpbb_test_case '3.2-A1', ); - for ($i = 0, $size = sizeof($releases); $i < $size - 1; ++$i) + for ($i = 0, $size = count($releases); $i < $size - 1; ++$i) { $version1 = $releases[$i]; $version2 = $releases[$i + 1]; -- cgit v1.2.1 From 4a2e203a80a4ab8f7983b8b203de38b37bd8764c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 28 Jan 2017 11:30:34 +0100 Subject: [ticket/15055] Debug issues PHPBB3-15055 --- tests/attachment/fixtures/resync.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/attachment/fixtures/resync.xml b/tests/attachment/fixtures/resync.xml index 6e2cc62f68..af04701b4a 100644 --- a/tests/attachment/fixtures/resync.xml +++ b/tests/attachment/fixtures/resync.xml @@ -1,6 +1,7 @@ + attach_idpost_msg_idtopic_idin_message @@ -9,6 +10,7 @@ physical_filenamethumbnail + 1 1 1 0 @@ -18,6 +20,7 @@ 0 + 2 1 1 1 @@ -27,6 +30,7 @@ 0 + 3 1 1 1 @@ -37,13 +41,16 @@
                + extension_idextensiongroup_id + 1 jpg 1 + 2 png 1 -- cgit v1.2.1 From 66143e99bee0931b77c50d9e3b1fbd0b9629e48d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 29 Jan 2017 11:05:45 +0100 Subject: [ticket/15055] Further fixes to ensure PHP 7.1 & mssql compatibility PHPBB3-15055 --- tests/console/user/base.php | 5 +++++ tests/test_framework/phpbb_functional_test_case.php | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/console/user/base.php b/tests/console/user/base.php index b84c0bb267..6e5436fb9d 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -34,6 +34,11 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case { global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; + if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux') + { + $this->markTestSkipped('Unable to test console feature on OS other than Linux.'); + } + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('cache.driver', new phpbb_mock_cache()); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index c9943c4302..4e22e7b039 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -509,7 +509,6 @@ class phpbb_functional_test_case extends phpbb_test_case else { $db->sql_multi_insert(STYLES_TABLE, array(array( - 'style_id' => $style_id, 'style_name' => $style_path, 'style_copyright' => '', 'style_active' => 1, -- cgit v1.2.1 From f296014c2375baeec30912e6d928879d414f0ce0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 29 Jan 2017 14:05:27 +0100 Subject: [ticket/15055] Start fixing missing keys in fixtures PHPBB3-15055 --- tests/dbal/fixtures/boolean_processor.xml | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/dbal/fixtures/boolean_processor.xml b/tests/dbal/fixtures/boolean_processor.xml index c5da677116..d31d679f45 100644 --- a/tests/dbal/fixtures/boolean_processor.xml +++ b/tests/dbal/fixtures/boolean_processor.xml @@ -60,25 +60,31 @@
                user_idgroup_id + group_leader 1 1 + 2 2 1 + 2 3 1 + 2 4 2 + 2 5 2 + 2
                -- cgit v1.2.1 From 635befa00e0d9791137a2a500260b578021f60b8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 29 Jan 2017 15:56:45 +0100 Subject: [ticket/15055] Drop primary keys when necessary and fix test comparisons PHPBB3-15055 --- tests/dbal/db_tools_test.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index f9243e7266..f78cebdec7 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -203,8 +203,15 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case public function test_list_columns() { + $config = $this->get_database_config(); + $table_columns = $this->table_data['COLUMNS']; + + if (strpos($config['dbms'], 'mssql') !== false) + { + ksort($table_columns); + } $this->assertEquals( - array_keys($this->table_data['COLUMNS']), + array_keys($table_columns), array_values($this->tools->sql_list_columns('prefix_table_name')) ); } -- cgit v1.2.1 From f4381a20d4ec6201a00cd618c24fd29b67f77965 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 24 Dec 2017 16:48:28 +0100 Subject: [ticket/15055] Handle default identity column on mssql in database tests PHPBB3-15055 --- tests/test_framework/phpbb_database_test_case.php | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index b7386e9a3e..670d39ed69 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -145,6 +145,53 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test public function createXMLDataSet($path) { $this->fixture_xml_data = parent::createXMLDataSet($path); + if (strpos($this->get_database_config()['dbms'], 'mssql') !== false) + { + $newXmlData = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet(); + $db = $this->new_dbal(); + foreach ($this->fixture_xml_data as $key => $value) + { + $sql = "SELECT COLUMN_NAME AS identity_column + FROM INFORMATION_SCHEMA.COLUMNS + WHERE COLUMNPROPERTY(object_id(TABLE_SCHEMA + '.' + TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1 + AND TABLE_NAME = '$key' + ORDER BY TABLE_NAME"; + $result = $db->sql_query($sql); + $identity_columns = $db->sql_fetchrowset($result); + $has_default_identity = false; + foreach ($identity_columns as $column) + { + if ($column['identity_column'] === 'mssqlindex') + { + $has_default_identity = true; + break; + } + } + + if ($has_default_identity) + { + /** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */ + $tableMetaData = $value->getTableMetaData(); + $columns = $tableMetaData->getColumns(); + $columns[] = 'mssqlindex'; + $newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $tableMetaData->getPrimaryKeys()); + $newTable = new PHPUnit_Extensions_Database_DataSet_DefaultTable($newMetaData); + for ($i = 0; $i < $value->getRowCount(); $i++) + { + $dataRow = $value->getRow($i); + $dataRow['mssqlindex'] = $i + 1; + $newTable->addRow($dataRow); + } + $newXmlData->addTable($newTable); + } + else + { + $newXmlData->addTable($value); + } + } + + $this->fixture_xml_data = $newXmlData; + } return $this->fixture_xml_data; } -- cgit v1.2.1 From 400fc0f73d03010d3bf28d2b1db5d789dc085334 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 25 Dec 2017 18:49:31 +0100 Subject: [ticket/15055] Only drop dependent PK indexes and fix more tests for mssql PHPBB3-15055 --- tests/dbal/db_tools_test.php | 5 +++- tests/functions/fixtures/validate_username.xml | 2 ++ tests/functions_user/fixtures/delete_user.xml | 9 +++++++ .../submit_post_notification.type.bookmark.xml | 2 ++ .../submit_post_notification.type.post.xml | 3 +++ ...submit_post_notification.type.post_in_queue.xml | 2 ++ .../submit_post_notification.type.quote.xml | 2 ++ .../submit_post_notification.type.topic.xml | 2 ++ tests/notification/notification_test.php | 2 +- tests/search/fixtures/posts.xml | 5 ++++ tests/test_framework/phpbb_database_test_case.php | 30 +++++++++++++++++----- 11 files changed, 55 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index f78cebdec7..dbe2c2909a 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -462,7 +462,10 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case // Index name has > 30 chars - that should not be possible. $too_long_index_name = str_repeat('i', 31); $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', $too_long_index_name)); - $this->setExpectedTriggerError(E_USER_ERROR); + if (strpos($this->tools->sql_layer, 'mssql') === false) + { + $this->setExpectedTriggerError(E_USER_ERROR); + } $this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp')); } } diff --git a/tests/functions/fixtures/validate_username.xml b/tests/functions/fixtures/validate_username.xml index 1b85a2f06d..add8f76553 100644 --- a/tests/functions/fixtures/validate_username.xml +++ b/tests/functions/fixtures/validate_username.xml @@ -1,9 +1,11 @@ + group_idgroup_namegroup_desc + 10 foobar_group test123 diff --git a/tests/functions_user/fixtures/delete_user.xml b/tests/functions_user/fixtures/delete_user.xml index 56014b35d1..8de2659722 100644 --- a/tests/functions_user/fixtures/delete_user.xml +++ b/tests/functions_user/fixtures/delete_user.xml @@ -515,35 +515,44 @@
                user_id + folder_id 2 + 1 3 + 2
                user_idrule_string + rule_id 2 + 1 3 + 2
                user_iddraft_message + draft_id 2 + 1 3 + 2
                diff --git a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml index 7f069abc59..db1cef2ef6 100644 --- a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml +++ b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml @@ -29,6 +29,7 @@ + notification_idnotification_type_iduser_iditem_id @@ -36,6 +37,7 @@ notification_readnotification_data + 1 1 5 1 diff --git a/tests/notification/fixtures/submit_post_notification.type.post.xml b/tests/notification/fixtures/submit_post_notification.type.post.xml index a4bf9d3ee4..920b271525 100644 --- a/tests/notification/fixtures/submit_post_notification.type.post.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post.xml @@ -21,6 +21,7 @@
                + notification_idnotification_type_iduser_iditem_id @@ -28,6 +29,7 @@ notification_readnotification_data + 1 1 5 1 @@ -36,6 +38,7 @@ + 2 1 8 1 diff --git a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml index 0a955c48d2..12e73b0ff2 100644 --- a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml @@ -1,6 +1,7 @@
                + notification_idnotification_type_iduser_iditem_id @@ -8,6 +9,7 @@ notification_readnotification_data + 1 1 6 1 diff --git a/tests/notification/fixtures/submit_post_notification.type.quote.xml b/tests/notification/fixtures/submit_post_notification.type.quote.xml index c66830fbf5..9f4ba91475 100644 --- a/tests/notification/fixtures/submit_post_notification.type.quote.xml +++ b/tests/notification/fixtures/submit_post_notification.type.quote.xml @@ -1,6 +1,7 @@
                + notification_idnotification_type_iduser_iditem_id @@ -8,6 +9,7 @@ notification_readnotification_data + 1 1 5 1 diff --git a/tests/notification/fixtures/submit_post_notification.type.topic.xml b/tests/notification/fixtures/submit_post_notification.type.topic.xml index e0f6583f48..1f96ed2ee7 100644 --- a/tests/notification/fixtures/submit_post_notification.type.topic.xml +++ b/tests/notification/fixtures/submit_post_notification.type.topic.xml @@ -21,6 +21,7 @@
                + notification_idnotification_type_iduser_iditem_id @@ -28,6 +29,7 @@ notification_readnotification_data + 1 1 8 1 diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index ec42aa193c..6bbabfc602 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -108,7 +108,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base $types = array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test'); foreach ($types as $id => $type) { - $this->db->sql_query('INSERT INTO phpbb_notification_types ' . + $this->getConnection()->createQueryTable('insertNotification', 'INSERT INTO phpbb_notification_types ' . $this->db->sql_build_array('INSERT', array( 'notification_type_id' => ($id + 1), 'notification_type_name' => $type, diff --git a/tests/search/fixtures/posts.xml b/tests/search/fixtures/posts.xml index 16232b8f39..4916cd188b 100644 --- a/tests/search/fixtures/posts.xml +++ b/tests/search/fixtures/posts.xml @@ -1,25 +1,30 @@
                + post_idpost_usernamepost_subjectpost_text + 1 foo foo foo + 2 bar bar bar + 3 commonword commonword commonword + 4 baaz baaz baaz diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 670d39ed69..bbcb8d9a48 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -151,6 +151,11 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $db = $this->new_dbal(); foreach ($this->fixture_xml_data as $key => $value) { + /** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */ + $tableMetaData = $value->getTableMetaData(); + $columns = $tableMetaData->getColumns(); + $primaryKeys = $tableMetaData->getPrimaryKeys(); + $sql = "SELECT COLUMN_NAME AS identity_column FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMNPROPERTY(object_id(TABLE_SCHEMA + '.' + TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1 @@ -159,8 +164,15 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $result = $db->sql_query($sql); $identity_columns = $db->sql_fetchrowset($result); $has_default_identity = false; + $add_primary_keys = false; foreach ($identity_columns as $column) { + if (in_array($column['identity_column'], $columns) && !in_array($column['identity_column'], $primaryKeys)) + { + $primaryKeys[] = $column['identity_column']; + $add_primary_keys = true; + } + if ($column['identity_column'] === 'mssqlindex') { $has_default_identity = true; @@ -168,18 +180,22 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test } } - if ($has_default_identity) + if ($has_default_identity || $add_primary_keys) { - /** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */ - $tableMetaData = $value->getTableMetaData(); - $columns = $tableMetaData->getColumns(); - $columns[] = 'mssqlindex'; - $newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $tableMetaData->getPrimaryKeys()); + if ($has_default_identity) + { + $columns[] = 'mssqlindex'; + } + + $newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $primaryKeys); $newTable = new PHPUnit_Extensions_Database_DataSet_DefaultTable($newMetaData); for ($i = 0; $i < $value->getRowCount(); $i++) { $dataRow = $value->getRow($i); - $dataRow['mssqlindex'] = $i + 1; + if ($has_default_identity) + { + $dataRow['mssqlindex'] = $i + 1; + } $newTable->addRow($dataRow); } $newXmlData->addTable($newTable); -- cgit v1.2.1 From 27a24d0a677a3f1fb0dcf2393859eb37fe3bc0c3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 25 Dec 2017 19:20:02 +0100 Subject: [ticket/15055] Try using build matrix PHPBB3-15055 --- .../test_framework/phpbb_database_test_connection_manager.php | 8 ++++++++ tests/tree/nestedset_forum_base.php | 10 ++++++++++ 2 files changed, 18 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 147029d699..74170f2f35 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -222,6 +222,14 @@ class phpbb_database_test_connection_manager $this->purge_extras(); break; + case 'phpbb\db\driver\mssql': + case 'phpbb\db\driver\mssqlnative': + $this->connect(); + // Drop all tables + $this->pdo->exec("EXEC sp_MSforeachtable 'DROP TABLE ?'"); + $this->purge_extras(); + break; + default: $this->connect(false); diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php index 3daa75b2e4..62f3e0bcab 100644 --- a/tests/tree/nestedset_forum_base.php +++ b/tests/tree/nestedset_forum_base.php @@ -100,6 +100,11 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case } else { + if (strpos($this->db->sql_layer, 'mssql') !== false) + { + $sql = 'SET IDENTITY_INSERT phpbb_forums ON'; + $this->db->sql_query($sql); + } $buffer = new \phpbb\db\sql_insert_buffer($this->db, 'phpbb_forums'); $buffer->insert_all($forums); $buffer->flush(); @@ -107,6 +112,11 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case $this->database_synchronisation(array( 'phpbb_forums' => array('forum_id'), )); + if (strpos($this->db->sql_layer, 'mssql') !== false) + { + $sql = 'SET IDENTITY_INSERT phpbb_forums OFF'; + $this->db->sql_query($sql); + } } } -- cgit v1.2.1 From ede339c1c8b19fa01a61594d231902013ef473b0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 30 Dec 2017 12:25:05 +0100 Subject: [ticket/15055] Extend build matrix and trim text in extension_acp_test PHPBB3-15055 --- tests/functional/extension_acp_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 8a71a5ce04..3f780a38da 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -133,7 +133,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case for ($i = 0; $i < $crawler->filter('dl')->count(); $i++) { - $text = $crawler->filter('dl')->eq($i)->text(); + $text = trim($crawler->filter('dl')->eq($i)->text()); $match = false; -- cgit v1.2.1 From a999718b42742c9911a24a74cf60f80e196d5cf8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 31 Dec 2017 11:53:15 +0100 Subject: [ticket/15055] Support console questions on windows PHPBB3-15055 --- tests/console/user/add_test.php | 48 ++++++++++++++++++++++++++++++++++--- tests/console/user/base.php | 5 ---- tests/dbal/db_tools_test.php | 4 ---- tests/tree/nestedset_forum_base.php | 10 +++++--- 4 files changed, 52 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index 8641bf87b6..d1a1f8542e 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -14,12 +14,15 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\user\add; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\Question; require_once dirname(__FILE__) . '/base.php'; class phpbb_console_user_add_test extends phpbb_console_user_base { - public function get_command_tester() + public function get_command_tester($question_answers = []) { $application = new Application(); $application->add(new add( @@ -34,7 +37,42 @@ class phpbb_console_user_add_test extends phpbb_console_user_base $command = $application->find('user:add'); $this->command_name = $command->getName(); - $this->question = $command->getHelper('question'); + + if (!empty($question_answers)) + { + $ask = function(InputInterface $input, OutputInterface $output, Question $question) use ($question_answers) + { + $text = $question->getQuestion(); + + // handle a question + foreach ($question_answers as $expected_question => $answer) + { + if (strpos($text, $expected_question) !== false) + { + $response = $answer; + } + } + + if (!isset($response)) + { + throw new \RuntimeException('Was asked for input on an unhandled question: ' . $text); + } + + $output->writeln(print_r($response, true)); + return $response; + }; + $helper = $this->createMock('\Symfony\Component\Console\Helper\QuestionHelper'); + $helper->expects($this->any()) + ->method('ask') + ->will($this->returnCallback($ask)); + $this->question = $helper; + $command->getHelperSet()->set($helper, 'question'); + } + else + { + $this->question = $command->getHelper('question'); + } + return new CommandTester($command); } @@ -57,7 +95,11 @@ class phpbb_console_user_add_test extends phpbb_console_user_base public function test_add_dialog() { - $command_tester = $this->get_command_tester(); + $command_tester = $this->get_command_tester([ + 'USERNAME' => 'bar', + 'PASSWORD' => 'password', + 'EMAIL_ADDRESS' => 'bar@test.com', + ]); $this->assertEquals(2, $this->get_user_id('Admin')); diff --git a/tests/console/user/base.php b/tests/console/user/base.php index 6e5436fb9d..b84c0bb267 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -34,11 +34,6 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case { global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; - if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux') - { - $this->markTestSkipped('Unable to test console feature on OS other than Linux.'); - } - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('cache.driver', new phpbb_mock_cache()); diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index dbe2c2909a..72a3718662 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -462,10 +462,6 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case // Index name has > 30 chars - that should not be possible. $too_long_index_name = str_repeat('i', 31); $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', $too_long_index_name)); - if (strpos($this->tools->sql_layer, 'mssql') === false) - { - $this->setExpectedTriggerError(E_USER_ERROR); - } $this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp')); } } diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php index 62f3e0bcab..498c6a69a2 100644 --- a/tests/tree/nestedset_forum_base.php +++ b/tests/tree/nestedset_forum_base.php @@ -69,7 +69,7 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case static $forums; if (empty($forums)) - { + { $this->create_forum('Parent with two flat children'); $this->create_forum('Flat child #1', 1); $this->create_forum('Flat child #2', 1); @@ -86,7 +86,7 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case // Updating forum_parents column here so it's not empty // This is required, so we can see whether the methods - // correctly clear the values. + // correctly clear the values. $sql = "UPDATE phpbb_forums SET forum_parents = 'a:0:{}'"; $this->db->sql_query($sql); @@ -100,6 +100,8 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case } else { + // Turn on identity insert on mssql to be able to insert into + // identity columns (e.g. forum_id) if (strpos($this->db->sql_layer, 'mssql') !== false) { $sql = 'SET IDENTITY_INSERT phpbb_forums ON'; @@ -112,12 +114,14 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case $this->database_synchronisation(array( 'phpbb_forums' => array('forum_id'), )); + + // Disable identity insert on mssql again if (strpos($this->db->sql_layer, 'mssql') !== false) { $sql = 'SET IDENTITY_INSERT phpbb_forums OFF'; $this->db->sql_query($sql); } - } + } } protected function create_forum($name, $parent_id = 0) -- cgit v1.2.1 From ee8b72d733a3e096f35ec65a7eaf3c63a237cb4b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 31 Dec 2017 14:00:36 +0100 Subject: [ticket/15055] Properly support index length check on mssql PHPBB3-15055 --- tests/dbal/db_tools_test.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 72a3718662..0365463a48 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -439,29 +439,39 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case $this->markTestIncomplete('The table prefix length is too long for proper testing of index shortening function.'); } + $max_index_length = 30; + + if ($this->tools instanceof \phpbb\db\tools\mssql) + { + $max_length_method = new ReflectionMethod('\phpbb\db\tools\mssql', 'get_max_index_name_length'); + $max_length_method->setAccessible(true); + $max_index_length = $max_length_method->invoke($this->tools); + } + $table_suffix = str_repeat('a', 25 - strlen($table_prefix)); $table_name = $table_prefix . $table_suffix; $this->tools->sql_create_table($table_name, $this->table_data); - // Index name and table suffix and table prefix have > 30 chars in total. - // Index name and table suffix have <= 30 chars in total. - $long_index_name = str_repeat('i', 30 - strlen($table_suffix)); + // Index name and table suffix and table prefix have > maximum index length chars in total. + // Index name and table suffix have <= maximum index length chars in total. + $long_index_name = str_repeat('i', $max_index_length - strlen($table_suffix)); $this->assertFalse($this->tools->sql_index_exists($table_name, $long_index_name)); $this->assertTrue($this->tools->sql_create_index($table_name, $long_index_name, array('c_timestamp'))); $this->assertTrue($this->tools->sql_index_exists($table_name, $long_index_name)); - // Index name and table suffix have > 30 chars in total. - $very_long_index_name = str_repeat('i', 30); + // Index name and table suffix have > maximum index length chars in total. + $very_long_index_name = str_repeat('i', $max_index_length); $this->assertFalse($this->tools->sql_index_exists($table_name, $very_long_index_name)); $this->assertTrue($this->tools->sql_create_index($table_name, $very_long_index_name, array('c_timestamp'))); $this->assertTrue($this->tools->sql_index_exists($table_name, $very_long_index_name)); $this->tools->sql_table_drop($table_name); - // Index name has > 30 chars - that should not be possible. - $too_long_index_name = str_repeat('i', 31); + // Index name has > maximum index length chars - that should not be possible. + $too_long_index_name = str_repeat('i', $max_index_length + 1); $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', $too_long_index_name)); + $this->setExpectedTriggerError(E_USER_ERROR); $this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp')); } } -- cgit v1.2.1 From 4afb53dd8d4fb53ce49e0164130cf34712e19324 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 1 Jan 2018 18:00:51 +0100 Subject: [ticket/15055] Add comments explaining overriden createXMLDataSet() PHPBB3-15055 --- tests/test_framework/phpbb_database_test_case.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index bbcb8d9a48..c2d658cfff 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -142,9 +142,17 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $manager->database_synchronisation($table_column_map); } + /** + * Create xml data set for insertion into database + * + * @param string $path Path to fixture XML + * @return PHPUnit_Extensions_Database_DataSet_DefaultDataSet|PHPUnit_Extensions_Database_DataSet_XmlDataSet + */ public function createXMLDataSet($path) { $this->fixture_xml_data = parent::createXMLDataSet($path); + + // Extend XML data set on MSSQL if (strpos($this->get_database_config()['dbms'], 'mssql') !== false) { $newXmlData = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet(); @@ -165,6 +173,11 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $identity_columns = $db->sql_fetchrowset($result); $has_default_identity = false; $add_primary_keys = false; + + // Iterate over identity columns to check for missing primary + // keys in data set and special identity column 'mssqlindex' + // that might have been added when no default identity column + // exists in the current table. foreach ($identity_columns as $column) { if (in_array($column['identity_column'], $columns) && !in_array($column['identity_column'], $primaryKeys)) @@ -182,6 +195,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test if ($has_default_identity || $add_primary_keys) { + // Add default identity column to columns list if ($has_default_identity) { $columns[] = 'mssqlindex'; -- cgit v1.2.1 From 7b6be23117aae157d2bff7ca9cc3610320f368a1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 1 Jan 2018 19:25:11 +0100 Subject: [ticket/15055] Use getMock() for phpBB 3.2 compatibility PHPBB3-15055 --- tests/console/user/add_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index d1a1f8542e..bdfb8a8d2a 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -61,7 +61,7 @@ class phpbb_console_user_add_test extends phpbb_console_user_base $output->writeln(print_r($response, true)); return $response; }; - $helper = $this->createMock('\Symfony\Component\Console\Helper\QuestionHelper'); + $helper = $this->getMock('\Symfony\Component\Console\Helper\QuestionHelper', array('ask')); $helper->expects($this->any()) ->method('ask') ->will($this->returnCallback($ask)); -- cgit v1.2.1 From daf668a9693a65d66d57ccbe1bb365b163610c40 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 8 Jan 2018 21:15:24 +0100 Subject: [ticket/15055] Display content on unexpted server error PHPBB3-15055 --- tests/test_framework/phpbb_functional_test_case.php | 7 ++++++- 1 file changed, 6 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 2be16c7198..a63d5dc5ec 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -911,10 +911,15 @@ class phpbb_functional_test_case extends phpbb_test_case * status code. This assertion tries to catch that. * * @param int $status_code Expected status code - * @return null + * @return void */ static public function assert_response_status_code($status_code = 200) { + if ($status_code != self::$client->getResponse()->getStatus() && + preg_match('/^5[0-9]{2}/', self::$client->getResponse()->getStatus())) + { + self::fail('Encountered unexpected server error:\n' . self::$client->getResponse()->getContent()); + } self::assertEquals($status_code, self::$client->getResponse()->getStatus(), 'HTTP status code does not match'); } -- cgit v1.2.1 From 3c7f45c1665d51b0aba1ab44d378f8a0ad861e09 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 8 Jan 2018 22:19:58 +0100 Subject: [ticket/15055] Fix line break and disable sql server 2017 for now SQL Server 2017 currently fails for unknown reasons and just results in an overall longer build time. Therefore disabling it for now. PHPBB3-15055 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 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 a63d5dc5ec..e1daa4558a 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -918,7 +918,7 @@ class phpbb_functional_test_case extends phpbb_test_case if ($status_code != self::$client->getResponse()->getStatus() && preg_match('/^5[0-9]{2}/', self::$client->getResponse()->getStatus())) { - self::fail('Encountered unexpected server error:\n' . self::$client->getResponse()->getContent()); + self::fail("Encountered unexpected server error:\n" . self::$client->getResponse()->getContent()); } self::assertEquals($status_code, self::$client->getResponse()->getStatus(), 'HTTP status code does not match'); } -- cgit v1.2.1 From 5878d66ebfe6a25c6d5e495c4fd07e7d3ad634ab Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 12 Jan 2018 16:28:37 +0100 Subject: [ticket/15512] Avoid reparsing non-existent polls PHPBB3-15512 --- tests/text_reparser/plugins/fixtures/polls.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/text_reparser/plugins/fixtures/polls.xml b/tests/text_reparser/plugins/fixtures/polls.xml index 2960d640a9..5247fb906d 100644 --- a/tests/text_reparser/plugins/fixtures/polls.xml +++ b/tests/text_reparser/plugins/fixtures/polls.xml @@ -44,55 +44,66 @@ topic_id topic_first_post_id poll_title + poll_start 1 1 This row should be [b]ignored[/b] + 1 2 1 [b]Not bold[/b] :) http://example.org + 1 3 2 [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + 1 4 3 :) http://example.org]]> + 1 5 4 http://example.org]]> + 1 6 2 + 1 7 1 + 1 8 2 + 1 9 1 + 1 1000 1 This row should be [b]ignored[/b] + 1
                -- cgit v1.2.1 From 3469545e3ad934bcb1fc9ac0c527b59aa97c072b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 14 Jan 2018 12:59:01 +0100 Subject: [ticket/15516] Add instructions for running UI tests PHPBB3-15516 --- tests/RUNNING_TESTS.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md index c9941d61e5..3bff4f5d26 100644 --- a/tests/RUNNING_TESTS.md +++ b/tests/RUNNING_TESTS.md @@ -143,14 +143,14 @@ If you want all tests, run: Functional tests ------------------ +================ Functional tests test software the way a user would. They simulate a user browsing the website, but they do these steps in an automated way. phpBB allows you to write such tests. Running -======= +------- Running the tests requires your phpBB3 repository to be accessible through a local web server. You will need to supply the URL to the webserver in @@ -170,6 +170,27 @@ If you only want the functional tests, run: This will change your board's config.php file, but it makes a backup at config_dev.php, so you can restore it after the test run is complete. +UI tests +======== + +UI tests are functional tests that also support running JavaScript in a +headless browser. These should be used when functionality that is only +executed using JS needs to be tested. The require a running +[PhantomJS WebDriver instance](http://phantomjs.org/). The executable can +either be downloaded from [PhantomJS](http://phantomjs.org/download.html) +or alternatively be installed with npm: + + $ npm install -g phantomjs-prebuilt + +You might have to run the command as superuser / administrator on some +systems. Afterwards, a new WebDriver instance can be started via command +line: + + $ phantomjs --webdriver=127.0.0.1:8910 + +Port 8910 is the default port that will be used by UI tests to connect +to the WebDriver instance. + More Information ================ -- cgit v1.2.1 From ad748ec0a7e6ed32064dea885cc3115f1ce4b23d Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Wed, 17 Jan 2018 22:10:53 +0100 Subject: [ticket/15099] Fix tests PHPBB3-15099 --- tests/template/template_includecss_test.php | 8 ++++---- tests/template/template_includejs_test.php | 32 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index bc871aa612..4eb30eda1e 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -95,19 +95,19 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te */ array( array('TEST' => 1), - '', + '', ), array( array('TEST' => 2), - '', + '', ), array( array('TEST' => 3), - '', + '', ), array( array('TEST' => 4), - '', + '', ), ); } diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index 232f551b4a..19c016ae5e 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -28,67 +28,67 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes */ array( array('TEST' => 1), - '', + '', ), array( array('TEST' => 2), - '', + '', ), array( array('TEST' => 3), - '', + '', ), array( array('TEST' => 4), - '', + '', ), array( array('TEST' => 6), - '', + '', ), array( array('TEST' => 7), - '', + '', ), array( array('TEST' => 8), - '', + '', ), array( array('TEST' => 9), - '', + '', ), array( array('TEST' => 10), - '', + '', ), array( array('TEST' => 11), - '', + '', ), array( array('TEST' => 12), - '', + '', ), array( array('TEST' => 14), - '', + '', ), array( array('TEST' => 15), - '', + '', ), array( array('TEST' => 16), - '', + '', ), array( array('TEST' => 17), - '', + '', ), array( array('TEST' => 18), - '', + '', ), ); } -- cgit v1.2.1 From 531d9dfa1f0dddfe765a92ca40c77015091ecc5e Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 22 Jan 2018 03:34:47 +0100 Subject: [ticket/15531] Log malformed BBCodes PHPBB3-15531 --- tests/test_framework/phpbb_test_case_helpers.php | 7 ++++-- tests/text_formatter/s9e/factory_test.php | 18 ++++++++++++++ .../s9e/fixtures/malformed_bbcode.xml | 28 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/text_formatter/s9e/fixtures/malformed_bbcode.xml (limited to 'tests') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 7fb9a740b8..c792976b1e 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -385,7 +385,7 @@ class phpbb_test_case_helpers $mb = $this->test_case->getMockBuilder('phpbb\\textformatter\\data_access'); $mb->setMethods(array('get_bbcodes', 'get_censored_words', 'get_smilies', 'get_styles')); $mb->setConstructorArgs(array( - $this->test_case->getMock('phpbb\\db\\driver\\driver'), + $this->test_case->getMockBuilder('phpbb\\db\\driver\\driver')->getMock(), 'phpbb_bbcodes', 'phpbb_smilies', 'phpbb_styles', @@ -489,8 +489,11 @@ class phpbb_test_case_helpers $request = new phpbb_mock_request; } + // Get a log interface + $log = ($container->has('log')) ? $container->get('log') : $this->test_case->getMockBuilder('phpbb\\log\\log_interface')->getMock(); + // Create and register the text_formatter.s9e.factory service - $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, new \phpbb\textformatter\s9e\link_helper, $cache_dir, $cache_key_parser, $cache_key_renderer); + $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, new \phpbb\textformatter\s9e\link_helper, $log, $cache_dir, $cache_key_parser, $cache_key_renderer); $container->set('text_formatter.s9e.factory', $factory); // Create a user if none was provided, and add the common lang strings diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index d35330a975..0d780a19a9 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -56,6 +56,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $this->dispatcher, new \phpbb\config\config(array('allowed_schemes_links' => 'http,https,ftp')), new \phpbb\textformatter\s9e\link_helper, + $this->getMockBuilder('phpbb\\log\\log_interface')->getMock(), $this->get_cache_dir(), '_foo_parser', '_foo_renderer' @@ -263,6 +264,23 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $this->assertSame($expected, $renderer->render($parser->parse($original))); } + /** + * @testdox Logs malformed BBCodes + */ + public function test_malformed_bbcodes() + { + $log = $this->getMockBuilder('phpbb\\log\\log_interface')->getMock(); + $log->expects($this->once()) + ->method('add') + ->with('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, ['[x !x]{TEXT}[/x]', 'Cannot interpret the BBCode definition']); + + $container = new phpbb_mock_container_builder; + $container->set('log', $log); + + $fixture = __DIR__ . '/fixtures/malformed_bbcode.xml'; + $this->get_test_case_helpers()->set_s9e_services($container, $fixture); + } + /** * @testdox get_configurator() triggers events before and after configuration */ diff --git a/tests/text_formatter/s9e/fixtures/malformed_bbcode.xml b/tests/text_formatter/s9e/fixtures/malformed_bbcode.xml new file mode 100644 index 0000000000..7e7aa1a39c --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/malformed_bbcode.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + x + + 1 + [x !x]{TEXT}[/x] + ... + + + + + +
                +
                -- cgit v1.2.1 From 94c168291c155db0bbf60c16e574758ed7373633 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Feb 2018 20:43:56 +0100 Subject: [ticket/15516] Fix typo in UI test instructions [ci skip] PHPBB3-15516 --- tests/RUNNING_TESTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md index 3bff4f5d26..12ae7fa687 100644 --- a/tests/RUNNING_TESTS.md +++ b/tests/RUNNING_TESTS.md @@ -175,7 +175,7 @@ UI tests UI tests are functional tests that also support running JavaScript in a headless browser. These should be used when functionality that is only -executed using JS needs to be tested. The require a running +executed using JS needs to be tested. They require a running [PhantomJS WebDriver instance](http://phantomjs.org/). The executable can either be downloaded from [PhantomJS](http://phantomjs.org/download.html) or alternatively be installed with npm: -- cgit v1.2.1 From aa9d24ad3176a2fa0551a65355c05208774eeb6b Mon Sep 17 00:00:00 2001 From: kasimi Date: Sun, 11 Mar 2018 22:13:03 +0100 Subject: [ticket/15586] Added tests for adding modules the automatic way PHPBB3-15586 --- tests/dbal/ext/foo/bar/acp/acp_test_info.php | 37 ++++++++++++++++++++++++++ tests/dbal/ext/foo/bar/acp/acp_test_module.php | 25 +++++++++++++++++ tests/dbal/ext/foo/bar/composer.json | 24 +++++++++++++++++ tests/dbal/ext/foo/bar/ucp/ucp_test_info.php | 37 ++++++++++++++++++++++++++ tests/dbal/ext/foo/bar/ucp/ucp_test_module.php | 25 +++++++++++++++++ tests/dbal/migrator_tool_module_test.php | 35 ++++++++++++++++++++++++ 6 files changed, 183 insertions(+) create mode 100644 tests/dbal/ext/foo/bar/acp/acp_test_info.php create mode 100644 tests/dbal/ext/foo/bar/acp/acp_test_module.php create mode 100644 tests/dbal/ext/foo/bar/composer.json create mode 100644 tests/dbal/ext/foo/bar/ucp/ucp_test_info.php create mode 100644 tests/dbal/ext/foo/bar/ucp/ucp_test_module.php (limited to 'tests') diff --git a/tests/dbal/ext/foo/bar/acp/acp_test_info.php b/tests/dbal/ext/foo/bar/acp/acp_test_info.php new file mode 100644 index 0000000000..ac92623c3a --- /dev/null +++ b/tests/dbal/ext/foo/bar/acp/acp_test_info.php @@ -0,0 +1,37 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace foo\bar\acp; + +class acp_test_info +{ + public function module() + { + return array( + 'filename' => '\foo\bar\acp\acp_test_module', + 'title' => 'ACP_NEW_MODULE', + 'modes' => array( + 'mode_1' => array( + 'title' => 'ACP_NEW_MODULE_MODE_1', + 'auth' => '', + 'cat' => array('ACP_NEW_MODULE'), + ), + 'mode_2' => array( + 'title' => 'ACP_NEW_MODULE_MODE_2', + 'auth' => '', + 'cat' => array('ACP_NEW_MODULE'), + ), + ), + ); + } +} diff --git a/tests/dbal/ext/foo/bar/acp/acp_test_module.php b/tests/dbal/ext/foo/bar/acp/acp_test_module.php new file mode 100644 index 0000000000..01ce5c17dc --- /dev/null +++ b/tests/dbal/ext/foo/bar/acp/acp_test_module.php @@ -0,0 +1,25 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace foo\bar\acp; + +class acp_test_module +{ + var $u_action; + + function main($id, $mode) + { + $this->tpl_name = 'foobar'; + $this->page_title = 'Bertie'; + } +} diff --git a/tests/dbal/ext/foo/bar/composer.json b/tests/dbal/ext/foo/bar/composer.json new file mode 100644 index 0000000000..2edfd43d84 --- /dev/null +++ b/tests/dbal/ext/foo/bar/composer.json @@ -0,0 +1,24 @@ +{ + "name": "foo/bar", + "type": "phpbb-extension", + "description": "An example/sample extension to be used for testing purposes in phpBB Development.", + "version": "1.0.0", + "time": "2012-02-15 01:01:01", + "license": "GNU GPL v2", + "authors": [{ + "name": "John Smith", + "username": "JohnSmith27", + "email": "email@phpbb.com", + "homepage": "http://phpbb.com", + "role": "N/A" + }], + "require": { + "php": ">=5.4.7" + }, + "extra": { + "display-name": "phpBB BarFoo Extension", + "soft-require": { + "phpbb/phpbb": "3.2.*@dev" + } + } +} diff --git a/tests/dbal/ext/foo/bar/ucp/ucp_test_info.php b/tests/dbal/ext/foo/bar/ucp/ucp_test_info.php new file mode 100644 index 0000000000..d3489af832 --- /dev/null +++ b/tests/dbal/ext/foo/bar/ucp/ucp_test_info.php @@ -0,0 +1,37 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace foo\bar\ucp; + +class ucp_test_info +{ + public function module() + { + return array( + 'filename' => '\foo\bar\ucp\ucp_test_module', + 'title' => 'UCP_NEW_MODULE', + 'modes' => array( + 'mode_1' => array( + 'title' => 'UCP_NEW_MODULE_MODE_1', + 'auth' => '', + 'cat' => array('UCP_NEW_MODULE'), + ), + 'mode_2' => array( + 'title' => 'UCP_NEW_MODULE_MODE_2', + 'auth' => '', + 'cat' => array('UCP_NEW_MODULE'), + ), + ), + ); + } +} diff --git a/tests/dbal/ext/foo/bar/ucp/ucp_test_module.php b/tests/dbal/ext/foo/bar/ucp/ucp_test_module.php new file mode 100644 index 0000000000..b06b3238b6 --- /dev/null +++ b/tests/dbal/ext/foo/bar/ucp/ucp_test_module.php @@ -0,0 +1,25 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace foo\bar\ucp; + +class ucp_test_module +{ + var $u_action; + + function main($id, $mode) + { + $this->tpl_name = 'foobar'; + $this->page_title = 'Bertie'; + } +} diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index c625b93ded..117db0760f 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -11,6 +11,9 @@ * */ +require_once dirname(__FILE__) . '/ext/foo/bar/acp/acp_test_info.php'; +require_once dirname(__FILE__) . '/ext/foo/bar/ucp/ucp_test_info.php'; + class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case { public function getDataSet() @@ -39,6 +42,9 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $auth = $this->getMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + // Correctly set the root path for this test to this directory, so the classes can be found + $phpbb_root_path = dirname(__FILE__) . '/'; + $phpbb_extension_manager = new phpbb_mock_extension_manager($phpbb_root_path); $module_manager = new \phpbb\module\module_manager($cache, $this->db, $phpbb_extension_manager, MODULES_TABLE, $phpbb_root_path, $phpEx); @@ -250,6 +256,35 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $this->fail($e); } $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_SUBCAT', 'UCP_NEW_MODULE')); + + // Test adding new UCP module the automatic way, single mode + try + { + $this->tool->add('ucp', 'UCP_NEW_CAT', array( + 'module_basename' => '\foo\bar\ucp\ucp_test_module', + 'modes' => array('mode_1'), + )); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_MODULE_MODE_1')); + $this->assertEquals(false, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_MODULE_MODE_2')); + + // Test adding new ACP module the automatic way, all modes + try + { + $this->tool->add('acp', 'ACP_NEW_CAT', array( + 'module_basename' => '\foo\bar\acp\acp_test_module', + )); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE_MODE_1')); + $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE_MODE_2')); } public function test_remove() -- cgit v1.2.1 From d7db5d366b9a326237efc7576d7db3215a51bc81 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 19 Mar 2018 16:42:53 -0700 Subject: [ticket/15595] Fix module exists tool when parent is false PHPBB3-15595 --- tests/dbal/migrator_tool_module_test.php | 161 ++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index c625b93ded..0f3febb24d 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -52,11 +52,39 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case array( '', 'ACP_CAT', + false, true, ), array( 0, 'ACP_CAT', + false, + true, + ), + array( + false, + 'ACP_CAT', + false, + true, + ), + + // Test the existing category lazily + array( + '', + 'ACP_CAT', + true, + true, + ), + array( + 0, + 'ACP_CAT', + true, + true, + ), + array( + false, + 'ACP_CAT', + true, true, ), @@ -65,16 +93,39 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case '', 'ACP_MODULE', false, + false, + ), + array( + false, + 'ACP_MODULE', + false, + true, + ), + array( + 'ACP_CAT', + 'ACP_MODULE', + false, + true, + ), + + // Test the existing module lazily + array( + '', + 'ACP_MODULE', + true, + false, ), array( false, 'ACP_MODULE', true, + true, ), array( 'ACP_CAT', 'ACP_MODULE', true, + true, ), // Test for non-existant modules @@ -82,11 +133,39 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case '', 'ACP_NON_EXISTANT_CAT', false, + false, + ), + array( + false, + 'ACP_NON_EXISTANT_CAT', + false, + false, ), array( 'ACP_CAT', 'ACP_NON_EXISTANT_MODULE', false, + false, + ), + + // Test for non-existant modules lazily + array( + '', + 'ACP_NON_EXISTANT_CAT', + true, + false, + ), + array( + false, + 'ACP_NON_EXISTANT_CAT', + true, + false, + ), + array( + 'ACP_CAT', + 'ACP_NON_EXISTANT_MODULE', + true, + false, ), ); } @@ -94,9 +173,9 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case /** * @dataProvider exists_data_acp */ - public function test_exists_acp($parent, $module, $expected) + public function test_exists_acp($parent, $module, $lazy, $expected) { - $this->assertEquals($expected, $this->tool->exists('acp', $parent, $module)); + $this->assertEquals($expected, $this->tool->exists('acp', $parent, $module, $lazy)); } public function exists_data_ucp() @@ -106,11 +185,39 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case array( '', 'UCP_MAIN_CAT', + false, true, ), array( 0, 'UCP_MAIN_CAT', + false, + true, + ), + array( + false, + 'UCP_MAIN_CAT', + false, + true, + ), + + // Test the existing category lazily + array( + '', + 'UCP_MAIN_CAT', + true, + true, + ), + array( + 0, + 'UCP_MAIN_CAT', + true, + true, + ), + array( + false, + 'UCP_MAIN_CAT', + true, true, ), @@ -119,20 +226,50 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case '', 'UCP_SUBCATEGORY', false, + false, ), array( false, 'UCP_SUBCATEGORY', + false, true, ), array( 'UCP_MAIN_CAT', 'UCP_SUBCATEGORY', + false, true, ), array( 'UCP_SUBCATEGORY', 'UCP_MODULE', + false, + true, + ), + + // Test the existing module lazily + array( + '', + 'UCP_SUBCATEGORY', + true, + false, + ), + array( + false, + 'UCP_SUBCATEGORY', + true, + true, + ), + array( + 'UCP_MAIN_CAT', + 'UCP_SUBCATEGORY', + true, + true, + ), + array( + 'UCP_SUBCATEGORY', + 'UCP_MODULE', + true, true, ), @@ -141,10 +278,26 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case '', 'UCP_NON_EXISTANT_CAT', false, + false, + ), + array( + 'UCP_MAIN_CAT', + 'UCP_NON_EXISTANT_MODULE', + false, + false, + ), + + // Test for non-existant modules lazily + array( + '', + 'UCP_NON_EXISTANT_CAT', + true, + false, ), array( 'UCP_MAIN_CAT', 'UCP_NON_EXISTANT_MODULE', + true, false, ), ); @@ -153,9 +306,9 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case /** * @dataProvider exists_data_ucp */ - public function test_exists_ucp($parent, $module, $expected) + public function test_exists_ucp($parent, $module, $lazy, $expected) { - $this->assertEquals($expected, $this->tool->exists('ucp', $parent, $module)); + $this->assertEquals($expected, $this->tool->exists('ucp', $parent, $module, $lazy)); } public function test_add() -- cgit v1.2.1 From 9e50e52fa5c72ee668c0d4c43b15e441f31ada5c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 17 Jun 2018 11:01:11 +0200 Subject: [ticket/15693] Update tests to reflect changes to gen_rand_string() PHPBB3-15693 --- tests/random/gen_rand_string_test.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php index a9d1ea20de..428db6ac98 100644 --- a/tests/random/gen_rand_string_test.php +++ b/tests/random/gen_rand_string_test.php @@ -40,7 +40,10 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case $random_string_length = strlen($random_string); $this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH); - $this->assertTrue($random_string_length <= $num_chars); + $this->assertTrue( + $random_string_length == $num_chars, + sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length) + ); $this->assertRegExp('#^[A-Z0-9]+$#', $random_string); } } @@ -56,7 +59,10 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case $random_string_length = strlen($random_string); $this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH); - $this->assertTrue($random_string_length <= $num_chars); + $this->assertTrue( + $random_string_length == $num_chars, + sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length) + ); $this->assertRegExp('#^[A-NP-Z1-9]+$#', $random_string); } } -- cgit v1.2.1 From 9ee7b9b81f313537f8888f559024c5d54a787865 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Wed, 4 Jul 2018 17:13:37 +0200 Subject: [ticket/15696] Add tests PHPBB3-15696 --- tests/migrator/get_callable_from_step_test.php | 136 +++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 tests/migrator/get_callable_from_step_test.php (limited to 'tests') diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php new file mode 100644 index 0000000000..af636f5d21 --- /dev/null +++ b/tests/migrator/get_callable_from_step_test.php @@ -0,0 +1,136 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +class get_callable_from_step_test extends phpbb_database_test_case +{ + public function setUp() + { + global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log; + + parent::setUp(); + + $phpbb_log = $this->getMockBuilder('\phpbb\log\log')->disableOriginalConstructor()->getMock(); + $db = $this->new_dbal(); + $factory = new \phpbb\db\tools\factory(); + $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock(); + $user = $this->getMockBuilder('\phpbb\user')->disableOriginalConstructor()->getMock(); + $module_manager = new \phpbb\module\module_manager( + $this->getMockBuilder('\phpbb\cache\driver\dummy')->disableOriginalConstructor()->getMock(), + $db, + new phpbb_mock_extension_manager($phpbb_root_path), + 'phpbb_modules', + $phpbb_root_path, + $php_ext + ); + $module_tools = new \phpbb\db\migration\tool\module($db, $cache_service, $user, $module_manager, $phpbb_root_path, $php_ext, 'phpbb_modules'); + $this->migrator = new \phpbb\db\migrator( + new phpbb_mock_container_builder(), + new \phpbb\config\config(array()), + $db, + $factory->get($db), + 'phpbb_migrations', + $phpbb_root_path, + $php_ext, + $table_prefix, + array($module_tools), + new \phpbb\db\migration\helper() + ); + + if (!$module_tools->exists('acp', 0, 'new_module_langname')) + { + $module_tools->add('acp', 0, array( + 'module_basename' => 'new_module_basename', + 'module_langname' => 'new_module_langname', + 'module_mode' => 'settings', + 'module_auth' => '', + 'module_display' => true, + 'before' => false, + 'after' => false, + )); + $this->module_added = true; + } + } + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/../dbal/fixtures/migrator.xml'); + } + + public function get_callable_from_step_provider() + { + return array( + array( + array('if', array( + false, + array('permission.add', array('some_data')), + )), + true, // expects false + ), + array( + array('if', array( + array('module.exists', array( + 'mcp', + 'RANDOM_PARENT', + 'RANDOM_MODULE' + )), + array('permission.add', array('some_data')), + )), + true, // expects false + ), + array( + array('if', array( + array('module.exists', array( + 'acp', + 0, + 'new_module_langname' + )), + array('module.add', array( + 'acp', + 0, + 'module_basename' => 'new_module_basename2', + 'module_langname' => 'new_module_langname2', + 'module_mode' => 'settings', + 'module_auth' => '', + 'module_display' => true, + 'before' => false, + 'after' => false, + )), + )), + false, // expects false + ), + ); + } + + /** + * @dataProvider get_callable_from_step_provider + */ + public function test_get_callable_from_step($step, $expects_false) + { + if ($expects_false) + { + $this->assertFalse($this->call_get_callable_from_step($step)); + } + else + { + $this->assertNotFalse($this->call_get_callable_from_step($step)); + } + } + + protected function call_get_callable_from_step($step) + { + $class = new ReflectionClass($this->migrator); + $method = $class->getMethod('get_callable_from_step'); + $method->setAccessible(true); + return $method->invokeArgs($this->migrator, array($step)); + } +} -- cgit v1.2.1 From b5daa91650aa482bbe5fce75761804259ee4eb94 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Mon, 18 Jun 2018 11:20:18 +0200 Subject: [ticket/15659] Fix retrieve_block_vars() PHPBB3-15659 --- tests/template/context_test.php | 96 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 tests/template/context_test.php (limited to 'tests') diff --git a/tests/template/context_test.php b/tests/template/context_test.php new file mode 100644 index 0000000000..52ce6c8fde --- /dev/null +++ b/tests/template/context_test.php @@ -0,0 +1,96 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +class context_test extends phpbb_test_case +{ + protected $context; + protected function setUp() + { + $this->context = new \phpbb\template\context(); + + for ($i = 0; $i < 10; $i++) + { + $this->context->assign_block_vars('block' . $i, array( + 'FOO' . $i => 'foo' . $i, + 'BAR' . $i => 'bar' . $i, + )); + + for ($j = 0; $j < 10; $j++) + { + $this->context->assign_block_vars('block' . $i . '.subblock', array( + 'SUBFOO' => 'subfoo' . $j, + 'SUBBAR' => 'subbar' . $j, + )); + + for ($k = 0; $k < 10; $k++) + { + $this->context->assign_block_vars('block' . $i . '.subblock.subsubblock', array( + 'SUBSUBFOO' => 'subsubfoo' . $k, + 'SUBSUBBAR' => 'subsubbar' . $k, + )); + } + } + } + } + + public function retrieve_block_vars_data() + { + return array( + array('foo', array(), array()), // non-existent top-level block + array('block1.foo', array(), array()), // non-existent sub-level block + array('block1', array(), array( // top-level block, all vars + 'FOO1' => 'foo1', + 'BAR1' => 'bar1', + )), + array('block1', array('FOO1'), array( // top-level block, one var + 'FOO1' => 'foo1', + )), + array('block2.subblock', array(), array( // sub-level block, all vars + 'SUBFOO' => 'subfoo9', + 'SUBBAR' => 'subbar9', + )), + array('block2.subblock', array('SUBBAR'), array( // sub-level block, one var + 'SUBBAR' => 'subbar9', + )), + array('block2.subblock.subsubblock', array(), array( // sub-sub-level block, all vars + 'SUBSUBFOO' => 'subsubfoo9', + 'SUBSUBBAR' => 'subsubbar9', + )), + array('block2.subblock.subsubblock', array('SUBSUBBAR'), array( // sub-sub-level block, one var + 'SUBSUBBAR' => 'subsubbar9', + )), + array('block3.subblock[2]', array(), array( // sub-level, exact index, all vars + 'SUBFOO' => 'subfoo2', + 'SUBBAR' => 'subbar2', + )), + array('block3.subblock[2]', array('SUBBAR'), array( // sub-level, exact index, one var + 'SUBBAR' => 'subbar2', + )), + array('block3.subblock[3].subsubblock[5]', array(), array( // sub-sub-level, exact index, all vars + 'SUBSUBFOO' => 'subsubfoo5', + 'SUBSUBBAR' => 'subsubbar5', + )), + array('block3.subblock[4].subsubblock[6]', array('SUBSUBFOO'), array( // sub-sub-level, exact index, one var + 'SUBSUBFOO' => 'subsubfoo6', + )), + ); + } + + /** + * @dataProvider retrieve_block_vars_data + */ + public function test_retrieve_block_vars($blockname, $vararray, $result) + { + $this->assertEquals($result, $this->context->retrieve_block_vars($blockname, $vararray)); + } +} -- cgit v1.2.1 From 517c601482b9400a6b6d72c04791c534e0170622 Mon Sep 17 00:00:00 2001 From: kasimi Date: Sat, 7 Jul 2018 20:13:49 +0200 Subject: [ticket/15637] Updated test fixture to include complete event description PHPBB3-15637 --- tests/event/fixtures/extra_description.test | 2 +- tests/event/php_exporter_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/event/fixtures/extra_description.test b/tests/event/fixtures/extra_description.test index ce8f97ce89..e93a1044ac 100644 --- a/tests/event/fixtures/extra_description.test +++ b/tests/event/fixtures/extra_description.test @@ -3,7 +3,7 @@ /** * Description * -* NOTE: This will not be exported +* NOTE: This will also be exported * * @event extra_description.dispatch * @since 3.1.0-b2 diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 21dbb1e1d4..0d40cc3e70 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -57,7 +57,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case 'file' => 'extra_description.test', 'arguments' => array(), 'since' => '3.1.0-b2', - 'description' => 'Description', + 'description' => 'Description NOTE: This will also be exported', ), ), ), -- cgit v1.2.1 From 245f4df47c0d33ef8fe83bc5fd049a1afda79bb1 Mon Sep 17 00:00:00 2001 From: kasimi Date: Sat, 7 Jul 2018 21:25:29 +0200 Subject: [ticket/15637] Preserve line breaks in event descriptions PHPBB3-15637 --- tests/event/php_exporter_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 0d40cc3e70..c6670e1340 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -57,7 +57,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case 'file' => 'extra_description.test', 'arguments' => array(), 'since' => '3.1.0-b2', - 'description' => 'Description NOTE: This will also be exported', + 'description' => 'Description

                NOTE: This will also be exported', ), ), ), -- cgit v1.2.1 From 4ebd582947d44b4fa34e0fd81602a171b744b677 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Thu, 26 Jul 2018 15:54:35 +0200 Subject: [ticket/11500] Remove unnamed input PHPBB3-11500 --- tests/functional/acp_profile_field_test.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/functional/acp_profile_field_test.php b/tests/functional/acp_profile_field_test.php index 88df782faa..7a0a6ca941 100644 --- a/tests/functional/acp_profile_field_test.php +++ b/tests/functional/acp_profile_field_test.php @@ -28,18 +28,20 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case public function data_add_profile_field() { return array( - array('bool', 'profilefields.type.bool', + array('profilefields.type.bool', array( + 'field_ident' => 'bool', + 'lang_name' => 'bool', 'lang_options[0]' => 'foo', 'lang_options[1]' => 'bar', ), - array(), ), - array('dropdown', 'profilefields.type.dropdown', + array('profilefields.type.dropdown', array( + 'field_ident' => 'dropdown', + 'lang_name' => 'dropdown', 'lang_options' => "foo\nbar\nbar\nfoo", ), - array(), ), ); } @@ -47,13 +49,12 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case /** * @dataProvider data_add_profile_field */ - public function test_add_profile_field($name, $type, $page1_settings, $page2_settings) + public function test_add_profile_field($type, $page1_settings) { // Custom profile fields page $crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid); // these language strings are html $form = $crawler->selectButton('Create new field')->form(array( - 'field_ident' => $name, 'field_type' => $type, )); $crawler = self::submit($form); @@ -63,7 +64,7 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case $crawler = self::submit($form); // Fill form for profile field specific options - $form = $crawler->selectButton('Save')->form($page2_settings); + $form = $crawler->selectButton('Save')->form(); $crawler= self::submit($form); $this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text()); -- cgit v1.2.1 From b2277e7bf688168acfa3097730f556b7218858ac Mon Sep 17 00:00:00 2001 From: MikelAlejoBR Date: Sat, 28 Jul 2018 14:29:37 +0200 Subject: [ticket/15733] Remove unused code related to deprecated flood control PHPBB3-15733 --- tests/test_framework/phpbb_functional_test_case.php | 4 ---- 1 file changed, 4 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 e1daa4558a..12a296a4bf 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -1176,10 +1176,6 @@ class phpbb_functional_test_case extends phpbb_test_case } } - // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened) - // is not at least 2 seconds before submission, cancel the form - $form_data['lastclick'] = 0; - // I use a request because the form submission method does not allow you to send data that is not // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) // Instead, I send it as a request with the submit button "post" set to true. -- cgit v1.2.1 From c20d84ce1702b1ea69bcc2ffbb2435225021c7a1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 21 Aug 2018 21:25:33 +0200 Subject: [ticket/15746] Adjust tests after twig update PHPBB3-15746 --- tests/template/template_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 0f761abc76..727f35e9d2 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -364,7 +364,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array(), array(), - "Value'\n1 O'Clock\nValue\\x27\n1\\x20O\\x27Clock", + "Value'\n1 O'Clock\nValue\\u0027\n1\\u0020O\\u0027Clock", array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"), ), array( -- cgit v1.2.1 From 0f10c6ff6f0537c9cb00f6007b6bee9944e6587a Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Thu, 6 Sep 2018 14:31:57 +0200 Subject: [ticket/15716] Remove OAuth data upon user deletion PHPBB3-15716 --- tests/console/user/base.php | 3 +++ tests/functions/user_delete_test.php | 4 ++++ tests/functions_user/delete_user_test.php | 3 +++ 3 files changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/console/user/base.php b/tests/console/user/base.php index b84c0bb267..2fb7ee0394 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -94,6 +94,9 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case 'auth.provider_collection', $provider_collection ); + $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens'); + $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states'); + $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts'); parent::setUp(); } diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index db9b6e0c90..88680d5719 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -82,6 +82,10 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $phpbb_container->set('auth.provider.oauth.service.google', $oauth_provider_google); $phpbb_container->set('auth.provider_collection', $provider_collection); $phpbb_container->set('notification_manager', $notification_manager); + + $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens'); + $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states'); + $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts'); } public function test_user_delete() diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 25042d9f1b..30253ccc2f 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -46,6 +46,9 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case 'auth.provider_collection', $provider_collection ); + $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens'); + $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states'); + $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts'); } public function first_last_post_data() -- cgit v1.2.1 From 89d1401a77f7a2f9ee067b90efa975e21363e914 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Thu, 13 Sep 2018 18:47:14 +0200 Subject: [ticket/15742] Remove addslashes_recursively() PHPBB3-15742 --- tests/request/type_cast_helper_test.php | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'tests') diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php index 143c05aa9c..6407dca894 100644 --- a/tests/request/type_cast_helper_test.php +++ b/tests/request/type_cast_helper_test.php @@ -20,16 +20,6 @@ class phpbb_type_cast_helper_test extends phpbb_test_case $this->type_cast_helper = new \phpbb\request\type_cast_helper(); } - public function test_addslashes_recursively() - { - $data = array('some"string' => array('that"' => 'really"', 'needs"' => '"escaping')); - $expected = array('some\\"string' => array('that\\"' => 'really\\"', 'needs\\"' => '\\"escaping')); - - $this->type_cast_helper->addslashes_recursively($data); - - $this->assertEquals($expected, $data); - } - public function test_simple_recursive_set_var() { $data = 'eviL<3'; -- cgit v1.2.1 From 02234783c6f0fd9b15faf7a17d3bb8b1d39da557 Mon Sep 17 00:00:00 2001 From: v12mike Date: Sun, 15 Jul 2018 21:50:18 +0100 Subject: [ticket/15726] Implement selective purge in APCu cache driver The current APCu cache driver implements a global clearing of the APCu when the phpBB cache is purged. This is inappropriate if there are other phpBB boards, or other php applications sharing the APCu cache. This patch changes the behviour so that only cache entries matching the key_prefix of this board are cleared by a phpBB cache purge. The APCu unit test script has been updated to test this behaviour. It has also been updated so that the test case can be run individually previously it relied on initialisations made in other test scripts. PHPBB3-15726 --- tests/cache/apcu_driver_test.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) mode change 100644 => 100755 tests/cache/apcu_driver_test.php (limited to 'tests') diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php old mode 100644 new mode 100755 index 9de1d82a15..2002fb66d8 --- a/tests/cache/apcu_driver_test.php +++ b/tests/cache/apcu_driver_test.php @@ -49,10 +49,27 @@ class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case protected function setUp() { + global $phpbb_container, $phpbb_root_path; + parent::setUp(); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); + $this->driver = new \phpbb\cache\driver\apcu; $this->driver->purge(); } + + public function test_purge() + { + /* add a cache entry which does not match our key */ + $foreign_key = 'test_' . $this->driver->key_prefix . 'test'; + $this->assertSame(true, apcu_store($foreign_key, 0, 600)); + $this->assertSame(true, apcu_exists($foreign_key)); + + parent::test_purge(); + + $this->assertSame(true, apcu_exists($foreign_key)); + } } -- cgit v1.2.1 From 7d4d9770cfc38d613c3cf2b8495d2f8e63623ebd Mon Sep 17 00:00:00 2001 From: v12mike Date: Mon, 16 Jul 2018 07:26:14 +0100 Subject: [ticket/15726] Implement selective purge in APCu cache driver fix file permissions PHPBB3-15726 --- tests/cache/apcu_driver_test.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tests/cache/apcu_driver_test.php (limited to 'tests') diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php old mode 100755 new mode 100644 -- cgit v1.2.1 From bf9af922208ad93c2afbe4fa9462f8914c8d4363 Mon Sep 17 00:00:00 2001 From: v12mike Date: Wed, 25 Jul 2018 19:36:25 +0100 Subject: [ticket/15726] Implement selective purge in APCu cache driver Correcting code formatting and whitespace PHPBB3-15726 --- tests/cache/apcu_driver_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php index 2002fb66d8..57f640c313 100644 --- a/tests/cache/apcu_driver_test.php +++ b/tests/cache/apcu_driver_test.php @@ -61,7 +61,7 @@ class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case $this->driver->purge(); } - public function test_purge() + public function test_purge() { /* add a cache entry which does not match our key */ $foreign_key = 'test_' . $this->driver->key_prefix . 'test'; -- cgit v1.2.1 From d29d4389f9efdec4986c62052df7cd8a87135645 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Tue, 25 Sep 2018 14:42:03 +0200 Subject: [ticket/15758] Show translated msg for INSECURE_REDIRECT PHPBB3-15758 --- tests/security/redirect_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index 40cb7d2f04..0177eb4259 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -109,7 +109,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base if ($expected_error !== false) { - $this->setExpectedTriggerError(E_USER_ERROR, $user->lang[$expected_error]); + $this->setExpectedTriggerError(E_USER_WARNING, $user->lang[$expected_error]); } $result = redirect($test, true, $disable_cd_check); -- cgit v1.2.1 From 4a2b12a0c8d7fc3761dde815ca3cfd5685c6a8c6 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 1 Oct 2018 13:56:37 -0700 Subject: [ticket/15824] Fix cache initialization in UI framework PHPBB3-15824 --- tests/test_framework/phpbb_ui_test_case.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index d38d14f45c..72d15ae0b0 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -338,6 +338,12 @@ class phpbb_ui_test_case extends phpbb_test_case { if (!$this->cache) { + global $phpbb_container, $phpbb_root_path; + + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); + $this->cache = new \phpbb\cache\driver\file; } -- cgit v1.2.1 From b487a3d9efbefc97aa7562ffbd4fa23577d7a8e8 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 1 Oct 2018 17:29:13 -0700 Subject: [ticket/15824] Make UI test framework correctly install exts PHPBB3-15824 --- tests/test_framework/phpbb_ui_test_case.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 72d15ae0b0..d16ac78c4b 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -192,6 +192,13 @@ class phpbb_ui_test_case extends phpbb_test_case } } + $install_config_file = $phpbb_root_path . 'store/install_config.php'; + + if (file_exists($install_config_file)) + { + unlink($install_config_file); + } + $container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $container = $container_builder ->with_environment('installer') @@ -205,11 +212,14 @@ class phpbb_ui_test_case extends phpbb_test_case ], 'cache.driver.class' => 'phpbb\cache\driver\file' ]) + ->with_config(new \phpbb\config_php_file($phpbb_root_path, $phpEx)) ->without_compiled_container() ->get_container(); $container->register('installer.install_finish.notify_user')->setSynthetic(true); $container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task()); + $container->register('installer.install_finish.install_extensions')->setSynthetic(true); + $container->set('installer.install_finish.install_extensions', new phpbb_mock_null_installer_task()); $container->compile(); $language = $container->get('language'); -- cgit v1.2.1 From 253b42372f05f38c57da95fa174eed92d7ff863a Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 3 Oct 2018 18:50:30 -0700 Subject: [ticket/15824] Add UI test method to wait for AJAX requests PHPBB3-15824 --- tests/test_framework/phpbb_ui_test_case.php | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index d16ac78c4b..15a1cd375e 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -606,4 +606,37 @@ class phpbb_ui_test_case extends phpbb_test_case $this->getDriver()->takeScreenshot($screenshot); } + + /** + * Wait for AJAX. Should be called after an AJAX action is made. + * + * @param string $framework javascript frameworks jquery|prototype|dojo + * @throws \Facebook\WebDriver\Exception\NoSuchElementException + * @throws \Facebook\WebDriver\Exception\TimeOutException + */ + public function waitForAjax($framework = 'jquery') + { + switch ($framework) + { + case 'jquery': + $code = 'return jQuery.active;'; + break; + case 'prototype': + $code = 'return Ajax.activeRequestCount;'; + break; + case 'dojo': + $code = 'return dojo.io.XMLHTTPTransport.inFlight.length;'; + break; + default: + throw new \RuntimeException('Unsupported framework'); + break; + } + // wait for at most 30s, retry every 2000ms (2s) + $driver = $this->getDriver(); + $driver->wait(30, 2000)->until( + function () use ($driver, $code) { + return !$driver->executeScript($code); + } + ); + } } -- cgit v1.2.1 From 101d3b763308efe823d03c09bd0a4a109d19fc26 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Mon, 14 Mar 2016 14:42:48 +0100 Subject: [ticket/10432] Don't require username when user forgets password PHPBB3-10432 --- tests/functional/user_password_reset_test.php | 45 ++++++++++++++++------ .../test_framework/phpbb_functional_test_case.php | 5 ++- 2 files changed, 36 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php index 3da78407cf..af53ba2b0d 100644 --- a/tests/functional/user_password_reset_test.php +++ b/tests/functional/user_password_reset_test.php @@ -21,25 +21,46 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca public function test_password_reset() { $this->add_lang('ucp'); - $user_id = $this->create_user('reset-password-test-user'); + $user_id = $this->create_user('reset-password-test-user', 'reset-password-test-user@test.com'); + + $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); + $form = $crawler->selectButton('submit')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('NO_EMAIL_USER', $crawler->text()); $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); $form = $crawler->selectButton('submit')->form(array( - 'username' => 'reset-password-test-user', + 'email' => 'reset-password-test-user@test.com', )); $crawler = self::submit($form); - $this->assertContainsLang('NO_EMAIL_USER', $crawler->text()); + $this->assertContainsLang('PASSWORD_UPDATED', $crawler->text()); + // Check if columns in database were updated for password reset + $this->get_user_data('reset-password-test-user'); + $this->assertNotNull($this->user_data['user_actkey']); + $this->assertNotNull($this->user_data['user_newpasswd']); + + // Create another user with the same email + $this->create_user('reset-password-test-user1', 'reset-password-test-user@test.com'); + + // Test that username is now also required $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); $form = $crawler->selectButton('submit')->form(array( - 'username' => 'reset-password-test-user', - 'email' => 'nobody@example.com', + 'email' => 'reset-password-test-user@test.com', + )); + $crawler = self::submit($form); + $this->assertContainsLang('EMAIL_NOT_UNIQUE', $crawler->text()); + + // Provide both username and email + $form = $crawler->selectButton('submit')->form(array( + 'email' => 'reset-password-test-user@test.com', + 'username' => 'reset-password-test-user1', )); $crawler = self::submit($form); $this->assertContainsLang('PASSWORD_UPDATED', $crawler->text()); // Check if columns in database were updated for password reset - $this->get_user_data(); + $this->get_user_data('reset-password-test-user1'); $this->assertNotNull($this->user_data['user_actkey']); $this->assertNotNull($this->user_data['user_newpasswd']); @@ -73,7 +94,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca public function test_activate_new_password($expected, $user_id, $act_key) { $this->add_lang('ucp'); - $this->get_user_data(); + $this->get_user_data('reset-password-test-user'); $user_id = (!$user_id) ? $this->user_data['user_id'] : $user_id; $act_key = (!$act_key) ? $this->user_data['user_actkey'] : $act_key; @@ -119,7 +140,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca public function test_acivateAfterDeactivate() { // User is active, actkey should not exist - $this->get_user_data(); + $this->get_user_data('reset-password-test-user'); $this->assertEmpty($this->user_data['user_actkey']); $this->login(); @@ -143,7 +164,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca $crawler = self::request('GET', preg_replace('#(.+)(adm/index.php.+)#', '$2', $link->getUri())); // Ensure again that actkey is empty after deactivation - $this->get_user_data(); + $this->get_user_data('reset-password-test-user'); $this->assertEmpty($this->user_data['user_actkey']); // Force reactivation of account and check that act key is not empty anymore @@ -152,16 +173,16 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca $crawler = self::submit($form, array('action' => 'reactivate')); $this->assertContainsLang('FORCE_REACTIVATION_SUCCESS', $crawler->filter('html')->text()); - $this->get_user_data(); + $this->get_user_data('reset-password-test-user'); $this->assertNotEmpty($this->user_data['user_actkey']); } - protected function get_user_data() + protected function get_user_data($username) { $db = $this->get_db(); $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason FROM ' . USERS_TABLE . " - WHERE username = 'reset-password-test-user'"; + WHERE username = '$username'"; $result = $db->sql_query($sql); $this->user_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 12a296a4bf..d4856f954a 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -550,9 +550,10 @@ class phpbb_functional_test_case extends phpbb_test_case * Creates a new user with limited permissions * * @param string $username Also doubles up as the user's password + * @param string $email User email (defaults to nobody@example.com) * @return int ID of created user */ - protected function create_user($username) + protected function create_user($username, $email = 'nobody@example.com') { // Required by unique_id global $config; @@ -604,7 +605,7 @@ class phpbb_functional_test_case extends phpbb_test_case $user_row = array( 'username' => $username, 'group_id' => 2, - 'user_email' => 'nobody@example.com', + 'user_email' => $email, 'user_type' => 0, 'user_lang' => 'en', 'user_timezone' => 'UTC', -- cgit v1.2.1 From b148bb5d707d739e92b66205866a764a9aa133b5 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Sun, 21 Oct 2018 05:56:29 +0000 Subject: [ticket/15849] Stop using php4 constructors PHPBB3-15849 --- tests/cache/cache_memory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/cache/cache_memory.php b/tests/cache/cache_memory.php index 806edb963a..565e9a48eb 100644 --- a/tests/cache/cache_memory.php +++ b/tests/cache/cache_memory.php @@ -18,7 +18,7 @@ class phpbb_cache_memory extends \phpbb\cache\driver\memory /** * Set cache path */ - function phpbb_cache_memory() + function __construct() { } -- cgit v1.2.1 From d753351edc04a45c61411ee09607fb932d314617 Mon Sep 17 00:00:00 2001 From: Derky Date: Tue, 23 Oct 2018 23:51:55 +0200 Subject: [ticket/security/227] Replace ImageMagick support with thumbnail event SECURITY-227 --- tests/console/thumbnail_test.php | 1 - tests/functional/acp_attachments_test.php | 78 ------------------------------- tests/functional/fileupload_form_test.php | 1 - 3 files changed, 80 deletions(-) delete mode 100644 tests/functional/acp_attachments_test.php (limited to 'tests') diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php index 439e3623fa..d5fbfa0fed 100644 --- a/tests/console/thumbnail_test.php +++ b/tests/console/thumbnail_test.php @@ -46,7 +46,6 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case $config = $this->config = new \phpbb\config\config(array( 'img_min_thumb_filesize' => 2, 'img_max_thumb_width' => 2, - 'img_imagick' => '', )); $this->db = $this->db = $this->new_dbal(); diff --git a/tests/functional/acp_attachments_test.php b/tests/functional/acp_attachments_test.php deleted file mode 100644 index 8e810a508a..0000000000 --- a/tests/functional/acp_attachments_test.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -/** - * @group functional - */ -class phpbb_functional_acp_attachments_test extends phpbb_functional_test_case -{ - public function data_imagick_path_linux() - { - return array( - array('/usr/bin', 'Configuration updated successfully'), - array('/usr/foobar', 'The entered path “/usr/foobar” does not exist.'), - array('/usr/bin/which', 'The entered path “/usr/bin/which” is not a directory.'), - ); - } - - /** - * @dataProvider data_imagick_path_linux - */ - public function test_imagick_path_linux($imagick_path, $expected) - { - if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux') - { - $this->markTestSkipped('Unable to test linux specific paths on other OS.'); - } - - $this->login(); - $this->admin_login(); - - $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid); - - $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path)); - - $crawler = self::submit($form); - $this->assertContains($expected, $crawler->filter('#main')->text()); - } - - public function data_imagick_path_windows() - { - return array( - array('C:\Windows', 'Configuration updated successfully'), - array('C:\Windows\foobar1', 'The entered path “C:\Windows\foobar1” does not exist.'), - array('C:\Windows\explorer.exe', 'The entered path “C:\Windows\explorer.exe” is not a directory.'), - ); - } - - /** - * @dataProvider data_imagick_path_windows - */ - public function test_imagick_path_windows($imagick_path, $expected) - { - if (strtolower(substr(PHP_OS, 0, 3)) !== 'win') - { - $this->markTestSkipped('Unable to test windows specific paths on other OS.'); - } - - $this->login(); - $this->admin_login(); - - $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid); - - $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path)); - - $crawler = self::submit($form); - $this->assertContains($expected, $crawler->filter('#main')->text()); - } -} diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index d381fa1ae2..b0780172ff 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -99,7 +99,6 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $form = $crawler->selectButton('Submit')->form(array( 'config[check_attachment_content]' => 0, - 'config[img_imagick]' => '', )); self::submit($form); -- cgit v1.2.1 From 1d2a654ad7f34367cc5f8c8b3d5893e617b92f3f Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Sun, 28 Oct 2018 10:12:13 +0100 Subject: [ticket/10432] Fix errors and address privacy concern PHPBB3-10432 --- tests/functional/user_password_reset_test.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php index af53ba2b0d..2361eed066 100644 --- a/tests/functional/user_password_reset_test.php +++ b/tests/functional/user_password_reset_test.php @@ -23,17 +23,27 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca $this->add_lang('ucp'); $user_id = $this->create_user('reset-password-test-user', 'reset-password-test-user@test.com'); + // test without email $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); $form = $crawler->selectButton('submit')->form(); $crawler = self::submit($form); $this->assertContainsLang('NO_EMAIL_USER', $crawler->text()); + // test with non-existent email + $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); + $form = $crawler->selectButton('submit')->form(array( + 'email' => 'non-existent@email.com', + )); + $crawler = self::submit($form); + $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text()); + + // test with correct email $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); $form = $crawler->selectButton('submit')->form(array( 'email' => 'reset-password-test-user@test.com', )); $crawler = self::submit($form); - $this->assertContainsLang('PASSWORD_UPDATED', $crawler->text()); + $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text()); // Check if columns in database were updated for password reset $this->get_user_data('reset-password-test-user'); @@ -57,7 +67,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca 'username' => 'reset-password-test-user1', )); $crawler = self::submit($form); - $this->assertContainsLang('PASSWORD_UPDATED', $crawler->text()); + $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text()); // Check if columns in database were updated for password reset $this->get_user_data('reset-password-test-user1'); @@ -182,7 +192,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca $db = $this->get_db(); $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason FROM ' . USERS_TABLE . " - WHERE username = '$username'"; + WHERE username = '" . $db->sql_escape($username) . "'"; $result = $db->sql_query($sql); $this->user_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); -- cgit v1.2.1 From 6a353853084ad7c7022f838e82ff82ff9ea11c9c Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Mon, 8 Oct 2018 15:45:21 +0200 Subject: [ticket/15833] Add core.avatar_manager_avatar_delete_after event PHPBB3-15833 --- tests/avatar/manager_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 9e826a3a59..0a64bfd69f 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -99,7 +99,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case $this->config['allow_avatar_' . get_class($this->avatar_barfoo)] = false; // Set up avatar manager - $this->manager = new \phpbb\avatar\manager($this->config, $avatar_drivers, $phpbb_container); + $this->manager = new \phpbb\avatar\manager($this->config, $dispatcher, $avatar_drivers); $this->db = $this->new_dbal(); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); -- cgit v1.2.1 From c0a26e3d57e69fb1dc436379b4e3609bc10f9194 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 7 Nov 2018 22:04:30 +0100 Subject: [ticket/security/227] Remove no longer needed validation tests SECURITY-227 --- tests/functions_acp/validate_config_vars_test.php | 96 ----------------------- 1 file changed, 96 deletions(-) (limited to 'tests') diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php index 5c31888291..1182d659f0 100644 --- a/tests/functions_acp/validate_config_vars_test.php +++ b/tests/functions_acp/validate_config_vars_test.php @@ -161,100 +161,4 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case $this->assertEquals($expected, $phpbb_error); } - - public function data_validate_path_linux() - { - return array( - array('/usr/bin', 'absolute_path', true), - array('/usr/bin/', 'absolute_path:50:200', true), - array('/usr/bin/which', 'absolute_path', 'DIRECTORY_NOT_DIR'), - array('/foo/bar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'), - array('C:\Windows', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'), - array('.', 'absolute_path', true), - array('', 'absolute_path', true), - array('mkdir /foo/bar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'), - // Make sure above command didn't do anything - array('/foo/bar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'), - ); - } - - /** - * @dataProvider data_validate_path_linux - */ - public function test_validate_path_linux($path, $validation_type, $expected) - { - if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux') - { - $this->markTestSkipped('Unable to test linux specific paths on other OS.'); - } - - $error = array(); - $config_ary = array( - 'path' => $path, - ); - - validate_config_vars(array( - 'path' => array('lang' => 'FOOBAR', 'validate' => $validation_type), - ), - $config_ary, - $error - ); - - if ($expected === true) - { - $this->assertEmpty($error); - } - else - { - $this->assertEquals(array($expected), $error); - } - } - - public function data_validate_path_windows() - { - return array( - array('C:\Windows', 'absolute_path', true), - array('C:\Windows\\', 'absolute_path:50:200', true), - array('C:\Windows\explorer.exe', 'absolute_path', 'DIRECTORY_NOT_DIR'), - array('C:\foobar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'), - array('/usr/bin', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'), - array('.', 'absolute_path', true), - array('', 'absolute_path', true), - array('mkdir C:\Windows\foobar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'), - // Make sure above command didn't do anything - array('C:\Windows\foobar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'), - ); - } - - /** - * @dataProvider data_validate_path_windows - */ - public function test_validate_path_windows($path, $validation_type, $expected) - { - if (strtolower(substr(PHP_OS, 0, 3)) !== 'win') - { - $this->markTestSkipped('Unable to test windows specific paths on other OS.'); - } - - $error = array(); - $config_ary = array( - 'path' => $path, - ); - - validate_config_vars(array( - 'path' => array('lang' => 'FOOBAR', 'validate' => $validation_type), - ), - $config_ary, - $error - ); - - if ($expected === true) - { - $this->assertEmpty($error); - } - else - { - $this->assertEquals(array($expected), $error); - } - } } -- cgit v1.2.1 From b6f6930eb56b9fd64f200a7b0e6d8cd28f0e73f6 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Thu, 29 Nov 2018 19:56:24 +0100 Subject: [ticket/15886] Group helper functions PHPBB3-15886 --- tests/group/helper_get_name_string_test.php | 114 ++++++++++++++++++++++++++ tests/group/helper_get_name_test.php | 31 +++++++ tests/group/helper_get_rank_test.php | 43 ++++++++++ tests/group/helper_test.php | 68 --------------- tests/group/helper_test_case.php | 123 ++++++++++++++++++++++++++++ 5 files changed, 311 insertions(+), 68 deletions(-) create mode 100644 tests/group/helper_get_name_string_test.php create mode 100644 tests/group/helper_get_name_test.php create mode 100644 tests/group/helper_get_rank_test.php delete mode 100644 tests/group/helper_test.php create mode 100644 tests/group/helper_test_case.php (limited to 'tests') diff --git a/tests/group/helper_get_name_string_test.php b/tests/group/helper_get_name_string_test.php new file mode 100644 index 0000000000..7ea0f156e4 --- /dev/null +++ b/tests/group/helper_get_name_string_test.php @@ -0,0 +1,114 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once dirname(__FILE__) . '/helper_test_case.php'; + +class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_case +{ + + public function get_name_string_profile_data() + { + global $phpbb_root_path, $phpEx; + + return array( + array(0, 'Non existing group', '', false, ''), + array(2, 'Administrators', 'AA0000', false, "{$phpbb_root_path}memberlist.$phpEx?mode=group&g=2"), + array(42, 'Example Group', '', 'http://www.example.org/group.php?mode=show', 'http://www.example.org/group.php?mode=show&g=42'), + ); + } + + /** + * @dataProvider get_name_string_profile_data + */ + public function test_get_name_string_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected) + { + $this->assertEquals($expected, $this->group_helper->get_name_string('profile', $group_id, $group_name, $group_colour, $custom_profile_url)); + } + + public function get_name_string_group_name_data() + { + return array( + // Should be fine + array(0, 'Bots', 'AA0000', false, 'Bots'), + array(1, 'new_group', '', false, 'Some new group'), + array(2, 'group_with_ümlauts', '', 'http://www.example.org/group.php?mode=show', 'Should work'), + + // Should fail and thus return the same + array(3, 'not_uppercase', 'FFFFFF', false, 'not_uppercase'), + array(4, 'Awesome group', '', false, 'Awesome group'), + ); + } + + /** + * @dataProvider get_name_string_group_name_data + */ + public function test_get_name_string_group_name($group_id, $group_name, $group_colour, $custom_profile_url, $expected) + { + $this->assertEquals($expected, $this->group_helper->get_name_string('group_name', $group_id, $group_name, $group_colour, $custom_profile_url)); + } + + public function get_name_string_colour_data() + { + return array( + array(0, '', '', false, ''), + array(0, '', 'F0F0F0', false, '#F0F0F0'), + array(1, 'Guests', '000000', false, '#000000'), + array(2, 'Administrators', '', false, ''), + ); + } + + /** + * @dataProvider get_name_string_colour_data + */ + public function test_get_name_string_colour($group_id, $group_name, $group_colour, $custom_profile_url, $expected) + { + $this->assertEquals($expected, $this->group_helper->get_name_string('colour', $group_id, $group_name, $group_colour, $custom_profile_url)); + } + + public function get_name_string_full_data() + { + global $phpbb_root_path, $phpEx; + + return array( + array(0, 'Bots', '000000', false, 'Bots'), + array(7, 'new_group', 'FFA500', false, 'Some new group'), + array(14, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', 'Awesome group'), + ); + } + + /** + * @dataProvider get_name_string_full_data + */ + public function test_get_name_string_full($group_id, $group_name, $group_colour, $custom_profile_url, $expected) + { + $this->assertEquals($expected, $this->group_helper->get_name_string('full', $group_id, $group_name, $group_colour, $custom_profile_url)); + } + + public function get_name_string_no_profile_data() + { + return array( + array(0, 'Bots', '000000', false, 'Bots'), + array(1, 'new_group', '', false, 'Some new group'), + arraY(2, 'not_uppercase', 'FF0000', false, 'not_uppercase'), + array(5, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', 'Awesome group'), + ); + } + + /** + * @dataProvider get_name_string_no_profile_data + */ + public function test_get_name_string_no_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected) + { + $this->assertEquals($expected, $this->group_helper->get_name_string('no_profile', $group_id, $group_name, $group_colour, $custom_profile_url)); + } +} diff --git a/tests/group/helper_get_name_test.php b/tests/group/helper_get_name_test.php new file mode 100644 index 0000000000..b39b2cbedd --- /dev/null +++ b/tests/group/helper_get_name_test.php @@ -0,0 +1,31 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once dirname(__FILE__) . '/helper_test_case.php'; + +class phpbb_group_helper_get_name_test extends phpbb_group_helper_test_case +{ + public function test_get_name() + { + // They should be totally fine + $this->assertEquals('Bots', $this->group_helper->get_name('Bots')); + $this->assertEquals('Some new group', $this->group_helper->get_name('new_group')); + $this->assertEquals('Should work', $this->group_helper->get_name('group_with_ümlauts')); + + // This should fail (obviously) + $this->assertNotEquals('The key does not contain uppercase letters', $this->group_helper->get_name('not_uppercase')); + + // The key doesn't exist so just return group name... + $this->assertEquals('Awesome group', $this->group_helper->get_name('Awesome group')); + } +} diff --git a/tests/group/helper_get_rank_test.php b/tests/group/helper_get_rank_test.php new file mode 100644 index 0000000000..5efd8ad95e --- /dev/null +++ b/tests/group/helper_get_rank_test.php @@ -0,0 +1,43 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once dirname(__FILE__) . '/helper_test_case.php'; + +class phpbb_group_helper_get_rank_test extends phpbb_group_helper_test_case +{ + public function get_rank_data() + { + global $phpbb_root_path; + + return array( + array( + array('group_id' => 0, 'group_rank' => 1), + array( + 'title' => 'Site admin', + 'img' => 'Site admin', + 'img_src' => $phpbb_root_path . 'images/ranks/siteadmin.png', + ) + ), + array(array('group_id' => 1, 'group_rank' => 0), array('title' => null, 'img' => null, 'img_src' => null)), + array(array('group_id' => 2, 'group_rank' => 2), array('title' => 'Test member', 'img' => '', 'img_src' => '')), + ); + } + + /** + * @dataProvider get_rank_data + */ + public function test_get_rank($group_data, $expected) + { + $this->assertEquals($expected, $this->group_helper->get_rank($group_data)); + } +} diff --git a/tests/group/helper_test.php b/tests/group/helper_test.php deleted file mode 100644 index 2377a6f47c..0000000000 --- a/tests/group/helper_test.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @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_group_helper_test extends phpbb_test_case -{ - /** @var \phpbb\group\helper */ - protected $group_helper; - - public function setUp() - { - global $phpbb_root_path, $phpEx; - - // Set up language service - $lang = new \phpbb\language\language( - new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx) - ); - - // Set up language data for testing - $reflection_class = new ReflectionClass('\phpbb\language\language'); - - // Set default language files loaded flag to true - $loaded_flag = $reflection_class->getProperty('common_language_files_loaded'); - $loaded_flag->setAccessible(true); - $loaded_flag->setValue($lang, true); - - // Set up test language data - $lang_array = $reflection_class->getProperty('lang'); - $lang_array->setAccessible(true); - $lang_array->setValue($lang, $this->get_test_language_data_set()); - - // Set up group helper - $this->group_helper = new \phpbb\group\helper($lang); - } - - public function test_get_name() - { - // They should be totally fine - $this->assertEquals('Bots', $this->group_helper->get_name('Bots')); - $this->assertEquals('Some new group', $this->group_helper->get_name('new_group')); - $this->assertEquals('Should work', $this->group_helper->get_name('group_with_ümlauts')); - - // This should fail (obviously) - $this->assertNotEquals('They key does not contain uppercase letters', $this->group_helper->get_name('not_uppercase')); - - // The key doesn't exist so just return group name... - $this->assertEquals('Awesome group', $this->group_helper->get_name('Awesome group')); - } - - protected function get_test_language_data_set() - { - return array( - 'G_BOTS' => 'Bots', - 'G_NEW_GROUP' => 'Some new group', - 'G_not_uppercase' => 'The key does not contain uppercase letters', - 'G_GROUP_WITH_ÜMLAUTS' => 'Should work', - ); - } -} diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php new file mode 100644 index 0000000000..1318cf9040 --- /dev/null +++ b/tests/group/helper_test_case.php @@ -0,0 +1,123 @@ + + * @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_group_helper_test_case extends phpbb_test_case +{ + /** @var \phpbb\group\helper */ + protected $group_helper; + + protected function config_defaults() + { + $defaults = array( + 'ranks_path' => 'images/ranks' + ); + return $defaults; + } + + protected function get_test_language_data_set() + { + return array( + 'G_BOTS' => 'Bots', + 'G_NEW_GROUP' => 'Some new group', + 'G_not_uppercase' => 'The key does not contain uppercase letters', + 'G_GROUP_WITH_ÜMLAUTS' => 'Should work', + ); + } + + protected function get_test_rank_data_set() + { + return array( + 'special' => array( + 1 => array( + 'rank_id' => 1, + 'rank_title' => 'Site admin', + 'rank_special' => 1, + 'rank_image' => 'siteadmin.png', + ), + 2 => array( + 'rank_id' => 2, + 'rank_title' => 'Test member', + 'rank_special' => 1, + 'rank_image' => '', + ) + ) + ); + } + + protected function setup_engine(array $new_config = array()) + { + global $cache, $phpbb_dispatcher, $phpbb_root_path, $phpEx; + + // Set up authentication data for testing + $auth = $this->getMock('\phpbb\auth\auth'); + $auth->expects($this->any()) + ->method('acl_get') + ->with($this->stringContains('_'), $this->anything()) + ->will($this->returnValueMap(array( + array('u_viewprofile', true), + ))); + + // Set up cache service + $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock(); + $cache_service->expects($this->any()) + ->method('obtain_ranks') + ->will($this->returnValue($this->get_test_rank_data_set())); + + // Set up configuration + $defaults = $this->config_defaults(); + $config = new \phpbb\config\config(array_merge($defaults, $new_config)); + + // Set up language service + $lang = new \phpbb\language\language( + new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx) + ); + + // Set up language data for testing + $reflection_class = new ReflectionClass('\phpbb\language\language'); + + // Set default language files loaded flag to true + $loaded_flag = $reflection_class->getProperty('common_language_files_loaded'); + $loaded_flag->setAccessible(true); + $loaded_flag->setValue($lang, true); + + // Set up test language data + $lang_array = $reflection_class->getProperty('lang'); + $lang_array->setAccessible(true); + $lang_array->setValue($lang, $this->get_test_language_data_set()); + + // Set up event dispatcher + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + + // Set up path helper + $filesystem = new \phpbb\filesystem\filesystem(); + $path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + $filesystem, + $this->getMock('\phpbb\request\request'), + $phpbb_root_path, + $phpEx + ); + + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $user->data['user_id'] = ANONYMOUS; + + $this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user, $phpbb_root_path, $phpEx); + } + + public function setUp() + { + $this->setup_engine(); + } +} -- cgit v1.2.1 From a1baf106d68259daa0c6b1cd1bec8e870aef94f6 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Thu, 29 Nov 2018 20:27:04 +0100 Subject: [ticket/15886] Fix notification_group_request_test PHPBB3-15886 --- tests/notification/group_request_test.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 92e758a336..36017945ec 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -49,9 +49,17 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas $this->cache->get_driver() )); $this->container->set('group_helper', new \phpbb\group\helper( + $this->getMock('\phpbb\auth\auth'), + $this->cache, + $this->config, new \phpbb\language\language( new phpbb\language\language_file_loader($phpbb_root_path, $phpEx) - ) + ), + new phpbb_mock_event_dispatcher(), + $this->getMock('\phpbb\path_helper'), + $this->user, + $phpbb_root_path, + $phpEx )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher; $phpbb_log = new \phpbb\log\dummy(); -- cgit v1.2.1 From d356fa9f97986d7d31aa77d44c08ae07fbbe1579 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Thu, 29 Nov 2018 20:46:52 +0100 Subject: [ticket/15886] Arguments for path_helper PHPBB3-15886 --- tests/notification/group_request_test.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 36017945ec..f53fe32f2a 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -56,7 +56,15 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas new phpbb\language\language_file_loader($phpbb_root_path, $phpEx) ), new phpbb_mock_event_dispatcher(), - $this->getMock('\phpbb\path_helper'), + new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem\filesystem(), + $this->getMock('\phpbb\request\request'), + $phpbb_root_path, + $phpEx + ), $this->user, $phpbb_root_path, $phpEx -- cgit v1.2.1 From fc27dc02b42e3afa98e96bdab0daf752c6cb9ccf Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 2 Dec 2018 12:54:31 +0100 Subject: [ticket/15893] Add test for covering phpbb_format_quote PHPBB3-15893 --- .../functions_content/phpbb_format_quote_test.php | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/functions_content/phpbb_format_quote_test.php (limited to 'tests') diff --git a/tests/functions_content/phpbb_format_quote_test.php b/tests/functions_content/phpbb_format_quote_test.php new file mode 100644 index 0000000000..0f6136f5d9 --- /dev/null +++ b/tests/functions_content/phpbb_format_quote_test.php @@ -0,0 +1,52 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php'; + +class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case +{ + public function setUp() + { + global $cache, $user, $phpbb_root_path, $phpEx; + + $lang_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_file_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $cache = new phpbb_mock_cache(); + + parent::setUp(); + } + + public function data_phpbb_format_quote() + { + return [ + [true, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "[quote=admin user_id=2][quote="username"]quoted[/quote][/quote]\n\n"], + [false, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "admin wrote:\n> [quote="username"]quoted[/quote]\n"] + ]; + } + + + /** + * @dataProvider data_phpbb_format_quote + */ + public function test_phpbb_format_quote($bbcode_status, $quote_attributes, $message, $expected) + { + $text_formatter_utils = new \phpbb\textformatter\s9e\utils(); + + $message_parser = new parse_message($message); + + phpbb_format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message_parser); + + $this->assertEquals($expected, $message_parser->message); + } +} -- cgit v1.2.1 From 087bf6fd35913152129eed97005953ac3979002a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 2 Dec 2018 12:55:02 +0100 Subject: [ticket/15893] Pass needed language class directly to format quote PHPBB3-15893 --- tests/functions_content/phpbb_format_quote_test.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/functions_content/phpbb_format_quote_test.php b/tests/functions_content/phpbb_format_quote_test.php index 0f6136f5d9..cbbd46d0a9 100644 --- a/tests/functions_content/phpbb_format_quote_test.php +++ b/tests/functions_content/phpbb_format_quote_test.php @@ -15,13 +15,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php'; class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case { + /** @var \phpbb\language\language */ + protected $lang; + public function setUp() { global $cache, $user, $phpbb_root_path, $phpEx; $lang_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); - $lang = new \phpbb\language\language($lang_file_loader); - $user = new \phpbb\user($lang, '\phpbb\datetime'); + $this->lang = new \phpbb\language\language($lang_file_loader); + $user = new \phpbb\user($this->lang, '\phpbb\datetime'); $cache = new phpbb_mock_cache(); parent::setUp(); @@ -30,8 +33,10 @@ class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case public function data_phpbb_format_quote() { return [ - [true, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "[quote=admin user_id=2][quote="username"]quoted[/quote][/quote]\n\n"], - [false, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "admin wrote:\n> [quote="username"]quoted[/quote]\n"] + [true, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', '', "[quote=admin user_id=2][quote="username"]quoted[/quote][/quote]\n\n"], + [false, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', '', "admin wrote:\n> [quote="username"]quoted[/quote]\n"], + [true, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "[url=http://viewtopic.php?p=1#p1]Subject: Foo[/url]\n\n", "[url=http://viewtopic.php?p=1#p1]Subject: Foo[/url]\n\n[quote=admin user_id=2][quote="username"]quoted[/quote][/quote]\n\n"], + [false, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "http://viewtopic.php?p=1#p1 - Subject: Foo\n\n", "http://viewtopic.php?p=1#p1 - Subject: Foo\n\nadmin wrote:\n> [quote="username"]quoted[/quote]\n"], ]; } @@ -39,13 +44,13 @@ class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case /** * @dataProvider data_phpbb_format_quote */ - public function test_phpbb_format_quote($bbcode_status, $quote_attributes, $message, $expected) + public function test_phpbb_format_quote($bbcode_status, $quote_attributes, $message, $message_link, $expected) { $text_formatter_utils = new \phpbb\textformatter\s9e\utils(); $message_parser = new parse_message($message); - phpbb_format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message_parser); + phpbb_format_quote($this->lang, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link); $this->assertEquals($expected, $message_parser->message); } -- cgit v1.2.1 From 83f4074116e646507bbb448f745e0d9b356aa593 Mon Sep 17 00:00:00 2001 From: kasimi Date: Wed, 12 Dec 2018 12:34:16 +0100 Subject: [ticket/15910] Pass object arguments by reference implicitly PHPBB3-15910 --- tests/upload/filespec_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 18b6deed1f..b41b95d925 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -79,7 +79,7 @@ class phpbb_filespec_test extends phpbb_test_case $this->phpbb_root_path = $phpbb_root_path; } - private function set_reflection_property(&$class, $property_name, $value) + private function set_reflection_property($class, $property_name, $value) { $property = new ReflectionProperty($class, $property_name); $property->setAccessible(true); -- cgit v1.2.1 From 14f9917db60b88bbf2d4d9923e2a2cee5766bbec Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 23 Dec 2018 14:35:58 +0100 Subject: [ticket/15919] Don't run lint test against node_modules Also, make sure to correctly handle opendir returning false instead of the stream handle. PHPBB3-15919 --- tests/lint_test.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/lint_test.php b/tests/lint_test.php index 70046bdfd2..8ab31f976c 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -67,6 +67,12 @@ class phpbb_lint_test extends phpbb_test_case { $files = array(); $dh = opendir($root); + + if ($dh === false) + { + return $files; + } + while (($filename = readdir($dh)) !== false) { if ($filename == '.' || $filename == '..') @@ -89,6 +95,7 @@ class phpbb_lint_test extends phpbb_test_case // PHP Fatal error: Cannot declare class Container because the name is already in use in /var/www/projects/phpbb3/tests/../phpBB/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php on line 20 // https://gist.github.com/e003913ffd493da63cbc dirname(__FILE__) . '/../phpBB/vendor', + dirname(__FILE__) . '/../node_modules', ))) { $files = array_merge($files, $this->check($path)); -- cgit v1.2.1 From 31c04668156638017a1c211100d7b86e5faff4d4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 24 Dec 2018 02:27:45 +0100 Subject: [ticket/15921] Updated dependencies to latest textformatter PHPBB3-15921 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- tests/text_processing/tickets_data/PHPBB3-15348.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 8887b9daee..abaf55f374 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -298,7 +298,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "Emoji: \xF0\x9F\x98\x80", - 'Emoji: ' . ' + 'Emoji: ' . ' ), array( "Emoji: \xF0\x9F\x98\x80", diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.html b/tests/text_processing/tickets_data/PHPBB3-15348.html index 5d44c07899..3ebe9aac88 100644 --- a/tests/text_processing/tickets_data/PHPBB3-15348.html +++ b/tests/text_processing/tickets_data/PHPBB3-15348.html @@ -1 +1 @@ -:o k: :ok: \ No newline at end of file +:o k: :ok: \ No newline at end of file -- cgit v1.2.1 From c51859c0bdaf1997efb6a8d792628bd35165bfec Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 27 Dec 2018 10:36:41 +0100 Subject: [ticket/15921] Update tests for twemoji PHPBB3-15921 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- tests/text_processing/tickets_data/PHPBB3-15348.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index abaf55f374..05a41c5095 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -298,7 +298,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "Emoji: \xF0\x9F\x98\x80", - 'Emoji: ' . ' + 'Emoji: ' . ' ), array( "Emoji: \xF0\x9F\x98\x80", diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.html b/tests/text_processing/tickets_data/PHPBB3-15348.html index 3ebe9aac88..1794232d08 100644 --- a/tests/text_processing/tickets_data/PHPBB3-15348.html +++ b/tests/text_processing/tickets_data/PHPBB3-15348.html @@ -1 +1 @@ -:o k: :ok: \ No newline at end of file +:o k: :ok: \ No newline at end of file -- cgit v1.2.1 From e2e3d402a25b6203f2c29296eddf2dae002053da Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Sat, 29 Dec 2018 13:28:00 +0100 Subject: [ticket/15886] Clean up services PHPBB3-15886 --- tests/group/helper_test_case.php | 246 +++++++++++++++--------------- tests/notification/group_request_test.php | 4 +- 2 files changed, 124 insertions(+), 126 deletions(-) (limited to 'tests') diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php index 1318cf9040..cfbcd5890c 100644 --- a/tests/group/helper_test_case.php +++ b/tests/group/helper_test_case.php @@ -1,123 +1,123 @@ - - * @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_group_helper_test_case extends phpbb_test_case -{ - /** @var \phpbb\group\helper */ - protected $group_helper; - - protected function config_defaults() - { - $defaults = array( - 'ranks_path' => 'images/ranks' - ); - return $defaults; - } - - protected function get_test_language_data_set() - { - return array( - 'G_BOTS' => 'Bots', - 'G_NEW_GROUP' => 'Some new group', - 'G_not_uppercase' => 'The key does not contain uppercase letters', - 'G_GROUP_WITH_ÜMLAUTS' => 'Should work', - ); - } - - protected function get_test_rank_data_set() - { - return array( - 'special' => array( - 1 => array( - 'rank_id' => 1, - 'rank_title' => 'Site admin', - 'rank_special' => 1, - 'rank_image' => 'siteadmin.png', - ), - 2 => array( - 'rank_id' => 2, - 'rank_title' => 'Test member', - 'rank_special' => 1, - 'rank_image' => '', - ) - ) - ); - } - - protected function setup_engine(array $new_config = array()) - { - global $cache, $phpbb_dispatcher, $phpbb_root_path, $phpEx; - - // Set up authentication data for testing - $auth = $this->getMock('\phpbb\auth\auth'); - $auth->expects($this->any()) - ->method('acl_get') - ->with($this->stringContains('_'), $this->anything()) - ->will($this->returnValueMap(array( - array('u_viewprofile', true), - ))); - - // Set up cache service - $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock(); - $cache_service->expects($this->any()) - ->method('obtain_ranks') - ->will($this->returnValue($this->get_test_rank_data_set())); - - // Set up configuration - $defaults = $this->config_defaults(); - $config = new \phpbb\config\config(array_merge($defaults, $new_config)); - - // Set up language service - $lang = new \phpbb\language\language( - new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx) - ); - - // Set up language data for testing - $reflection_class = new ReflectionClass('\phpbb\language\language'); - - // Set default language files loaded flag to true - $loaded_flag = $reflection_class->getProperty('common_language_files_loaded'); - $loaded_flag->setAccessible(true); - $loaded_flag->setValue($lang, true); - - // Set up test language data - $lang_array = $reflection_class->getProperty('lang'); - $lang_array->setAccessible(true); - $lang_array->setValue($lang, $this->get_test_language_data_set()); - - // Set up event dispatcher - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - - // Set up path helper - $filesystem = new \phpbb\filesystem\filesystem(); - $path_helper = new \phpbb\path_helper( - new \phpbb\symfony_request( - new phpbb_mock_request() - ), - $filesystem, - $this->getMock('\phpbb\request\request'), - $phpbb_root_path, - $phpEx - ); - - $user = new \phpbb\user($lang, '\phpbb\datetime'); - $user->data['user_id'] = ANONYMOUS; - - $this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user, $phpbb_root_path, $phpEx); - } - - public function setUp() - { - $this->setup_engine(); - } -} + + * @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_group_helper_test_case extends phpbb_test_case +{ + /** @var \phpbb\group\helper */ + protected $group_helper; + + protected function config_defaults() + { + $defaults = array( + 'ranks_path' => 'images/ranks' + ); + return $defaults; + } + + protected function get_test_language_data_set() + { + return array( + 'G_BOTS' => 'Bots', + 'G_NEW_GROUP' => 'Some new group', + 'G_not_uppercase' => 'The key does not contain uppercase letters', + 'G_GROUP_WITH_ÜMLAUTS' => 'Should work', + ); + } + + protected function get_test_rank_data_set() + { + return array( + 'special' => array( + 1 => array( + 'rank_id' => 1, + 'rank_title' => 'Site admin', + 'rank_special' => 1, + 'rank_image' => 'siteadmin.png', + ), + 2 => array( + 'rank_id' => 2, + 'rank_title' => 'Test member', + 'rank_special' => 1, + 'rank_image' => '', + ) + ) + ); + } + + protected function setup_engine(array $new_config = array()) + { + global $phpbb_dispatcher, $phpbb_root_path, $phpEx; + + // Set up authentication data for testing + $auth = $this->getMock('\phpbb\auth\auth'); + $auth->expects($this->any()) + ->method('acl_get') + ->with($this->stringContains('_'), $this->anything()) + ->will($this->returnValueMap(array( + array('u_viewprofile', true), + ))); + + // Set up cache service + $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock(); + $cache_service->expects($this->any()) + ->method('obtain_ranks') + ->will($this->returnValue($this->get_test_rank_data_set())); + + // Set up configuration + $defaults = $this->config_defaults(); + $config = new \phpbb\config\config(array_merge($defaults, $new_config)); + + // Set up language service + $lang = new \phpbb\language\language( + new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx) + ); + + // Set up language data for testing + $reflection_class = new ReflectionClass('\phpbb\language\language'); + + // Set default language files loaded flag to true + $loaded_flag = $reflection_class->getProperty('common_language_files_loaded'); + $loaded_flag->setAccessible(true); + $loaded_flag->setValue($lang, true); + + // Set up test language data + $lang_array = $reflection_class->getProperty('lang'); + $lang_array->setAccessible(true); + $lang_array->setValue($lang, $this->get_test_language_data_set()); + + // Set up event dispatcher + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + + // Set up path helper + $filesystem = new \phpbb\filesystem\filesystem(); + $path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + $filesystem, + $this->getMock('\phpbb\request\request'), + $phpbb_root_path, + $phpEx + ); + + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $user->data['user_id'] = ANONYMOUS; + + $this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user); + } + + public function setUp() + { + $this->setup_engine(); + } +} diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index f53fe32f2a..e849c66fa5 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -65,9 +65,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas $phpbb_root_path, $phpEx ), - $this->user, - $phpbb_root_path, - $phpEx + $this->user )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher; $phpbb_log = new \phpbb\log\dummy(); -- cgit v1.2.1 From f023dd590f28b2721773f8429a2d1fbf995f544f Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Wed, 2 Jan 2019 12:33:25 +0100 Subject: [ticket/15886] Mock path helper in group helper tests PHPBB3-15886 --- tests/group/helper_test_case.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php index cfbcd5890c..e298770331 100644 --- a/tests/group/helper_test_case.php +++ b/tests/group/helper_test_case.php @@ -99,16 +99,16 @@ class phpbb_group_helper_test_case extends phpbb_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); // Set up path helper - $filesystem = new \phpbb\filesystem\filesystem(); - $path_helper = new \phpbb\path_helper( - new \phpbb\symfony_request( - new phpbb_mock_request() - ), - $filesystem, - $this->getMock('\phpbb\request\request'), - $phpbb_root_path, - $phpEx - ); + $path_helper = $this->getMockBuilder('\phpbb\path_helper') + ->disableOriginalConstructor() + ->setMethods(array()) + ->getMock(); + $path_helper->method('get_phpbb_root_path') + ->willReturn($phpbb_root_path); + $path_helper->method('get_php_ext') + ->willReturn($phpEx); + $path_helper->method('update_web_root_path') + ->will($this->returnArgument(0)); $user = new \phpbb\user($lang, '\phpbb\datetime'); $user->data['user_id'] = ANONYMOUS; -- cgit v1.2.1 From f6c93a81d302be22d754fb65e50d60699ea7b5c0 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Wed, 2 Jan 2019 13:21:44 +0100 Subject: [ticket/15886] No profile url for BOTS group PHPBB3-15886 --- tests/group/helper_get_name_string_test.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/group/helper_get_name_string_test.php b/tests/group/helper_get_name_string_test.php index 7ea0f156e4..565602a346 100644 --- a/tests/group/helper_get_name_string_test.php +++ b/tests/group/helper_get_name_string_test.php @@ -39,7 +39,7 @@ class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_ca { return array( // Should be fine - array(0, 'Bots', 'AA0000', false, 'Bots'), + array(0, 'BOTS', 'AA0000', false, 'Bots'), array(1, 'new_group', '', false, 'Some new group'), array(2, 'group_with_ümlauts', '', 'http://www.example.org/group.php?mode=show', 'Should work'), @@ -80,7 +80,8 @@ class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_ca global $phpbb_root_path, $phpEx; return array( - array(0, 'Bots', '000000', false, 'Bots'), + array(0, 'BOTS', '000000', false, 'Bots'), + array(1, 'BOTS', '111111', false, 'Bots'), array(7, 'new_group', 'FFA500', false, 'Some new group'), array(14, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', 'Awesome group'), ); @@ -97,7 +98,7 @@ class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_ca public function get_name_string_no_profile_data() { return array( - array(0, 'Bots', '000000', false, 'Bots'), + array(0, 'BOTS', '000000', false, 'Bots'), array(1, 'new_group', '', false, 'Some new group'), arraY(2, 'not_uppercase', 'FF0000', false, 'not_uppercase'), array(5, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', 'Awesome group'), -- cgit v1.2.1 From 813789c644dfd34ec9f63e16ad9f6b8a2aa97163 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Wed, 2 Jan 2019 13:30:58 +0100 Subject: [ticket/15886] Capital Y in arraY PHPBB3-15886 --- tests/group/helper_get_name_string_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/group/helper_get_name_string_test.php b/tests/group/helper_get_name_string_test.php index 565602a346..c626328dcc 100644 --- a/tests/group/helper_get_name_string_test.php +++ b/tests/group/helper_get_name_string_test.php @@ -100,7 +100,7 @@ class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_ca return array( array(0, 'BOTS', '000000', false, 'Bots'), array(1, 'new_group', '', false, 'Some new group'), - arraY(2, 'not_uppercase', 'FF0000', false, 'not_uppercase'), + array(2, 'not_uppercase', 'FF0000', false, 'not_uppercase'), array(5, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', 'Awesome group'), ); } -- cgit v1.2.1 From 1fba679c6833ea1e1fa2cd46f5bbc26cee9a3ed8 Mon Sep 17 00:00:00 2001 From: AJ Quick Date: Thu, 31 Jan 2019 18:52:49 -0700 Subject: [ticket/15959] Fix invalid CNAME record PHPBB3-15959 --- tests/network/checkdnsrr_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/network/checkdnsrr_test.php b/tests/network/checkdnsrr_test.php index 6503a4c40b..e67b72118c 100644 --- a/tests/network/checkdnsrr_test.php +++ b/tests/network/checkdnsrr_test.php @@ -38,7 +38,7 @@ class phpbb_network_checkdnsrr_test extends phpbb_test_case array('does-not-exist.phpbb.com', 'AAAA', false), // Existing CNAME record - array('news.cnet.com', 'CNAME', true), + array('www.github.com', 'CNAME', true), // Non-existing CNAME record array('does-not-exist.phpbb.com', 'CNAME', false), -- cgit v1.2.1 From 43d8432809e264c8fdddba85565d527da9d6463d Mon Sep 17 00:00:00 2001 From: AJ Quick Date: Fri, 1 Feb 2019 19:38:42 -0700 Subject: [ticket/15959] Fix invalid CNAME record PHPBB3-15959 --- tests/network/checkdnsrr_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/network/checkdnsrr_test.php b/tests/network/checkdnsrr_test.php index e67b72118c..8cbd4f7e97 100644 --- a/tests/network/checkdnsrr_test.php +++ b/tests/network/checkdnsrr_test.php @@ -38,7 +38,7 @@ class phpbb_network_checkdnsrr_test extends phpbb_test_case array('does-not-exist.phpbb.com', 'AAAA', false), // Existing CNAME record - array('www.github.com', 'CNAME', true), + array('area51.phpbb.com', 'CNAME', true), // Non-existing CNAME record array('does-not-exist.phpbb.com', 'CNAME', false), -- cgit v1.2.1 From 96491a70e8b61ba5700c78dd7b20fe9ca9a3b665 Mon Sep 17 00:00:00 2001 From: rubencm Date: Sat, 9 Feb 2019 12:16:47 +0000 Subject: [ticket/15965] Fix hardcoded directory PHPBB3-15965 --- tests/console/thumbnail_test.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php index d5fbfa0fed..e425d998a2 100644 --- a/tests/console/thumbnail_test.php +++ b/tests/console/thumbnail_test.php @@ -46,6 +46,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case $config = $this->config = new \phpbb\config\config(array( 'img_min_thumb_filesize' => 2, 'img_max_thumb_width' => 2, + 'upload_path' => 'files', )); $this->db = $this->db = $this->new_dbal(); @@ -63,8 +64,8 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case ))); $this->application = new Application(); - $this->application->add(new generate($this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx)); - $this->application->add(new delete($this->user, $this->db, $this->phpbb_root_path)); + $this->application->add(new generate($config, $this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx)); + $this->application->add(new delete($config, $this->user, $this->db, $this->phpbb_root_path)); $this->application->add(new recreate($this->user)); $phpbb_filesystem = new \phpbb\filesystem\filesystem(); -- cgit v1.2.1 From e315ea90b8f0d5763cd657090cadc99f221e8b44 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Sat, 23 Feb 2019 01:56:03 +0100 Subject: [ticket/15975] Remove user notification data upon user deletion PHPBB3-15975 --- tests/console/user/base.php | 2 ++ tests/functions/user_delete_test.php | 2 ++ tests/functions_user/delete_user_test.php | 2 ++ 3 files changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/console/user/base.php b/tests/console/user/base.php index 2fb7ee0394..ad328ac893 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -98,6 +98,8 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states'); $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts'); + $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); + parent::setUp(); } diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index 88680d5719..f419c90e9e 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -86,6 +86,8 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens'); $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states'); $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts'); + + $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); } public function test_user_delete() diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 30253ccc2f..09ed51890c 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -49,6 +49,8 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens'); $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states'); $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts'); + + $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); } public function first_last_post_data() -- cgit v1.2.1 From 0d166e87b86c17ab6384abd1659c8abc5f65c476 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 19 Mar 2019 21:13:27 +0100 Subject: [ticket/15996] Rename dataProvider to not start with test_ PHPBB3-15996 --- tests/dbal/migrator_tool_permission_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php index d84f6a68ff..ccad6a1387 100644 --- a/tests/dbal/migrator_tool_permission_test.php +++ b/tests/dbal/migrator_tool_permission_test.php @@ -163,7 +163,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case $this->assertFalse($this->tool->exists('global_test', true)); } - public function test_permission_set_data() + public function data_test_permission_set() { return array( array( @@ -188,7 +188,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case } /** - * @dataProvider test_permission_set_data + * @dataProvider data_test_permission_set */ public function test_permission_set($group_name, $auth_option, $type, $has_permission) { -- cgit v1.2.1 From 220d388cac09883d554b9640976a082d8ebc5f9d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 19 Mar 2019 21:20:38 +0100 Subject: [ticket/15997] Use higher than default timeout for webdriver connections PHPBB3-15997 --- tests/test_framework/phpbb_ui_test_case.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 15a1cd375e..7b950a7d5d 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -80,7 +80,12 @@ class phpbb_ui_test_case extends phpbb_test_case try { $capabilities = DesiredCapabilities::firefox(); - self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); + self::$webDriver = RemoteWebDriver::create( + self::$host . ':' . self::$port, + $capabilities, + 60 * 1000, // 60 seconds connection timeout + 60 * 1000 // 60 seconds request timeout + ); } catch (WebDriverCurlException $e) { self::markTestSkipped('PhantomJS webserver is not running.'); } -- cgit v1.2.1 From 7160c67b2ca8fa1c819d5da3e629fb02621a7066 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Mon, 1 Apr 2019 23:12:55 +0200 Subject: [ticket/16004] Add tests/functions/validate_username_test.php PHPBB3-16004 --- tests/functions/validate_username_test.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/functions/validate_username_test.php b/tests/functions/validate_username_test.php index d310f58036..cee5d38400 100644 --- a/tests/functions/validate_username_test.php +++ b/tests/functions/validate_username_test.php @@ -47,6 +47,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case 'foobar_letter_num' => array(), 'foobar_letter_num_sp' => array(), 'foobar_quot' => array('INVALID_CHARS'), + 'foobar_emoji' => array('INVALID_EMOJIS'), 'barfoo_disallow' => array('USERNAME_DISALLOWED'), 'admin_taken' => array('USERNAME_TAKEN'), 'group_taken' => array('USERNAME_TAKEN'), @@ -60,6 +61,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case 'foobar_letter_num' => array(), 'foobar_letter_num_sp' => array('INVALID_CHARS'), 'foobar_quot' => array('INVALID_CHARS'), + 'foobar_emoji' => array('INVALID_EMOJIS'), 'barfoo_disallow' => array('USERNAME_DISALLOWED'), 'admin_taken' => array('USERNAME_TAKEN'), 'group_taken' => array('INVALID_CHARS'), @@ -73,6 +75,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case 'foobar_letter_num' => array(), 'foobar_letter_num_sp' => array('INVALID_CHARS'), 'foobar_quot' => array('INVALID_CHARS'), + 'foobar_emoji' => array('INVALID_EMOJIS'), 'barfoo_disallow' => array('USERNAME_DISALLOWED'), 'admin_taken' => array('USERNAME_TAKEN'), 'group_taken' => array('USERNAME_TAKEN'), @@ -86,6 +89,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case 'foobar_letter_num' => array(), 'foobar_letter_num_sp' => array('INVALID_CHARS'), 'foobar_quot' => array('INVALID_CHARS'), + 'foobar_emoji' => array('INVALID_EMOJIS'), 'barfoo_disallow' => array('USERNAME_DISALLOWED'), 'admin_taken' => array('USERNAME_TAKEN'), 'group_taken' => array('INVALID_CHARS'), @@ -99,6 +103,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case 'foobar_letter_num' => array(), 'foobar_letter_num_sp' => array(), 'foobar_quot' => array('INVALID_CHARS'), + 'foobar_emoji' => array('INVALID_EMOJIS'), 'barfoo_disallow' => array('USERNAME_DISALLOWED'), 'admin_taken' => array('USERNAME_TAKEN'), 'group_taken' => array('USERNAME_TAKEN'), @@ -112,6 +117,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case 'foobar_letter_num' => array(), 'foobar_letter_num_sp' => array('INVALID_CHARS'), 'foobar_quot' => array('INVALID_CHARS'), + 'foobar_emoji' => array('INVALID_EMOJIS'), 'barfoo_disallow' => array('USERNAME_DISALLOWED'), 'admin_taken' => array('USERNAME_TAKEN'), 'group_taken' => array('USERNAME_TAKEN'), @@ -173,6 +179,11 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case '"foobar"', array('username'), ), + 'foobar_emoji' => array( + $expected['foobar_emoji'], + 'username😮', + array('username'), + ), 'barfoo_disallow' => array( $expected['barfoo_disallow'], 'barfoo', -- cgit v1.2.1 From 562601fd9bb7ec7ba9dff9132840ed9b231a7f72 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Tue, 2 Apr 2019 18:01:59 +0200 Subject: [ticket/16007] Correct check_ban_test to boolean PHPBB3-16007 --- tests/session/check_ban_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index 04da5f08b9..16a65b0ade 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -72,7 +72,8 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case { try { - $is_banned = $this->session->check_ban($user_id, $user_ips, $user_email, $return); + $ban = $this->session->check_ban($user_id, $user_ips, $user_email, $return); + $is_banned = !empty($ban); } catch (PHPUnit_Framework_Error_Notice $e) { -- cgit v1.2.1 From f1c2e26f0af688240f915e3d8d2aab428f0ff76f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 14 Apr 2019 14:11:36 +0200 Subject: [ticket/security/234] Add test for URL validation SECURITY-234 --- tests/functions_acp/validate_config_vars_test.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php index 1182d659f0..3bd2204de9 100644 --- a/tests/functions_acp/validate_config_vars_test.php +++ b/tests/functions_acp/validate_config_vars_test.php @@ -19,10 +19,11 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case { parent::setUp(); - global $user; + global $language, $user; $user = new phpbb_mock_user(); $user->lang = new phpbb_mock_lang(); + $language = $user->lang; } /** @@ -44,6 +45,7 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case 'test_int_32' => array('lang' => 'TEST_INT', 'validate' => 'int:32'), 'test_int_32_64' => array('lang' => 'TEST_INT', 'validate' => 'int:32:64'), 'test_lang' => array('lang' => 'TEST_LANG', 'validate' => 'lang'), + 'test_url' => array('lang' => 'TEST_URL', 'validate' => 'url'), /* 'test_sp' => array('lang' => 'TEST_SP', 'validate' => 'script_path'), 'test_rpath' => array('lang' => 'TEST_RPATH', 'validate' => 'rpath'), @@ -64,6 +66,7 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case 'test_int_32' => 32, 'test_int_32_64' => 48, 'test_lang' => 'en', + 'test_url' => 'http://foobar.com', ), ), ); @@ -148,6 +151,11 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case array('test_lang' => 'this_is_no_language'), array('WRONG_DATA_LANG'), ), + array( + array('test_url' => array('lang' => 'TEST_URL', 'validate' => 'url')), + array('test_url' => 'javascript://foobar.com'), + array('URL_INVALID TEST_URL'), + ), ); } -- cgit v1.2.1 From 58f33921b56c3524e5c2b2c15bbf0dddea1ff461 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 23 Apr 2019 20:41:37 +0200 Subject: [ticket/16027] Force clearing of cache folder on install for functional PHPBB3-16027 --- tests/test_framework/phpbb_functional_test_case.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d4856f954a..4d294fd523 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -397,6 +397,14 @@ class phpbb_functional_test_case extends phpbb_test_case global $phpbb_container; $phpbb_container->reset(); + // Purge cache to remove cached files + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); + + $cache = new \phpbb\cache\driver\file; + $cache->purge(); + $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; foreach (array_keys($GLOBALS) as $key) -- cgit v1.2.1 From 2353ad11f2afe213e407842a9a9e1533c0de57b0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 26 Apr 2019 23:39:51 +0200 Subject: [ticket/security/235] Update search native tests SECURITY-235 --- tests/search/native_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/search/native_test.php b/tests/search/native_test.php index 29d0d0a8d3..0e6f719cef 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -70,7 +70,7 @@ class phpbb_search_native_test extends phpbb_search_test_case 'ba*az', 'all', true, - array('\'ba%az\''), + array(4), array(), array(), ), @@ -78,7 +78,7 @@ class phpbb_search_native_test extends phpbb_search_test_case 'ba*z', 'all', true, - array('\'ba%z\''), + array(), // <= 3 chars after removing * array(), array(), ), @@ -86,7 +86,7 @@ class phpbb_search_native_test extends phpbb_search_test_case 'baa* baaz*', 'all', true, - array('\'baa%\'', '\'baaz%\''), + array('\'baa%\'', 4), array(), array(), ), @@ -94,7 +94,7 @@ class phpbb_search_native_test extends phpbb_search_test_case 'ba*z baa*', 'all', true, - array('\'ba%z\'', '\'baa%\''), + array('\'baa%\''), // baz is <= 3 chars, only baa* is left array(), array(), ), -- cgit v1.2.1 From 1843e4f6b4e63b43de7da3fce0f7dd4c235853a9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 27 Apr 2019 13:52:37 +0200 Subject: [prep-release-3.2.6] Fix expected data in avatar manager test --- tests/avatar/manager_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 0a64bfd69f..d1e907b53d 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -185,7 +185,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case $avatar_settings = $this->manager->get_avatar_settings($this->avatar_foobar); $expected_settings = array( - 'allow_avatar_' . get_class($this->avatar_foobar) => array('lang' => 'ALLOW_' . strtoupper(get_class($this->avatar_foobar)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + 'allow_avatar_' . get_class($this->avatar_foobar) => array('lang' => 'ALLOW_' . strtoupper(get_class($this->avatar_foobar)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), ); $this->assertEquals($expected_settings, $avatar_settings); -- cgit v1.2.1 From 06a95487feac7a7fae6f9afdd81250fbf5925041 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 28 Apr 2019 02:43:05 +0200 Subject: [ticket/16034] Fix [url=] links being incorrectly shortened PHPBB3-16034 --- tests/text_formatter/s9e/default_formatting_test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 05a41c5095..a35c9138a5 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -253,6 +253,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '[url=http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx[/url]', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ), + array( + '[url=http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx[/url]', + 'http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' + ), array( '[quote="[url=http://example.org]xxx[/url]"]...[/quote]', '
                xxx wrote:...
                ' -- cgit v1.2.1 From 3208c41da866f80e8345ecd34056fd41ba25b164 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 17 May 2019 15:36:33 +0200 Subject: [ticket/16053] Update s9e/text-formatter PHPBB3-16053 --- .../text_processing/tickets_data/PHPBB3-16053.html | 1 + .../text_processing/tickets_data/PHPBB3-16053.txt | 1 + .../text_processing/tickets_data/PHPBB3-16053.xml | 28 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-16053.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-16053.txt create mode 100644 tests/text_processing/tickets_data/PHPBB3-16053.xml (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-16053.html b/tests/text_processing/tickets_data/PHPBB3-16053.html new file mode 100644 index 0000000000..af70ddf7eb --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-16053.html @@ -0,0 +1 @@ +Test \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-16053.txt b/tests/text_processing/tickets_data/PHPBB3-16053.txt new file mode 100644 index 0000000000..c786665eb9 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-16053.txt @@ -0,0 +1 @@ +[test=http://ea117.com]Test[/test] \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-16053.xml b/tests/text_processing/tickets_data/PHPBB3-16053.xml new file mode 100644 index 0000000000..25f7c9e34e --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-16053.xml @@ -0,0 +1,28 @@ + + + + bbcode_id + bbcode_tag + bbcode_helpline + display_on_posting + bbcode_match + bbcode_tpl + first_pass_match + first_pass_replace + second_pass_match + second_pass_replace + + + 13 + test + + 1 + [test={URL}]{TEXT}[/test] + {TEXT}]]> + ((?!)) + + ((?!)) + + +
                +
                -- cgit v1.2.1 From a563b616e018088bcd2dd2fe1d6ba90c698caa3f Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 4 Jun 2019 18:21:11 +0200 Subject: [ticket/16074] Fix Twemoji URL for ZWJ sequences PHPBB3-16074 --- tests/text_processing/tickets_data/PHPBB3-16074.html | 1 + tests/text_processing/tickets_data/PHPBB3-16074.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-16074.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-16074.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-16074.html b/tests/text_processing/tickets_data/PHPBB3-16074.html new file mode 100644 index 0000000000..b588e2ac47 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-16074.html @@ -0,0 +1 @@ +:man_judge: 👨‍⚖️ \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-16074.txt b/tests/text_processing/tickets_data/PHPBB3-16074.txt new file mode 100644 index 0000000000..f067a7294d --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-16074.txt @@ -0,0 +1 @@ +:man_judge: 👨‍⚖️ \ No newline at end of file -- cgit v1.2.1 From 34a6493fb529bbac4f4c1b6a4831960ecb0de582 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 6 Jun 2019 18:51:52 +0200 Subject: [ticket/16078] Use chrome as webdriver PHPBB3-16078 --- tests/test_framework/phpbb_ui_test_case.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 7b950a7d5d..e76c8cd159 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -79,12 +79,12 @@ class phpbb_ui_test_case extends phpbb_test_case } try { - $capabilities = DesiredCapabilities::firefox(); + $capabilities = DesiredCapabilities::chrome(); self::$webDriver = RemoteWebDriver::create( self::$host . ':' . self::$port, $capabilities, - 60 * 1000, // 60 seconds connection timeout - 60 * 1000 // 60 seconds request timeout + 30 * 1000, // 30 seconds connection timeout + 30 * 1000 // 30 seconds request timeout ); } catch (WebDriverCurlException $e) { self::markTestSkipped('PhantomJS webserver is not running.'); -- cgit v1.2.1 From 1be392a16a8ff5923e28bac080f7c21659f52be5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 19 Jun 2019 07:32:52 +0200 Subject: [ticket/16078] Use headless chrome and disable gpu acceleration This is to hopefully get rid of some of the issues with timeouts. PHPBB3-16078 --- tests/test_framework/phpbb_ui_test_case.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index e76c8cd159..a17fd608c1 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -80,6 +80,8 @@ class phpbb_ui_test_case extends phpbb_test_case try { $capabilities = DesiredCapabilities::chrome(); + $chromeOptions = (new ChromeOptions)->addArguments(['headless', 'disable-gpu']); + $capabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions); self::$webDriver = RemoteWebDriver::create( self::$host . ':' . self::$port, $capabilities, -- cgit v1.2.1 From 3002c1b22af3b4ca139b98fe069a84cb8cb3b8de Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 19 Jun 2019 08:29:34 +0200 Subject: [ticket/16078] Add use statement for ChromeOptions PHPBB3-16078 --- tests/test_framework/phpbb_ui_test_case.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index a17fd608c1..4d88d7d9cb 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -11,6 +11,7 @@ * */ +use Facebook\WebDriver\Chrome\ChromeOptions; use Facebook\WebDriver\WebDriverBy; use Facebook\WebDriver\Exception\WebDriverCurlException; use Facebook\WebDriver\Remote\RemoteWebDriver; -- cgit v1.2.1 From f75577e5f858e43e202010f6889bd55096f75ea3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 18 Jul 2019 22:32:19 +0200 Subject: [ticket/security/243] Use bbcode.html like formatting SECURITY-243 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- tests/text_processing/tickets_data/PHPBB3-13921.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index a35c9138a5..1aa4f0bc3a 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -70,7 +70,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( '[size=75]smaller[/size]', - 'smaller' + 'smaller' ), array( '[quote]quoted[/quote]', diff --git a/tests/text_processing/tickets_data/PHPBB3-13921.html b/tests/text_processing/tickets_data/PHPBB3-13921.html index 690668ef28..6a9dc7f504 100644 --- a/tests/text_processing/tickets_data/PHPBB3-13921.html +++ b/tests/text_processing/tickets_data/PHPBB3-13921.html @@ -1 +1 @@ -
                xxx
                \ No newline at end of file +
                xxx
                \ No newline at end of file -- cgit v1.2.1 From 59f489c01f63d76ae879b2e25b8fad1b5a82a3dc Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 21 Jul 2019 16:03:19 +0200 Subject: [ticket/security/244] Add missing form parameters to tests SECURITY-244 --- tests/functional/fileupload_form_test.php | 9 +++- tests/functional/plupload_test.php | 14 ++++-- .../test_framework/phpbb_functional_test_case.php | 51 ++++++++++++++++------ 3 files changed, 55 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index b0780172ff..ff9450be0d 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -46,6 +46,13 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case private function upload_file($filename, $mimetype) { + $crawler = self::$client->request( + 'GET', + 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid + ); + + $file_form_data = array_merge(['add_file' => $this->lang('ADD_FILE')], $this->get_hidden_fields($crawler, 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid)); + $file = array( 'tmp_name' => $this->path . $filename, 'name' => $filename, @@ -57,7 +64,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $crawler = self::$client->request( 'POST', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid, - array('add_file' => $this->lang('ADD_FILE')), + $file_form_data, array('fileupload' => $file) ); diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php index 9d284a7e57..4ab1c8e9e5 100644 --- a/tests/functional/plupload_test.php +++ b/tests/functional/plupload_test.php @@ -76,6 +76,10 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case $chunk_size = ceil(filesize($this->path . 'valid.jpg') / self::CHUNKS); $handle = fopen($this->path . 'valid.jpg', 'rb'); + $crawler = self::$client->request('POST', $url . '&sid=' . $this->sid); + + $file_form_data = $this->get_hidden_fields($crawler, $url); + for ($i = 0; $i < self::CHUNKS; $i++) { $chunk = fread($handle, $chunk_size); @@ -94,13 +98,13 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case $crawler = self::$client->request( 'POST', $url . '&sid=' . $this->sid, - array( + array_merge(array( 'chunk' => $i, 'chunks' => self::CHUNKS, 'name' => md5('valid') . '.jpg', 'real_filename' => 'valid.jpg', 'add_file' => $this->lang('ADD_FILE'), - ), + ), $file_form_data), array('fileupload' => $file), array('X-PHPBB-USING-PLUPLOAD' => '1') ); @@ -134,17 +138,19 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case 'error' => UPLOAD_ERR_OK, ); + $file_form_data = $this->get_hidden_fields(null, $url); + self::$client->setServerParameter('HTTP_X_PHPBB_USING_PLUPLOAD', '1'); self::$client->request( 'POST', $url . '&sid=' . $this->sid, - array( + array_merge(array( 'chunk' => '0', 'chunks' => '1', 'name' => md5('valid') . '.jpg', 'real_filename' => 'valid.jpg', 'add_file' => $this->lang('ADD_FILE'), - ), + ), $file_form_data), array('fileupload' => $file) ); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 4d294fd523..2659cf6e73 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -1166,24 +1166,14 @@ class phpbb_functional_test_case extends phpbb_test_case 'error' => UPLOAD_ERR_OK, ); - $crawler = self::$client->request('POST', $posting_url, array('add_file' => $this->lang('ADD_FILE')), array('fileupload' => $file)); + $file_form_data = array_merge(['add_file' => $this->lang('ADD_FILE')], $this->get_hidden_fields($crawler, $posting_url)); + + $crawler = self::$client->request('POST', $posting_url, $file_form_data, array('fileupload' => $file)); } unset($form_data['upload_files']); } - $hidden_fields = array( - $crawler->filter('[type="hidden"]')->each(function ($node, $i) { - return array('name' => $node->attr('name'), 'value' => $node->attr('value')); - }), - ); - - foreach ($hidden_fields as $fields) - { - foreach($fields as $field) - { - $form_data[$field['name']] = $field['value']; - } - } + $form_data = array_merge($form_data, $this->get_hidden_fields($crawler, $posting_url)); // I use a request because the form submission method does not allow you to send data that is not // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) @@ -1314,4 +1304,37 @@ class phpbb_functional_test_case extends phpbb_test_case return self::request('GET', substr($link, strpos($link, 'mcp.'))); } + + /** + * Get hidden fields for URL + * + * @param Symfony\Component\DomCrawler\Crawler|null $crawler Crawler instance or null + * @param string $url Request URL + * + * @return array Hidden form fields array + */ + protected function get_hidden_fields($crawler, $url) + { + if (!$crawler) + { + $crawler = self::$client->request('GET', $url); + } + $hidden_fields = [ + $crawler->filter('[type="hidden"]')->each(function ($node, $i) { + return ['name' => $node->attr('name'), 'value' => $node->attr('value')]; + }), + ]; + + $file_form_data = []; + + foreach ($hidden_fields as $fields) + { + foreach($fields as $field) + { + $file_form_data[$field['name']] = $field['value']; + } + } + + return $file_form_data; + } } -- cgit v1.2.1 From cf898133a4fa0c412911a9b65a533c84524edc34 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 7 Sep 2019 13:24:20 +0200 Subject: [ticket/16123] Add tests to cover different ban reasons PHPBB3-16123 --- tests/functions/fixtures/validate_email.xml | 21 +++++++++++++++++++++ tests/functions/validate_user_email_test.php | 10 +++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/functions/fixtures/validate_email.xml b/tests/functions/fixtures/validate_email.xml index eb4fd90217..5a21e51d13 100644 --- a/tests/functions/fixtures/validate_email.xml +++ b/tests/functions/fixtures/validate_email.xml @@ -1,5 +1,26 @@ + + ban_userid + ban_exclude + ban_end + ban_email + ban_give_reason + + 0 + 0 + 0 + banned@example.com + + + + 0 + 0 + 0 + banned2@example.com + just because + +
                user_idusername diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php index 8dcec88103..f64d01517c 100644 --- a/tests/functions/validate_user_email_test.php +++ b/tests/functions/validate_user_email_test.php @@ -28,10 +28,14 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case protected function setUp() { + global $phpbb_dispatcher, $phpbb_root_path, $phpEx; + parent::setUp(); $this->db = $this->new_dbal(); - $this->user = new phpbb_mock_user; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $language = new phpbb\language\language(new phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->user = new phpbb\user($language, '\phpbb\datetime'); $this->helper = new phpbb_functions_validate_data_helper($this); } @@ -47,7 +51,6 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case $config['email_check_mx'] = $check_mx; $db = $this->db; $user = $this->user; - $user->optionset('banned_users', array('banned@example.com')); } public static function validate_user_email_data() @@ -58,7 +61,8 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case array('valid_complex', array(), "'%$~test@example.com"), array('invalid', array('EMAIL_INVALID'), 'fööbar@example.com'), array('taken', array('EMAIL_TAKEN'), 'admin@example.com'), - array('banned', array('EMAIL_BANNED'), 'banned@example.com'), + array('banned', ['just because'], 'banned2@example.com'), + array('banned', ['EMAIL_BANNED'], 'banned@example.com') ); } -- cgit v1.2.1 From d186df8cb40f5375ae7143fb432cb36cafe7d0a1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 7 Sep 2019 21:57:38 +0200 Subject: [ticket/16123] Purge cache to ensure up to date ban list in tests PHPBB3-16123 --- tests/functions/validate_user_email_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php index f64d01517c..d23ffc0503 100644 --- a/tests/functions/validate_user_email_test.php +++ b/tests/functions/validate_user_email_test.php @@ -28,10 +28,12 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case protected function setUp() { - global $phpbb_dispatcher, $phpbb_root_path, $phpEx; + global $cache, $phpbb_dispatcher, $phpbb_root_path, $phpEx; parent::setUp(); + $cache = new \phpbb\cache\driver\file(); + $cache->purge(); $this->db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $language = new phpbb\language\language(new phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); -- cgit v1.2.1 From 4abdfd1709d1c39362656de70f95d762e3f031f8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 8 Sep 2019 09:40:56 +0200 Subject: [ticket/16123] Specify ban_id in validate email fixture PHPBB3-16123 --- tests/functions/fixtures/validate_email.xml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/functions/fixtures/validate_email.xml b/tests/functions/fixtures/validate_email.xml index 5a21e51d13..fa139f6f18 100644 --- a/tests/functions/fixtures/validate_email.xml +++ b/tests/functions/fixtures/validate_email.xml @@ -1,12 +1,14 @@
                + ban_idban_useridban_excludeban_endban_emailban_give_reason + 1 0 0 0 @@ -14,6 +16,7 @@ + 2 0 0 0 -- cgit v1.2.1 From 88d94a7c1992e43dd8300ba41352e36d3d2c6381 Mon Sep 17 00:00:00 2001 From: v12mike Date: Sun, 8 Sep 2019 14:23:09 -0400 Subject: [ticket/16150] Make post subject links reliable Change links that were relative to topic page into absolute links. Update related test cases. PHPBB3-16150 --- tests/functional/download_test.php | 2 +- tests/functional/feed_test.php | 6 +++--- tests/functional/posting_test.php | 4 ++-- tests/functional/prune_shadow_topic_test.php | 2 +- tests/functional/visibility_softdelete_test.php | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php index e2f1d065be..3d4f316d72 100644 --- a/tests/functional/download_test.php +++ b/tests/functional/download_test.php @@ -55,7 +55,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case // Test creating a reply $post2 = $this->create_post($this->data['forums']['Download #1'], $post['topic_id'], 'Re: Download Topic #1-#2', 'This is a test post posted by the testing framework.', array('upload_files' => 1)); - $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); $this->assertContains('Re: Download Topic #1-#2', $crawler->filter('html')->text()); $this->data['posts']['Re: Download Topic #1-#2'] = (int) $post2['post_id']; diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 3792b0a23c..725a44ae5e 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -337,7 +337,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case // Test creating a reply $post2 = $this->create_post($this->data['forums']['Feeds #news'], $post['topic_id'], 'Re: Feeds #news - Topic #2', 'This is a test post posted by the testing framework.'); - $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); self::assertContains('Re: Feeds #news - Topic #2', $crawler->filter('html')->text()); $this->data['posts']['Re: Feeds #news - Topic #2'] = (int) $post2['post_id']; @@ -493,7 +493,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case // Test creating a reply $post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.'); - $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); self::assertContains('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text()); $this->data['posts']['Re: Feeds #1 - Topic #2'] = (int) $post2['post_id']; @@ -1222,7 +1222,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case // Test creating a reply with 1 missing attachment $post2 = $this->create_post($this->data['forums']['Feeds #1'], $this->data['topics']['Feeds #1 - Topic #3'], 'Re: Feeds #1 - Topic #3-1', 'This is a test post posted by the testing framework. [attachment=0]Attachment #0[/attachment]'); - $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); self::assertContains('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text()); $this->data['posts']['Re: Feeds #1 - Topic #3-1'] = (int) $post2['post_id']; diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 764376a945..7150f20a9d 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -29,7 +29,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case // Test creating a reply with bbcode $post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test [b]post[/b] posted by the testing framework.'); - $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text()); // Test quoting a message @@ -161,7 +161,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case { $this->set_quote_depth($quote_depth); - $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + $post = $this->create_post(2, $topic['topic_id'], "Re: Test Topic 1#$quote_depth", $text); $url = "viewtopic.php?p={$post['post_id']}&sid={$this->sid}"; $crawler = self::request('GET', $url); diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php index c014119b98..2bf0280d62 100644 --- a/tests/functional/prune_shadow_topic_test.php +++ b/tests/functional/prune_shadow_topic_test.php @@ -77,7 +77,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas // Test creating a reply $post2 = $this->create_post($this->data['forums']['Prune Shadow'], $this->post['topic_id'], 'Re: Prune Shadow #1-#2', 'This is a test post posted by the testing framework.'); - $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); $this->assertContains('Re: Prune Shadow #1-#2', $crawler->filter('html')->text()); $this->data['posts']['Re: Prune Shadow #1-#2'] = (int) $post2['post_id']; diff --git a/tests/functional/visibility_softdelete_test.php b/tests/functional/visibility_softdelete_test.php index 6450c00c1e..fd994361a5 100644 --- a/tests/functional/visibility_softdelete_test.php +++ b/tests/functional/visibility_softdelete_test.php @@ -97,7 +97,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ // Test creating a reply $post2 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#2', 'This is a test post posted by the testing framework.'); - $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); $this->assertContains('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text()); $this->data['posts']['Re: Soft Delete Topic #1-#2'] = (int) $post2['post_id']; @@ -114,7 +114,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ // Test creating another reply $post3 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#3', 'This is another test post posted by the testing framework.'); - $crawler = self::request('GET', "viewtopic.php?t={$post3['topic_id']}&sid={$this->sid}"); + $crawler = self::request('GET', "viewtopic.php?p={$post3['post_id']}&sid={$this->sid}"); $this->assertContains('Re: Soft Delete Topic #1-#3', $crawler->filter('html')->text()); $this->data['posts']['Re: Soft Delete Topic #1-#3'] = (int) $post3['post_id']; -- cgit v1.2.1 From bcac30c8bbc1839fd20ef612faccaffc5df74464 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Wed, 11 Sep 2019 01:46:02 +0200 Subject: [ticket/16153] Functional test PHPBB3-16153 --- tests/functional/posting_test.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 764376a945..298bb40a90 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -46,9 +46,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case self::create_post(2, 1, "Unsupported: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", - 'This is a test with emoji characters in the topic title.', - array(), - 'Your subject contains the following unsupported characters' + 'This is a test with emoji characters in the topic title.' ); } -- cgit v1.2.1 From 41728f2258c409480b9c3d4c1753b6eb1b47c677 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Wed, 11 Sep 2019 03:44:12 +0200 Subject: [ticket/16153] Functional test 2 PHPBB3-16153 --- tests/functional/posting_test.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 298bb40a90..e4b23c3215 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -41,13 +41,10 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case { $this->login(); - $this->add_lang('posting'); - - self::create_post(2, - 1, - "Unsupported: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", - 'This is a test with emoji characters in the topic title.' - ); + $post = $this->create_topic(2, "Test Topic \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji character in the topic title.'); + $this->create_post(2, $post['topic_id'], "Re: Test Topic 1 \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji characters in the topic title.'); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + $this->assertContains("\xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", $crawler->text()); } public function test_supported_unicode_characters() -- cgit v1.2.1 From b149e50bf16850cab268660c0f7291be6c130f9f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 19 Oct 2019 16:11:22 +0200 Subject: [ticket/16141] Add tests for plupload's get_chunk_size() PHPBB3-16141 --- tests/plupload/plupload_test.php | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'tests') diff --git a/tests/plupload/plupload_test.php b/tests/plupload/plupload_test.php index 46bebb8d35..65141f4f2a 100644 --- a/tests/plupload/plupload_test.php +++ b/tests/plupload/plupload_test.php @@ -54,4 +54,72 @@ class phpbb_plupload_test extends phpbb_test_case $this->assertEquals($expected, $plupload->generate_resize_string()); } + + public function data_get_chunk_size() + { + return [ + [[ + 'memory_limit' => -1, + 'upload_max_filesize' => 0, + 'post_max_size' => 0, + ], 0], + [[ + 'memory_limit' => -1, + 'upload_max_filesize' => 500, + 'post_max_size' => 400, + ], 200], + [[ + 'memory_limit' => 100, + 'upload_max_filesize' => 0, + 'post_max_size' => 300, + ], 50], + [[ + 'memory_limit' => 300, + 'upload_max_filesize' => 200, + 'post_max_size' => 0, + ], 100], + [[ + 'memory_limit' => 3000, + 'upload_max_filesize' => 800, + 'post_max_size' => 900, + ], 400], + [[ + 'memory_limit' => 2000, + 'upload_max_filesize' => 1000, + 'post_max_size' => 600, + ], 300], + ]; + } + + /** + * @dataProvider data_get_chunk_size + */ + public function test_get_chunk_size($limits_ary, $expected) + { + global $phpbb_root_path, $phpEx; + + $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $config = new \phpbb\config\config([]); + + $ini_wrapper = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper') + ->setMethods(['getBytes']) + ->getMock(); + $ini_wrapper->method('getBytes') + ->will($this->returnValueMap([ + ['memory_limit', $limits_ary['memory_limit']], + ['upload_max_filesize', $limits_ary['upload_max_filesize']], + ['post_max_size', $limits_ary['post_max_size']] + ])); + + $plupload = new \phpbb\plupload\plupload( + '', + $config, + new phpbb_mock_request, + new \phpbb\user($lang, '\phpbb\datetime'), + $ini_wrapper, + new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)) + ); + + $this->assertEquals($expected, $plupload->get_chunk_size()); + } } -- cgit v1.2.1 From 6eb00414536f583e4e1ac5fc72cb00025f55b2ce Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 19 Oct 2019 17:35:25 +0200 Subject: [ticket/16141] Add assertion for memory limit divided by two PHPBB3-16141 --- tests/plupload/plupload_test.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/plupload/plupload_test.php b/tests/plupload/plupload_test.php index 65141f4f2a..eb4657afbc 100644 --- a/tests/plupload/plupload_test.php +++ b/tests/plupload/plupload_test.php @@ -88,6 +88,11 @@ class phpbb_plupload_test extends phpbb_test_case 'upload_max_filesize' => 1000, 'post_max_size' => 600, ], 300], + [[ + 'memory_limit' => 1000, + 'upload_max_filesize' => 2000, + 'post_max_size' => 3000, + ], 500], ]; } -- cgit v1.2.1 From 1ba0ae6e8530d3dab55ad1333c0d392eefa2d401 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 19 Oct 2019 17:48:34 +0200 Subject: [ticket/16078] Try using retries for timeout issue The timeout only seems to occur on the first test so let's see what a retry can do to help with this issue. PHPBB3-16078 --- tests/test_framework/phpbb_ui_test_case.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 4d88d7d9cb..e7c9bd4d0b 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -158,7 +158,23 @@ class phpbb_ui_test_case extends phpbb_test_case public function visit($path) { - $this->getDriver()->get(self::$root_url . $path); + // Retry three times on curl issues, e.g. timeout + try + { + $this->getDriver()->get(self::$root_url . $path); + } + catch (Facebook\WebDriver\Exception\WebDriverCurlException $exception) + { + try + { + $this->getDriver()->get(self::$root_url . $path); + } + catch (Facebook\WebDriver\Exception\WebDriverCurlException $exception) + { + // Last try, throw exception after this one fails + $this->getDriver()->get(self::$root_url . $path); + } + } } static protected function recreate_database($config) -- cgit v1.2.1 From 8b6776eed22edc33b3f35946fba6b5de4bfe73a1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Oct 2019 15:51:47 +0200 Subject: [ticket/16078] Use while loop for visit retries PHPBB3-16078 --- tests/test_framework/phpbb_ui_test_case.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index e7c9bd4d0b..48e510abe3 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -159,20 +159,23 @@ class phpbb_ui_test_case extends phpbb_test_case public function visit($path) { // Retry three times on curl issues, e.g. timeout - try - { - $this->getDriver()->get(self::$root_url . $path); - } - catch (Facebook\WebDriver\Exception\WebDriverCurlException $exception) + $attempts = 0; + $retries = 3; + + while (true) { + $attempts++; try { $this->getDriver()->get(self::$root_url . $path); + break; } catch (Facebook\WebDriver\Exception\WebDriverCurlException $exception) { - // Last try, throw exception after this one fails - $this->getDriver()->get(self::$root_url . $path); + if ($attempts >= $retries) + { + throw $exception; + } } } } -- cgit v1.2.1 From 7b428641f04766ea8711cb47e76bbe2b52638abe Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 14 Nov 2019 21:32:50 +0100 Subject: [ticket/16211] Prevent skipping COPPA via URL parameter PHPBB3-16211 --- tests/functional/registration_test.php | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'tests') diff --git a/tests/functional/registration_test.php b/tests/functional/registration_test.php index 690f4ae9f2..be6dd50203 100644 --- a/tests/functional/registration_test.php +++ b/tests/functional/registration_test.php @@ -36,6 +36,10 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case { $this->add_lang('ucp'); + // Check that we can't skip + self::request('GET', 'ucp.php?mode=register&agreed=1'); + $this->assertContainsLang('AGREE', $this->get_content()); + $crawler = self::request('GET', 'ucp.php?mode=register'); $this->assertContainsLang('REGISTRATION', $crawler->filter('div.content h2')->text()); @@ -64,4 +68,55 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case $this->assert_checkbox_is_checked($crawler, 'notification.type.post_notification.method.email'); $this->assert_checkbox_is_checked($crawler, 'notification.type.topic_notification.method.email'); } + + /** + * @depends test_disable_captcha_on_registration + */ + public function test_register_coppa_account() + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_board&mode=registration&sid={$this->sid}"); + $form = $crawler->selectButton('Submit')->form(); + $form['config[coppa_enable]']->setValue('1'); + $crawler = self::submit($form); + + $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('#main .successbox')->text()); + $this->logout(); + + $this->add_lang('ucp'); + + // Check that we can't skip + $crawler = self::request('GET', 'ucp.php?mode=register&coppa=1'); + $this->assertContainsLang('COPPA_BIRTHDAY', $crawler->html()); + + $agreement_url = $crawler->filter('#agreement')->filter('a')->links()[0]->getUri(); + preg_match('/(&hash=\w+)/', $agreement_url, $matches); + $crawler = self::request('GET', 'ucp.php?mode=register&coppa=1' . $matches[1]); + + $this->assertContainsLang('REGISTRATION', $crawler->filter('div.content h2')->text()); + + $form = $crawler->selectButton('I agree to these terms')->form(); + $crawler = self::submit($form); + + $form = $crawler->selectButton('Submit')->form(array( + 'username' => 'user-coppa-test', + 'email' => 'user-coppa-test@phpbb.com', + 'new_password' => 'user-coppa-testuser-coppa-test', + 'password_confirm' => 'user-coppa-testuser-coppa-test', + )); + $form['tz']->select('Europe/Berlin'); + $crawler = self::submit($form); + + $this->assertContainsLang('ACCOUNT_COPPA', $crawler->filter('#message')->text()); + + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_board&mode=registration&sid={$this->sid}"); + $form = $crawler->selectButton('Submit')->form(); + $form['config[coppa_enable]']->setValue('0'); + $crawler = self::submit($form); + } } -- cgit v1.2.1 From d6f5b5ef6cd052d43f4bf75af423eaafd8ba9b07 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 25 Nov 2019 18:34:04 +0100 Subject: [ticket/16228] Fix BBCodes merging PHPBB3-16228 --- tests/text_formatter/s9e/bbcode_merger_test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/text_formatter/s9e/bbcode_merger_test.php b/tests/text_formatter/s9e/bbcode_merger_test.php index 815539056b..5ec0c91971 100644 --- a/tests/text_formatter/s9e/bbcode_merger_test.php +++ b/tests/text_formatter/s9e/bbcode_merger_test.php @@ -275,6 +275,22 @@ class phpbb_textformatter_s9e_bbcode_merger_test extends phpbb_test_case

                 

                ' ], + [ + // https://www.phpbb.com/community/viewtopic.php?f=438&t=2530451 + '[issue]{NUMBER}[/issue]', + ' Issue #{NUMBER}', + + '[issue={SIMPLETEXT}]{NUMBER}[/issue]', + ' Issue #{NUMBER} ({SIMPLETEXT})', + + '[issue={SIMPLETEXT?}]{NUMBER}[/issue]', + ' + + //issues/ Issue # () + /default/issues/ Issue # + + ' + ], ]; } } -- cgit v1.2.1 From c7ed162a0627a0cfcf000631f236fbb7f6722ba3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 28 Nov 2019 07:39:51 +0100 Subject: [ticket/16211] Fix coppa registration test PHPBB3-16211 --- tests/functional/registration_test.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/functional/registration_test.php b/tests/functional/registration_test.php index be6dd50203..48982edc8c 100644 --- a/tests/functional/registration_test.php +++ b/tests/functional/registration_test.php @@ -91,9 +91,8 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case $crawler = self::request('GET', 'ucp.php?mode=register&coppa=1'); $this->assertContainsLang('COPPA_BIRTHDAY', $crawler->html()); - $agreement_url = $crawler->filter('#agreement')->filter('a')->links()[0]->getUri(); - preg_match('/(&hash=\w+)/', $agreement_url, $matches); - $crawler = self::request('GET', 'ucp.php?mode=register&coppa=1' . $matches[1]); + $form = $crawler->selectButton('coppa_yes')->form(); + $crawler = self::submit($form); $this->assertContainsLang('REGISTRATION', $crawler->filter('div.content h2')->text()); -- cgit v1.2.1 From 17f8134a3b1003a90b4f20ad36b03e637ec67b5a Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 5 Dec 2019 10:32:27 +0100 Subject: [ticket/16247] Add test not tested PHPBB3-16247 --- tests/functional/private_messages_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index 7fda26fb49..ce709524a9 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -85,7 +85,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case public function test_quote_pm() { $text = 'This is a test private message sent by the testing framework.'; - $expected = "(\\[quote=admin time=\\d+ user_id=2\\]\n" . $text . "\n\\[/quote\\])"; + $expected = "(\\[quote=admin msg_id=\\d+ time=\\d+ user_id=2\\]\n" . $text . "\n\\[/quote\\])"; $this->login(); $message_id = $this->create_private_message('Test', $text, array(2)); -- cgit v1.2.1 From 6758190afd7b77d5800fe1e03e87ec4f2f09e91f Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 9 Dec 2019 02:16:01 +0100 Subject: [ticket/16251] Prevent shortened links from overriding other plugins PHPBB3-16251 --- tests/text_formatter/s9e/link_helper_test.php | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/text_formatter/s9e/link_helper_test.php (limited to 'tests') diff --git a/tests/text_formatter/s9e/link_helper_test.php b/tests/text_formatter/s9e/link_helper_test.php new file mode 100644 index 0000000000..762d67f883 --- /dev/null +++ b/tests/text_formatter/s9e/link_helper_test.php @@ -0,0 +1,35 @@ + +* @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_textformatter_s9e_link_helper_test extends phpbb_test_case +{ + public function test_does_not_override_autoimage() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $configurator = $container->get('text_formatter.s9e.factory')->get_configurator(); + + $configurator->Autoimage; + extract($configurator->finalize()); + + $original = 'http://localhost/path_to_long_image_filename_0123456789.png'; + $expected = ' + + + http://localhost/path_to_long_image_filename_0123456789.png + + + '; + + $this->assertXmlStringEqualsXmlString($expected, $parser->parse($original)); + } +} -- cgit v1.2.1 From 5813b5fbee2ac332f14dee2da7df9c3dfd6c2719 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 9 Dec 2019 18:06:30 +0100 Subject: [ticket/16252] Ignore non-BBCodes when looking for unauthorized markup PHPBB3-16252 --- .../tickets_data/PHPBB3-16252.after.php | 18 ++++++++++++++++++ .../tickets_data/PHPBB3-16252.before.php | 17 +++++++++++++++++ tests/text_processing/tickets_data/PHPBB3-16252.html | 1 + tests/text_processing/tickets_data/PHPBB3-16252.txt | 1 + 4 files changed, 37 insertions(+) create mode 100644 tests/text_processing/tickets_data/PHPBB3-16252.after.php create mode 100644 tests/text_processing/tickets_data/PHPBB3-16252.before.php create mode 100644 tests/text_processing/tickets_data/PHPBB3-16252.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-16252.txt (limited to 'tests') diff --git a/tests/text_processing/tickets_data/PHPBB3-16252.after.php b/tests/text_processing/tickets_data/PHPBB3-16252.after.php new file mode 100644 index 0000000000..c2f57c171e --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-16252.after.php @@ -0,0 +1,18 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +function after_assert_phpbb3_16252($vars) +{ + extract($vars); + $test->assertEmpty($parser->get_errors()); +} diff --git a/tests/text_processing/tickets_data/PHPBB3-16252.before.php b/tests/text_processing/tickets_data/PHPBB3-16252.before.php new file mode 100644 index 0000000000..94c59d9602 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-16252.before.php @@ -0,0 +1,17 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +function before_assert_phpbb3_16252($vars) +{ + $vars['parser']->disable_bbcode('url'); +} diff --git a/tests/text_processing/tickets_data/PHPBB3-16252.html b/tests/text_processing/tickets_data/PHPBB3-16252.html new file mode 100644 index 0000000000..5b14ab0e7a --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-16252.html @@ -0,0 +1 @@ +http://localhost/ \ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-16252.txt b/tests/text_processing/tickets_data/PHPBB3-16252.txt new file mode 100644 index 0000000000..5b14ab0e7a --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-16252.txt @@ -0,0 +1 @@ +http://localhost/ \ No newline at end of file -- cgit v1.2.1 From 4f007321e19e18e9166c4df2e8cb0d98d17fc14c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 24 Dec 2019 12:44:16 +0100 Subject: [ticket/security-250] Check form key when approving group membership SECURITY-250 --- tests/functional/ucp_groups_test.php | 68 ++++++++++++++++++++++ .../test_framework/phpbb_functional_test_case.php | 33 +++++++---- 2 files changed, 89 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index cd18a0fcae..445c124158 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -54,4 +54,72 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); $this->assertEquals($teampage_settings, $this->get_teampage_settings()); } + + public function test_create_request_group() + { + $this->login(); + $this->admin_login(); + $this->add_lang('acp/groups'); + + $crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form, array('group_name' => 'request-group')); + + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form, array('group_name' => 'request-group')); + + $this->assertContainsLang('GROUP_CREATED', $crawler->filter('#main')->text()); + + $group_id = $this->get_group_id('request-group'); + + // Make admin group leader + $crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=list&g=' . $group_id . '&sid=' . $this->sid); + $form = $crawler->filter('input[name=addusers]')->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form, [ + 'leader' => 1, + 'usernames' => 'admin', + ]); + + $this->assertContainsLang('GROUP_MODS_ADDED', $crawler->filter('#main')->text()); + } + + /** + * @depends test_create_request_group + */ + public function test_request_group_membership() + { + $this->create_user('request-group-user'); + $this->login('request-group-user'); + $this->add_lang('groups'); + + $group_id = $this->get_group_id('request-group'); + + $crawler = self::request('GET', 'ucp.php?i=ucp_groups&mode=membership&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form, ['selected' => $group_id, 'action' => 'join']); + $this->assertContainsLang('GROUP_JOIN_PENDING_CONFIRM', $crawler->text()); + + $form = $crawler->selectButton($this->lang('YES'))->form(); + $crawler = self::submit($form); + $this->assertContainsLang('GROUP_JOINED_PENDING', $crawler->text()); + } + + /** + * @depends test_request_group_membership + */ + public function test_approve_group_membership() + { + $this->login(); + $this->add_lang('acp/groups'); + + $group_id = $this->get_group_id('request-group'); + $crawler = self::request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=list&g=' . $group_id . '&sid=' . $this->sid); + $form = $crawler->filter('input[name=update]')->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form, [ + 'mark' => [$crawler->filter('input[name="mark[]"]')->first()->attr('value')], + 'action' => 'approve', + ]); + + $this->assertContainsLang('USERS_APPROVED', $crawler->text()); + } } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 2659cf6e73..f1b30f0fed 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -623,6 +623,25 @@ class phpbb_functional_test_case extends phpbb_test_case return user_add($user_row); } + /** + * Get group ID + * + * @param string $group_name Group name + * @return int Group id of specified group name + */ + protected function get_group_id($group_name) + { + $db = $this->get_db(); + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = '" . $db->sql_escape($group_name) . "'"; + $result = $db->sql_query($sql); + $group_id = (int) $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + + return $group_id; + } + protected function remove_user_group($group_name, $usernames) { global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; @@ -655,12 +674,7 @@ class phpbb_functional_test_case extends phpbb_test_case require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); } - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $db->sql_escape($group_name) . "'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); + $group_id = $this->get_group_id($group_name); return group_user_del($group_id, false, $usernames, $group_name); } @@ -700,12 +714,7 @@ class phpbb_functional_test_case extends phpbb_test_case require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); } - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $db->sql_escape($group_name) . "'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); + $group_id = $this->get_group_id($group_name); return group_user_add($group_id, false, $usernames, $group_name, $default, $leader); } -- cgit v1.2.1