From c8040024cb9c1d28b669568789c5dfacc0941f54 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 23 Oct 2013 18:36:11 +0200 Subject: [ticket/11912] Add tests for phpbb mimetype guesser PHPBB3-11912 --- tests/mimetype/fixtures/jpg | Bin 0 -> 519 bytes tests/mimetype/guesser_test.php | 83 +++++++++++++++++++++++++++++++++++ tests/mimetype/incorrect_guesser.php | 18 ++++++++ tests/mimetype/null_guesser.php | 30 +++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 tests/mimetype/fixtures/jpg create mode 100644 tests/mimetype/guesser_test.php create mode 100644 tests/mimetype/incorrect_guesser.php create mode 100644 tests/mimetype/null_guesser.php (limited to 'tests') diff --git a/tests/mimetype/fixtures/jpg b/tests/mimetype/fixtures/jpg new file mode 100644 index 0000000000..3cd5038e38 Binary files /dev/null and b/tests/mimetype/fixtures/jpg differ diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php new file mode 100644 index 0000000000..3728961460 --- /dev/null +++ b/tests/mimetype/guesser_test.php @@ -0,0 +1,83 @@ +guesser = new \phpbb\mimetype\guesser($guessers); + $this->path = dirname(__FILE__); + $this->jpg_file = $this->path . '/fixtures/jpg'; + } + + public function data_guess_files() + { + return array( + array('image/gif', 'gif'), + array('image/png', 'png'), + array('image/jpeg', 'jpg'), + array('image/tiff', 'tif'), + array('text/html', 'txt'), + array(false, 'foobar'), + ); + } + + /** + * @dataProvider data_guess_files + */ + public function test_guess_files($expected, $file) + { + $this->assertEquals($expected, $this->guesser->guess($this->path . '/../upload/fixture/' . $file)); + } + + public function test_file_not_readable() + { + @chmod($this->jpg_file, 0000); + if (is_readable($this->jpg_file)) + { + @chmod($this->jpg_file, 0644); + $this->markTestSkipped('is_readable always returns true if user is superuser or chmod does not work'); + } + $this->assertEquals(false, $this->guesser->guess($this->jpg_file)); + @chmod($this->jpg_file, 0644); + $this->assertEquals('image/jpeg', $this->guesser->guess($this->jpg_file)); + } + + public function test_null_guess() + { + $guesser = new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\null_guesser)); + $this->assertEquals('application/octet-stream', $guesser->guess($this->jpg_file)); + } + + public function data_incorrect_guessers() + { + return array( + array(array(new \phpbb\mimetype\incorrect_guesser)), + array(array(new \phpbb\mimetype\null_guesser(false))), + array(array()), + ); + } + + /** + * @dataProvider data_incorrect_guessers + * + * @expectedException \LogicException + */ + public function test_incorrect_guesser($guessers) + { + $guesser = new \phpbb\mimetype\guesser($guessers); + } +} diff --git a/tests/mimetype/incorrect_guesser.php b/tests/mimetype/incorrect_guesser.php new file mode 100644 index 0000000000..3939826faa --- /dev/null +++ b/tests/mimetype/incorrect_guesser.php @@ -0,0 +1,18 @@ +is_supported = $is_supported; + } + + public function is_supported() + { + return $this->is_supported; + } + + public function guess($file) + { + return null; + } +} -- cgit v1.2.1 From f617aff182f5f291d5b7d0ff854abea12a04cb0b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 23 Oct 2013 23:18:40 +0200 Subject: [ticket/11912] Add tests for content_guesser PHPBB3-11912 --- tests/mimetype/guesser_test.php | 51 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 3728961460..6484606210 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -7,20 +7,32 @@ * */ +namespace phpbb\mimetype; + require_once dirname(__FILE__) . '/null_guesser.php'; require_once dirname(__FILE__) . '/incorrect_guesser.php'; -class phpbb_mimetype_guesser_test extends phpbb_test_case +function function_exists($name) +{ + return guesser_test::$function_exists; +} + +class guesser_test extends \phpbb_test_case { + public static $function_exists = true; + public function setUp() { + global $phpbb_root_path; + $guessers = array( - new Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), - new Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), + new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), + new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), ); $this->guesser = new \phpbb\mimetype\guesser($guessers); $this->path = dirname(__FILE__); $this->jpg_file = $this->path . '/fixtures/jpg'; + $this->phpbb_root_path = $phpbb_root_path; } public function data_guess_files() @@ -80,4 +92,37 @@ class phpbb_mimetype_guesser_test extends phpbb_test_case { $guesser = new \phpbb\mimetype\guesser($guessers); } + + public function data_content_guesser() + { + return array( + array( + array( + 'image/jpeg', + 'image/jpeg', + ), + false, + ), + array( + array( + 'application/octet-stream', + 'image/jpeg', + ), + true, + ), + ); + } + + /** + * @dataProvider data_content_guesser + */ + public function test_content_guesser($expected, $overload = false) + { + self::$function_exists = ($overload) ? false : true; + $guesser = new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\content_guesser($this->phpbb_root_path, new \phpbb\php\ini))); + $this->assertEquals($expected[0], $guesser->guess($this->jpg_file)); + @copy($this->jpg_file, $this->jpg_file . '.jpg'); + $this->assertEquals($expected[1], $guesser->guess($this->jpg_file . '.jpg')); + @unlink($this->jpg_file . '.jpg'); + } } -- cgit v1.2.1 From bc7ff47537bae4f6db9de781cf8ba3487e28a30b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 12:05:00 +0200 Subject: [ticket/11912] Supply filename to content_guesser for guessing on windows The filename of the files sent to the guesser by plupload do not contain the file extension. Therefore, it's impossible to guess the mimetype if only the content_guesser is available and the function mime_content_type() doesn't exist. By supplying the filename we can circumvent this issue. PHPBB3-11912 --- tests/mimetype/guesser_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 6484606210..9d4d965d63 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -119,8 +119,9 @@ class guesser_test extends \phpbb_test_case public function test_content_guesser($expected, $overload = false) { self::$function_exists = ($overload) ? false : true; - $guesser = new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\content_guesser($this->phpbb_root_path, new \phpbb\php\ini))); + $guesser = new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\content_guesser)); $this->assertEquals($expected[0], $guesser->guess($this->jpg_file)); + $this->assertEquals($expected[1], $guesser->guess($this->jpg_file, $this->jpg_file . '.jpg')); @copy($this->jpg_file, $this->jpg_file . '.jpg'); $this->assertEquals($expected[1], $guesser->guess($this->jpg_file . '.jpg')); @unlink($this->jpg_file . '.jpg'); -- cgit v1.2.1 From 9d4d212e0f71789e1f0332046dd852d80ab9c8ba Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 13:55:23 +0200 Subject: [ticket/11525] Only remove group or user prefix from given avatar data Until now, the user data had both user_id and group_id keys in the avatar data. As both group_ and user_ prefixes were removed the group_id was collapsed onto the user_id and therefore all users in the same group had the same prefix for their uploaded avatars. This patch will make sure that the correct id is used depending on whether it's a group's or user's avatar data. PHPBB3-11525 --- tests/avatar/manager_test.php | 44 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 4afa594beb..f687f7bc86 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -201,20 +201,58 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase 'foobar_avatar_height' => '', ), ), + array( + array( + 'user_avatar' => '', + 'user_id' => 5, + 'group_id' => 4, + ), + array( + 'avatar' => '', + 'id' => 4, + ), + ), + array( + array( + 'user_avatar' => '', + 'user_id' => 5, + 'group_id' => 4, + ), + array( + 'avatar' => '', + 'id' => 5, + 'group_id' => 4, + ), + 'user', + ), + array( + array( + 'group_avatar' => '', + 'user_id' => 5, + 'group_id' => 4, + ), + array( + 'avatar' => '', + 'id' => 4, + 'user_id' => 5, + ), + 'group', + ), ); } /** * @dataProvider database_row_data */ - public function test_clean_row(array $input, array $output) + public function test_clean_row(array $input, array $output, $prefix = '') { $cleaned_row = array(); - $cleaned_row = \phpbb\avatar\manager::clean_row($input); - foreach ($output as $key => $null) + $cleaned_row = \phpbb\avatar\manager::clean_row($input, $prefix); + foreach ($output as $key => $value) { $this->assertArrayHasKey($key, $cleaned_row); + $this->assertEquals($output[$key], $value); } } -- cgit v1.2.1 From 1f624e136785893d0c9e4bfeb1a12f9c08693a24 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 21:41:41 +0200 Subject: [ticket/11842] Replace outdated occurences of user and group avatar_type user_avatar_type und group_avatar_type are now a string and should therefore be treated accordingly. PHPBB3-11842 --- tests/functions_user/group_user_attributes_test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index f8d52a9a6a..5ed60f6593 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -27,7 +27,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 2, array( 'group_avatar' => '', - 'group_avatar_type' => 0, + 'group_avatar_type' => '', 'group_avatar_height' => 0, 'group_avatar_width' => 0, 'group_rank' => 0, @@ -43,7 +43,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 2, array( 'group_avatar' => '', - 'group_avatar_type' => 0, + 'group_avatar_type' => '', 'group_avatar_height' => 0, 'group_avatar_width' => 0, 'group_rank' => 0, @@ -59,7 +59,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 2, array( 'group_avatar' => '', - 'group_avatar_type' => 0, + 'group_avatar_type' => '', 'group_avatar_height' => 0, 'group_avatar_width' => 0, 'group_rank' => 0, @@ -75,7 +75,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 3, array( 'group_avatar' => 'default2', - 'group_avatar_type' => 1, + 'group_avatar_type' => 'avatar.driver.upload', 'group_avatar_height' => 1, 'group_avatar_width' => 1, 'group_rank' => 3, @@ -91,7 +91,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 3, array( 'group_avatar' => 'default2', - 'group_avatar_type' => 1, + 'group_avatar_type' => 'avatar.driver.upload', 'group_avatar_height' => 1, 'group_avatar_width' => 1, 'group_rank' => 3, @@ -107,7 +107,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes 3, array( 'group_avatar' => 'default2', - 'group_avatar_type' => 1, + 'group_avatar_type' => 'avatar.driver.upload', 'group_avatar_height' => 1, 'group_avatar_width' => 1, 'group_rank' => 3, -- cgit v1.2.1 From 9b0b5481fe05b10a254861495280d04721e8d9d1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 21:03:06 +0200 Subject: [ticket/11534] Check remote avatar content type if possible This should make sure that error pages like 404 or 503 pages are not treated as remote avatar images. PHPBB3-11534 --- tests/functional/avatar_acp_groups_test.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php index 9fdc29cc76..5e908bc6da 100644 --- a/tests/functional/avatar_acp_groups_test.php +++ b/tests/functional/avatar_acp_groups_test.php @@ -50,6 +50,15 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av 'avatar_delete' => array('tick', ''), ), ), + array( + 'The URL you specified is invalid.', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), ); } -- cgit v1.2.1 From b2f638b79359ee6df600ca940ffa2b1657235364 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 27 Oct 2013 09:52:09 +0100 Subject: [ticket/11857] Use passed service collection instead of container in manager The service collection that was already passed to the avatar manager should be used in the avatar manager method get_driver() instead of the container itself. PHPBB3-11857 --- tests/avatar/manager_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 4afa594beb..0db3f13617 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -112,7 +112,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase public function test_get_driver_enabled($driver_name, $expected) { $driver = $this->manager->get_driver($driver_name); - $this->assertEquals($expected, $driver); + $this->assertEquals($expected, ($driver === null) ? null : $driver->get_name()); } public function get_driver_data_all() @@ -133,7 +133,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase public function test_get_driver_all($driver_name, $expected) { $driver = $this->manager->get_driver($driver_name, false); - $this->assertEquals($expected, $driver); + $this->assertEquals($expected, ($driver === null) ? $driver : $driver->get_name()); } public function test_get_avatar_settings() -- cgit v1.2.1 From a175b091b9066478900d4a1a92c3e67f33cd9b33 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 2 Nov 2013 18:12:50 +0100 Subject: [ticket/11995] Add unit test for reverting config.remove PHPBB3-11995 --- tests/dbal/migrator_tool_config_test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php index a8d8966839..d007e36da1 100644 --- a/tests/dbal/migrator_tool_config_test.php +++ b/tests/dbal/migrator_tool_config_test.php @@ -94,6 +94,7 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case public function test_reverse() { + // add $this->config->set('foo', 'bar'); try @@ -106,6 +107,21 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case } $this->assertFalse(isset($this->config['foo'])); + // remove + $this->config->delete('foo'); + + try + { + $this->tool->reverse('remove', 'foo'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertTrue(isset($this->config['foo'])); + $this->assertEquals('', $this->config['foo']); + + // update_if_equals $this->config->set('foo', 'bar'); try -- cgit v1.2.1 From e8a3028ea6505942f6f192105b75dabc177dae44 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 2 Nov 2013 19:26:45 +0100 Subject: [ticket/11995] Remove exceptions and split reverse into different tests PHPBB3-11995 --- tests/dbal/migrator_tool_config_test.php | 99 ++++++++------------------------ 1 file changed, 24 insertions(+), 75 deletions(-) (limited to 'tests') diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php index d007e36da1..807399385c 100644 --- a/tests/dbal/migrator_tool_config_test.php +++ b/tests/dbal/migrator_tool_config_test.php @@ -20,35 +20,24 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case public function test_add() { - try - { - $this->tool->add('foo', 'bar'); - } - catch (Exception $e) - { - $this->fail($e); - } + $this->tool->add('foo', 'bar'); $this->assertEquals('bar', $this->config['foo']); + } - try - { - $this->tool->add('foo', 'bar'); - $this->fail('Exception not thrown'); - } - catch (Exception $e) {} + public function test_add_twice() + { + $this->tool->add('foo', 'bar'); + $this->assertEquals('bar', $this->config['foo']); + + $this->tool->add('foo', 'bar2'); + $this->assertEquals('bar', $this->config['foo']); } public function test_update() { $this->config->set('foo', 'bar'); - try - { - $this->tool->update('foo', 'bar2'); - } - catch (Exception $e) - { - $this->fail($e); - } + + $this->tool->update('foo', 'bar2'); $this->assertEquals('bar2', $this->config['foo']); } @@ -56,24 +45,10 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case { $this->config->set('foo', 'bar'); - try - { - $this->tool->update_if_equals('', 'foo', 'bar2'); - } - catch (Exception $e) - { - $this->fail($e); - } + $this->tool->update_if_equals('', 'foo', 'bar2'); $this->assertEquals('bar', $this->config['foo']); - try - { - $this->tool->update_if_equals('bar', 'foo', 'bar2'); - } - catch (Exception $e) - { - $this->fail($e); - } + $this->tool->update_if_equals('bar', 'foo', 'bar2'); $this->assertEquals('bar2', $this->config['foo']); } @@ -81,57 +56,31 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case { $this->config->set('foo', 'bar'); - try - { - $this->tool->remove('foo'); - } - catch (Exception $e) - { - $this->fail($e); - } + $this->tool->remove('foo'); $this->assertFalse(isset($this->config['foo'])); } - public function test_reverse() + public function test_reverse_add() { - // add $this->config->set('foo', 'bar'); - try - { - $this->tool->reverse('add', 'foo'); - } - catch (Exception $e) - { - $this->fail($e); - } + $this->tool->reverse('add', 'foo'); $this->assertFalse(isset($this->config['foo'])); + } - // remove + public function test_reverse_remove() + { $this->config->delete('foo'); - try - { - $this->tool->reverse('remove', 'foo'); - } - catch (Exception $e) - { - $this->fail($e); - } - $this->assertTrue(isset($this->config['foo'])); + $this->tool->reverse('remove', 'foo'); $this->assertEquals('', $this->config['foo']); + } - // update_if_equals + public function test_reverse_update_if_equals() + { $this->config->set('foo', 'bar'); - try - { - $this->tool->reverse('update_if_equals', 'test', 'foo', 'bar'); - } - catch (Exception $e) - { - $this->fail($e); - } + $this->tool->reverse('update_if_equals', 'test', 'foo', 'bar'); $this->assertEquals('test', $this->config['foo']); } } -- cgit v1.2.1 From c609f25bae6aee2b7fab8dfeb8b3a58e2c2f396f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 4 Nov 2013 12:15:02 -0600 Subject: [ticket/11943] Add test for DEFINE $VAR = false PHPBB3-11943 --- tests/template/template_test.php | 2 +- tests/template/templates/define.html | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 39eb08ab79..0ff469779d 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -158,7 +158,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), array(), - "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n((\$VALUE == 'abc'))\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|", + "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n((\$VALUE == 'abc'))\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|false", ), array( 'define_advanced.html', diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html index e7ce7f7def..276d2ebb99 100644 --- a/tests/template/templates/define.html +++ b/tests/template/templates/define.html @@ -29,3 +29,9 @@ $VALUE == 'abc' [{$VALUE}] foobar|{$TEST}| + + +true + +false + -- cgit v1.2.1 From 7aa4d8fce2e61776d5f2dbf67386a589bcd7d634 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Nov 2013 12:56:10 +0100 Subject: [ticket/11927] Correctly add new files on update Currently we ignore language and style files when the directory where they go to do not exist. However in 3.1 we introduce some new sub directories: * language/en/email/short/ * styles/prosilver/theme/en/ So we need to change our check to look whether the language or style exist, rather then the parent directory. PHPBB3-11927 --- .../ignore_new_file_on_update_test.php | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/functions_install/ignore_new_file_on_update_test.php (limited to 'tests') diff --git a/tests/functions_install/ignore_new_file_on_update_test.php b/tests/functions_install/ignore_new_file_on_update_test.php new file mode 100644 index 0000000000..0c05cc6907 --- /dev/null +++ b/tests/functions_install/ignore_new_file_on_update_test.php @@ -0,0 +1,39 @@ +assertEquals($expected, ignore_new_file_on_update($phpbb_root_path, $file)); + } +} -- cgit v1.2.1 From 95348c8f6d64302d2d525f2ba1a9408f1510144b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Nov 2013 13:49:55 +0100 Subject: [ticket/11927] Prefix function with phpbb_ PHPBB3-11927 --- tests/functions_install/ignore_new_file_on_update_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functions_install/ignore_new_file_on_update_test.php b/tests/functions_install/ignore_new_file_on_update_test.php index 0c05cc6907..ae1dde96f7 100644 --- a/tests/functions_install/ignore_new_file_on_update_test.php +++ b/tests/functions_install/ignore_new_file_on_update_test.php @@ -34,6 +34,6 @@ class phpbb_functions_install_ignore_new_file_on_update_test extends phpbb_test_ public function test_ignore_new_file_on_update($file, $expected) { global $phpbb_root_path; - $this->assertEquals($expected, ignore_new_file_on_update($phpbb_root_path, $file)); + $this->assertEquals($expected, phpbb_ignore_new_file_on_update($phpbb_root_path, $file)); } } -- cgit v1.2.1 From f98ddb23e8b60cd30bcbaa4c1c2ce772c0cbcc96 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Nov 2013 16:25:22 +0100 Subject: [ticket/11994] Fix functional extension tests PHPBB3-11994 --- tests/functional/extension_acp_test.php | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 401b18f11c..029f13b4f1 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -83,18 +83,18 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertCount(5, $crawler->filter('.ext_disabled')); $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); - $this->assertContainsLang('PURGE', $crawler->filter('.ext_enabled')->eq(0)->text()); + $this->assertContainsLang('EXTENSION_UNINSTALL', $crawler->filter('.ext_enabled')->eq(0)->text()); - $this->assertContains('The "test2" extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); + $this->assertContains('The “test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); - $this->assertContains('The "test3" extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); + $this->assertContains('The “test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContainsLang('ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContainsLang('PURGE', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContainsLang('EXTENSION_UNINSTALL', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContains('The "bar" extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text()); + $this->assertContains('The “bar” extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text()); } public function test_details() @@ -148,8 +148,8 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('ENABLE_CONFIRM', $crawler->filter('html')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'vendor/moo'), $crawler->filter('html')->text()); } public function test_disable_pre() @@ -160,8 +160,8 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContainsLang('DISABLE_CONFIRM', $crawler->filter('html')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid); + $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'foo'), $crawler->filter('html')->text()); } public function test_purge_pre() @@ -170,19 +170,19 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=test2&sid=' . $this->sid); $this->assertContains('The required file does not exist', $crawler->filter('html')->text()); - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContainsLang('PURGE_CONFIRM', $crawler->filter('html')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid); + $this->assertContains($this->lang('EXTENSION_UNINSTALL_CONFIRM', 'foo'), $crawler->filter('html')->text()); } public function test_actions() { - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('ENABLE_SUCCESS', $crawler->filter('html')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('html')->text()); - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('DISABLE_SUCCESS', $crawler->filter('html')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('html')->text()); - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('PURGE_SUCCESS', $crawler->filter('html')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_UNINSTALL_SUCCESS', $crawler->filter('html')->text()); } } -- cgit v1.2.1 From e60588a25943f7cf662a5d759bfc8c1936da75a7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Nov 2013 16:26:04 +0100 Subject: [ticket/11994] Replace spaces with tabs PHPBB3-11994 --- tests/functional/extension_acp_test.php | 110 ++++++++++++++++---------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 029f13b4f1..d466e01c80 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -77,59 +77,59 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case public function test_list() { - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); - $this->assertCount(1, $crawler->filter('.ext_enabled')); - $this->assertCount(5, $crawler->filter('.ext_disabled')); + $this->assertCount(1, $crawler->filter('.ext_enabled')); + $this->assertCount(5, $crawler->filter('.ext_disabled')); - $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); - $this->assertContainsLang('EXTENSION_UNINSTALL', $crawler->filter('.ext_enabled')->eq(0)->text()); + $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); + $this->assertContainsLang('EXTENSION_UNINSTALL', $crawler->filter('.ext_enabled')->eq(0)->text()); - $this->assertContains('The “test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); + $this->assertContains('The “test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); - $this->assertContains('The “test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); + $this->assertContains('The “test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); - $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContainsLang('EXTENSION_UNINSTALL', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContainsLang('EXTENSION_UNINSTALL', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContains('The “bar” extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text()); + $this->assertContains('The “bar” extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text()); } public function test_details() { - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid); - - $validation = array( - 'DISPLAY_NAME' => 'phpBB Foo Extension', - 'CLEAN_NAME' => 'foo/example', - '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', - 'LICENCE' => 'GPL-2.0', - 'PHPBB_VERSION' => '3.1.*@dev', - 'PHP_VERSION' => '>=5.3', - 'AUTHOR_NAME' => 'John Smith', - 'AUTHOR_EMAIL' => 'email@phpbb.com', - 'AUTHOR_HOMEPAGE' => 'http://phpbb.com', - 'AUTHOR_ROLE' => 'N/A', - ); - - for ($i = 0; $i < $crawler->filter('dl')->count(); $i++) - { - $text = $crawler->filter('dl')->eq($i)->text(); - - $match = false; - - foreach ($validation as $language_key => $expected) - { - if (strpos($text, $this->lang($language_key)) === 0) - { - $match = true; - - $this->assertContains($expected, $text); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid); + + $validation = array( + 'DISPLAY_NAME' => 'phpBB Foo Extension', + 'CLEAN_NAME' => 'foo/example', + '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', + 'LICENCE' => 'GPL-2.0', + 'PHPBB_VERSION' => '3.1.*@dev', + 'PHP_VERSION' => '>=5.3', + 'AUTHOR_NAME' => 'John Smith', + 'AUTHOR_EMAIL' => 'email@phpbb.com', + 'AUTHOR_HOMEPAGE' => 'http://phpbb.com', + 'AUTHOR_ROLE' => 'N/A', + ); + + for ($i = 0; $i < $crawler->filter('dl')->count(); $i++) + { + $text = $crawler->filter('dl')->eq($i)->text(); + + $match = false; + + foreach ($validation as $language_key => $expected) + { + if (strpos($text, $this->lang($language_key)) === 0) + { + $match = true; + + $this->assertContains($expected, $text); } } @@ -143,10 +143,10 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case public function test_enable_pre() { // Foo is already enabled (redirect to list) - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text()); - $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); - $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); $this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'vendor/moo'), $crawler->filter('html')->text()); @@ -154,11 +154,11 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case public function test_disable_pre() { - // Moo is not enabled (redirect to list) - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text()); - $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); - $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); + // Moo is not enabled (redirect to list) + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid); $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'foo'), $crawler->filter('html')->text()); @@ -166,9 +166,9 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case public function test_purge_pre() { - // test2 is not available (error) - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=test2&sid=' . $this->sid); - $this->assertContains('The required file does not exist', $crawler->filter('html')->text()); + // test2 is not available (error) + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=test2&sid=' . $this->sid); + $this->assertContains('The required file does not exist', $crawler->filter('html')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid); $this->assertContains($this->lang('EXTENSION_UNINSTALL_CONFIRM', 'foo'), $crawler->filter('html')->text()); -- cgit v1.2.1 From 476464374a159ef90c28f2b58f8655fb706e0360 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 2 Nov 2013 14:57:03 +0100 Subject: [ticket/11994] Update functional tests with display name PHPBB3-11994 --- tests/functional/extension_acp_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index d466e01c80..a99f3cbfa4 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -149,7 +149,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'vendor/moo'), $crawler->filter('html')->text()); + $this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('html')->text()); } public function test_disable_pre() @@ -161,7 +161,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'foo'), $crawler->filter('html')->text()); + $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('html')->text()); } public function test_purge_pre() @@ -171,7 +171,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContains('The required file does not exist', $crawler->filter('html')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_UNINSTALL_CONFIRM', 'foo'), $crawler->filter('html')->text()); + $this->assertContains($this->lang('EXTENSION_UNINSTALL_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('html')->text()); } public function test_actions() -- cgit v1.2.1 From 40fcc906a27072ff824b503017dac14c89181dbb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 2 Nov 2013 23:46:10 +0100 Subject: [ticket/11994] Fix tests after uninstall rename PHPBB3-11994 --- tests/functional/extension_acp_test.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index a99f3cbfa4..83382116b4 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -83,7 +83,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertCount(5, $crawler->filter('.ext_disabled')); $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); - $this->assertContainsLang('EXTENSION_UNINSTALL', $crawler->filter('.ext_enabled')->eq(0)->text()); + $this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text()); $this->assertContains('The “test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); @@ -92,7 +92,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text()); $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContainsLang('EXTENSION_UNINSTALL', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(2)->text()); $this->assertContains('The “bar” extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text()); } @@ -164,14 +164,14 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('html')->text()); } - public function test_purge_pre() + public function test_delete_data_pre() { // test2 is not available (error) - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=test2&sid=' . $this->sid); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=test2&sid=' . $this->sid); $this->assertContains('The required file does not exist', $crawler->filter('html')->text()); - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_UNINSTALL_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('html')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=foo&sid=' . $this->sid); + $this->assertContains($this->lang('EXTENSION_DELETE_DATA_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('html')->text()); } public function test_actions() @@ -182,7 +182,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid); $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('html')->text()); - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_UNINSTALL_SUCCESS', $crawler->filter('html')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('html')->text()); } } -- cgit v1.2.1 From 12a6e2c603846db0054e27494429292316b209db Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Nov 2013 20:29:14 +0100 Subject: [ticket/11994] Filter crawler for better search comparisons PHPBB3-11994 --- tests/functional/extension_acp_test.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 83382116b4..7db0067499 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -144,45 +144,45 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case { // Foo is already enabled (redirect to list) $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text()); - $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); - $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text()); + $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text()); + $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('html')->text()); + $this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('.errorbox')->text()); } public function test_disable_pre() { // Moo is not enabled (redirect to list) $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text()); - $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); - $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text()); + $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text()); + $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('html')->text()); + $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('.errorbox')->text()); } public function test_delete_data_pre() { // test2 is not available (error) $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=test2&sid=' . $this->sid); - $this->assertContains('The required file does not exist', $crawler->filter('html')->text()); + $this->assertContains('The required file does not exist', $crawler->filter('.errorbox')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_DELETE_DATA_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('html')->text()); + $this->assertContains($this->lang('EXTENSION_DELETE_DATA_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('.errorbox')->text()); } public function test_actions() { $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('.successbox')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('.successbox')->text()); } } -- cgit v1.2.1 From d17bf9aa273d8cd3dfb730b506f7aac2bd51a97a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Nov 2013 20:30:09 +0100 Subject: [ticket/11994] "Delete data" is only available for disabled extensions PHPBB3-11994 --- tests/functional/extension_acp_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 7db0067499..0cd03d8ccb 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -170,8 +170,8 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=test2&sid=' . $this->sid); $this->assertContains('The required file does not exist', $crawler->filter('.errorbox')->text()); - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_DELETE_DATA_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('.errorbox')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContains($this->lang('EXTENSION_DELETE_DATA_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('.errorbox')->text()); } public function test_actions() -- cgit v1.2.1 From bf7eab423edc9bde69c960bb182b8313be7d5e3a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Nov 2013 23:39:48 +0100 Subject: [ticket/11994] Fix functional tests PHPBB3-11994 --- tests/functional/extension_acp_test.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 0cd03d8ccb..44bb895f67 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -170,8 +170,14 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=test2&sid=' . $this->sid); $this->assertContains('The required file does not exist', $crawler->filter('.errorbox')->text()); + // foo is not disabled (redirect to list) + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=foo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text()); + $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text()); + $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_DELETE_DATA_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('.errorbox')->text()); + $this->assertContains('Are you sure that you wish to delete the data associated with “phpBB Moo Extension”?', $crawler->filter('.errorbox')->text()); } public function test_actions() -- cgit v1.2.1 From 7a8a4408952659d59a3c92108eae6ef0f10a5bb3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 8 Nov 2013 14:08:55 +0100 Subject: [ticket/12002] Change functional test to use link hash PHPBB3-12002 --- tests/functional/extension_acp_test.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 44bb895f67..5d391e42f7 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -182,13 +182,34 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case public function test_actions() { + // Access enable page without hash $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text()); + + // Correctly submit the enable form + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $form = $crawler->selectButton('enable')->form(); + $crawler = self::submit($form); $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text()); + // Access disable page without hash $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text()); + + // Correctly submit the disable form + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $form = $crawler->selectButton('disable')->form(); + $crawler = self::submit($form); $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('.successbox')->text()); + // Access delete_data page without hash $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text()); + + // Correctly submit the delete data form + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $form = $crawler->selectButton('delete_data')->form(); + $crawler = self::submit($form); $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('.successbox')->text()); } } -- cgit v1.2.1 From 2e5117a71eb64c734e5738235c44ef92818ca33b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 9 Nov 2013 11:14:55 -0600 Subject: [ticket/11943] Throw an exception if DEFINE is setup improperly PHPBB3-11943 --- tests/template/template_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 0ff469779d..6e9b7d3ee9 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -561,4 +561,12 @@ EOT $expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]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 S_NUM_ROWS is correct after modification'); } + + /** + * @expectedException Twig_Error_Syntax + */ + public function test_define_error() + { + $this->run_template('define_error.html', array(), array(), array(), ''); + } } -- cgit v1.2.1 From 64ed46e682564600c8b8688e7d4e49620eb79bb3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 9 Nov 2013 11:39:35 -0600 Subject: [ticket/11943] Forgot template file for test PHPBB3-11943 --- tests/template/templates/define_error.html | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/template/templates/define_error.html (limited to 'tests') diff --git a/tests/template/templates/define_error.html b/tests/template/templates/define_error.html new file mode 100644 index 0000000000..a272071736 --- /dev/null +++ b/tests/template/templates/define_error.html @@ -0,0 +1,2 @@ + +{$VAR} \ No newline at end of file -- cgit v1.2.1 From 29d3b08d5097ad90a5ed2d26bfc981898732dbab Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 9 Nov 2013 20:33:01 +0100 Subject: [ticket/11896] Add ability to define expected message after posting This change will add the ability to define the expected message after a topic or post has been submitted with the methods create_post() and create_topic(). If the expected message is not 'POST_STORED', we will not try to get the topic and post id. PHPBB3-11896 --- .../test_framework/phpbb_functional_test_case.php | 36 +++++++++++++++++----- 1 file changed, 29 insertions(+), 7 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 a0d186e0f2..64c8406adb 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -868,9 +868,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request + * @param string $expected Lang var of expected message after posting * @return array post_id, topic_id */ - public function create_topic($forum_id, $subject, $message, $additional_form_data = array()) + public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; @@ -880,7 +881,14 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - return self::submit_post($posting_url, 'POST_TOPIC', $form_data); + if ($expected !== '') + { + return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected); + } + else + { + return self::submit_post($posting_url, 'POST_TOPIC', $form_data); + } } /** @@ -893,9 +901,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request + * @param string $expected Lang var of expected message after posting * @return array post_id, topic_id */ - public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array()) + public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; @@ -905,7 +914,14 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - return self::submit_post($posting_url, 'POST_REPLY', $form_data); + if ($expected !== '') + { + return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected); + } + else + { + return self::submit_post($posting_url, 'POST_REPLY', $form_data); + } } /** @@ -914,9 +930,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $posting_url * @param string $posting_contains * @param array $form_data - * @return array post_id, topic_id + * @param string $expected Lang var of expected message after posting + * @return array|null post_id, topic_id if message is 'POST_STORED' */ - protected function submit_post($posting_url, $posting_contains, $form_data) + protected function submit_post($posting_url, $posting_contains, $form_data, $expected = 'POST_STORED') { $this->add_lang('posting'); @@ -945,7 +962,12 @@ class phpbb_functional_test_case extends phpbb_test_case // 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. $crawler = self::request('POST', $posting_url, $form_data); - $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); + $this->assertContains($this->lang($expected), $crawler->filter('html')->text()); + + if ($expected !== 'POST_STORED') + { + return; + } $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); return array( -- cgit v1.2.1 From 95c2b12bf7be4e6ad1070d7dd11a9afd7fc1efa8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 9 Nov 2013 20:35:37 +0100 Subject: [ticket/11896] Add functional tests for marking all notifications read PHPBB3-11896 --- tests/functional/notification_test.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index 7f33ad1859..dd1b8ec981 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -52,4 +52,37 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case $this->assert_checkbox_is_unchecked($cplist, $checkbox_name); } } + + public function test_mark_notifications_read() + { + // Create a new standard user + $this->create_user('notificationtestuser'); + $this->add_user_group('NEWLY_REGISTERED', array('notificationtestuser')); + $this->login('notificationtestuser'); + $crawler = self::request('GET', 'index.php'); + $this->assertContains('notificationtestuser', $crawler->filter('.icon-logout')->text()); + + // Post a new post that needs approval + $this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD'); + $crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}"); + $this->assertNotContains('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text()); + + // logout + $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); + + // admin login + $this->login(); + $this->add_lang('ucp'); + $crawler = self::request('GET', 'ucp.php?i=ucp_notifications'); + + // At least one notification should exist + $this->assertGreaterThan(0, $crawler->filter('#notification_list_button strong')->text()); + + // Get form token + $link = $crawler->selectLink($this->lang('NOTIFICATIONS_MARK_ALL_READ'))->link()->getUri(); + $crawler = self::request('GET', substr($link, strpos($link, 'ucp.'))); + $form = $crawler->selectButton($this->lang('YES'))->form(); + $crawler = self::submit($form); + $this->assertEquals(0, $crawler->filter('#notification_list_button strong')->text()); + } } -- cgit v1.2.1 From 32ba402c34922fca9bd0d8a5d02bde62e7334d1a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 11 Nov 2013 00:01:31 +0100 Subject: [ticket/11525] Compare correct array to expected value PHPBB3-11525 --- 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 f687f7bc86..47d19be66d 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -252,7 +252,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase foreach ($output as $key => $value) { $this->assertArrayHasKey($key, $cleaned_row); - $this->assertEquals($output[$key], $value); + $this->assertEquals($cleaned_row[$key], $value); } } -- cgit v1.2.1 From a74c560ecafc0c6e63f1e0fc8191e85b066a05ef Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 11 Nov 2013 00:02:12 +0100 Subject: [ticket/11525] Fix expected value of group avatar test PHPBB3-11525 --- 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 47d19be66d..e9f622bfde 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -233,7 +233,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase ), array( 'avatar' => '', - 'id' => 4, + 'id' => 'g4', 'user_id' => 5, ), 'group', -- cgit v1.2.1 From 47e364ae68a92dbf2107c56a2165b219e4312b50 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 11 Nov 2013 10:59:17 -0600 Subject: [ticket/11943] New line at EOF for define_error.html PHPBB3-11943 --- tests/template/templates/define_error.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/template/templates/define_error.html b/tests/template/templates/define_error.html index a272071736..72ab1ba033 100644 --- a/tests/template/templates/define_error.html +++ b/tests/template/templates/define_error.html @@ -1,2 +1,2 @@ -{$VAR} \ No newline at end of file +{$VAR} -- cgit v1.2.1 From b1719db47df4f3089f90bbfac2ca0bec24dcf027 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 11 Nov 2013 20:15:28 +0100 Subject: [ticket/11912] Add extension_guesser for guessing mimetype by extension The content_guesser now only guesses the mimetype with the function mime_content_type() while the guessing by extension is done using the extension_guesser. PHPBB3-11912 --- tests/mimetype/guesser_test.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 9d4d965d63..8d076abae5 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -101,25 +101,34 @@ class guesser_test extends \phpbb_test_case 'image/jpeg', 'image/jpeg', ), + array(new \phpbb\mimetype\content_guesser), false, ), array( array( 'application/octet-stream', - 'image/jpeg', + 'application/octet-stream', ), + array(new \phpbb\mimetype\content_guesser), true, ), + array( + array( + 'application/octet-stream', + 'image/jpeg', + ), + array(new \phpbb\mimetype\extension_guesser), + ), ); } /** * @dataProvider data_content_guesser */ - public function test_content_guesser($expected, $overload = false) + public function test_content_guesser($expected, $guessers, $overload = false) { self::$function_exists = ($overload) ? false : true; - $guesser = new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\content_guesser)); + $guesser = new \phpbb\mimetype\guesser($guessers); $this->assertEquals($expected[0], $guesser->guess($this->jpg_file)); $this->assertEquals($expected[1], $guesser->guess($this->jpg_file, $this->jpg_file . '.jpg')); @copy($this->jpg_file, $this->jpg_file . '.jpg'); -- cgit v1.2.1 From bef6a5a6401314da7e5688907f4ebfc06ef83f2b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 11 Nov 2013 21:18:23 +0100 Subject: [ticket/11912] Introduce guesser priority to mimetype guessers The mimetype guesser priority can now be set through the service definition. Mimetypes will be guessed from the guesser with the highest priority to the one with the lowest priority. Standard priority types have been added to the service definition file. Any integer value can be used though. Standard mimetype guessers that do not have the methods get_priority and set_priority implemented, like the standard MimeTypeGuessers of symfony, will have the default priority with the value of 0. Lower priority guessers have values lower than 0 while high priority ones can be added with values higher than 0. PHPBB3-11912 --- tests/mimetype/guesser_test.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 8d076abae5..a489e68b40 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -135,4 +135,19 @@ class guesser_test extends \phpbb_test_case $this->assertEquals($expected[1], $guesser->guess($this->jpg_file . '.jpg')); @unlink($this->jpg_file . '.jpg'); } + + public function test_sort_priority() + { + $guessers = array( + 'FileinfoMimeTypeGuesser' => new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser, + 'extension_guesser' => new \phpbb\mimetype\extension_guesser, + 'FileBinaryMimeTypeGuesser' => new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser, + 'content_guesser' => new \phpbb\mimetype\content_guesser, + ); + $guessers['content_guesser']->set_priority(5); + $guessers['extension_guesser']->set_priority(-5); + usort($guessers, array($this->guesser, 'sort_priority')); + $this->assertInstanceOf('\phpbb\mimetype\content_guesser', $guessers[0]); + $this->assertInstanceOf('\phpbb\mimetype\extension_guesser', $guessers[3]); + } } -- cgit v1.2.1 From 95b22819a7c0f6bddee0f6b095f8bf777ef653b6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 11 Nov 2013 21:59:47 +0100 Subject: [ticket/11912] Use inverted $overload for setting function_exists in tests PHPBB3-11912 --- tests/mimetype/guesser_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index a489e68b40..2c1a35544f 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -127,7 +127,7 @@ class guesser_test extends \phpbb_test_case */ public function test_content_guesser($expected, $guessers, $overload = false) { - self::$function_exists = ($overload) ? false : true; + self::$function_exists = !$overload; $guesser = new \phpbb\mimetype\guesser($guessers); $this->assertEquals($expected[0], $guesser->guess($this->jpg_file)); $this->assertEquals($expected[1], $guesser->guess($this->jpg_file, $this->jpg_file . '.jpg')); -- cgit v1.2.1 From fbf5911ac54c83d439121e90032afca0ec2a7fc4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 13 Nov 2013 17:38:58 +0100 Subject: [ticket/12016] Update functional tests to use service for event listeners PHPBB3-12016 --- tests/functional/fixtures/ext/foo/bar/config/services.yml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/functional/fixtures/ext/foo/bar/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml index 3bca4c6567..64e1163408 100644 --- a/tests/functional/fixtures/ext/foo/bar/config/services.yml +++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml @@ -4,3 +4,12 @@ services: arguments: - @controller.helper - @template + foo_bar.listener.permission: + class: foo\bar\event\permission + tags: + - { name: event.listener } + foo_bar.listener.user_setup: + class: foo\bar\event\user_setup + tags: + - { name: event.listener } + -- cgit v1.2.1 From 13a4ceedb18ba938d3cd18e2f68707385bc9283a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 13 Nov 2013 18:27:40 +0100 Subject: [ticket/11525] Use foreach instead of array_walk in method clean_row() This approach is cleaner and probably even faster the previous ways that included using array_walk() or array_map() and other helper functions and methods. PHPBB3-11525 --- tests/avatar/manager_test.php | 50 +++++++++++-------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) (limited to 'tests') diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index e9f622bfde..f29f7aee95 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -152,31 +152,20 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase return array( array( array( - 'user_avatar' => '', - 'user_avatar_type' => '', - 'user_avatar_width' => '', + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_width' => '', 'user_avatar_height' => '', + 'group_avatar' => '', ), array( - 'avatar' => '', - 'avatar_type' => '', - 'avatar_width' => '', - 'avatar_height' => '', - ), - ), - array( - array( - 'group_avatar' => '', - 'group_avatar_type' => '', - 'group_avatar_width' => '', - 'group_avatar_height' => '', - ), - array( - 'avatar' => '', - 'avatar_type' => '', - 'avatar_width' => '', - 'avatar_height' => '', + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_width' => '', + 'user_avatar_height' => '', + 'group_avatar' => '', ), + 'foobar', ), array( array(), @@ -187,20 +176,6 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase 'avatar_height' => '', ), ), - array( - array( - 'foobar_avatar' => '', - 'foobar_avatar_type' => '', - 'foobar_avatar_width' => '', - 'foobar_avatar_height' => '', - ), - array( - 'foobar_avatar' => '', - 'foobar_avatar_type' => '', - 'foobar_avatar_width' => '', - 'foobar_avatar_height' => '', - ), - ), array( array( 'user_avatar' => '', @@ -208,8 +183,9 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase 'group_id' => 4, ), array( - 'avatar' => '', - 'id' => 4, + 'user_avatar' => '', + 'user_id' => 5, + 'group_id' => 4, ), ), array( -- cgit v1.2.1 From 009a1303f59628417573b47b162690b057594953 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Nov 2013 00:14:04 +0100 Subject: [ticket/12017] Remove IN_PHPBB defined check PHPBB3-12017 --- tests/functional/fixtures/ext/foo/bar/event/permission.php | 9 --------- tests/functional/fixtures/ext/foo/bar/event/user_setup.php | 9 --------- 2 files changed, 18 deletions(-) (limited to 'tests') diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission.php b/tests/functional/fixtures/ext/foo/bar/event/permission.php index 92e24074ad..9b319dd35f 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/permission.php +++ b/tests/functional/fixtures/ext/foo/bar/event/permission.php @@ -10,15 +10,6 @@ namespace foo\bar\event; -/** -* @ignore -*/ - -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * Event listener */ diff --git a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php index 1409f97470..8fa7ac97da 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php +++ b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php @@ -10,15 +10,6 @@ namespace foo\bar\event; -/** -* @ignore -*/ - -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * Event listener */ -- cgit v1.2.1 From 4e2bb6ef535a5188aeda6d04286b6b9bb8825c72 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Nov 2013 00:14:53 +0100 Subject: [ticket/12017] Copy config/ dir so events work PHPBB3-12017 --- tests/functional/extension_controller_test.php | 2 ++ tests/functional/extension_global_lang_test.php | 3 ++- tests/functional/extension_permission_lang_test.php | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 41bd48c204..37752b8fbb 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -19,6 +19,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c static protected $fixtures = array( 'foo/bar/config/', 'foo/bar/controller/', + 'foo/bar/event/', + 'foo/bar/language/en/', 'foo/bar/styles/prosilver/template/', ); diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php index fb8f87e6de..094eda8257 100644 --- a/tests/functional/extension_global_lang_test.php +++ b/tests/functional/extension_global_lang_test.php @@ -17,8 +17,9 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ static private $helper; static protected $fixtures = array( - 'foo/bar/language/en/', + 'foo/bar/config/', 'foo/bar/event/', + 'foo/bar/language/en/', ); static public function setUpBeforeClass() diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 19adb89819..e922abdaf1 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -17,8 +17,9 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static private $helper; static protected $fixtures = array( - 'foo/bar/language/en/', + 'foo/bar/config/', 'foo/bar/event/', + 'foo/bar/language/en/', ); static public function setUpBeforeClass() -- cgit v1.2.1 From 1e73e0c9544d2601127b7179fdbd0724370e8b04 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Nov 2013 00:15:23 +0100 Subject: [ticket/12017] Fix phpbb requirement in composer.json PHPBB3-12017 --- tests/functional/fixtures/ext/foo/bar/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functional/fixtures/ext/foo/bar/composer.json b/tests/functional/fixtures/ext/foo/bar/composer.json index cb9dbc9514..e3e5fc21cd 100644 --- a/tests/functional/fixtures/ext/foo/bar/composer.json +++ b/tests/functional/fixtures/ext/foo/bar/composer.json @@ -14,7 +14,7 @@ }], "require": { "php": ">=5.3", - "phpbb": "3.1.*@dev" + "phpbb/phpbb": "3.1.*@dev" }, "extra": { "display-name": "phpBB 3.1 Extension Testing" -- cgit v1.2.1 From 287c2550b8689a6fd34043ec4b5652997e9a6ab7 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 13 Nov 2013 23:58:21 -0800 Subject: [ticket/12008] Update the run time value for the prune notifications cron task PHPBB3-12008 --- tests/notification/base.php | 1 + tests/notification/submit_post_base.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/notification/base.php b/tests/notification/base.php index 549545f01b..f6333866c3 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -70,6 +70,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case array(), $this->container, $this->user_loader, + $this->config, $this->db, $this->cache, $this->user, diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 8597c626a4..a9ed59686a 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -118,7 +118,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case // Notification Manager $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), - $phpbb_container, $user_loader, $db, $cache, $user, + $phpbb_container, $user_loader, $config, $db, $cache, $user, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); $phpbb_container->set('notification_manager', $phpbb_notifications); -- cgit v1.2.1 From 308329b5479d16e104c9eb7372222fee67ccdbf5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 14 Nov 2013 15:09:49 +0100 Subject: [ticket/11896] Minor code improvements in phpbb_functional_test_case Use assertContainsLang() and get rid of unnecessary logic in create_post() and create_topic(). The docblocks were also slightly improved. PHPBB3-11896 --- .../test_framework/phpbb_functional_test_case.php | 28 ++++++---------------- 1 file changed, 7 insertions(+), 21 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 64c8406adb..876e42a4c2 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -868,10 +868,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request - * @param string $expected Lang var of expected message after posting + * @param string $expected Lang var of expected message after posting or null * @return array post_id, topic_id */ - public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = '') + public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') { $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; @@ -881,14 +881,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - if ($expected !== '') - { - return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected); - } - else - { - return self::submit_post($posting_url, 'POST_TOPIC', $form_data); - } + return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected); } /** @@ -901,10 +894,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request - * @param string $expected Lang var of expected message after posting + * @param string $expected Lang var of expected message after posting or null * @return array post_id, topic_id */ - public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = '') + public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') { $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; @@ -914,14 +907,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - if ($expected !== '') - { - return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected); - } - else - { - return self::submit_post($posting_url, 'POST_REPLY', $form_data); - } + return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected); } /** @@ -962,7 +948,7 @@ class phpbb_functional_test_case extends phpbb_test_case // 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. $crawler = self::request('POST', $posting_url, $form_data); - $this->assertContains($this->lang($expected), $crawler->filter('html')->text()); + $this->assertContainsLang($expected, $crawler->filter('html')->text()); if ($expected !== 'POST_STORED') { -- cgit v1.2.1 From 7f10312bf21dba335a863fb1222db8b9ed64ef0e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 14 Nov 2013 15:17:25 +0100 Subject: [ticket/11896] Correctly document return of null in docblocks Also got rid of previous incorrect comment in docblocks. PHPBB3-11896 --- tests/test_framework/phpbb_functional_test_case.php | 8 ++++---- 1 file changed, 4 insertions(+), 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 876e42a4c2..eba5a2dfdf 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -868,8 +868,8 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request - * @param string $expected Lang var of expected message after posting or null - * @return array post_id, topic_id + * @param string $expected Lang var of expected message after posting + * @return array|null post_id, topic_id if message is 'POST_STORED' */ public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') { @@ -894,8 +894,8 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request - * @param string $expected Lang var of expected message after posting or null - * @return array post_id, topic_id + * @param string $expected Lang var of expected message after posting + * @return array|null post_id, topic_id if message is 'POST_STORED' */ public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') { -- cgit v1.2.1 From 632d6e96218c70ee89c411679304e2529efff514 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 19 Nov 2013 00:23:23 +0100 Subject: [ticket/12023] Add test for failing .css copy PHPBB3-12023 --- tests/functions_install/ignore_new_file_on_update_test.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/functions_install/ignore_new_file_on_update_test.php b/tests/functions_install/ignore_new_file_on_update_test.php index ae1dde96f7..703da4e435 100644 --- a/tests/functions_install/ignore_new_file_on_update_test.php +++ b/tests/functions_install/ignore_new_file_on_update_test.php @@ -25,6 +25,8 @@ class phpbb_functions_install_ignore_new_file_on_update_test extends phpbb_test_ array('styles/prosilver/theme/en/icon_user_online.gif', false), array('styles/prosilver/theme/languagewillneverexist/icon_user_online.gif', true), + + array('styles/prosilver/theme/imageset.css', false), ); } -- cgit v1.2.1 From 9861cd21dd1e60943dbba7d5b2dc64c272ccd20d Mon Sep 17 00:00:00 2001 From: Mario Skouat Date: Sun, 31 Mar 2013 18:50:52 +0200 Subject: [ticket/10910] Add unit tests for select PHPBB3-10910 --- tests/functions_acp/build_cfg_template_test.php | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests') diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php index acf4da1bd6..d4bd80e4c2 100644 --- a/tests/functions_acp/build_cfg_template_test.php +++ b/tests/functions_acp/build_cfg_template_test.php @@ -234,4 +234,39 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); } + + public function build_cfg_template_select_data() + { + return array( + array( + array('select'), + 'key_name', + array('config_key_name' => '0'), + 'config_key_name', + array(), + '', + ), + array( + array('select', 8), + 'key_name', + array('config_key_name' => '1'), + 'config_key_name', + array(), + '', + ), + ); + } + + /** + * @dataProvider build_cfg_template_select_data + */ + public function test_build_cfg_template_select($tpl_type, $key, $new, $config_key, $vars, $expected) + { + global $user, $phpbb_dispatcher; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $user->lang = new phpbb_mock_lang(); + + $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); + } } -- cgit v1.2.1 From 8c73c9658e70f8cbdf52a89899f4fc094586b229 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 22 Nov 2013 15:51:22 +0100 Subject: [ticket/10910] Fix unit tests PHPBB3-10910 --- tests/functions_acp/build_cfg_template_test.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php index d4bd80e4c2..7f8db799c5 100644 --- a/tests/functions_acp/build_cfg_template_test.php +++ b/tests/functions_acp/build_cfg_template_test.php @@ -243,16 +243,16 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case 'key_name', array('config_key_name' => '0'), 'config_key_name', - array(), - '', + array('method' => 'select_helper'), + '', ), array( array('select', 8), 'key_name', array('config_key_name' => '1'), 'config_key_name', - array(), - '', + array('method' => 'select_helper'), + '', ), ); } @@ -262,11 +262,26 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case */ public function test_build_cfg_template_select($tpl_type, $key, $new, $config_key, $vars, $expected) { - global $user, $phpbb_dispatcher; + global $module, $user, $phpbb_dispatcher; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $user = new phpbb_mock_user(); $user->lang = new phpbb_mock_lang(); + $user->module = $this; + $module = $user; $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); } + + public function select_helper() + { + return build_select( + array( + '1' => 'First_Option', + '2' => 'Second_Option', + '3' => 'Third_Option', + ), + '2' + ); + } } -- cgit v1.2.1 From c9c419c4317ddd12b49082368e245f881a001610 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 23 Nov 2013 01:19:43 +0100 Subject: [ticket/11912] Expect logic exceptions in test if no guesser available PHPBB3-11912 --- tests/mimetype/guesser_test.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 2c1a35544f..9f0371262b 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -127,7 +127,20 @@ class guesser_test extends \phpbb_test_case */ public function test_content_guesser($expected, $guessers, $overload = false) { + $supported = false; self::$function_exists = !$overload; + + // Cover possible LogicExceptions + foreach ($guessers as $cur_guesser) + { + $supported += $cur_guesser->is_supported(); + } + + if (!$supported) + { + $this->setExpectedException('\LogicException'); + } + $guesser = new \phpbb\mimetype\guesser($guessers); $this->assertEquals($expected[0], $guesser->guess($this->jpg_file)); $this->assertEquals($expected[1], $guesser->guess($this->jpg_file, $this->jpg_file . '.jpg')); -- cgit v1.2.1 From b0a561117c557c6abe0db91c210a71d0604a07cd Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 27 Nov 2013 15:28:14 +0100 Subject: [ticket/11859] Add missing get_template_name method to test drivers PHPBB3-11859 --- tests/avatar/driver/barfoo.php | 5 +++++ tests/avatar/driver/foobar.php | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php index 11c100db36..0bf30b8a91 100644 --- a/tests/avatar/driver/barfoo.php +++ b/tests/avatar/driver/barfoo.php @@ -18,4 +18,9 @@ class barfoo extends \phpbb\avatar\driver\driver { return false; } + + public function get_template_name() + { + return 'barfoo.html'; + } } diff --git a/tests/avatar/driver/foobar.php b/tests/avatar/driver/foobar.php index a1e7bdf7cc..aabdaf5ac4 100644 --- a/tests/avatar/driver/foobar.php +++ b/tests/avatar/driver/foobar.php @@ -18,4 +18,9 @@ class foobar extends \phpbb\avatar\driver\driver { return false; } + + public function get_template_name() + { + return 'foobar.html'; + } } -- cgit v1.2.1 From 97b1d70a37f77e54315197c7ad582890cf144b9f Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 29 Nov 2013 10:50:38 +0100 Subject: [ticket/11699] Exclude build/new_version and build/old_versions from lint. PHPBB3-11699 --- tests/lint_test.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/lint_test.php b/tests/lint_test.php index 905067072d..5b5d8975e8 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -23,6 +23,8 @@ class phpbb_lint_test extends phpbb_test_case } self::$exclude = array( + dirname(__FILE__) . '/../build/new_version', + dirname(__FILE__) . '/../build/old_versions', // 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', -- cgit v1.2.1 From 0834a749e72e6239ed22113e25dd4778a44bb976 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 29 Nov 2013 14:00:55 +0100 Subject: [ticket/11699] Properly exclude the .git directory. Namely missing dot prefix. PHPBB3-11699 --- tests/lint_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/lint_test.php b/tests/lint_test.php index 5b5d8975e8..6951ee5ef7 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -23,6 +23,7 @@ class phpbb_lint_test extends phpbb_test_case } self::$exclude = array( + dirname(__FILE__) . '/../.git', dirname(__FILE__) . '/../build/new_version', dirname(__FILE__) . '/../build/old_versions', // 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 @@ -47,7 +48,7 @@ class phpbb_lint_test extends phpbb_test_case $dh = opendir($root); while (($filename = readdir($dh)) !== false) { - if ($filename == '.' || $filename == '..' || $filename == 'git') + if ($filename == '.' || $filename == '..') { continue; } -- cgit v1.2.1 From 981df153d2fbeba5f9aa6a677e11f1df15b3ea15 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 29 Nov 2013 14:02:50 +0100 Subject: [ticket/11699] Also exclude the phpBB/cache directory. PHPBB3-11699 --- tests/lint_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/lint_test.php b/tests/lint_test.php index 6951ee5ef7..eba117839b 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -26,6 +26,7 @@ class phpbb_lint_test extends phpbb_test_case dirname(__FILE__) . '/../.git', dirname(__FILE__) . '/../build/new_version', dirname(__FILE__) . '/../build/old_versions', + dirname(__FILE__) . '/../phpBB/cache', // 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', -- cgit v1.2.1 From 0b55ab720cc16939e653b73b89a6dd0910a31d3d Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 1 Dec 2013 13:03:03 +0100 Subject: [ticket/12050] Make phpbb_notification_submit_post_base abstract. PHPBB3-12050 --- tests/notification/submit_post_base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index a9ed59686a..fb8e2ac807 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -12,7 +12,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; -class phpbb_notification_submit_post_base extends phpbb_database_test_case +abstract class phpbb_notification_submit_post_base extends phpbb_database_test_case { protected $notifications, $db, $container, $user, $config, $auth, $cache; -- cgit v1.2.1 From 9fbeae3e0ca373f98a6102266f2bb75653e5211a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 3 Dec 2013 17:57:34 +0100 Subject: [ticket/12026] Add functional test for ucp extension module PHPBB3-12026 --- tests/functional/extension_module_test.php | 45 +++++++++++++++++++--- .../foo/bar/styles/prosilver/template/foobar.html | 3 ++ .../fixtures/ext/foo/bar/ucp/main_info.php | 26 +++++++++++++ .../fixtures/ext/foo/bar/ucp/main_module.php | 22 +++++++++++ 4 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html create mode 100644 tests/functional/fixtures/ext/foo/bar/ucp/main_info.php create mode 100644 tests/functional/fixtures/ext/foo/bar/ucp/main_module.php (limited to 'tests') diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index 090cd38daf..ba025d582e 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -80,18 +80,53 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case ); $modules->update_module_data($module_data, true); + $parent_data = array( + 'module_basename' => '', + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => 0, + 'module_class' => 'ucp', + 'module_langname' => 'UCP_FOOBAR_TITLE', + 'module_mode' => '', + 'module_auth' => '', + ); + $modules->update_module_data($parent_data, true); + + $module_data = array( + 'module_basename' => 'foo\\bar\\ucp\\main_module', + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => $parent_data['module_id'], + 'module_class' => 'ucp', + 'module_langname' => 'UCP_FOOBAR_TITLE', + 'module_mode' => 'mode', + 'module_auth' => '', + ); + $modules->update_module_data($module_data, true); + $this->purge_cache(); } - /** - * Check a controller for extension foo/bar. - */ - public function test_foo_bar() + public function test_acp() { $this->login(); $this->admin_login(); + $crawler = self::request('GET', 'adm/index.php?i=foo%5cbar%5cacp%5cmain_module&mode=mode&sid=' . $this->sid); - $this->assertContains("Bertie rulez!", $crawler->filter('#main')->text()); + $this->assertContains('Bertie rulez!', $crawler->filter('#main')->text()); + } + + public function test_ucp() + { + $this->login(); + + $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid); + $this->assertContains('UCP_FOOBAR_TITLE', $crawler->filter('#tabs')->text()); + + $link = $crawler->selectLink('UCP_FOOBAR_TITLE')->link()->getUri(); + $crawler = self::request('GET', substr($link, strpos($link, 'ucp.'))); + $this->assertContains('UCP Extension Template Test Passed!', $crawler->filter('#content')->text()); + $this->phpbb_extension_manager->purge('foo/bar'); } } diff --git a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html new file mode 100644 index 0000000000..cbded623f4 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html @@ -0,0 +1,3 @@ + +
UCP Extension Template Test Passed!
+ diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php new file mode 100644 index 0000000000..2ba37f3050 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php @@ -0,0 +1,26 @@ + '\foo\bar\ucp\main_module', + 'title' => 'ACP_FOOBAR_TITLE', + 'version' => '1.0.0', + 'modes' => array( + 'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')), + ), + ); + } +} diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_module.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_module.php new file mode 100644 index 0000000000..cd3dacc9db --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_module.php @@ -0,0 +1,22 @@ +tpl_name = 'foobar'; + $this->page_title = 'Bertie'; + } +} -- cgit v1.2.1 From e41cd384f533b8caa27fba10fedb89f9713c32b5 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:22:47 +0100 Subject: [ticket/12056] Fix failure due to "Creating default object from empty value". PHPBB3-12056 --- tests/functions/obtain_online_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index b3beb55a96..de6451a0db 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -22,8 +22,9 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case { parent::setUp(); - global $config, $db; + global $config, $db, $user; + $user = new StdClass; $db = $this->db = $this->new_dbal(); $config = array( 'load_online_time' => 5, -- cgit v1.2.1 From c659fe4cbe1e80b7d1ed7c46815ce2573412fd6b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:29:40 +0100 Subject: [ticket/12056] h_radio test: Fix "Creating default object from empty value" PHPBB3-12056 --- tests/functions_acp/h_radio_test.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/functions_acp/h_radio_test.php b/tests/functions_acp/h_radio_test.php index a61f2e8975..4c1872d341 100644 --- a/tests/functions_acp/h_radio_test.php +++ b/tests/functions_acp/h_radio_test.php @@ -11,6 +11,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; class phpbb_functions_acp_h_radio_test extends phpbb_test_case { + protected function setUp() + { + parent::setUp(); + + global $user; + + $user = new phpbb_mock_user(); + $user->lang = new phpbb_mock_lang(); + } + public function h_radio_data() { return array( @@ -111,10 +121,6 @@ class phpbb_functions_acp_h_radio_test extends phpbb_test_case */ public function test_h_radio($name, $input_ary, $input_default, $id, $key, $expected) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $this->assertEquals($expected, h_radio($name, $input_ary, $input_default, $id, $key)); } } -- cgit v1.2.1 From c07b44716c87ca2c74b49fd37b7fe7381f6a3769 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:31:12 +0100 Subject: [ticket/12056] build_select: Fix "Creating default object from empty value" PHPBB3-12056 --- tests/functions_acp/build_select_test.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/functions_acp/build_select_test.php b/tests/functions_acp/build_select_test.php index aca49b7655..c44fd97ec3 100644 --- a/tests/functions_acp/build_select_test.php +++ b/tests/functions_acp/build_select_test.php @@ -11,6 +11,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; class phpbb_functions_acp_built_select_test extends phpbb_test_case { + protected function setUp() + { + parent::setUp(); + + global $user; + + $user = new phpbb_mock_user(); + $user->lang = new phpbb_mock_lang(); + } + public function build_select_data() { return array( @@ -46,10 +56,6 @@ class phpbb_functions_acp_built_select_test extends phpbb_test_case */ public function test_build_select($option_ary, $option_default, $expected) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $this->assertEquals($expected, build_select($option_ary, $option_default)); } } -- cgit v1.2.1 From 70e47bc9290ff0ce54b53374f703a3574c54325c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:33:19 +0100 Subject: [ticket/12056] validate_range: Fix "Creating default object from empty value" PHPBB3-12056 --- tests/functions_acp/validate_range_test.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/functions_acp/validate_range_test.php b/tests/functions_acp/validate_range_test.php index 8606158251..cb028d4d07 100644 --- a/tests/functions_acp/validate_range_test.php +++ b/tests/functions_acp/validate_range_test.php @@ -12,6 +12,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; class phpbb_functions_acp_validate_range_test extends phpbb_test_case { + protected function setUp() + { + parent::setUp(); + + global $user; + + $user = new phpbb_mock_user(); + $user->lang = new phpbb_mock_lang(); + } + /** * Data sets that don't throw an error. */ @@ -52,10 +62,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case */ public function test_validate_range_fit($test_data) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_range($test_data, $phpbb_error); @@ -91,10 +97,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case */ public function test_validate_range_too_low($test_data) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_range($test_data, $phpbb_error); @@ -130,10 +132,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case */ public function test_validate_range_too_big($test_data) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_range($test_data, $phpbb_error); @@ -158,10 +156,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case */ public function test_validate_range_too_long($test_data) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_range($test_data, $phpbb_error); -- cgit v1.2.1 From 0f4124127306408b3560aace31d55864b0043697 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:36:23 +0100 Subject: [ticket/12056] validate_config_vars: Fix "Creating ... from empty value". PHPBB3-12056 --- tests/functions_acp/validate_config_vars_test.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 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 7cd7fa3892..5ccd73fe8d 100644 --- a/tests/functions_acp/validate_config_vars_test.php +++ b/tests/functions_acp/validate_config_vars_test.php @@ -11,6 +11,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case { + protected function setUp() + { + parent::setUp(); + + global $user; + + $user = new phpbb_mock_user(); + $user->lang = new phpbb_mock_lang(); + } + /** * Data sets that don't throw an error. */ @@ -60,10 +70,6 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case */ public function test_validate_config_vars_fit($test_data, $cfg_array) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_config_vars($test_data, $cfg_array, $phpbb_error); @@ -146,10 +152,6 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case */ public function test_validate_config_vars_error($test_data, $cfg_array, $expected) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_config_vars($test_data, $cfg_array, $phpbb_error); -- cgit v1.2.1 From 7e160e4fc0a7b3e02d15b892d8b8c202cb0639f6 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:37:56 +0100 Subject: [ticket/12056] validate_config_vars: Fix ".. undefined function utf8_strlen()" PHPBB3-12056 --- tests/functions_acp/validate_config_vars_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php index 5ccd73fe8d..acc98fbf0d 100644 --- a/tests/functions_acp/validate_config_vars_test.php +++ b/tests/functions_acp/validate_config_vars_test.php @@ -8,6 +8,7 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case { -- cgit v1.2.1 From 417fddf710374a65321974173aa6e3f89cff50b1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:44:33 +0100 Subject: [ticket/12056] Fix "undefined function phpbb_pcre_utf8_support()". PHPBB3-12056 --- tests/functions/validate_password_test.php | 1 + tests/regex/password_complexity_test.php | 1 + 2 files changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/functions/validate_password_test.php b/tests/functions/validate_password_test.php index 4639f6cc89..82c5fa03c1 100644 --- a/tests/functions/validate_password_test.php +++ b/tests/functions/validate_password_test.php @@ -7,6 +7,7 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; require_once dirname(__FILE__) . '/validate_data_helper.php'; diff --git a/tests/regex/password_complexity_test.php b/tests/regex/password_complexity_test.php index 07453555ee..e2aefdaac8 100644 --- a/tests/regex/password_complexity_test.php +++ b/tests/regex/password_complexity_test.php @@ -7,6 +7,7 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; class phpbb_password_complexity_test extends phpbb_test_case -- cgit v1.2.1 From d63ac61b1946d5ed96392b6aaafd656f3f4031be Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:46:51 +0100 Subject: [ticket/12056] Fix "Call to undefined function phpbb\phpbb_get_plural_form()". PHPBB3-12056 --- tests/user/lang_test.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php index c7c858c59d..9cb9e320b3 100644 --- a/tests/user/lang_test.php +++ b/tests/user/lang_test.php @@ -7,6 +7,8 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + class phpbb_user_lang_test extends phpbb_test_case { public function test_user_lang_sprintf() -- cgit v1.2.1 From b41781ed64f9a980cec621f0e847cfb13ffa7857 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 13:51:42 +0100 Subject: [ticket/12056] Fix "Call to a member function trigger_event() on a non-object". PHPBB3-12056 --- tests/text_processing/generate_text_for_display_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index a157fe7d9a..15905535ac 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -16,7 +16,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca { public function setUp() { - global $cache, $user; + global $cache, $user, $phpbb_dispatcher; parent::setUp(); @@ -24,6 +24,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $user = new phpbb_mock_user; $user->optionset('viewcensors', false); + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); } public function test_empty_string() -- cgit v1.2.1 From d589696827d25aa0287f984a32a3295028d2f062 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 14:13:59 +0100 Subject: [ticket/12056] Fix "Call to undefined function ...\utf8_clean_string()" PHPBB3-12056 --- tests/auth/provider_db_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php index 140a28cd3d..45a893220b 100644 --- a/tests/auth/provider_db_test.php +++ b/tests/auth/provider_db_test.php @@ -7,7 +7,8 @@ * */ -require_once dirname(__FILE__).'/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_auth_provider_db_test extends phpbb_database_test_case { -- cgit v1.2.1 From ffc24a507da5bbc0988a740bd00617bf7d413a3e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 14:16:10 +0100 Subject: [ticket/12056] Fix "Call to undefined function ...\utf8_normalize_nfc()" PHPBB3-12056 --- tests/auth/provider_apache_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index e135a1f002..d7509a72bf 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -7,7 +7,8 @@ * */ -require_once dirname(__FILE__).'/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_auth_provider_apache_test extends phpbb_database_test_case { -- cgit v1.2.1 From 3a03b01ce0b860490851c620a6c4dac2630481d4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Dec 2013 14:22:33 +0100 Subject: [ticket/12056] group_user_attributes: Fix "Creating ... from empty value". PHPBB3-12056 --- tests/functions_user/group_user_attributes_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index f8d52a9a6a..4317cf79da 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -127,6 +127,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes { global $auth, $cache, $db, $phpbb_dispatcher, $user, $phpbb_container, $phpbb_log, $phpbb_root_path, $phpEx; + $user = new phpbb_mock_user; $user->ip = ''; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); -- cgit v1.2.1 From abb2def48d7a946fd4d0a67f88682c9fa2556223 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 4 Dec 2013 15:42:17 +0100 Subject: [ticket/11842] Use avatar_data for obtaining driver that should be deleted PHPBB3-11842 --- tests/functional/avatar_acp_groups_test.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php index 5e908bc6da..5f767b44f2 100644 --- a/tests/functional/avatar_acp_groups_test.php +++ b/tests/functional/avatar_acp_groups_test.php @@ -69,4 +69,13 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av { $this->assert_avatar_submit($expected, $avatar_type, $data); } + + // Test if avatar was really deleted + public function test_no_avatar_acp_groups() + { + $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form_data = $form->getValues(); + $this->assertEmpty($form_data['avatar_type']); + } } -- cgit v1.2.1 From 80fa658e8fc94972349b5f0d01f93afba7744e0e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 4 Dec 2013 15:58:07 +0100 Subject: [ticket/11842] Add functional test for creating group PHPBB3-11842 --- tests/functional/group_create_test.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/functional/group_create_test.php (limited to 'tests') diff --git a/tests/functional/group_create_test.php b/tests/functional/group_create_test.php new file mode 100644 index 0000000000..96780069f7 --- /dev/null +++ b/tests/functional/group_create_test.php @@ -0,0 +1,31 @@ +login(); + $this->admin_login(); + $this->add_lang('acp/groups'); + + $crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form, array('group_name' => 'testtest')); + + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form, array('group_name' => 'testtest')); + + $this->assertContainsLang('GROUP_CREATED', $crawler->filter('#main')->text()); + } +} -- cgit v1.2.1