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 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 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 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