diff options
Diffstat (limited to 'tests')
56 files changed, 1415 insertions, 199 deletions
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 44e5e12ab0..3c74c16bae 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -89,6 +89,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->user = new \phpbb\user($lang, '\phpbb\datetime');; $container = new phpbb_mock_container_builder(); + $container->setParameter('core.environment', PHPBB_ENVIRONMENT); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); $loader = new \phpbb\template\twig\loader($this->filesystem, ''); @@ -121,7 +122,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); + $this->router = new phpbb_mock_router($container, $this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path @@ -155,6 +156,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller2', array(), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, '/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -195,6 +199,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller2', array(), false, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, '/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -235,6 +242,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -275,6 +285,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, 'app.php/foo/bar', 'no params using empty array'), array('controller2', array(), false, false, 'app.php/foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, 'app.php/foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -315,6 +328,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -355,6 +371,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -435,6 +454,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'), + + // Resolves DI parameters + array('controller4', array(), true, false, '//localhost/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 5781d3ebc1..d0295d66bc 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,7 +40,10 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); + $container = new phpbb_mock_container_builder(); + $container->setParameter('core.environment', PHPBB_ENVIRONMENT); + + $router = new \phpbb\routing\router($container, new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); diff --git a/tests/controller/ext/vendor2/foo/config/routing.yml b/tests/controller/ext/vendor2/foo/config/routing.yml index e3e8ee5f98..7d4ac7be93 100644 --- a/tests/controller/ext/vendor2/foo/config/routing.yml +++ b/tests/controller/ext/vendor2/foo/config/routing.yml @@ -5,3 +5,7 @@ controller1: include_controller2: resource: "routing_2.yml" prefix: /foo + +controller4: + path: /foo/%core.environment% + defaults: { _controller: foo.controller:handle } diff --git a/tests/dbal/fixtures/migrator_permission.xml b/tests/dbal/fixtures/migrator_permission.xml index 08cec42a42..c07956fa85 100644 --- a/tests/dbal/fixtures/migrator_permission.xml +++ b/tests/dbal/fixtures/migrator_permission.xml @@ -27,5 +27,139 @@ <value>1</value> <value>0</value> </row> + <row> + <value>4</value> + <value>a_test</value> + <value>1</value> + <value>0</value> + <value>0</value> + </row> + <row> + <value>5</value> + <value>m_test</value> + <value>1</value> + <value>0</value> + <value>0</value> + </row> + <row> + <value>6</value> + <value>u_test</value> + <value>1</value> + <value>0</value> + <value>0</value> + </row> + </table> + + <table name="phpbb_groups"> + <column>group_id</column> + <column>group_name</column> + <column>group_desc</column> + <row> + <value>2</value> + <value>REGISTERED</value> + <value></value> + </row> + <row> + <value>4</value> + <value>GLOBAL_MODERATORS</value> + <value></value> + </row> + <row> + <value>5</value> + <value>ADMINISTRATORS</value> + <value></value> + </row> + </table> + + <table name="phpbb_acl_groups"> + <column>group_id</column> + <column>auth_role_id</column> + <column>forum_id</column> + <row> + <value>2</value> + <value>5</value> + <value>0</value> + </row> + <row> + <value>4</value> + <value>5</value> + <value>0</value> + </row> + <row> + <value>4</value> + <value>10</value> + <value>0</value> + </row> + <row> + <value>5</value> + <value>1</value> + <value>0</value> + </row> + <row> + <value>5</value> + <value>5</value> + <value>0</value> + </row> + </table> + + <table name="phpbb_acl_roles"> + <column>role_id</column> + <column>role_name</column> + <column>role_type</column> + <column>role_description</column> + <row> + <value>1</value> + <value>ROLE_ADMIN_STANDARD</value> + <value>a_</value> + <value></value> + </row> + <row> + <value>5</value> + <value>ROLE_USER_FULL</value> + <value>u_</value> + <value></value> + </row> + <row> + <value>10</value> + <value>ROLE_MOD_FULL</value> + <value>m_</value> + <value></value> + </row> + </table> + + <table name="phpbb_acl_roles_data"> + <column>role_id</column> + <column>auth_option_id</column> + <column>auth_setting</column> + <row> + <value>1</value> + <value>4</value> + <value>0</value> + </row> + <row> + <value>1</value> + <value>5</value> + <value>0</value> + </row> + <row> + <value>1</value> + <value>6</value> + <value>0</value> + </row> + <row> + <value>6</value> + <value>6</value> + <value>0</value> + </row> + <row> + <value>10</value> + <value>5</value> + <value>0</value> + </row> + <row> + <value>10</value> + <value>6</value> + <value>0</value> + </row> </table> </dataset> diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 695a7e7a7f..a71334f23f 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -41,7 +41,10 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $auth = $this->getMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); - $this->tool = new \phpbb\db\migration\tool\module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules'); + $phpbb_extension_manager = new phpbb_mock_extension_manager($phpbb_root_path); + $module_manager = new \phpbb\module\module_manager($cache, $this->db, $phpbb_extension_manager, MODULES_TABLE, $phpbb_root_path, $phpEx); + + $this->tool = new \phpbb\db\migration\tool\module($this->db, $this->cache, $this->user, $module_manager, $phpbb_root_path, $phpEx, 'phpbb_modules'); } public function exists_data() diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php index 3d190e7a11..bfb2e07080 100644 --- a/tests/dbal/migrator_tool_permission_test.php +++ b/tests/dbal/migrator_tool_permission_test.php @@ -15,6 +15,12 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case { + public $group_ids = array( + 'REGISTERED' => 2, + 'GLOBAL_MODERATORS' => 4, + 'ADMINISTRATORS' => 5, + ); + public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_permission.xml'); @@ -158,4 +164,60 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case } $this->assertFalse($this->tool->exists('global_test', true)); } + + public function test_permission_set_data() + { + return array( + array( + 'ADMINISTRATORS', + 'a_test', + 'group', + true, + ), + array( + 'GLOBAL_MODERATORS', + 'm_test', + 'group', + true, + ), + array( + 'REGISTERED', + 'u_test', + 'group', + true, + ), + ); + } + + /** + * @dataProvider test_permission_set_data + */ + public function test_permission_set($group_name, $auth_option, $type, $has_permission) + { + $this->tool->permission_set($group_name, $auth_option, $type, $has_permission); + $administrators_perm = $this->auth->acl_group_raw_data($this->group_ids['ADMINISTRATORS'], $auth_option); + $global_moderators_perm = $this->auth->acl_group_raw_data($this->group_ids['GLOBAL_MODERATORS'], $auth_option); + $registered_users_perm = $this->auth->acl_group_raw_data($this->group_ids['REGISTERED'], $auth_option); + + switch($group_name) + { + case 'GLOBAL_MODERATORS': + $this->assertEquals(false, empty($administrators_perm), 'm_test is not empty for Administrators'); + $this->assertEquals(false, empty($global_moderators_perm), 'm_test is not empty for Global moderators'); + $this->assertEquals(true, empty($registered_users_perm), 'm_test empty for Registered users'); + break; + + case 'ADMINISTRATORS': + $this->assertEquals(false, empty($administrators_perm), 'a_test is not empty for Administrators'); + $this->assertEquals(true, empty($global_moderators_perm), 'a_test is empty for Global moderators'); + $this->assertEquals(true, empty($registered_users_perm), 'a_test is empty for Registered users'); + break; + + case 'REGISTERED': + $this->assertEquals(false, empty($administrators_perm), 'u_test is not empty for Administrators'); + $this->assertEquals(false, empty($global_moderators_perm), 'u_test is not empty for Global moderators'); + $this->assertEquals(false, empty($registered_users_perm), 'u_test is not empty for Registered users'); + break; + } + } } diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index d52fb6b085..2d94f1d778 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -31,7 +31,8 @@ namespace { $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->config_php = new \phpbb\config_php_file($this->phpbb_root_path . 'fixtures/', 'php'); - $this->builder = new phpbb_mock_phpbb_di_container_builder($this->config_php, $this->phpbb_root_path . 'fixtures/', 'php'); + $this->builder = new phpbb_mock_phpbb_di_container_builder($this->phpbb_root_path . 'fixtures/', 'php'); + $this->builder->with_config($this->config_php); $this->filename = $this->phpbb_root_path . '../tmp/container.php'; if (is_file($this->filename)) @@ -78,9 +79,9 @@ namespace $this->assertTrue($container->isFrozen()); } - public function test_dump_container() + public function test_without_cache() { - $this->builder->set_dump_container(false); + $this->builder->without_cache(); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -94,9 +95,9 @@ namespace $this->assertTrue($container->isFrozen()); } - public function test_use_extensions() + public function test_without_extensions() { - $this->builder->set_use_extensions(false); + $this->builder->without_extensions(); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -109,9 +110,9 @@ namespace $this->assertFalse($container->hasParameter('available')); } - public function test_compile_container() + public function test_without_compiled_container() { - $this->builder->set_compile_container(false); + $this->builder->without_compiled_container(); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -119,19 +120,9 @@ namespace $this->assertFalse($container->isFrozen()); } - public function test_inject_config() + public function test_with_config_path() { - $this->builder->set_inject_config(false); - $container = $this->builder->get_container(); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); - - // Checks inject_config - $this->assertFalse($container->hasParameter('dbal.dbhost')); - } - - public function test_set_config_path() - { - $this->builder->set_config_path($this->phpbb_root_path . 'fixtures/other_config/'); + $this->builder->with_config_path($this->phpbb_root_path . 'fixtures/other_config/'); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -139,9 +130,9 @@ namespace $this->assertFalse($container->hasParameter('core')); } - public function test_set_custom_parameters() + public function test_with_custom_parameters() { - $this->builder->set_custom_parameters(array('my_parameter' => true)); + $this->builder->with_custom_parameters(array('my_parameter' => true)); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -150,61 +141,21 @@ namespace } } -namespace phpbb\db\driver +namespace phpbb\extension { - class container_mock extends \phpbb\db\driver\driver + class manager_mock extends \phpbb\extension\manager { - public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - } - - public function sql_query($query = '', $cache_ttl = 0) - { - } - - public function sql_fetchrow($query_id = false) - { - } - - public function sql_freeresult($query_id = false) - { - } - - function sql_server_info($raw = false, $use_cache = true) - { - } - - function sql_affectedrows() - { - } - - function sql_rowseek($rownum, &$query_id) - { - } - - function sql_nextid() - { - } - - function sql_escape($msg) - { - } - - function sql_like_expression($expression) - { - } - - function sql_not_like_expression($expression) + public function __construct() { } - function sql_fetchrowset($query_id = false) + public function all_enabled($phpbb_relative = true) { return array( - array('ext_name' => 'vendor/enabled'), - array('ext_name' => 'vendor/enabled-2'), - array('ext_name' => 'vendor/enabled-3'), - array('ext_name' => 'vendor/enabled_4'), + 'vendor/enabled' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled/', + 'vendor/enabled-2' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled-2/', + 'vendor/enabled-3' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled-3/', + 'vendor/enabled_4' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled_4/', ); } } diff --git a/tests/di/fixtures/config.php b/tests/di/fixtures/config.php index f2e1145efa..1e9207d924 100644 --- a/tests/di/fixtures/config.php +++ b/tests/di/fixtures/config.php @@ -1,7 +1,7 @@ <?php // phpBB 3.1.x auto-generated configuration file // Do not change anything in this file! -$dbms = 'container_mock'; +$dbms = 'mysql'; $dbhost = '127.0.0.1'; $dbport = ''; $dbname = 'phpbb'; diff --git a/tests/di/fixtures/config/production/config.yml b/tests/di/fixtures/config/production/config.yml new file mode 100644 index 0000000000..fcfa84f68b --- /dev/null +++ b/tests/di/fixtures/config/production/config.yml @@ -0,0 +1,2 @@ +core: + require_dev_dependencies: true diff --git a/tests/di/fixtures/config/production/container/environment.yml b/tests/di/fixtures/config/production/container/environment.yml new file mode 100644 index 0000000000..9dcf11d865 --- /dev/null +++ b/tests/di/fixtures/config/production/container/environment.yml @@ -0,0 +1,29 @@ +parameters: + core: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock + + ext.manager: + class: phpbb\extension\manager_mock + + template.twig.environment: + class: Exception + arguments: + - ~ + - ~ + - ~ + - ~ + - ~ + - ~ + - ~ + - [] diff --git a/tests/di/fixtures/config/test/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml index 0873078844..14c986d123 100644 --- a/tests/di/fixtures/config/test/container/environment.yml +++ b/tests/di/fixtures/config/test/container/environment.yml @@ -22,4 +22,5 @@ services: - ~ - ~ - ~ + - ~ - [] diff --git a/tests/di/fixtures/other_config/test/container/environment.yml b/tests/di/fixtures/other_config/test/container/environment.yml index 2aa29db2eb..e285b1b781 100644 --- a/tests/di/fixtures/other_config/test/container/environment.yml +++ b/tests/di/fixtures/other_config/test/container/environment.yml @@ -22,4 +22,5 @@ services: - ~ - ~ - ~ + - ~ - [] diff --git a/tests/event/fixtures/adm/style/acp_bbcodes.html b/tests/event/fixtures/adm/style/acp_bbcodes.html new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/event/fixtures/adm/style/acp_bbcodes.html diff --git a/tests/event/fixtures/normal_events.md.test b/tests/event/fixtures/normal_events.md.test new file mode 100644 index 0000000000..47921c4e57 --- /dev/null +++ b/tests/event/fixtures/normal_events.md.test @@ -0,0 +1,20 @@ +acp_bbcodes_actions_append +=== +* Location: adm/style/acp_bbcodes.html +* Since: 3.1.0-a3 +* Changed: 3.1.0-a4 +* Purpose: desc1 + +acp_bbcodes_actions_prepend +=== +* Location: adm/style/acp_bbcodes.html +* Since: 3.1.0-a5 +* Purpose: desc2 + +acp_bbcodes_actions_prepend2 +=== +* Location: adm/style/acp_bbcodes.html +* Since: 3.1.0-a4 +* Changed: 3.1.0-a5 Moved up +* Changed: 3.1.0-a6 Moved down +* Purpose: desc2 diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php index 28649e4f21..a6c1dc78de 100644 --- a/tests/event/md_exporter_test.php +++ b/tests/event/md_exporter_test.php @@ -11,21 +11,105 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + class phpbb_event_md_exporter_test extends phpbb_test_case { - static public function crawl_eventsmd_data() { return array( + array('normal_events.md.test', null, null, array( + 'acp_bbcodes_actions_append' => array( + 'event' => 'acp_bbcodes_actions_append', + 'files' => array( + 'prosilver' => array(), + 'adm' => array('acp_bbcodes.html'), + ), + 'since' => '3.1.0-a3', + 'changed' => array( + '3.1.0-a4' => '', + ), + 'description' => 'desc1' . "\n", + ), + 'acp_bbcodes_actions_prepend' => array( + 'event' => 'acp_bbcodes_actions_prepend', + 'files' => array( + 'prosilver' => array(), + 'adm' => array('acp_bbcodes.html'), + ), + 'since' => '3.1.0-a5', + 'changed' => array(), + 'description' => 'desc2' . "\n", + ), + 'acp_bbcodes_actions_prepend2' => array( + 'event' => 'acp_bbcodes_actions_prepend2', + 'files' => array( + 'prosilver' => array(), + 'adm' => array('acp_bbcodes.html'), + ), + 'since' => '3.1.0-a4', + 'changed' => array( + '3.1.0-a5' => 'Moved up', + '3.1.0-a6' => 'Moved down', + ), + 'description' => 'desc2' . "\n", + ), + )), + array('normal_events.md.test', '3.1.0-a5', '3.1.0-a5', array( + 'acp_bbcodes_actions_prepend' => array( + 'event' => 'acp_bbcodes_actions_prepend', + 'files' => array( + 'prosilver' => array(), + 'adm' => array('acp_bbcodes.html'), + ), + 'since' => '3.1.0-a5', + 'changed' => array(), + 'description' => 'desc2' . "\n", + ), + 'acp_bbcodes_actions_prepend2' => array( + 'event' => 'acp_bbcodes_actions_prepend2', + 'files' => array( + 'prosilver' => array(), + 'adm' => array('acp_bbcodes.html'), + ), + 'since' => '3.1.0-a4', + 'changed' => array( + '3.1.0-a5' => 'Moved up', + '3.1.0-a6' => 'Moved down', + ), + 'description' => 'desc2' . "\n", + ), + )), + ); + } + + /** + * @dataProvider crawl_eventsmd_data + * + * @param string $file + * @param string $min_version + * @param string $max_version + * @param array $events + */ + public function test_crawl_eventsmd($file, $min_version, $max_version, $events) + { + $exporter = new \phpbb\event\md_exporter(dirname(__FILE__) . '/fixtures/', null, $min_version, $max_version); + $this->assertSame(sizeof($events), $exporter->crawl_eventsmd($file, 'adm')); + $this->assertEquals($events, $exporter->get_events()); + } + + static public function crawl_phpbb_eventsmd_data() + { + return array( array('styles'), array('adm'), ); } /** - * @dataProvider crawl_eventsmd_data - */ - public function test_crawl_eventsmd($filter) + * @dataProvider crawl_phpbb_eventsmd_data + */ + public function test_crawl_phpbb_eventsmd($filter) { global $phpbb_root_path; $exporter = new \phpbb\event\md_exporter($phpbb_root_path); diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index cbcfdfb787..88634bc6ba 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -22,6 +22,7 @@ class phpbb_extension_modules_test extends phpbb_test_case { protected $extension_manager; protected $finder; + protected $module_manager; public function setUp() { @@ -43,7 +44,14 @@ class phpbb_extension_modules_test extends phpbb_test_case )); $phpbb_extension_manager = $this->extension_manager; - $this->acp_modules = new acp_modules(); + $this->module_manager = new \phpbb\module\module_manager( + new \phpbb\cache\driver\dummy(), + $this->getMock('\phpbb\db\driver\driver_interface'), + $this->extension_manager, + MODULES_TABLE, + dirname(__FILE__) . '/', + 'php' + ); } public function test_get_module_infos() @@ -56,8 +64,7 @@ class phpbb_extension_modules_test extends phpbb_test_case $phpbb_root_path = dirname(__FILE__) . '/'; // Find acp module info files - $this->acp_modules->module_class = 'acp'; - $acp_modules = $this->acp_modules->get_module_infos(); + $acp_modules = $this->module_manager->get_module_infos('acp'); $this->assertEquals(array( 'vendor2\\foo\\acp\\a_module' => array( 'filename' => 'vendor2\\foo\\acp\\a_module', @@ -76,8 +83,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Find mcp module info files - $this->acp_modules->module_class = 'mcp'; - $acp_modules = $this->acp_modules->get_module_infos(); + $acp_modules = $this->module_manager->get_module_infos('mcp'); $this->assertEquals(array( 'vendor2\\foo\\mcp\\a_module' => array( 'filename' => 'vendor2\\foo\\mcp\\a_module', @@ -89,21 +95,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Find a specific module info file (mcp_a_module) - $this->acp_modules->module_class = 'mcp'; - $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module'); - $this->assertEquals(array( - 'vendor2\\foo\\mcp\\a_module' => array( - 'filename' => 'vendor2\\foo\\mcp\\a_module', - 'title' => 'Foobar', - 'modes' => array( - 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), - ), - ), - ), $acp_modules); - - // Find a specific module info file (mcp_a_module) with passing the module_class - $this->acp_modules->module_class = ''; - $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module', 'mcp'); + $acp_modules = $this->module_manager->get_module_infos('mcp', 'mcp_a_module'); $this->assertEquals(array( 'vendor2\\foo\\mcp\\a_module' => array( 'filename' => 'vendor2\\foo\\mcp\\a_module', @@ -115,18 +107,15 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // The mcp module info file we're looking for shouldn't exist - $this->acp_modules->module_class = 'mcp'; - $acp_modules = $this->acp_modules->get_module_infos('mcp_a_fail'); + $acp_modules = $this->module_manager->get_module_infos('mcp', 'mcp_a_fail'); $this->assertEquals(array(), $acp_modules); // As there are no ucp modules we shouldn't find any - $this->acp_modules->module_class = 'ucp'; - $acp_modules = $this->acp_modules->get_module_infos(); + $acp_modules = $this->module_manager->get_module_infos('ucp'); $this->assertEquals(array(), $acp_modules); // Get module info of specified extension module - $this->acp_modules->module_class = 'acp'; - $acp_modules = $this->acp_modules->get_module_infos('foo_acp_a_module'); + $acp_modules = $this->module_manager->get_module_infos('acp', 'foo_acp_a_module'); $this->assertEquals(array( 'vendor2\\foo\\acp\\a_module' => array ( 'filename' => 'vendor2\\foo\\acp\\a_module', @@ -138,18 +127,16 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // No specific module and module class set to an incorrect name - $acp_modules = $this->acp_modules->get_module_infos('', 'wcp', true); + $acp_modules = $this->module_manager->get_module_infos('wcp', '', true); $this->assertEquals(array(), $acp_modules); // No specific module, no module_class set in the function parameter, and an incorrect module class - $this->acp_modules->module_class = 'wcp'; - $acp_modules = $this->acp_modules->get_module_infos(); + $acp_modules = $this->module_manager->get_module_infos('wcp'); $this->assertEquals(array(), $acp_modules); // No specific module, module class set to false (will default to the above acp) // Setting $use_all_available will cause get_module_infos() to also load not enabled extensions (vendor2/bar) - $this->acp_modules->module_class = 'acp'; - $acp_modules = $this->acp_modules->get_module_infos('', false, true); + $acp_modules = $this->module_manager->get_module_infos('acp', '', true); $this->assertEquals(array( 'vendor2\\foo\\acp\\a_module' => array( 'filename' => 'vendor2\\foo\\acp\\a_module', @@ -175,7 +162,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Specific module set to disabled extension - $acp_modules = $this->acp_modules->get_module_infos('vendor2_bar_acp_a_module', 'acp', true); + $acp_modules = $this->module_manager->get_module_infos('acp', 'vendor2_bar_acp_a_module', true); $this->assertEquals(array( 'vendor2\\bar\\acp\\a_module' => array( 'filename' => 'vendor2\\bar\\acp\\a_module', diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index b9e74a280f..4f28879687 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -34,6 +34,18 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case $this->assertGreaterThan(0, $crawler->filter('.postbody')->count()); } + public function test_help_faq() + { + $crawler = self::request('GET', 'app.php/help/faq'); + $this->assertGreaterThan(0, $crawler->filter('h2.faq-title')->count()); + } + + public function test_help_bbcode() + { + $crawler = self::request('GET', 'app.php/help/bbcode'); + $this->assertGreaterThan(0, $crawler->filter('h2.faq-title')->count()); + } + public function test_feed() { $crawler = self::request('GET', 'feed.php', array(), false); diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index ee084720e4..95107665cd 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -49,8 +49,9 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case $this->phpbb_extension_manager = $this->get_extension_manager(); $this->phpbb_extension_manager->enable('foo/bar'); - $modules = new acp_modules(); $db = $this->get_db(); + $cache = $this->get_cache_driver(); + $modules = new \phpbb\module\module_manager($cache, $db, $this->phpbb_extension_manager, MODULES_TABLE, dirname(__FILE__) . '/../../phpBB/', 'php'); $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " @@ -70,7 +71,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case 'module_mode' => '', 'module_auth' => '', ); - $modules->update_module_data($parent_data, true); + $modules->update_module_data($parent_data); $module_data = array( 'module_basename' => 'foo\\bar\\acp\\main_module', @@ -82,7 +83,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case 'module_mode' => 'mode', 'module_auth' => '', ); - $modules->update_module_data($module_data, true); + $modules->update_module_data($module_data); $parent_data = array( 'module_basename' => '', @@ -94,7 +95,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case 'module_mode' => '', 'module_auth' => '', ); - $modules->update_module_data($parent_data, true); + $modules->update_module_data($parent_data); $module_data = array( 'module_basename' => 'foo\\bar\\ucp\\main_module', @@ -106,7 +107,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case 'module_mode' => 'mode', 'module_auth' => '', ); - $modules->update_module_data($module_data, true); + $modules->update_module_data($module_data); $this->purge_cache(); } diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 7acf375c5d..ccfeb10deb 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -71,4 +71,135 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); $this->assertContains('😀', $crawler->text()); } + + public function test_quote() + { + $text = 'Test post </textarea>"\' &&amp;'; + $expected = '[quote="admin"]' . $text . '[/quote]'; + + $this->login(); + $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); + $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + + $crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post['topic_id']}&p={$post['post_id']}&sid={$this->sid}"); + + $this->assertContains($expected, $crawler->filter('textarea#message')->text()); + } + + /** + * @testdox max_quote_depth is applied to the text populating the posting form + */ + public function test_quote_depth_form() + { + $text = '0[quote]1[quote]2[/quote]1[/quote]0'; + $expected = array( + 0 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]', + 1 => '[quote="admin"]00[/quote]', + 2 => '[quote="admin"]0[quote]11[/quote]0[/quote]', + 3 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]', + ); + + $this->login(); + $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); + $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + $quote_url = "posting.php?mode=quote&f=2&t={$post['topic_id']}&p={$post['post_id']}&sid={$this->sid}"; + + $this->admin_login(); + foreach ($expected as $quote_depth => $expected_text) + { + $this->set_quote_depth($quote_depth); + $crawler = self::request('GET', $quote_url); + $this->assertContains($expected_text, $crawler->filter('textarea#message')->text()); + } + } + + /** + * @testdox max_quote_depth is applied to the submitted text + */ + public function test_quote_depth_submit() + { + $text = 'depth:0[quote]depth:1[quote]depth:2[quote]depth:3[/quote][/quote][/quote]'; + $contains = array( + 0 => array('depth:0', 'depth:1', 'depth:2', 'depth:3'), + 1 => array('depth:0', 'depth:1'), + 2 => array('depth:0', 'depth:1', 'depth:2'), + 3 => array('depth:0', 'depth:1', 'depth:2', 'depth:3'), + ); + $not_contains = array( + 0 => array(), + 1 => array('depth:2', 'depth:3'), + 2 => array('depth:3'), + 3 => array(), + ); + + $this->login(); + $this->admin_login(); + $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); + + for ($quote_depth = 0; $quote_depth <= 2; ++$quote_depth) + { + $this->set_quote_depth($quote_depth); + + $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + $url = "viewtopic.php?p={$post['post_id']}&sid={$this->sid}"; + + $crawler = self::request('GET', $url); + $text_content = $crawler->filter('#p' . $post['post_id'])->text(); + foreach ($contains[$quote_depth] as $contains_text) + { + $this->assertContains($contains_text, $text_content); + } + foreach ($not_contains[$quote_depth] as $not_contains_text) + { + $this->assertNotContains($not_contains_text, $text_content); + } + } + } + + protected function set_quote_depth($depth) + { + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + $values['config[max_quote_depth]'] = $depth; + $form->setValues($values); + $crawler = self::submit($form); + $this->assertEquals(1, $crawler->filter('.successbox')->count()); + } + + public function test_ticket_8420() + { + $text = '[b][url=http://example.org] :arrow: here[/url][/b]'; + + $this->login(); + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => $text + )); + $crawler = self::submit($form); + $this->assertEquals($text, $crawler->filter('#message')->text()); + } + + public function test_old_signature_in_preview() + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_sig = '[b:2u8sdcwb]My signature[/b:2u8sdcwb]', + user_sig_bbcode_uid = '2u8sdcwb', + user_sig_bbcode_bitfield = 'QA==' + WHERE user_id = 2"; + $this->get_db()->sql_query($sql); + + $this->login(); + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => 'My post', + )); + $crawler = self::submit($form); + $this->assertContains( + '<span style="font-weight: bold">My signature</span>', + $crawler->filter('#preview .signature')->html() + ); + } } diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index 1f6dc3a979..be584c20c1 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -66,4 +66,31 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case $crawler = self::submit($form); $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text()); } + + public function test_quote_post() + { + $text = 'Test post'; + $expected = '[quote="admin"]' . $text . '[/quote]'; + + $this->login(); + $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); + $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + + $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quotepost&p=' . $post['post_id'] . '&sid=' . $this->sid); + + $this->assertContains($expected, $crawler->filter('textarea#message')->text()); + } + + public function test_quote_forward() + { + $text = 'This is a test private message sent by the testing framework.'; + $expected = "[quote=\"admin\"]\n" . $text . "\n[/quote]"; + + $this->login(); + $message_id = $this->create_private_message('Test', $text, array(2)); + + $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid); + + $this->assertContains($expected, $crawler->filter('textarea#message')->text()); + } } diff --git a/tests/functions/fixtures/user_delete.xml b/tests/functions/fixtures/user_delete.xml new file mode 100644 index 0000000000..4c4479d29b --- /dev/null +++ b/tests/functions/fixtures/user_delete.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_users"> + <column>user_id</column> + <column>username_clean</column> + <column>username</column> + <column>user_permissions</column> + <column>user_sig</column> + <row> + <value>1</value> + <value>anonymous</value> + <value>anonymous</value> + <value></value> + <value></value> + </row> + <row> + <value>2</value> + <value>2</value> + <value>2</value> + <value></value> + <value></value> + </row> + </table> + <table name="phpbb_oauth_accounts"> + <column>user_id</column> + <column>provider</column> + <column>oauth_provider_id</column> + <row> + <value>2</value> + <value>google</value> + <value>1234567890123456789</value> + </row> + </table> + <table name="phpbb_oauth_tokens"> + <column>user_id</column> + <column>session_id</column> + <column>provider</column> + <column>oauth_token</column> + <row> + <value>2</value> + <value>897a897b797c8789997d7979879</value> + <value>auth.provider.oauth.service.google</value> + <value>{"accessToken":"ya29.YPHwCWVkrvwu1kgbYKiDNYaQ451ZuHy9OEQAGVME8if-WBzR-v7a9ftxbx41kaL)5VLEXB-6qJEvri","endOfLife":1429959670,"extraParams":{"token_type":"Bearer","id_token":"eyJhbGciOiJSUzI1NiIsImupZCI6IjE0YuRjNzc2MDQwYjUyNDZmNTI5OWFkZDVlMmQ1NWNOPTdjMDdlZTAifQ.eyJpc3MiOiJhY2NvdW90cy5nb78nbGUuY29tIiwic3ViIjoiMTExMDMwNwerNjM4MTM5NTQwMTM1IiwiYXpwIjoiOTk3MzUwMTY0NzE0LWhwOXJrYjZpcjM4MW80YjV1NjRpaGtmM29zMnRvbWxhLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiZW1haWwiOiJtYXJjLmFsZXhhbmRlci4zN0BnbWFpbC5jb20iLCJhdF9oYXNoIjoiWHk2b1JabnVZUWRfRTZDeDV0RkItdyIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdWQiOiI5OTczNTAxNjQ3MTQtaHA5cmtiNmlyMzgxbzRiNXU2NGloa2Yzb3MydG9tbGEuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJpYXQiOjE0Mjk5NTYwNzEsImV4cCI6MTQyOTk1OTY3MX0.C5gfSzjqwlRRvVMuTP6jfWIuEHMXn55oYHsSA3eh97n2BZL0TZHhUm4K206Fgucd6ufAphan4l0J7y6tMAHLZPr-kk6KDINxWnPG-up99reblGutay0lRYjMCcrhJAOql8EI1bi84GyliZFYHL67pE0ZtSf-CMb1CeH18TFe-Fk"},"refreshToken":null,"token_class":"OAuth\\\\OAuth2\\\\Token\\\\StdOAuth2Token"}</value> + </row> + </table> +</dataset> diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php new file mode 100644 index 0000000000..21561492fd --- /dev/null +++ b/tests/functions/user_delete_test.php @@ -0,0 +1,113 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; + +class phpbb_functions_user_delete_test extends phpbb_database_test_case +{ + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/user_delete.xml'); + } + + protected function setUp() + { + parent::setUp(); + + global $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx; + + $this->db = $db = $this->new_dbal(); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_container = new phpbb_mock_container_builder(); + $config = new \phpbb\config\config(array( + 'auth_method' => 'oauth', + 'auth_oauth_google_key' => 'foo', + 'auth_oauth_google_secret' => 'bar', + )); + $cache = new \phpbb\cache\driver\dummy(); + $request = new phpbb_mock_request(); + $notification_manager = new phpbb_mock_notification_manager(); + $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); + $oauth_provider_google = new \phpbb\auth\provider\oauth\service\google($config, $request); + $oauth_provider_collection = new \phpbb\di\service_collection($phpbb_container); + $oauth_provider_collection->offsetSet('auth.provider.oauth.service.google', $oauth_provider_google); + + $driver_helper = new \phpbb\passwords\driver\helper($config); + $passwords_drivers = array( + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $driver_helper), + 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $driver_helper), + 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper), + ); + + $passwords_helper = new \phpbb\passwords\helper; + // Set up passwords manager + $passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); + + $oauth_provider = new \phpbb\auth\provider\oauth\oauth( + $db, + $config, + $passwords_manager, + $request, + $user, + 'phpbb_oauth_tokens', + 'phpbb_oauth_accounts', + $oauth_provider_collection, + 'phpbb_users', + $phpbb_container, + $this->phpbb_root_path, + $this->php_ext + ); + $provider_collection->offsetSet('auth.provider.oauth', $oauth_provider); + + $phpbb_container->set('auth.provider.oauth', $oauth_provider); + $phpbb_container->set('auth.provider.oauth.service.google', $oauth_provider_google); + $phpbb_container->set('auth.provider_collection', $provider_collection); + $phpbb_container->set('notification_manager', $notification_manager); + } + + public function test_user_delete() + { + // Check that user is linked + $sql = 'SELECT ot.user_id AS user_id + FROM phpbb_oauth_accounts oa, phpbb_oauth_tokens ot + WHERE oa.user_id = 2 + AND ot.user_id = oa.user_id'; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertEquals(array('user_id' => '2'), $row); + + // user_delete() should return false + $this->assertFalse(user_delete('remove', array(2))); + + // Make sure user link was removed + $sql = 'SELECT ot.user_id AS user_id + FROM phpbb_oauth_accounts oa, phpbb_oauth_tokens ot + WHERE oa.user_id = 2 + AND ot.user_id = oa.user_id'; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertEmpty($row); + } +} diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php index 8ae78b97db..a8d7ae6f09 100644 --- a/tests/functions_acp/build_cfg_template_test.php +++ b/tests/functions_acp/build_cfg_template_test.php @@ -32,7 +32,7 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case array('config_key_name' => '2'), 'config_key_name', array(), - '<input id="key_name" type="password" size="20" maxlength="128" name="config[config_key_name]" value="2" autocomplete="off" />', + '<input id="key_name" type="password" size="20" maxlength="128" name="config[config_key_name]" value="********" autocomplete="off" />', ), array( array('text', 0, 255), diff --git a/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml b/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml new file mode 100644 index 0000000000..c78d63f7cb --- /dev/null +++ b/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_groups"> + <column>group_id</column> + <column>group_desc</column> + <column>group_message_limit</column> + <column>group_max_recipients</column> + <row> + <value>1</value> + <value></value> + <value>1</value> + <value>3</value> + </row> + <row> + <value>2</value> + <value></value> + <value>2</value> + <value>4</value> + </row> + <row> + <value>3</value> + <value></value> + <value>0</value> + <value>0</value> + </row> + <row> + <value>4</value> + <value></value> + <value>0</value> + <value>5</value> + </row> + </table> + <table name="phpbb_user_group"> + <column>user_id</column> + <column>group_id</column> + <column>user_pending</column> + <row> + <value>1</value> + <value>1</value> + <value>0</value> + </row> + <row> + <value>1</value> + <value>2</value> + <value>0</value> + </row> + <row> + <value>1</value> + <value>3</value> + <value>0</value> + </row> + <row> + <value>2</value> + <value>1</value> + <value>0</value> + </row> + <row> + <value>2</value> + <value>2</value> + <value>0</value> + </row> + <row> + <value>3</value> + <value>3</value> + <value>0</value> + </row> + <row> + <value>4</value> + <value>4</value> + <value>0</value> + </row> + <row> + <value>5</value> + <value>3</value> + <value>1</value> + </row> + <row> + <value>5</value> + <value>2</value> + <value>0</value> + </row> + </table> +</dataset> diff --git a/tests/functions_privmsgs/get_max_setting_from_group_test.php b/tests/functions_privmsgs/get_max_setting_from_group_test.php new file mode 100644 index 0000000000..3eb7866802 --- /dev/null +++ b/tests/functions_privmsgs/get_max_setting_from_group_test.php @@ -0,0 +1,64 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_privmsgs.php'; + +class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/get_max_setting_from_group.xml'); + } + + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + + protected function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + } + + static public function get_max_setting_from_group_data() + { + return array( + array(1, 0, 'message_limit'), + array(2, 2, 'message_limit'), + array(3, 0, 'message_limit'), + array(4, 0, 'message_limit'), + array(5, 2, 'message_limit'), + array(1, 0, 'max_recipients'), + array(2, 4, 'max_recipients'), + array(3, 0, 'max_recipients'), + array(4, 5, 'max_recipients'), + array(5, 4, 'max_recipients'), + ); + } + + /** + * @dataProvider get_max_setting_from_group_data + */ + public function test_get_max_setting_from_group($user_id, $expected, $setting) + { + $this->assertEquals($expected, phpbb_get_max_setting_from_group($this->db, $user_id, $setting)); + } + + /** + * @expectedException InvalidArgumentException + */ + public function test_get_max_setting_from_group_throws() + { + phpbb_get_max_setting_from_group($this->db, ANONYMOUS, 'not_a_setting'); + } +} diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 0cb171c885..9e2caf9d21 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -36,6 +36,16 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + $phpbb_container->set( + 'auth.provider.db', + new phpbb_mock_auth_provider() + ); + $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); + $provider_collection->add('auth.provider.db'); + $phpbb_container->set( + 'auth.provider_collection', + $provider_collection + ); } public function first_last_post_data() diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php new file mode 100644 index 0000000000..68534d9a32 --- /dev/null +++ b/tests/help/manager_test.php @@ -0,0 +1,184 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +class phpbb_help_manager_test extends phpbb_test_case +{ + /** @var \phpbb\help\manager */ + protected $manager; + /** @var \phpbb\template\template */ + protected $template; + /** @var \phpbb\language\language */ + protected $language; + + public function setUp() + { + $this->template = $this->getMockBuilder('\phpbb\template\template') + ->disableOriginalConstructor() + ->getMock(); + $this->language = $this->getMockBuilder('\phpbb\language\language') + ->disableOriginalConstructor() + ->getMock(); + + $this->manager = new \phpbb\help\manager( + new \phpbb_mock_event_dispatcher(), + $this->language, + $this->template + ); + } + + public function add_block_data() + { + return array( + array('abc', false, array(), false), + array('def', true, array(), true), + array( + 'abc', + false, + array( + 'question1' => 'answer1', + 'question2' => 'answer2', + 'question3' => 'answer3', + ), + false + ), + ); + } + + /** + * @dataProvider add_block_data + * + * @param string $block_name + * @param bool $switch + * @param array $questions + * @param bool $switch_expected + */ + public function test_add_block($block_name, $switch, $questions, $switch_expected) + { + $this->language->expects($this->at(0)) + ->method('lang') + ->with($block_name) + ->willReturn(strtoupper($block_name)); + $lang_call_count = 1; + foreach ($questions as $question => $answer) + { + $this->language->expects($this->at($lang_call_count)) + ->method('lang') + ->with($question) + ->willReturn(strtoupper($question)); + $lang_call_count++; + + $this->language->expects($this->at($lang_call_count)) + ->method('lang') + ->with($answer) + ->willReturn(strtoupper($answer)); + $lang_call_count++; + } + + $this->template->expects($this->at(0)) + ->method('assign_block_vars') + ->with('faq_block', array( + 'BLOCK_TITLE' => strtoupper($block_name), + 'SWITCH_COLUMN' => $switch_expected, + )); + $template_call_count = 1; + foreach ($questions as $question => $answer) + { + $this->template->expects($this->at($template_call_count)) + ->method('assign_block_vars') + ->with('faq_block.faq_row', array( + 'FAQ_QUESTION' => strtoupper($question), + 'FAQ_ANSWER' => strtoupper($answer), + )); + $template_call_count++; + } + + $this->manager->add_block($block_name, $switch, $questions); + + $this->assertEquals($switch_expected, $this->manager->switched_column()); + } + + public function add_question_data() + { + return array( + array('abc', false, false), + array('def', true, true), + ); + } + + /** + * @dataProvider add_question_data + * + * @param string $question + * @param string $answer + */ + public function test_add_question($question, $answer) + { + $this->language->expects($this->at(0)) + ->method('lang') + ->with($question) + ->willReturn(strtoupper($question)); + $this->language->expects($this->at(1)) + ->method('lang') + ->with($answer) + ->willReturn(strtoupper($answer)); + + $this->template->expects($this->once()) + ->method('assign_block_vars') + ->with('faq_block.faq_row', array( + 'FAQ_QUESTION' => strtoupper($question), + 'FAQ_ANSWER' => strtoupper($answer), + )); + + $this->manager->add_question($question, $answer); + } + + public function test_add_block_double_switch() + { + $block_name = 'abc'; + $switch_expected = true; + + $this->language->expects($this->at(0)) + ->method('lang') + ->with($block_name) + ->willReturn(strtoupper($block_name)); + + $this->template->expects($this->at(0)) + ->method('assign_block_vars') + ->with('faq_block', array( + 'BLOCK_TITLE' => strtoupper($block_name), + 'SWITCH_COLUMN' => $switch_expected, + )); + + $this->manager->add_block($block_name, true); + $this->assertTrue($this->manager->switched_column()); + + // Add a second block with switch + $block_name = 'def'; + $switch_expected = false; + + $this->language->expects($this->at(0)) + ->method('lang') + ->with($block_name) + ->willReturn(strtoupper($block_name)); + + $this->template->expects($this->at(0)) + ->method('assign_block_vars') + ->with('faq_block', array( + 'BLOCK_TITLE' => strtoupper($block_name), + 'SWITCH_COLUMN' => $switch_expected, + )); + + $this->manager->add_block($block_name, true); + $this->assertTrue($this->manager->switched_column()); + } +} diff --git a/tests/lint_test.php b/tests/lint_test.php index fb43196bae..70046bdfd2 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -84,6 +84,8 @@ class phpbb_lint_test extends phpbb_test_case dirname(__FILE__) . '/../build/new_version', dirname(__FILE__) . '/../build/old_versions', dirname(__FILE__) . '/../phpBB/cache', + dirname(__FILE__) . '/../phpBB/ext', + dirname(__FILE__) . '/../phpBB/store', // 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', diff --git a/tests/notification/base.php b/tests/notification/base.php index a1ebecd6f9..45b0b6f179 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -116,7 +116,14 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case { global $phpbb_root_path, $phpEx; - return new $type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); + $instance = new $type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); + + if ($type === 'phpbb\\notification\\type\\quote') + { + $instance->set_utils(new \phpbb\textformatter\s9e\utils); + } + + return $instance; } protected function assert_notifications($expected, $options = array()) diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 75b7275d3a..48bf5b177b 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -48,6 +48,11 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager $item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); + if ($item_type === 'phpbb\\notification\\type\\quote') + { + $item->set_utils(new \phpbb\textformatter\s9e\utils); + } + $item->set_notification_manager($this); $item->set_initial_data($data); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index d7a711e007..04fb6658c3 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -117,6 +117,11 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); + if ($type === 'quote') + { + $class->set_utils(new \phpbb\textformatter\s9e\utils); + } + $phpbb_container->set('notification.type.' . $type, $class); $notification_types_array['notification.type.' . $type] = $class; diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php index 61e3840773..8ad6a62b09 100644 --- a/tests/notification/submit_post_type_quote_test.php +++ b/tests/notification/submit_post_type_quote_test.php @@ -51,6 +51,8 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ */ public function submit_post_data() { + $parser = $this->get_test_case_helpers()->set_s9e_services()->get('text_formatter.parser'); + return array( /** * Normal post @@ -65,15 +67,15 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ */ array( array( - 'message' => implode(' ', array( - '[quote="poster":uid]poster should not be notified[/quote:uid]', - '[quote="test":uid]test should be notified[/quote:uid]', - '[quote="unauthorized":uid]unauthorized to read, should not receive a notification[/quote:uid]', - '[quote="notified":uid]already notified, should not receive a new notification[/quote:uid]', - '[quote="disabled":uid]option disabled, should not receive a notification[/quote:uid]', - '[quote="default":uid]option set to default, should receive a notification[/quote:uid]', - '[quote="doesn\'t exist":uid]user does not exist, should not receive a notification[/quote:uid]', - )), + 'message' => $parser->parse(implode(' ', array( + '[quote="poster"]poster should not be notified[/quote]', + '[quote="test"]test should be notified[/quote]', + '[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]', + '[quote="notified"]already notified, should not receive a new notification[/quote]', + '[quote="disabled"]option disabled, should not receive a notification[/quote]', + '[quote="default"]option set to default, should receive a notification[/quote]', + '[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]', + ))), 'bbcode_uid' => 'uid', ), array( @@ -94,15 +96,15 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ */ array( array( - 'message' => implode(' ', array( - '[quote="poster":uid]poster should not be notified[/quote:uid]', - '[quote="test":uid]test should be notified[/quote:uid]', - '[quote="unauthorized":uid]unauthorized to read, should not receive a notification[/quote:uid]', - '[quote="notified":uid]already notified, should not receive a new notification[/quote:uid]', - '[quote="disabled":uid]option disabled, should not receive a notification[/quote:uid]', - '[quote="default":uid]option set to default, should receive a notification[/quote:uid]', - '[quote="doesn\'t exist":uid]user does not exist, should not receive a notification[/quote:uid]', - )), + 'message' => $parser->parse(implode(' ', array( + '[quote="poster"]poster should not be notified[/quote]', + '[quote="test"]test should be notified[/quote]', + '[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]', + '[quote="notified"]already notified, should not receive a new notification[/quote]', + '[quote="disabled"]option disabled, should not receive a notification[/quote]', + '[quote="default"]option set to default, should receive a notification[/quote]', + '[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]', + ))), 'bbcode_uid' => 'uid', 'force_approved_state' => false, ), diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 67c3d0a30f..07f9ec9c56 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -41,7 +41,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $router = new phpbb_mock_router($filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $manager); + $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $manager); $router->find_routing_files($manager->all_enabled(false)); $router->find(dirname(__FILE__) . '/'); diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php index 50c6778c8c..5625b0020b 100644 --- a/tests/regex/censor_test.php +++ b/tests/regex/censor_test.php @@ -37,17 +37,7 @@ class phpbb_regex_censor_test extends phpbb_test_case */ public function test_censor_unicode($pattern, $subject) { - $regex = get_censor_preg_expression($pattern, true); - - $this->assertRegExp($regex, $subject); - } - - /** - * @dataProvider censor_test_data - */ - public function test_censor_no_unicode($pattern, $subject) - { - $regex = get_censor_preg_expression($pattern, false); + $regex = get_censor_preg_expression($pattern); $this->assertRegExp($regex, $subject); } diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php index c0c16456f4..3a791f5e81 100644 --- a/tests/search/mysql_test.php +++ b/tests/search/mysql_test.php @@ -37,8 +37,9 @@ class phpbb_search_mysql_test extends phpbb_search_common_test_case $config['fulltext_mysql_max_word_len'] = 254; $this->db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $error = null; $class = self::get_search_wrapper('\phpbb\search\fulltext_mysql'); - $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); + $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user, $phpbb_dispatcher); } } diff --git a/tests/search/native_test.php b/tests/search/native_test.php index 61fde7d098..29d0d0a8d3 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -33,11 +33,12 @@ class phpbb_search_native_test extends phpbb_search_test_case $cache = new phpbb_mock_cache(); $this->db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $error = null; $class = self::get_search_wrapper('\phpbb\search\fulltext_native'); $config['fulltext_native_min_chars'] = 2; $config['fulltext_native_max_chars'] = 14; - $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); + $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user, $phpbb_dispatcher); } public function keywords() diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php index f96d71e2bc..97cca0e70c 100644 --- a/tests/search/postgres_test.php +++ b/tests/search/postgres_test.php @@ -37,8 +37,9 @@ class phpbb_search_postgres_test extends phpbb_search_common_test_case $config['fulltext_postgres_max_word_len'] = 254; $this->db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $error = null; $class = self::get_search_wrapper('\phpbb\search\fulltext_postgres'); - $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); + $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user, $phpbb_dispatcher); } } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 0fec3c2dff..bef1208609 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -863,15 +863,15 @@ class phpbb_functional_test_case extends phpbb_test_case */ static public function assert_response_html($status_code = 200) { - if ($status_code !== false) - { - self::assert_response_status_code($status_code); - } - // Any output before the doc type means there was an error $content = self::$client->getResponse()->getContent(); self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith('<!DOCTYPE', trim($content), 'Output found before DOCTYPE specification.'); + + if ($status_code !== false) + { + self::assert_response_status_code($status_code); + } } /* @@ -884,15 +884,15 @@ class phpbb_functional_test_case extends phpbb_test_case */ static public function assert_response_xml($status_code = 200) { - if ($status_code !== false) - { - self::assert_response_status_code($status_code); - } - // Any output before the xml opening means there was an error $content = self::$client->getResponse()->getContent(); self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith('<?xml', trim($content), 'Output found before XML specification.'); + + if ($status_code !== false) + { + self::assert_response_status_code($status_code); + } } /** diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 685014d3e4..210cda9a94 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -494,11 +494,9 @@ class phpbb_test_case_helpers $parser = new \phpbb\textformatter\s9e\parser( $cache, $cache_key_parser, - $user, $factory, $dispatcher ); - $container->set('text_formatter.parser', $parser); $container->set('text_formatter.s9e.parser', $parser); diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 79232562cf..67921d5b1e 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -68,7 +68,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( '[code]unparsed code[/code]', - '<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><code>unparsed code</code></div>' + '<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><pre><code>unparsed code</code></pre></div>' ), array( '[list]no item[/list]', @@ -181,12 +181,12 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case array( // Do not parse textual bbcodes in code '[code]unparsed code [b]bold [i]bold + italic[/i][/b][/code]', - '<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><code>unparsed code [b]bold [i]bold + italic[/i][/b]</code></div>' + '<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><pre><code>unparsed code [b]bold [i]bold + italic[/i][/b]</code></pre></div>' ), array( // Do not parse quote bbcodes in code '[code]unparsed code [quote="username"]quoted[/quote][/code]', - '<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><code>unparsed code [quote="username"]quoted[/quote]</code></div>' + '<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><pre><code>unparsed code [quote="username"]quoted[/quote]</code></pre></div>' ), array( // Textual bbcode nesting into textual bbcode @@ -195,7 +195,11 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "[code]\tline1\n line2[/code]", - '<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><code> line1<br>' . "\n" . ' line2</code></div>' + '<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><pre><code>' . "\tline1\n line2</code></pre></div>" + ), + array( + "[code]\n\tline1\n line2[/code]", + '<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><pre><code>' . "\tline1\n line2</code></pre></div>" ), array( '... http://example.org ...', @@ -217,6 +221,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '[quote="http://example.org"]...[/quote]', '<blockquote><div><cite><a href="http://example.org" class="postlink">http://example.org</a> wrote:</cite>...</div></blockquote>' ), + array( + "[quote]\nThis is a long quote that is definitely going to exceed 80 characters\n[/quote]\n\nFollowed by a reply", + "<blockquote class=\"uncited\"><div>\nThis is a long quote that is definitely going to exceed 80 characters\n</div></blockquote>\n\nFollowed by a reply" + ), ); } } diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 71966f9d36..3b72e713e1 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -35,7 +35,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( $cache, '_foo_parser', - $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), $factory, new phpbb_mock_event_dispatcher ); @@ -63,7 +62,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( $cache, '_foo_parser', - $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), $factory, new phpbb_mock_event_dispatcher ); @@ -92,7 +90,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( new phpbb_mock_cache, '_foo_parser', - $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), $factory, new phpbb_mock_event_dispatcher ); @@ -126,7 +123,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( $cache, '_foo_parser', - $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock(), $factory, new phpbb_mock_event_dispatcher ); @@ -191,7 +187,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case new \phpbb\textformatter\s9e\parser( $container->get('cache.driver'), '_foo_parser', - $container->get('user'), $container->get('text_formatter.s9e.factory'), $dispatcher ); @@ -200,9 +195,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case public function setup_event_callback($vars) { return isset($vars['parser']) - && $vars['parser'] instanceof \phpbb\textformatter\s9e\parser - && isset($vars['user']) - && $vars['user'] instanceof \phpbb\user; + && $vars['parser'] instanceof \phpbb\textformatter\s9e\parser; } /** @@ -236,7 +229,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $parser = new \phpbb\textformatter\s9e\parser( $container->get('cache.driver'), '_foo_parser', - $container->get('user'), $container->get('text_formatter.s9e.factory'), $dispatcher ); diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php index 69f8682cac..152c316b2e 100644 --- a/tests/text_formatter/s9e/utils_test.php +++ b/tests/text_formatter/s9e/utils_test.php @@ -75,6 +75,121 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case } /** + * @dataProvider get_outermost_quote_authors_tests + */ + public function test_get_outermost_quote_authors($original, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + $parser = $container->get('text_formatter.parser'); + + $this->assertSame($expected, $utils->get_outermost_quote_authors($parser->parse($original))); + } + + public function get_outermost_quote_authors_tests() + { + return array( + array( + 'No quotes here', + array() + ), + array( + '[quote="foo"]..[/quote] [quote]..[/quote]', + array('foo') + ), + array( + '[quote="foo"]..[/quote] [quote="bar"]..[/quote]', + array('foo', 'bar') + ), + array( + '[quote="foo"].[quote="baz"]..[/quote].[/quote] [quote="bar"]..[/quote]', + array('foo', 'bar') + ), + ); + } + + /** + * @dataProvider get_generate_quote_tests + */ + public function test_generate_quote($text, $params, $expected) + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $utils = $container->get('text_formatter.utils'); + + $this->assertSame($expected, $utils->generate_quote($text, $params)); + } + + public function get_generate_quote_tests() + { + return array( + array( + '...', + array(), + '[quote]...[/quote]', + ), + array( + '...', + array('author' => 'Brian Kibler'), + '[quote="Brian Kibler"]...[/quote]', + ), + array( + '...', + array('author' => 'Brian "Brian Kibler" Kibler of Brian Kibler Gaming'), + '[quote=\'Brian "Brian Kibler" Kibler of Brian Kibler Gaming\']...[/quote]', + ), + array( + '...', + array('author' => "Brian Kibler Gaming's Brian Kibler"), + '[quote="Brian Kibler Gaming\'s Brian Kibler"]...[/quote]', + ), + array( + '...', + array('author' => "\\\"'"), + '[quote="\\\\\\"\'"]...[/quote]', + ), + array( + '...', + array('author' => 'Lots of doubles """ one single \' one backslash \\'), + '[quote=\'Lots of doubles """ one single \\\' one backslash \\\\\']...[/quote]', + ), + array( + '...', + array('author' => "Lots of singles ''' one double \" one backslash \\"), + '[quote="Lots of singles \'\'\' one double \\" one backslash \\\\"]...[/quote]', + ), + array( + '...', + array('author' => 'Defaults to doublequotes """\'\'\''), + '[quote="Defaults to doublequotes \\"\\"\\"\'\'\'"]...[/quote]', + ), + array( + '...', + array( + 'author' => 'user', + 'post_id' => 123, + 'url' => 'http://example.org' + ), + '[quote="user" post_id="123" url="http://example.org"]...[/quote]', + ), + array( + 'This is a long quote that is definitely going to exceed 80 characters', + array(), + "[quote]\nThis is a long quote that is definitely going to exceed 80 characters\n[/quote]", + ), + array( + ' This is a short quote on its own line ', + array(), + '[quote]This is a short quote on its own line[/quote]', + ), + array( + "This is a short quote\non two lines", + array(), + "[quote]\nThis is a short quote\non two lines\n[/quote]", + ), + ); + } + + /** * @dataProvider get_remove_bbcode_tests */ public function test_remove_bbcode($original, $name, $depth, $expected) diff --git a/tests/text_processing/message_parser_test.php b/tests/text_processing/message_parser_test.php index 691c0d5b8a..bee1b3fca3 100644 --- a/tests/text_processing/message_parser_test.php +++ b/tests/text_processing/message_parser_test.php @@ -61,6 +61,13 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ->method('lang') ->will($this->returnValueMap($map)); + $user->data = array( + 'is_bot' => false, + 'is_registered' => true, + 'user_id' => 2, + ); + $user->style = array('style_id' => 1); + $user->lang = array( 'NO_POLL_TITLE' => 'You have to enter a poll title.', 'POLL_TITLE_TOO_LONG' => 'The poll title must contain fewer than 100 characters.', @@ -76,7 +83,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case if (isset($setup)) { - $setup($parser, $phpbb_container, $this); + $setup($phpbb_container, $this); } $this->get_test_case_helpers()->set_s9e_services($phpbb_container); @@ -286,7 +293,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=200]200[/size]', '<r><SIZE size="200"><s>[size=200]</s>200<e>[/size]</e></SIZE></r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_font_size', 200); } @@ -295,7 +302,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=200]200[/size]', '<r><SIZE size="200"><s>[size=200]</s>200<e>[/size]</e></SIZE></r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_font_size', 0); } @@ -304,7 +311,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=2000]2000[/size]', '<t>[size=2000]2000[/size]</t>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_font_size', 200); }, @@ -314,7 +321,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=0]0[/size]', '<t>[size=0]0[/size]</t>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_font_size', 200); } @@ -323,7 +330,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=200]200[/size]', '<r><SIZE size="200"><s>[size=200]</s>200<e>[/size]</e></SIZE></r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_font_size', 200); } @@ -332,7 +339,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[size=200]200[/size]', '<t>[size=200]200[/size]</t>', array(true, true, true, true, true, true, true, true, 'sig'), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_font_size', 120); }, @@ -342,7 +349,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '<r>[img]<URL url="http://example.org/100x100.png">http://example.org/100x100.png</URL>[/img]</r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 12); }, @@ -352,7 +359,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '<r>[img]<URL url="http://example.org/100x100.png">http://example.org/100x100.png</URL>[/img]</r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_width', 34); }, @@ -362,7 +369,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '<r><IMG src="http://example.org/100x100.png"><s>[img]</s><URL url="http://example.org/100x100.png">http://example.org/100x100.png</URL><e>[/img]</e></IMG></r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 0); $phpbb_container->get('config')->set('max_post_img_width', 0); @@ -372,7 +379,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '<r><IMG src="http://example.org/100x100.png"><s>[img]</s><URL url="http://example.org/100x100.png">http://example.org/100x100.png</URL><e>[/img]</e></IMG></r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 100); $phpbb_container->get('config')->set('max_post_img_width', 100); @@ -382,7 +389,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/100x100.png[/img]', '<r><IMG src="http://example.org/100x100.png"><s>[img]</s><URL url="http://example.org/100x100.png">http://example.org/100x100.png</URL><e>[/img]</e></IMG></r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_img_height', 12); $phpbb_container->get('config')->set('max_sig_img_width', 34); @@ -392,7 +399,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[img]http://example.org/404.png[/img]', '<r>[img]<URL url="http://example.org/404.png">http://example.org/404.png</URL>[/img]</r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 12); }, @@ -402,7 +409,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[flash=999,999]http://example.org/foo.swf[/flash]', '<r>[flash=999,999]<URL url="http://example.org/foo.swf">http://example.org/foo.swf</URL>[/flash]</r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_height', 123); }, @@ -412,7 +419,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case '[flash=999,999]http://example.org/foo.swf[/flash]', '<r>[flash=999,999]<URL url="http://example.org/foo.swf">http://example.org/foo.swf</URL>[/flash]</r>', array(true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_img_width', 456); }, @@ -422,7 +429,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :)', '<r><E>:)</E> <E>:)</E> <E>:)</E></r>', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_smilies', 3); } @@ -431,7 +438,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :) :)', '<r><E>:)</E> <E>:)</E> <E>:)</E> :)</r>', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_smilies', 3); }, @@ -441,7 +448,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :) :)', '<r><E>:)</E> <E>:)</E> <E>:)</E> <E>:)</E></r>', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_smilies', 0); } @@ -450,7 +457,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :) :)', '<r><E>:)</E> <E>:)</E> <E>:)</E> <E>:)</E></r>', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_smilies', 3); } @@ -459,7 +466,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case ':) :) :) :)', '<r><E>:)</E> <E>:)</E> <E>:)</E> :)</r>', array(true, true, true, true, true, true, true, true, 'sig'), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_smilies', 3); }, @@ -469,7 +476,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case 'http://example.org http://example.org http://example.org', '<r><URL url="http://example.org">http://example.org</URL> <URL url="http://example.org">http://example.org</URL> http://example.org</r>', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_urls', 2); }, @@ -479,7 +486,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case 'http://example.org http://example.org http://example.org', '<r><URL url="http://example.org">http://example.org</URL> <URL url="http://example.org">http://example.org</URL> <URL url="http://example.org">http://example.org</URL></r>', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_post_urls', 0); } @@ -488,7 +495,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case 'http://example.org http://example.org http://example.org', '<r><URL url="http://example.org">http://example.org</URL> <URL url="http://example.org">http://example.org</URL> <URL url="http://example.org">http://example.org</URL></r>', array(true, true, true, true, true, true, true, true), - function ($parser, $phpbb_container) + function ($phpbb_container) { $phpbb_container->get('config')->set('max_sig_urls', 2); } diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.html b/tests/text_processing/tickets_data/PHPBB3-10922.html index cdf8316df0..3ff117f171 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.html +++ b/tests/text_processing/tickets_data/PHPBB3-10922.html @@ -1 +1,9 @@ -<a href="mailto:user@example.org">user@example.org</a><a href="mailto:user@example.org">...</a>
\ No newline at end of file +<a href="mailto:user@example.org">user@example.org</a><br> +<a href="mailto:user@example.org">...</a><br> +<a href="mailto:user@example.org">...</a><br> +<a href="mailto:user@example.org?subject=Hello">...</a><br> +<a href="mailto:user@example.org?subject=Hi%20there">user@example.org</a><br> +<a href="mailto:user@example.org?body=Hi%20there">user@example.org</a><br> +<a href="mailto:user@example.org?subject=Hello&body=Sent%20from%20phpBB">user@example.org</a><br> +<a href="mailto:user@example.org?subject=Hello&body=Sent%20from%20phpBB">user@example.org</a><br> +<a href="mailto:user@example.org?subject=Hello&body=Sent%20from%20phpBB">...</a><br> diff --git a/tests/text_processing/tickets_data/PHPBB3-10922.txt b/tests/text_processing/tickets_data/PHPBB3-10922.txt index 348f8a1541..e533ce6ed5 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10922.txt +++ b/tests/text_processing/tickets_data/PHPBB3-10922.txt @@ -1 +1,9 @@ -[email]user@example.org[/email][email=user@example.org]...[/email]
\ No newline at end of file +[email]user@example.org[/email] +[email=user@example.org]...[/email] +[email=user@example.org ]...[/email] +[email=user@example.org subject="Hello"]...[/email] +[email subject="Hi there"]user@example.org[/email] +[email body="Hi there"]user@example.org[/email] +[email subject="Hello" body="Sent from phpBB"]user@example.org[/email] +[email body="Sent from phpBB" subject="Hello"]user@example.org[/email] +[email body="Sent from phpBB" subject="Hello" email="user@example.org"]...[/email] diff --git a/tests/text_processing/tickets_data/PHPBB3-11742.html b/tests/text_processing/tickets_data/PHPBB3-11742.html new file mode 100644 index 0000000000..e7890eef19 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-11742.html @@ -0,0 +1 @@ +<div class="codebox"><p>CODE: <a href="#" onclick="selectCode(this); return false;">Select all</a></p><pre><code> tab</code></pre></div>
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-11742.txt b/tests/text_processing/tickets_data/PHPBB3-11742.txt new file mode 100644 index 0000000000..db72e5dda0 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-11742.txt @@ -0,0 +1 @@ +[code] tab[/code]
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13641.html b/tests/text_processing/tickets_data/PHPBB3-13641.html new file mode 100644 index 0000000000..1bd1c06dbb --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13641.html @@ -0,0 +1 @@ +<code>[color=#FF0000]</code> - <span style="color: #FF0000">red</span>
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13641.txt b/tests/text_processing/tickets_data/PHPBB3-13641.txt new file mode 100644 index 0000000000..58f324715e --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13641.txt @@ -0,0 +1 @@ +[c][color=#FF0000][/c] - [color=#FF0000]red[/color]
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13641.xml b/tests/text_processing/tickets_data/PHPBB3-13641.xml new file mode 100644 index 0000000000..451c5c69cd --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13641.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_bbcodes"> + <column>bbcode_id</column> + <column>bbcode_tag</column> + <column>bbcode_helpline</column> + <column>display_on_posting</column> + <column>bbcode_match</column> + <column>bbcode_tpl</column> + <column>first_pass_match</column> + <column>first_pass_replace</column> + <column>second_pass_match</column> + <column>second_pass_replace</column> + + <row> + <value>13</value> + <value>c</value> + <value></value> + <value>1</value> + <value>[c]{TEXT}[/c]</value> + <value><![CDATA[<code>{TEXT}</code>]]></value> + <value><\[/c\]!ies]]></value> + <value><![CDATA['[c:$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', ''', '(', ')'), trim('${1}')).'[/c:$uid]']]></value> + <value><\[/c:$uid\]!s]]></value> + <value><![CDATA[<code>${1}</code>]]></value> + </row> + </table> +</dataset> diff --git a/tests/text_processing/tickets_data/PHPBB3-13921.html b/tests/text_processing/tickets_data/PHPBB3-13921.html new file mode 100644 index 0000000000..6a9dc7f504 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13921.html @@ -0,0 +1 @@ +<span style="font-size: 200%; line-height: normal"></span><div style="text-align:center"><span style="font-size: 200%; line-height: normal">xxx</span></div>
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13921.txt b/tests/text_processing/tickets_data/PHPBB3-13921.txt new file mode 100644 index 0000000000..392da0c3c8 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13921.txt @@ -0,0 +1 @@ +[size=200][center]xxx[/center][/size]
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-13921.xml b/tests/text_processing/tickets_data/PHPBB3-13921.xml new file mode 100644 index 0000000000..8d39246bb4 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-13921.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_bbcodes"> + <column>bbcode_id</column> + <column>bbcode_tag</column> + <column>bbcode_helpline</column> + <column>display_on_posting</column> + <column>bbcode_match</column> + <column>bbcode_tpl</column> + <column>first_pass_match</column> + <column>first_pass_replace</column> + <column>second_pass_match</column> + <column>second_pass_replace</column> + + <row> + <value>13</value> + <value>center</value> + <value></value> + <value>1</value> + <value>[center]{TEXT}[/center]</value> + <value><![CDATA[<div style="text-align:center">{TEXT}</div>]]></value> + <value>!\[center\](.*?)\[/center\]!ies</value> + <value>'[center:$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', ''', '(', ')'), trim('${1}')).'[/center:$uid]'</value> + <value>!\[center:$uid\](.*?)\[/center:$uid\]!s</value> + <value><![CDATA[<div style="text-align:center">${1}</div>]]></value> + </row> + </table> +</dataset> diff --git a/tests/text_processing/tickets_data/PHPBB3-8419.html b/tests/text_processing/tickets_data/PHPBB3-8419.html new file mode 100644 index 0000000000..38df626a94 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-8419.html @@ -0,0 +1 @@ +<span style="font-style: italic"><span style="font-weight: bold"><span style="color: #FF0000">tę </span></span></span>przykład
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-8419.txt b/tests/text_processing/tickets_data/PHPBB3-8419.txt new file mode 100644 index 0000000000..dac47823b6 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-8419.txt @@ -0,0 +1 @@ +[ort]tę [/ort]przykład
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-8419.xml b/tests/text_processing/tickets_data/PHPBB3-8419.xml new file mode 100644 index 0000000000..2f1df345f9 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-8419.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_bbcodes"> + <column>bbcode_id</column> + <column>bbcode_tag</column> + <column>bbcode_helpline</column> + <column>display_on_posting</column> + <column>bbcode_match</column> + <column>bbcode_tpl</column> + <column>first_pass_match</column> + <column>first_pass_replace</column> + <column>second_pass_match</column> + <column>second_pass_replace</column> + + <row> + <value>13</value> + <value>myemail</value> + <value></value> + <value>1</value> + <value>[ort]{TEXT}[/ort]</value> + <value><![CDATA[<span style="font-style: italic"><span style="font-weight: bold"><span style="color: #FF0000">{TEXT}</span></span></span>]]></value> + <value><\[/ort\]!ies]]></value> + <value><![CDATA['[ort:$uid]'.str_replace(array("\r\n", '\"', '\'', '(', ')'), array("\n", '"', ''', '(', ')'), trim('${1}')).'[/ort:$uid]']]></value> + <value><\[/ort:$uid\]!s]]></value> + <value><![CDATA[<span style="font-style: italic"><span style="font-weight: bold"><span style="color: #FF0000">${1}</span></span></span>]]></value> + </row> + </table> +</dataset> |