aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/RUNNING_TESTS.md25
-rw-r--r--tests/attachment/fixtures/resync.xml7
-rw-r--r--tests/avatar/manager_test.php4
-rw-r--r--tests/cache/apcu_driver_test.php17
-rw-r--r--tests/cache/cache_memory.php2
-rw-r--r--tests/cache/cache_memory_test.php2
-rw-r--r--tests/console/thumbnail_test.php6
-rw-r--r--tests/console/user/add_test.php48
-rw-r--r--tests/console/user/base.php5
-rw-r--r--tests/cron/manager_test.php2
-rw-r--r--tests/dbal/db_tools_test.php32
-rw-r--r--tests/dbal/ext/foo/bar/acp/acp_test_info.php37
-rw-r--r--tests/dbal/ext/foo/bar/acp/acp_test_module.php25
-rw-r--r--tests/dbal/ext/foo/bar/composer.json24
-rw-r--r--tests/dbal/ext/foo/bar/ucp/ucp_test_info.php37
-rw-r--r--tests/dbal/ext/foo/bar/ucp/ucp_test_module.php25
-rw-r--r--tests/dbal/fixtures/boolean_processor.xml6
-rw-r--r--tests/dbal/migrator_tool_module_test.php215
-rw-r--r--tests/dbal/migrator_tool_permission_test.php4
-rw-r--r--tests/dbal/write_test.php2
-rw-r--r--tests/error_collector_test.php4
-rw-r--r--tests/event/dispatcher_test.php16
-rw-r--r--tests/event/fixtures/event_migration.test30
-rw-r--r--tests/event/fixtures/extra_description.test2
-rw-r--r--tests/event/md_exporter_test.php4
-rw-r--r--tests/event/php_exporter_test.php21
-rw-r--r--tests/feed/attachments_base_test.php14
-rw-r--r--tests/functional/acp_attachments_test.php78
-rw-r--r--tests/functional/acp_profile_field_test.php15
-rw-r--r--tests/functional/extension_acp_test.php4
-rw-r--r--tests/functional/extension_controller_test.php2
-rw-r--r--tests/functional/extension_global_lang_test.php2
-rw-r--r--tests/functional/extension_module_test.php2
-rw-r--r--tests/functional/extension_permission_lang_test.php2
-rw-r--r--tests/functional/fileupload_form_test.php1
-rw-r--r--tests/functional/fileupload_remote_test.php4
-rw-r--r--tests/functional/metadata_manager_test.php2
-rw-r--r--tests/functional/posting_test.php2
-rw-r--r--tests/functional/user_password_reset_test.php57
-rw-r--r--tests/functions/fixtures/validate_username.xml2
-rw-r--r--tests/functions/get_remote_file_test.php2
-rw-r--r--tests/functions/make_clickable_test.php12
-rw-r--r--tests/functions/user_delete_test.php6
-rw-r--r--tests/functions/validate_username_test.php11
-rw-r--r--tests/functions_acp/validate_config_vars_test.php106
-rw-r--r--tests/functions_content/phpbb_format_quote_test.php57
-rw-r--r--tests/functions_user/delete_user_test.php5
-rw-r--r--tests/functions_user/fixtures/delete_user.xml9
-rw-r--r--tests/group/helper_get_name_string_test.php115
-rw-r--r--tests/group/helper_get_name_test.php31
-rw-r--r--tests/group/helper_get_rank_test.php43
-rw-r--r--tests/group/helper_test.php68
-rw-r--r--tests/group/helper_test_case.php123
-rw-r--r--tests/lint_test.php7
-rw-r--r--tests/migrator/get_callable_from_step_test.php136
-rw-r--r--tests/mock/sql_insert_buffer.php2
-rw-r--r--tests/network/checkdnsrr_test.php2
-rw-r--r--tests/notification/base.php2
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.bookmark.xml2
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.post.xml3
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml2
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.quote.xml2
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.topic.xml2
-rw-r--r--tests/notification/group_request_test.php16
-rw-r--r--tests/notification/notification_test.php2
-rw-r--r--tests/profilefields/type_string_test.php15
-rw-r--r--tests/profilefields/type_url_test.php70
-rw-r--r--tests/random/gen_rand_string_test.php10
-rw-r--r--tests/request/type_cast_helper_test.php10
-rw-r--r--tests/search/fixtures/posts.xml5
-rw-r--r--tests/search/native_test.php8
-rw-r--r--tests/security/redirect_test.php2
-rw-r--r--tests/session/check_ban_test.php3
-rw-r--r--tests/template/context_test.php96
-rw-r--r--tests/template/template_includecss_test.php8
-rw-r--r--tests/template/template_includejs_test.php32
-rw-r--r--tests/template/template_test.php42
-rw-r--r--tests/template/templates/loop_nested.html3
-rw-r--r--tests/test_framework/phpbb_database_test_case.php79
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php10
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php32
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php7
-rw-r--r--tests/test_framework/phpbb_ui_test_case.php63
-rw-r--r--tests/text_formatter/s9e/bbcode_merger_test.php280
-rw-r--r--tests/text_formatter/s9e/default_formatting_test.php40
-rw-r--r--tests/text_formatter/s9e/factory_test.php34
-rw-r--r--tests/text_formatter/s9e/fixtures/malformed_bbcode.xml28
-rw-r--r--tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html40
-rw-r--r--tests/text_formatter/s9e/fixtures/unsafe_default_bbcodes.xml24
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-10122.html2
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-10268.html4
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-13641.html2
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-13921.html2
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-14706.html2
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-14790.html8
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-14846.html2
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-15348.html2
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-16053.html1
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-16053.txt1
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-16053.xml28
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-16074.html1
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-16074.txt1
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-8419.html2
-rw-r--r--tests/text_reparser/base_test.php15
-rw-r--r--tests/text_reparser/fixtures/base.xml8
-rw-r--r--tests/text_reparser/plugins/fixtures/polls.xml11
-rw-r--r--tests/tree/nestedset_forum_base.php20
-rw-r--r--tests/upload/filespec_test.php2
-rw-r--r--tests/upload/fileupload_test.php12
-rw-r--r--tests/wrapper/version_compare_test.php2
110 files changed, 2190 insertions, 434 deletions
diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md
index c9941d61e5..12ae7fa687 100644
--- a/tests/RUNNING_TESTS.md
+++ b/tests/RUNNING_TESTS.md
@@ -143,14 +143,14 @@ If you want all tests, run:
Functional tests
------------------
+================
Functional tests test software the way a user would. They simulate a user
browsing the website, but they do these steps in an automated way.
phpBB allows you to write such tests.
Running
-=======
+-------
Running the tests requires your phpBB3 repository to be accessible through a
local web server. You will need to supply the URL to the webserver in
@@ -170,6 +170,27 @@ If you only want the functional tests, run:
This will change your board's config.php file, but it makes a backup at
config_dev.php, so you can restore it after the test run is complete.
+UI tests
+========
+
+UI tests are functional tests that also support running JavaScript in a
+headless browser. These should be used when functionality that is only
+executed using JS needs to be tested. They require a running
+[PhantomJS WebDriver instance](http://phantomjs.org/). The executable can
+either be downloaded from [PhantomJS](http://phantomjs.org/download.html)
+or alternatively be installed with npm:
+
+ $ npm install -g phantomjs-prebuilt
+
+You might have to run the command as superuser / administrator on some
+systems. Afterwards, a new WebDriver instance can be started via command
+line:
+
+ $ phantomjs --webdriver=127.0.0.1:8910
+
+Port 8910 is the default port that will be used by UI tests to connect
+to the WebDriver instance.
+
More Information
================
diff --git a/tests/attachment/fixtures/resync.xml b/tests/attachment/fixtures/resync.xml
index 6e2cc62f68..af04701b4a 100644
--- a/tests/attachment/fixtures/resync.xml
+++ b/tests/attachment/fixtures/resync.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_attachments">
+ <column>attach_id</column>
<column>post_msg_id</column>
<column>topic_id</column>
<column>in_message</column>
@@ -11,6 +12,7 @@
<row>
<value>1</value>
<value>1</value>
+ <value>1</value>
<value>0</value>
<value>0</value>
<value>foo</value>
@@ -18,6 +20,7 @@
<value>0</value>
</row>
<row>
+ <value>2</value>
<value>1</value>
<value>1</value>
<value>1</value>
@@ -27,6 +30,7 @@
<value>0</value>
</row>
<row>
+ <value>3</value>
<value>1</value>
<value>1</value>
<value>1</value>
@@ -37,13 +41,16 @@
</row>
</table>
<table name="phpbb_extensions">
+ <column>extension_id</column>
<column>extension</column>
<column>group_id</column>
<row>
+ <value>1</value>
<value>jpg</value>
<value>1</value>
</row>
<row>
+ <value>2</value>
<value>png</value>
<value>1</value>
</row>
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index 9e826a3a59..d1e907b53d 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -99,7 +99,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
$this->config['allow_avatar_' . get_class($this->avatar_barfoo)] = false;
// Set up avatar manager
- $this->manager = new \phpbb\avatar\manager($this->config, $avatar_drivers, $phpbb_container);
+ $this->manager = new \phpbb\avatar\manager($this->config, $dispatcher, $avatar_drivers);
$this->db = $this->new_dbal();
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
@@ -185,7 +185,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
$avatar_settings = $this->manager->get_avatar_settings($this->avatar_foobar);
$expected_settings = array(
- 'allow_avatar_' . get_class($this->avatar_foobar) => array('lang' => 'ALLOW_' . strtoupper(get_class($this->avatar_foobar)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
+ 'allow_avatar_' . get_class($this->avatar_foobar) => array('lang' => 'ALLOW_' . strtoupper(get_class($this->avatar_foobar)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
);
$this->assertEquals($expected_settings, $avatar_settings);
diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php
index 9de1d82a15..57f640c313 100644
--- a/tests/cache/apcu_driver_test.php
+++ b/tests/cache/apcu_driver_test.php
@@ -49,10 +49,27 @@ class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case
protected function setUp()
{
+ global $phpbb_container, $phpbb_root_path;
+
parent::setUp();
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
+
$this->driver = new \phpbb\cache\driver\apcu;
$this->driver->purge();
}
+
+ public function test_purge()
+ {
+ /* add a cache entry which does not match our key */
+ $foreign_key = 'test_' . $this->driver->key_prefix . 'test';
+ $this->assertSame(true, apcu_store($foreign_key, 0, 600));
+ $this->assertSame(true, apcu_exists($foreign_key));
+
+ parent::test_purge();
+
+ $this->assertSame(true, apcu_exists($foreign_key));
+ }
}
diff --git a/tests/cache/cache_memory.php b/tests/cache/cache_memory.php
index 806edb963a..565e9a48eb 100644
--- a/tests/cache/cache_memory.php
+++ b/tests/cache/cache_memory.php
@@ -18,7 +18,7 @@ class phpbb_cache_memory extends \phpbb\cache\driver\memory
/**
* Set cache path
*/
- function phpbb_cache_memory()
+ function __construct()
{
}
diff --git a/tests/cache/cache_memory_test.php b/tests/cache/cache_memory_test.php
index 9f92e8d8dc..ba1010bcf3 100644
--- a/tests/cache/cache_memory_test.php
+++ b/tests/cache/cache_memory_test.php
@@ -116,7 +116,7 @@ class phpbb_cache_memory_test extends phpbb_database_test_case
$results[] = $row;
}
$this->cache->sql_freeresult($query_id);
- $this->assertEquals($query[1], sizeof($results));
+ $this->assertEquals($query[1], count($results));
}
$this->cache->destroy('sql', $table);
diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php
index 439e3623fa..e425d998a2 100644
--- a/tests/console/thumbnail_test.php
+++ b/tests/console/thumbnail_test.php
@@ -46,7 +46,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
$config = $this->config = new \phpbb\config\config(array(
'img_min_thumb_filesize' => 2,
'img_max_thumb_width' => 2,
- 'img_imagick' => '',
+ 'upload_path' => 'files',
));
$this->db = $this->db = $this->new_dbal();
@@ -64,8 +64,8 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
)));
$this->application = new Application();
- $this->application->add(new generate($this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx));
- $this->application->add(new delete($this->user, $this->db, $this->phpbb_root_path));
+ $this->application->add(new generate($config, $this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx));
+ $this->application->add(new delete($config, $this->user, $this->db, $this->phpbb_root_path));
$this->application->add(new recreate($this->user));
$phpbb_filesystem = new \phpbb\filesystem\filesystem();
diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php
index 8641bf87b6..bdfb8a8d2a 100644
--- a/tests/console/user/add_test.php
+++ b/tests/console/user/add_test.php
@@ -14,12 +14,15 @@
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use phpbb\console\command\user\add;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Question\Question;
require_once dirname(__FILE__) . '/base.php';
class phpbb_console_user_add_test extends phpbb_console_user_base
{
- public function get_command_tester()
+ public function get_command_tester($question_answers = [])
{
$application = new Application();
$application->add(new add(
@@ -34,7 +37,42 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
$command = $application->find('user:add');
$this->command_name = $command->getName();
- $this->question = $command->getHelper('question');
+
+ if (!empty($question_answers))
+ {
+ $ask = function(InputInterface $input, OutputInterface $output, Question $question) use ($question_answers)
+ {
+ $text = $question->getQuestion();
+
+ // handle a question
+ foreach ($question_answers as $expected_question => $answer)
+ {
+ if (strpos($text, $expected_question) !== false)
+ {
+ $response = $answer;
+ }
+ }
+
+ if (!isset($response))
+ {
+ throw new \RuntimeException('Was asked for input on an unhandled question: ' . $text);
+ }
+
+ $output->writeln(print_r($response, true));
+ return $response;
+ };
+ $helper = $this->getMock('\Symfony\Component\Console\Helper\QuestionHelper', array('ask'));
+ $helper->expects($this->any())
+ ->method('ask')
+ ->will($this->returnCallback($ask));
+ $this->question = $helper;
+ $command->getHelperSet()->set($helper, 'question');
+ }
+ else
+ {
+ $this->question = $command->getHelper('question');
+ }
+
return new CommandTester($command);
}
@@ -57,7 +95,11 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
public function test_add_dialog()
{
- $command_tester = $this->get_command_tester();
+ $command_tester = $this->get_command_tester([
+ 'USERNAME' => 'bar',
+ 'PASSWORD' => 'password',
+ 'EMAIL_ADDRESS' => 'bar@test.com',
+ ]);
$this->assertEquals(2, $this->get_user_id('Admin'));
diff --git a/tests/console/user/base.php b/tests/console/user/base.php
index b84c0bb267..ad328ac893 100644
--- a/tests/console/user/base.php
+++ b/tests/console/user/base.php
@@ -94,6 +94,11 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
'auth.provider_collection',
$provider_collection
);
+ $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens');
+ $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states');
+ $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts');
+
+ $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
parent::setUp();
}
diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php
index f4dd69b19b..76f8c753bf 100644
--- a/tests/cron/manager_test.php
+++ b/tests/cron/manager_test.php
@@ -40,7 +40,7 @@ class phpbb_cron_manager_test extends \phpbb_test_case
public function test_manager_finds_all_ready_tasks()
{
$tasks = $this->manager->find_all_ready_tasks();
- $this->assertEquals(3, sizeof($tasks));
+ $this->assertEquals(3, count($tasks));
}
public function test_manager_finds_one_ready_task()
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index f9243e7266..0365463a48 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -203,8 +203,15 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_list_columns()
{
+ $config = $this->get_database_config();
+ $table_columns = $this->table_data['COLUMNS'];
+
+ if (strpos($config['dbms'], 'mssql') !== false)
+ {
+ ksort($table_columns);
+ }
$this->assertEquals(
- array_keys($this->table_data['COLUMNS']),
+ array_keys($table_columns),
array_values($this->tools->sql_list_columns('prefix_table_name'))
);
}
@@ -432,28 +439,37 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->markTestIncomplete('The table prefix length is too long for proper testing of index shortening function.');
}
+ $max_index_length = 30;
+
+ if ($this->tools instanceof \phpbb\db\tools\mssql)
+ {
+ $max_length_method = new ReflectionMethod('\phpbb\db\tools\mssql', 'get_max_index_name_length');
+ $max_length_method->setAccessible(true);
+ $max_index_length = $max_length_method->invoke($this->tools);
+ }
+
$table_suffix = str_repeat('a', 25 - strlen($table_prefix));
$table_name = $table_prefix . $table_suffix;
$this->tools->sql_create_table($table_name, $this->table_data);
- // Index name and table suffix and table prefix have > 30 chars in total.
- // Index name and table suffix have <= 30 chars in total.
- $long_index_name = str_repeat('i', 30 - strlen($table_suffix));
+ // Index name and table suffix and table prefix have > maximum index length chars in total.
+ // Index name and table suffix have <= maximum index length chars in total.
+ $long_index_name = str_repeat('i', $max_index_length - strlen($table_suffix));
$this->assertFalse($this->tools->sql_index_exists($table_name, $long_index_name));
$this->assertTrue($this->tools->sql_create_index($table_name, $long_index_name, array('c_timestamp')));
$this->assertTrue($this->tools->sql_index_exists($table_name, $long_index_name));
- // Index name and table suffix have > 30 chars in total.
- $very_long_index_name = str_repeat('i', 30);
+ // Index name and table suffix have > maximum index length chars in total.
+ $very_long_index_name = str_repeat('i', $max_index_length);
$this->assertFalse($this->tools->sql_index_exists($table_name, $very_long_index_name));
$this->assertTrue($this->tools->sql_create_index($table_name, $very_long_index_name, array('c_timestamp')));
$this->assertTrue($this->tools->sql_index_exists($table_name, $very_long_index_name));
$this->tools->sql_table_drop($table_name);
- // Index name has > 30 chars - that should not be possible.
- $too_long_index_name = str_repeat('i', 31);
+ // Index name has > maximum index length chars - that should not be possible.
+ $too_long_index_name = str_repeat('i', $max_index_length + 1);
$this->assertFalse($this->tools->sql_index_exists('prefix_table_name', $too_long_index_name));
$this->setExpectedTriggerError(E_USER_ERROR);
$this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp'));
diff --git a/tests/dbal/ext/foo/bar/acp/acp_test_info.php b/tests/dbal/ext/foo/bar/acp/acp_test_info.php
new file mode 100644
index 0000000000..ac92623c3a
--- /dev/null
+++ b/tests/dbal/ext/foo/bar/acp/acp_test_info.php
@@ -0,0 +1,37 @@
+<?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.
+*
+*/
+
+namespace foo\bar\acp;
+
+class acp_test_info
+{
+ public function module()
+ {
+ return array(
+ 'filename' => '\foo\bar\acp\acp_test_module',
+ 'title' => 'ACP_NEW_MODULE',
+ 'modes' => array(
+ 'mode_1' => array(
+ 'title' => 'ACP_NEW_MODULE_MODE_1',
+ 'auth' => '',
+ 'cat' => array('ACP_NEW_MODULE'),
+ ),
+ 'mode_2' => array(
+ 'title' => 'ACP_NEW_MODULE_MODE_2',
+ 'auth' => '',
+ 'cat' => array('ACP_NEW_MODULE'),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/ext/foo/bar/acp/acp_test_module.php b/tests/dbal/ext/foo/bar/acp/acp_test_module.php
new file mode 100644
index 0000000000..01ce5c17dc
--- /dev/null
+++ b/tests/dbal/ext/foo/bar/acp/acp_test_module.php
@@ -0,0 +1,25 @@
+<?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.
+*
+*/
+
+namespace foo\bar\acp;
+
+class acp_test_module
+{
+ var $u_action;
+
+ function main($id, $mode)
+ {
+ $this->tpl_name = 'foobar';
+ $this->page_title = 'Bertie';
+ }
+}
diff --git a/tests/dbal/ext/foo/bar/composer.json b/tests/dbal/ext/foo/bar/composer.json
new file mode 100644
index 0000000000..2edfd43d84
--- /dev/null
+++ b/tests/dbal/ext/foo/bar/composer.json
@@ -0,0 +1,24 @@
+{
+ "name": "foo/bar",
+ "type": "phpbb-extension",
+ "description": "An example/sample extension to be used for testing purposes in phpBB Development.",
+ "version": "1.0.0",
+ "time": "2012-02-15 01:01:01",
+ "license": "GNU GPL v2",
+ "authors": [{
+ "name": "John Smith",
+ "username": "JohnSmith27",
+ "email": "email@phpbb.com",
+ "homepage": "http://phpbb.com",
+ "role": "N/A"
+ }],
+ "require": {
+ "php": ">=5.4.7"
+ },
+ "extra": {
+ "display-name": "phpBB BarFoo Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.2.*@dev"
+ }
+ }
+}
diff --git a/tests/dbal/ext/foo/bar/ucp/ucp_test_info.php b/tests/dbal/ext/foo/bar/ucp/ucp_test_info.php
new file mode 100644
index 0000000000..d3489af832
--- /dev/null
+++ b/tests/dbal/ext/foo/bar/ucp/ucp_test_info.php
@@ -0,0 +1,37 @@
+<?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.
+*
+*/
+
+namespace foo\bar\ucp;
+
+class ucp_test_info
+{
+ public function module()
+ {
+ return array(
+ 'filename' => '\foo\bar\ucp\ucp_test_module',
+ 'title' => 'UCP_NEW_MODULE',
+ 'modes' => array(
+ 'mode_1' => array(
+ 'title' => 'UCP_NEW_MODULE_MODE_1',
+ 'auth' => '',
+ 'cat' => array('UCP_NEW_MODULE'),
+ ),
+ 'mode_2' => array(
+ 'title' => 'UCP_NEW_MODULE_MODE_2',
+ 'auth' => '',
+ 'cat' => array('UCP_NEW_MODULE'),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/ext/foo/bar/ucp/ucp_test_module.php b/tests/dbal/ext/foo/bar/ucp/ucp_test_module.php
new file mode 100644
index 0000000000..b06b3238b6
--- /dev/null
+++ b/tests/dbal/ext/foo/bar/ucp/ucp_test_module.php
@@ -0,0 +1,25 @@
+<?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.
+*
+*/
+
+namespace foo\bar\ucp;
+
+class ucp_test_module
+{
+ var $u_action;
+
+ function main($id, $mode)
+ {
+ $this->tpl_name = 'foobar';
+ $this->page_title = 'Bertie';
+ }
+}
diff --git a/tests/dbal/fixtures/boolean_processor.xml b/tests/dbal/fixtures/boolean_processor.xml
index c5da677116..d31d679f45 100644
--- a/tests/dbal/fixtures/boolean_processor.xml
+++ b/tests/dbal/fixtures/boolean_processor.xml
@@ -60,25 +60,31 @@
<table name="phpbb_user_group">
<column>user_id</column>
<column>group_id</column>
+ <column>group_leader</column>
<row>
<value>1</value>
<value>1</value>
+ <value>2</value>
</row>
<row>
<value>2</value>
<value>1</value>
+ <value>2</value>
</row>
<row>
<value>3</value>
<value>1</value>
+ <value>2</value>
</row>
<row>
<value>4</value>
<value>2</value>
+ <value>2</value>
</row>
<row>
<value>5</value>
<value>2</value>
+ <value>2</value>
</row>
</table>
</dataset>
diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php
index 29b21166b6..e34ee7b59c 100644
--- a/tests/dbal/migrator_tool_module_test.php
+++ b/tests/dbal/migrator_tool_module_test.php
@@ -11,6 +11,9 @@
*
*/
+require_once dirname(__FILE__) . '/ext/foo/bar/acp/acp_test_info.php';
+require_once dirname(__FILE__) . '/ext/foo/bar/ucp/ucp_test_info.php';
+
class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
{
public function getDataSet()
@@ -39,6 +42,9 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$auth = $this->getMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
+ // Correctly set the root path for this test to this directory, so the classes can be found
+ $phpbb_root_path = dirname(__FILE__) . '/';
+
$phpbb_extension_manager = new phpbb_mock_extension_manager($phpbb_root_path);
$module_manager = new \phpbb\module\module_manager($cache, $this->db, $phpbb_extension_manager, MODULES_TABLE, $phpbb_root_path, $phpEx);
@@ -52,11 +58,39 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
array(
'',
'ACP_CAT',
+ false,
true,
),
array(
0,
'ACP_CAT',
+ false,
+ true,
+ ),
+ array(
+ false,
+ 'ACP_CAT',
+ false,
+ true,
+ ),
+
+ // Test the existing category lazily
+ array(
+ '',
+ 'ACP_CAT',
+ true,
+ true,
+ ),
+ array(
+ 0,
+ 'ACP_CAT',
+ true,
+ true,
+ ),
+ array(
+ false,
+ 'ACP_CAT',
+ true,
true,
),
@@ -65,16 +99,39 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
'',
'ACP_MODULE',
false,
+ false,
+ ),
+ array(
+ false,
+ 'ACP_MODULE',
+ false,
+ true,
+ ),
+ array(
+ 'ACP_CAT',
+ 'ACP_MODULE',
+ false,
+ true,
+ ),
+
+ // Test the existing module lazily
+ array(
+ '',
+ 'ACP_MODULE',
+ true,
+ false,
),
array(
false,
'ACP_MODULE',
true,
+ true,
),
array(
'ACP_CAT',
'ACP_MODULE',
true,
+ true,
),
// Test for non-existant modules
@@ -82,10 +139,38 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
'',
'ACP_NON_EXISTANT_CAT',
false,
+ false,
+ ),
+ array(
+ false,
+ 'ACP_NON_EXISTANT_CAT',
+ false,
+ false,
+ ),
+ array(
+ 'ACP_CAT',
+ 'ACP_NON_EXISTANT_MODULE',
+ false,
+ false,
+ ),
+
+ // Test for non-existant modules lazily
+ array(
+ '',
+ 'ACP_NON_EXISTANT_CAT',
+ true,
+ false,
+ ),
+ array(
+ false,
+ 'ACP_NON_EXISTANT_CAT',
+ true,
+ false,
),
array(
'ACP_CAT',
'ACP_NON_EXISTANT_MODULE',
+ true,
false,
),
);
@@ -94,9 +179,9 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
/**
* @dataProvider exists_data_acp
*/
- public function test_exists_acp($parent, $module, $expected)
+ public function test_exists_acp($parent, $module, $lazy, $expected)
{
- $this->assertEquals($expected, $this->tool->exists('acp', $parent, $module));
+ $this->assertEquals($expected, $this->tool->exists('acp', $parent, $module, $lazy));
}
public function exists_data_ucp()
@@ -106,12 +191,40 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
array(
'',
'UCP_MAIN_CAT',
+ false,
+ true,
+ ),
+ array(
+ 0,
+ 'UCP_MAIN_CAT',
+ false,
+ true,
+ ),
+ array(
+ false,
+ 'UCP_MAIN_CAT',
+ false,
+ true,
+ ),
+
+ // Test the existing category lazily
+ array(
+ '',
+ 'UCP_MAIN_CAT',
+ true,
true,
),
array(
0,
'UCP_MAIN_CAT',
true,
+ true,
+ ),
+ array(
+ false,
+ 'UCP_MAIN_CAT',
+ true,
+ true,
),
// Test the existing module
@@ -119,21 +232,51 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
'',
'UCP_SUBCATEGORY',
false,
+ false,
+ ),
+ array(
+ false,
+ 'UCP_SUBCATEGORY',
+ false,
+ true,
+ ),
+ array(
+ 'UCP_MAIN_CAT',
+ 'UCP_SUBCATEGORY',
+ false,
+ true,
+ ),
+ array(
+ 'UCP_SUBCATEGORY',
+ 'UCP_MODULE',
+ false,
+ true,
+ ),
+
+ // Test the existing module lazily
+ array(
+ '',
+ 'UCP_SUBCATEGORY',
+ true,
+ false,
),
array(
false,
'UCP_SUBCATEGORY',
true,
+ true,
),
array(
'UCP_MAIN_CAT',
'UCP_SUBCATEGORY',
true,
+ true,
),
array(
'UCP_SUBCATEGORY',
'UCP_MODULE',
true,
+ true,
),
// Test for non-existant modules
@@ -141,10 +284,26 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
'',
'UCP_NON_EXISTANT_CAT',
false,
+ false,
+ ),
+ array(
+ 'UCP_MAIN_CAT',
+ 'UCP_NON_EXISTANT_MODULE',
+ false,
+ false,
+ ),
+
+ // Test for non-existant modules lazily
+ array(
+ '',
+ 'UCP_NON_EXISTANT_CAT',
+ true,
+ false,
),
array(
'UCP_MAIN_CAT',
'UCP_NON_EXISTANT_MODULE',
+ true,
false,
),
);
@@ -153,9 +312,9 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
/**
* @dataProvider exists_data_ucp
*/
- public function test_exists_ucp($parent, $module, $expected)
+ public function test_exists_ucp($parent, $module, $lazy, $expected)
{
- $this->assertEquals($expected, $this->tool->exists('ucp', $parent, $module));
+ $this->assertEquals($expected, $this->tool->exists('ucp', $parent, $module, $lazy));
}
public function test_add()
@@ -195,25 +354,6 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
// Test adding module when plural parent module_langname exists
// PHPBB3-14703
- // Adding fail
- try
- {
- $this->tool->add('acp', 'ACP_FORUM_BASED_PERMISSIONS', array(
- 'module_basename' => 'acp_new_permissions_module',
- 'module_langname' => 'ACP_NEW_PERMISSIONS_MODULE',
- 'module_mode' => 'test',
- 'module_auth' => '',
- ));
- $this->fail('Exception not thrown');
- }
- catch (Exception $e)
- {
- $this->assertEquals('phpbb\db\migration\exception', get_class($e));
- $this->assertEquals('MODULE_EXIST_MULTIPLE', $e->getMessage());
- }
-
- // Test adding module when plural parent module_langname exists
- // PHPBB3-14703
// Adding success
try
{
@@ -269,6 +409,35 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$this->fail($e);
}
$this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_SUBCAT', 'UCP_NEW_MODULE'));
+
+ // Test adding new UCP module the automatic way, single mode
+ try
+ {
+ $this->tool->add('ucp', 'UCP_NEW_CAT', array(
+ 'module_basename' => '\foo\bar\ucp\ucp_test_module',
+ 'modes' => array('mode_1'),
+ ));
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_MODULE_MODE_1'));
+ $this->assertEquals(false, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_MODULE_MODE_2'));
+
+ // Test adding new ACP module the automatic way, all modes
+ try
+ {
+ $this->tool->add('acp', 'ACP_NEW_CAT', array(
+ 'module_basename' => '\foo\bar\acp\acp_test_module',
+ ));
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE_MODE_1'));
+ $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE_MODE_2'));
}
public function test_remove()
diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php
index d84f6a68ff..ccad6a1387 100644
--- a/tests/dbal/migrator_tool_permission_test.php
+++ b/tests/dbal/migrator_tool_permission_test.php
@@ -163,7 +163,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
$this->assertFalse($this->tool->exists('global_test', true));
}
- public function test_permission_set_data()
+ public function data_test_permission_set()
{
return array(
array(
@@ -188,7 +188,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
}
/**
- * @dataProvider test_permission_set_data
+ * @dataProvider data_test_permission_set
*/
public function test_permission_set($group_name, $auth_option, $type, $has_permission)
{
diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php
index 98709fb043..4fa5cc37a2 100644
--- a/tests/dbal/write_test.php
+++ b/tests/dbal/write_test.php
@@ -67,7 +67,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
- $this->assertEquals(1, sizeof($rows));
+ $this->assertEquals(1, count($rows));
$this->assertEquals('config2', $rows[0]['config_name']);
$db->sql_freeresult($result);
diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php
index 273284c8fc..8ed89bbe52 100644
--- a/tests/error_collector_test.php
+++ b/tests/error_collector_test.php
@@ -52,8 +52,8 @@ class phpbb_error_collector_test extends phpbb_test_case
1/0; $line = __LINE__;
// Cause a notice
- $array = array('ITEM' => 'value');
- $value = $array[ITEM]; $line2 = __LINE__;
+ $array = array(0 => 'value');
+ $value = $array[1]; $line2 = __LINE__;
$collector->uninstall();
diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php
index 7bba5bf337..da28d24daa 100644
--- a/tests/event/dispatcher_test.php
+++ b/tests/event/dispatcher_test.php
@@ -29,5 +29,21 @@ class phpbb_event_dispatcher_test extends phpbb_test_case
$result = $dispatcher->trigger_event('core.test_event', compact($vars));
$this->assertSame(array('foo' => 'foo2', 'bar' => 'bar2'), $result);
+
+ // Test migrating events
+ $dispatcher->addListener('core.foo_br', function(\phpbb\event\data $event) {
+ $event['pi'] = '3.14159';
+ });
+ $dispatcher->addListener('core.foo_bar', function(\phpbb\event\data $event) {
+ $event['pi'] = '3.1';
+ });
+
+
+ $pi = '3';
+
+ $vars = array('pi');
+ $result = $dispatcher->trigger_event(['core.foo_bar', 'core.foo_br'], compact($vars));
+
+ $this->assertSame(array('pi' => '3.14159'), $result);
}
}
diff --git a/tests/event/fixtures/event_migration.test b/tests/event/fixtures/event_migration.test
new file mode 100644
index 0000000000..b2df9f95df
--- /dev/null
+++ b/tests/event/fixtures/event_migration.test
@@ -0,0 +1,30 @@
+<?php
+
+ /**
+ * Modify pm and sender data before it is assigned to the template
+ *
+ * @event core.ucp_pm_view_message
+ * @var mixed id Active module category (can be int or string)
+ * @var string mode Active module
+ * @var int folder_id ID of the folder the message is in
+ * @var int msg_id ID of the private message
+ * @var array folder Array with data of user's message folders
+ * @var array message_row Array with message data
+ * @var array cp_row Array with senders custom profile field data
+ * @var array msg_data Template array with message data
+ * @var array user_info User data of the sender
+ * @since 3.1.0-a1
+ * @changed 3.1.6-RC1 Added user_info into event
+ */
+ $vars = array(
+ 'id',
+ 'mode',
+ 'folder_id',
+ 'msg_id',
+ 'folder',
+ 'message_row',
+ 'cp_row',
+ 'msg_data',
+ 'user_info',
+ );
+ extract($phpbb_dispatcher->trigger_event(['core.ucp_pm_view_message', 'core.ucp_pm_view_messsage'], compact($vars)));
diff --git a/tests/event/fixtures/extra_description.test b/tests/event/fixtures/extra_description.test
index ce8f97ce89..e93a1044ac 100644
--- a/tests/event/fixtures/extra_description.test
+++ b/tests/event/fixtures/extra_description.test
@@ -3,7 +3,7 @@
/**
* Description
*
-* NOTE: This will not be exported
+* NOTE: This will also be exported
*
* @event extra_description.dispatch
* @since 3.1.0-b2
diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php
index 607f442fdf..2eeb48ea05 100644
--- a/tests/event/md_exporter_test.php
+++ b/tests/event/md_exporter_test.php
@@ -92,7 +92,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
public function test_crawl_eventsmd($file, $min_version, $max_version, $events)
{
$exporter = new \phpbb\event\md_exporter(dirname(__FILE__) . '/fixtures/', null, $min_version, $max_version);
- $this->assertSame(sizeof($events), $exporter->crawl_eventsmd($file, 'adm'));
+ $this->assertSame(count($events), $exporter->crawl_eventsmd($file, 'adm'));
$this->assertEquals($events, $exporter->get_events());
}
@@ -146,7 +146,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
$exporter->crawl_eventsmd('docs/events.md', $filter);
$events = $exporter->crawl_file_for_events($file);
- $this->assertGreaterThanOrEqual(0, sizeof($events));
+ $this->assertGreaterThanOrEqual(0, count($events));
$this->assertTrue($exporter->validate_events_from_file($file, $events));
}
}
diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php
index 692a57f93c..c6670e1340 100644
--- a/tests/event/php_exporter_test.php
+++ b/tests/event/php_exporter_test.php
@@ -38,6 +38,18 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
),
),
array(
+ 'event_migration.test',
+ array(
+ 'core.ucp_pm_view_message' => array(
+ 'event' => 'core.ucp_pm_view_message',
+ 'file' => 'event_migration.test',
+ 'arguments' => array('cp_row', 'folder', 'folder_id', 'id', 'message_row', 'mode', 'msg_data', 'msg_id', 'user_info'),
+ 'since' => '3.1.0-a1',
+ 'description' => 'Modify pm and sender data before it is assigned to the template',
+ ),
+ ),
+ ),
+ array(
'extra_description.test',
array(
'extra_description.dispatch' => array(
@@ -45,7 +57,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
'file' => 'extra_description.test',
'arguments' => array(),
'since' => '3.1.0-b2',
- 'description' => 'Description',
+ 'description' => 'Description<br/><br/>NOTE: This will also be exported',
),
),
),
@@ -240,6 +252,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
array("\t\$phpbb_dispatcher->dispatch('dispatch.one2.thr_ee4');", 'dispatch.one2.thr_ee4'),
array("\$this->dispatcher->dispatch('dispatch.one2');", 'dispatch.one2'),
array("\$phpbb_dispatcher->dispatch('dis_patch.one');", 'dis_patch.one'),
+ array("\$phpbb_dispatcher->dispatch(['dis_patch.one', 'dis_patch.one2']);", 'dis_patch.one'),
+ array("\$phpbb_dispatcher->dispatch(['dis_patch.one', 'dis_patch.one2', 'dis_patch.two3']);", 'dis_patch.one'),
);
}
@@ -259,6 +273,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
array("\$phpbb_dispatcher->dispatch('');"),
array("\$phpbb_dispatcher->dispatch('dispatch.2one');"),
array("\$phpbb_dispatcher->dispatch('dispatch');"),
+ array("\$phpbb_dispatcher->dispatch(['dispatch.one']);"),
+ array("\$phpbb_dispatcher->dispatch(array('dispatch.one', 'dispatch.one2'));"),
);
}
@@ -279,6 +295,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
array("\textract(\$phpbb_dispatcher->trigger_event('dispatch.one2.thr_ee4', compact(\$vars)));", 'dispatch.one2.thr_ee4'),
array("extract(\$this->dispatcher->trigger_event('dispatch.one2', compact(\$vars)));", 'dispatch.one2'),
array("extract(\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars)));", 'dis_patch.one'),
+ array("extract(\$phpbb_dispatcher->trigger_event(['dis_patch.one', 'dis_patch.one2'], compact(\$vars)));", 'dis_patch.one'),
+ array("extract(\$phpbb_dispatcher->trigger_event(['dis_patch.one', 'dis_patch.one2', 'dis_patch.two3'], compact(\$vars)));", 'dis_patch.one'),
);
}
@@ -301,6 +319,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', \$vars));"),
array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$var)));"),
array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$array)));"),
+ array("extract(\$phpbb_dispatcher->trigger_event(['dispatch.one'], compact(\$vars)));"),
array("\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars));", 'dis_patch.one'),
);
}
diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php
index dd432d13f5..573218be42 100644
--- a/tests/feed/attachments_base_test.php
+++ b/tests/feed/attachments_base_test.php
@@ -31,13 +31,25 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case
$this->filesystem = new \phpbb\filesystem();
$config = new \phpbb\config\config(array());
+ $path_helper = new \phpbb\path_helper(
+ new \phpbb\symfony_request(
+ new phpbb_mock_request()
+ ),
+ $this->filesystem,
+ $this->getMock('\phpbb\request\request'),
+ $phpbb_root_path,
+ 'php'
+ );
$user = new \phpbb\user(
new \phpbb\language\language(
new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
),
'\phpbb\datetime'
);
- $feed_helper = new \phpbb\feed\helper($config, $user, $phpbb_root_path, $phpEx);
+ $container = new phpbb_mock_container_builder();
+ $this->get_test_case_helpers()->set_s9e_services($container);
+ $container->set('feed.quote_helper', new \phpbb\feed\quote_helper($user, $phpbb_root_path, 'php'));
+ $feed_helper = new \phpbb\feed\helper($config, $container, $path_helper, $container->get('text_formatter.renderer'), $user);
$db = $this->new_dbal();
$cache = new \phpbb_mock_cache();
$auth = new \phpbb\auth\auth();
diff --git a/tests/functional/acp_attachments_test.php b/tests/functional/acp_attachments_test.php
deleted file mode 100644
index 8e810a508a..0000000000
--- a/tests/functional/acp_attachments_test.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?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.
- *
- */
-
-/**
- * @group functional
- */
-class phpbb_functional_acp_attachments_test extends phpbb_functional_test_case
-{
- public function data_imagick_path_linux()
- {
- return array(
- array('/usr/bin', 'Configuration updated successfully'),
- array('/usr/foobar', 'The entered path “/usr/foobar” does not exist.'),
- array('/usr/bin/which', 'The entered path “/usr/bin/which” is not a directory.'),
- );
- }
-
- /**
- * @dataProvider data_imagick_path_linux
- */
- public function test_imagick_path_linux($imagick_path, $expected)
- {
- if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux')
- {
- $this->markTestSkipped('Unable to test linux specific paths on other OS.');
- }
-
- $this->login();
- $this->admin_login();
-
- $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid);
-
- $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path));
-
- $crawler = self::submit($form);
- $this->assertContains($expected, $crawler->filter('#main')->text());
- }
-
- public function data_imagick_path_windows()
- {
- return array(
- array('C:\Windows', 'Configuration updated successfully'),
- array('C:\Windows\foobar1', 'The entered path “C:\Windows\foobar1” does not exist.'),
- array('C:\Windows\explorer.exe', 'The entered path “C:\Windows\explorer.exe” is not a directory.'),
- );
- }
-
- /**
- * @dataProvider data_imagick_path_windows
- */
- public function test_imagick_path_windows($imagick_path, $expected)
- {
- if (strtolower(substr(PHP_OS, 0, 3)) !== 'win')
- {
- $this->markTestSkipped('Unable to test windows specific paths on other OS.');
- }
-
- $this->login();
- $this->admin_login();
-
- $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid);
-
- $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path));
-
- $crawler = self::submit($form);
- $this->assertContains($expected, $crawler->filter('#main')->text());
- }
-}
diff --git a/tests/functional/acp_profile_field_test.php b/tests/functional/acp_profile_field_test.php
index 88df782faa..7a0a6ca941 100644
--- a/tests/functional/acp_profile_field_test.php
+++ b/tests/functional/acp_profile_field_test.php
@@ -28,18 +28,20 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case
public function data_add_profile_field()
{
return array(
- array('bool', 'profilefields.type.bool',
+ array('profilefields.type.bool',
array(
+ 'field_ident' => 'bool',
+ 'lang_name' => 'bool',
'lang_options[0]' => 'foo',
'lang_options[1]' => 'bar',
),
- array(),
),
- array('dropdown', 'profilefields.type.dropdown',
+ array('profilefields.type.dropdown',
array(
+ 'field_ident' => 'dropdown',
+ 'lang_name' => 'dropdown',
'lang_options' => "foo\nbar\nbar\nfoo",
),
- array(),
),
);
}
@@ -47,13 +49,12 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case
/**
* @dataProvider data_add_profile_field
*/
- public function test_add_profile_field($name, $type, $page1_settings, $page2_settings)
+ public function test_add_profile_field($type, $page1_settings)
{
// Custom profile fields page
$crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid);
// these language strings are html
$form = $crawler->selectButton('Create new field')->form(array(
- 'field_ident' => $name,
'field_type' => $type,
));
$crawler = self::submit($form);
@@ -63,7 +64,7 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case
$crawler = self::submit($form);
// Fill form for profile field specific options
- $form = $crawler->selectButton('Save')->form($page2_settings);
+ $form = $crawler->selectButton('Save')->form();
$crawler= self::submit($form);
$this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text());
diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php
index 8a71a5ce04..ce0f4911e3 100644
--- a/tests/functional/extension_acp_test.php
+++ b/tests/functional/extension_acp_test.php
@@ -26,7 +26,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/../extension/ext/', self::$fixtures);
}
@@ -133,7 +133,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
for ($i = 0; $i < $crawler->filter('dl')->count(); $i++)
{
- $text = $crawler->filter('dl')->eq($i)->text();
+ $text = trim($crawler->filter('dl')->eq($i)->text());
$match = false;
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 18eb9ad4c6..58c3878b8b 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -34,7 +34,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php
index f615114c08..a1e2547745 100644
--- a/tests/functional/extension_global_lang_test.php
+++ b/tests/functional/extension_global_lang_test.php
@@ -30,7 +30,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php
index 95107665cd..d3a66b9b35 100644
--- a/tests/functional/extension_module_test.php
+++ b/tests/functional/extension_module_test.php
@@ -29,7 +29,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php
index 92d8d596c7..f570d45215 100644
--- a/tests/functional/extension_permission_lang_test.php
+++ b/tests/functional/extension_permission_lang_test.php
@@ -30,7 +30,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index d381fa1ae2..b0780172ff 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -99,7 +99,6 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
$form = $crawler->selectButton('Submit')->form(array(
'config[check_attachment_content]' => 0,
- 'config[img_imagick]' => '',
));
self::submit($form);
diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php
index 88f8999005..426ebcee53 100644
--- a/tests/functional/fileupload_remote_test.php
+++ b/tests/functional/fileupload_remote_test.php
@@ -102,7 +102,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
->set_allowed_extensions(array('gif'))
->set_max_filesize(2000);
$file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif');
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
$this->assertTrue(file_exists($file->get('filename')));
$this->assertTrue($file->is_uploaded());
}
@@ -115,7 +115,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
->set_allowed_extensions(array('gif'))
->set_max_filesize(100);
$file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif');
- $this->assertEquals(1, sizeof($file->error));
+ $this->assertEquals(1, count($file->error));
$this->assertEquals('WRONG_FILESIZE', $file->error[0]);
}
}
diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php
index 0d2fdf082e..8456c40f00 100644
--- a/tests/functional/metadata_manager_test.php
+++ b/tests/functional/metadata_manager_test.php
@@ -35,7 +35,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index 8e6328d1d3..764376a945 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -235,7 +235,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
));
$crawler = self::submit($form);
$this->assertContains(
- '<span style="font-weight: bold">My signature</span>',
+ '<strong class="text-strong">My signature</strong>',
$crawler->filter('#preview .signature')->html()
);
}
diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php
index 3da78407cf..2361eed066 100644
--- a/tests/functional/user_password_reset_test.php
+++ b/tests/functional/user_password_reset_test.php
@@ -21,25 +21,56 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
public function test_password_reset()
{
$this->add_lang('ucp');
- $user_id = $this->create_user('reset-password-test-user');
+ $user_id = $this->create_user('reset-password-test-user', 'reset-password-test-user@test.com');
+ // test without email
+ $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
+ $form = $crawler->selectButton('submit')->form();
+ $crawler = self::submit($form);
+ $this->assertContainsLang('NO_EMAIL_USER', $crawler->text());
+
+ // test with non-existent email
$crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
$form = $crawler->selectButton('submit')->form(array(
- 'username' => 'reset-password-test-user',
+ 'email' => 'non-existent@email.com',
));
$crawler = self::submit($form);
- $this->assertContainsLang('NO_EMAIL_USER', $crawler->text());
+ $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text());
+ // test with correct email
$crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
$form = $crawler->selectButton('submit')->form(array(
- 'username' => 'reset-password-test-user',
- 'email' => 'nobody@example.com',
+ 'email' => 'reset-password-test-user@test.com',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text());
+
+ // Check if columns in database were updated for password reset
+ $this->get_user_data('reset-password-test-user');
+ $this->assertNotNull($this->user_data['user_actkey']);
+ $this->assertNotNull($this->user_data['user_newpasswd']);
+
+ // Create another user with the same email
+ $this->create_user('reset-password-test-user1', 'reset-password-test-user@test.com');
+
+ // Test that username is now also required
+ $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
+ $form = $crawler->selectButton('submit')->form(array(
+ 'email' => 'reset-password-test-user@test.com',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContainsLang('EMAIL_NOT_UNIQUE', $crawler->text());
+
+ // Provide both username and email
+ $form = $crawler->selectButton('submit')->form(array(
+ 'email' => 'reset-password-test-user@test.com',
+ 'username' => 'reset-password-test-user1',
));
$crawler = self::submit($form);
- $this->assertContainsLang('PASSWORD_UPDATED', $crawler->text());
+ $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text());
// Check if columns in database were updated for password reset
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user1');
$this->assertNotNull($this->user_data['user_actkey']);
$this->assertNotNull($this->user_data['user_newpasswd']);
@@ -73,7 +104,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
public function test_activate_new_password($expected, $user_id, $act_key)
{
$this->add_lang('ucp');
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user');
$user_id = (!$user_id) ? $this->user_data['user_id'] : $user_id;
$act_key = (!$act_key) ? $this->user_data['user_actkey'] : $act_key;
@@ -119,7 +150,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
public function test_acivateAfterDeactivate()
{
// User is active, actkey should not exist
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user');
$this->assertEmpty($this->user_data['user_actkey']);
$this->login();
@@ -143,7 +174,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
$crawler = self::request('GET', preg_replace('#(.+)(adm/index.php.+)#', '$2', $link->getUri()));
// Ensure again that actkey is empty after deactivation
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user');
$this->assertEmpty($this->user_data['user_actkey']);
// Force reactivation of account and check that act key is not empty anymore
@@ -152,16 +183,16 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
$crawler = self::submit($form, array('action' => 'reactivate'));
$this->assertContainsLang('FORCE_REACTIVATION_SUCCESS', $crawler->filter('html')->text());
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user');
$this->assertNotEmpty($this->user_data['user_actkey']);
}
- protected function get_user_data()
+ protected function get_user_data($username)
{
$db = $this->get_db();
$sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
FROM ' . USERS_TABLE . "
- WHERE username = 'reset-password-test-user'";
+ WHERE username = '" . $db->sql_escape($username) . "'";
$result = $db->sql_query($sql);
$this->user_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
diff --git a/tests/functions/fixtures/validate_username.xml b/tests/functions/fixtures/validate_username.xml
index 1b85a2f06d..add8f76553 100644
--- a/tests/functions/fixtures/validate_username.xml
+++ b/tests/functions/fixtures/validate_username.xml
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_groups">
+ <column>group_id</column>
<column>group_name</column>
<column>group_desc</column>
<row>
+ <value>10</value>
<value>foobar_group</value>
<value>test123</value>
</row>
diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php
index 1550aa37e6..75e5a6dc61 100644
--- a/tests/functions/get_remote_file_test.php
+++ b/tests/functions/get_remote_file_test.php
@@ -58,7 +58,7 @@ class phpbb_functions_get_remote_file extends phpbb_test_case
$this->assertGreaterThanOrEqual(
2,
- sizeof($lines),
+ count($lines),
'Failed asserting that the version file has at least two lines.'
);
diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php
index a351a6d527..a6af12b624 100644
--- a/tests/functions/make_clickable_test.php
+++ b/tests/functions/make_clickable_test.php
@@ -53,6 +53,14 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
'<!-- l --><a class="postlink-local" href="http://testhost/viewtopic.php?t=1">viewtopic.php?t=1</a><!-- l -->'
),
array(
+ 'javascript://testhost/viewtopic.php?t=1',
+ 'javascript://testhost/viewtopic.php?t=1'
+ ),
+ array(
+ "java\nscri\npt://testhost/viewtopic.php?t=1",
+ "java\nscri\n<!-- m --><a class=\"postlink\" href=\"pt://testhost/viewtopic.php?t=1\">pt://testhost/viewtopic.php?t=1</a><!-- m -->"
+ ),
+ array(
'email@domain.com',
'<!-- e --><a href="mailto:email@domain.com">email@domain.com</a><!-- e -->'
),
@@ -90,6 +98,10 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
'<!-- m --><a class="postlink" href="ftp://ftp.täst.de/">ftp://ftp.täst.de/</a><!-- m -->'
),
array(
+ 'javascript://täst.de/',
+ 'javascript://täst.de/'
+ ),
+ array(
'sip://bantu@täst.de',
'<!-- m --><a class="postlink" href="sip://bantu@täst.de">sip://bantu@täst.de</a><!-- m -->'
),
diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php
index db9b6e0c90..f419c90e9e 100644
--- a/tests/functions/user_delete_test.php
+++ b/tests/functions/user_delete_test.php
@@ -82,6 +82,12 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case
$phpbb_container->set('auth.provider.oauth.service.google', $oauth_provider_google);
$phpbb_container->set('auth.provider_collection', $provider_collection);
$phpbb_container->set('notification_manager', $notification_manager);
+
+ $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens');
+ $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states');
+ $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts');
+
+ $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
}
public function test_user_delete()
diff --git a/tests/functions/validate_username_test.php b/tests/functions/validate_username_test.php
index d310f58036..cee5d38400 100644
--- a/tests/functions/validate_username_test.php
+++ b/tests/functions/validate_username_test.php
@@ -47,6 +47,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case
'foobar_letter_num' => array(),
'foobar_letter_num_sp' => array(),
'foobar_quot' => array('INVALID_CHARS'),
+ 'foobar_emoji' => array('INVALID_EMOJIS'),
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
'admin_taken' => array('USERNAME_TAKEN'),
'group_taken' => array('USERNAME_TAKEN'),
@@ -60,6 +61,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case
'foobar_letter_num' => array(),
'foobar_letter_num_sp' => array('INVALID_CHARS'),
'foobar_quot' => array('INVALID_CHARS'),
+ 'foobar_emoji' => array('INVALID_EMOJIS'),
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
'admin_taken' => array('USERNAME_TAKEN'),
'group_taken' => array('INVALID_CHARS'),
@@ -73,6 +75,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case
'foobar_letter_num' => array(),
'foobar_letter_num_sp' => array('INVALID_CHARS'),
'foobar_quot' => array('INVALID_CHARS'),
+ 'foobar_emoji' => array('INVALID_EMOJIS'),
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
'admin_taken' => array('USERNAME_TAKEN'),
'group_taken' => array('USERNAME_TAKEN'),
@@ -86,6 +89,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case
'foobar_letter_num' => array(),
'foobar_letter_num_sp' => array('INVALID_CHARS'),
'foobar_quot' => array('INVALID_CHARS'),
+ 'foobar_emoji' => array('INVALID_EMOJIS'),
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
'admin_taken' => array('USERNAME_TAKEN'),
'group_taken' => array('INVALID_CHARS'),
@@ -99,6 +103,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case
'foobar_letter_num' => array(),
'foobar_letter_num_sp' => array(),
'foobar_quot' => array('INVALID_CHARS'),
+ 'foobar_emoji' => array('INVALID_EMOJIS'),
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
'admin_taken' => array('USERNAME_TAKEN'),
'group_taken' => array('USERNAME_TAKEN'),
@@ -112,6 +117,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case
'foobar_letter_num' => array(),
'foobar_letter_num_sp' => array('INVALID_CHARS'),
'foobar_quot' => array('INVALID_CHARS'),
+ 'foobar_emoji' => array('INVALID_EMOJIS'),
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
'admin_taken' => array('USERNAME_TAKEN'),
'group_taken' => array('USERNAME_TAKEN'),
@@ -173,6 +179,11 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case
'"foobar"',
array('username'),
),
+ 'foobar_emoji' => array(
+ $expected['foobar_emoji'],
+ 'username😮',
+ array('username'),
+ ),
'barfoo_disallow' => array(
$expected['barfoo_disallow'],
'barfoo',
diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php
index 5c31888291..3bd2204de9 100644
--- a/tests/functions_acp/validate_config_vars_test.php
+++ b/tests/functions_acp/validate_config_vars_test.php
@@ -19,10 +19,11 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
{
parent::setUp();
- global $user;
+ global $language, $user;
$user = new phpbb_mock_user();
$user->lang = new phpbb_mock_lang();
+ $language = $user->lang;
}
/**
@@ -44,6 +45,7 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
'test_int_32' => array('lang' => 'TEST_INT', 'validate' => 'int:32'),
'test_int_32_64' => array('lang' => 'TEST_INT', 'validate' => 'int:32:64'),
'test_lang' => array('lang' => 'TEST_LANG', 'validate' => 'lang'),
+ 'test_url' => array('lang' => 'TEST_URL', 'validate' => 'url'),
/*
'test_sp' => array('lang' => 'TEST_SP', 'validate' => 'script_path'),
'test_rpath' => array('lang' => 'TEST_RPATH', 'validate' => 'rpath'),
@@ -64,6 +66,7 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
'test_int_32' => 32,
'test_int_32_64' => 48,
'test_lang' => 'en',
+ 'test_url' => 'http://foobar.com',
),
),
);
@@ -148,6 +151,11 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
array('test_lang' => 'this_is_no_language'),
array('WRONG_DATA_LANG'),
),
+ array(
+ array('test_url' => array('lang' => 'TEST_URL', 'validate' => 'url')),
+ array('test_url' => 'javascript://foobar.com'),
+ array('URL_INVALID TEST_URL'),
+ ),
);
}
@@ -161,100 +169,4 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
$this->assertEquals($expected, $phpbb_error);
}
-
- public function data_validate_path_linux()
- {
- return array(
- array('/usr/bin', 'absolute_path', true),
- array('/usr/bin/', 'absolute_path:50:200', true),
- array('/usr/bin/which', 'absolute_path', 'DIRECTORY_NOT_DIR'),
- array('/foo/bar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
- array('C:\Windows', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
- array('.', 'absolute_path', true),
- array('', 'absolute_path', true),
- array('mkdir /foo/bar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
- // Make sure above command didn't do anything
- array('/foo/bar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
- );
- }
-
- /**
- * @dataProvider data_validate_path_linux
- */
- public function test_validate_path_linux($path, $validation_type, $expected)
- {
- if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux')
- {
- $this->markTestSkipped('Unable to test linux specific paths on other OS.');
- }
-
- $error = array();
- $config_ary = array(
- 'path' => $path,
- );
-
- validate_config_vars(array(
- 'path' => array('lang' => 'FOOBAR', 'validate' => $validation_type),
- ),
- $config_ary,
- $error
- );
-
- if ($expected === true)
- {
- $this->assertEmpty($error);
- }
- else
- {
- $this->assertEquals(array($expected), $error);
- }
- }
-
- public function data_validate_path_windows()
- {
- return array(
- array('C:\Windows', 'absolute_path', true),
- array('C:\Windows\\', 'absolute_path:50:200', true),
- array('C:\Windows\explorer.exe', 'absolute_path', 'DIRECTORY_NOT_DIR'),
- array('C:\foobar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
- array('/usr/bin', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
- array('.', 'absolute_path', true),
- array('', 'absolute_path', true),
- array('mkdir C:\Windows\foobar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
- // Make sure above command didn't do anything
- array('C:\Windows\foobar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
- );
- }
-
- /**
- * @dataProvider data_validate_path_windows
- */
- public function test_validate_path_windows($path, $validation_type, $expected)
- {
- if (strtolower(substr(PHP_OS, 0, 3)) !== 'win')
- {
- $this->markTestSkipped('Unable to test windows specific paths on other OS.');
- }
-
- $error = array();
- $config_ary = array(
- 'path' => $path,
- );
-
- validate_config_vars(array(
- 'path' => array('lang' => 'FOOBAR', 'validate' => $validation_type),
- ),
- $config_ary,
- $error
- );
-
- if ($expected === true)
- {
- $this->assertEmpty($error);
- }
- else
- {
- $this->assertEquals(array($expected), $error);
- }
- }
}
diff --git a/tests/functions_content/phpbb_format_quote_test.php b/tests/functions_content/phpbb_format_quote_test.php
new file mode 100644
index 0000000000..cbbd46d0a9
--- /dev/null
+++ b/tests/functions_content/phpbb_format_quote_test.php
@@ -0,0 +1,57 @@
+<?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/message_parser.php';
+
+class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case
+{
+ /** @var \phpbb\language\language */
+ protected $lang;
+
+ public function setUp()
+ {
+ global $cache, $user, $phpbb_root_path, $phpEx;
+
+ $lang_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $this->lang = new \phpbb\language\language($lang_file_loader);
+ $user = new \phpbb\user($this->lang, '\phpbb\datetime');
+ $cache = new phpbb_mock_cache();
+
+ parent::setUp();
+ }
+
+ public function data_phpbb_format_quote()
+ {
+ return [
+ [true, ['author' => 'admin', 'user_id' => 2], '[quote=&quot;username&quot;]quoted[/quote]', '', "[quote=admin user_id=2][quote=&quot;username&quot;]quoted[/quote][/quote]\n\n"],
+ [false, ['author' => 'admin', 'user_id' => 2], '[quote=&quot;username&quot;]quoted[/quote]', '', "admin wrote:\n&gt; [quote=&quot;username&quot;]quoted[/quote]\n"],
+ [true, ['author' => 'admin', 'user_id' => 2], '[quote=&quot;username&quot;]quoted[/quote]', "[url=http://viewtopic.php?p=1#p1]Subject: Foo[/url]\n\n", "[url=http://viewtopic.php?p=1#p1]Subject: Foo[/url]\n\n[quote=admin user_id=2][quote=&quot;username&quot;]quoted[/quote][/quote]\n\n"],
+ [false, ['author' => 'admin', 'user_id' => 2], '[quote=&quot;username&quot;]quoted[/quote]', "http://viewtopic.php?p=1#p1 - Subject: Foo\n\n", "http://viewtopic.php?p=1#p1 - Subject: Foo\n\nadmin wrote:\n&gt; [quote=&quot;username&quot;]quoted[/quote]\n"],
+ ];
+ }
+
+
+ /**
+ * @dataProvider data_phpbb_format_quote
+ */
+ public function test_phpbb_format_quote($bbcode_status, $quote_attributes, $message, $message_link, $expected)
+ {
+ $text_formatter_utils = new \phpbb\textformatter\s9e\utils();
+
+ $message_parser = new parse_message($message);
+
+ phpbb_format_quote($this->lang, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link);
+
+ $this->assertEquals($expected, $message_parser->message);
+ }
+}
diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php
index 25042d9f1b..09ed51890c 100644
--- a/tests/functions_user/delete_user_test.php
+++ b/tests/functions_user/delete_user_test.php
@@ -46,6 +46,11 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
'auth.provider_collection',
$provider_collection
);
+ $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens');
+ $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states');
+ $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts');
+
+ $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
}
public function first_last_post_data()
diff --git a/tests/functions_user/fixtures/delete_user.xml b/tests/functions_user/fixtures/delete_user.xml
index 56014b35d1..8de2659722 100644
--- a/tests/functions_user/fixtures/delete_user.xml
+++ b/tests/functions_user/fixtures/delete_user.xml
@@ -515,35 +515,44 @@
</table>
<table name="phpbb_privmsgs_folder">
<column>user_id</column>
+ <column>folder_id</column>
<row>
<value>2</value>
+ <value>1</value>
</row>
<row>
<value>3</value>
+ <value>2</value>
</row>
</table>
<table name="phpbb_privmsgs_rules">
<column>user_id</column>
<column>rule_string</column>
+ <column>rule_id</column>
<row>
<value>2</value>
<value></value>
+ <value>1</value>
</row>
<row>
<value>3</value>
<value></value>
+ <value>2</value>
</row>
</table>
<table name="phpbb_drafts">
<column>user_id</column>
<column>draft_message</column>
+ <column>draft_id</column>
<row>
<value>2</value>
<value></value>
+ <value>1</value>
</row>
<row>
<value>3</value>
<value></value>
+ <value>2</value>
</row>
</table>
</dataset>
diff --git a/tests/group/helper_get_name_string_test.php b/tests/group/helper_get_name_string_test.php
new file mode 100644
index 0000000000..c626328dcc
--- /dev/null
+++ b/tests/group/helper_get_name_string_test.php
@@ -0,0 +1,115 @@
+<?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__) . '/helper_test_case.php';
+
+class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_case
+{
+
+ public function get_name_string_profile_data()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ return array(
+ array(0, 'Non existing group', '', false, ''),
+ array(2, 'Administrators', 'AA0000', false, "{$phpbb_root_path}memberlist.$phpEx?mode=group&amp;g=2"),
+ array(42, 'Example Group', '', 'http://www.example.org/group.php?mode=show', 'http://www.example.org/group.php?mode=show&amp;g=42'),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_profile_data
+ */
+ public function test_get_name_string_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('profile', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+
+ public function get_name_string_group_name_data()
+ {
+ return array(
+ // Should be fine
+ array(0, 'BOTS', 'AA0000', false, 'Bots'),
+ array(1, 'new_group', '', false, 'Some new group'),
+ array(2, 'group_with_ümlauts', '', 'http://www.example.org/group.php?mode=show', 'Should work'),
+
+ // Should fail and thus return the same
+ array(3, 'not_uppercase', 'FFFFFF', false, 'not_uppercase'),
+ array(4, 'Awesome group', '', false, 'Awesome group'),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_group_name_data
+ */
+ public function test_get_name_string_group_name($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('group_name', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+
+ public function get_name_string_colour_data()
+ {
+ return array(
+ array(0, '', '', false, ''),
+ array(0, '', 'F0F0F0', false, '#F0F0F0'),
+ array(1, 'Guests', '000000', false, '#000000'),
+ array(2, 'Administrators', '', false, ''),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_colour_data
+ */
+ public function test_get_name_string_colour($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('colour', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+
+ public function get_name_string_full_data()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ return array(
+ array(0, 'BOTS', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
+ array(1, 'BOTS', '111111', false, '<span class="username-coloured" style="color: #111111;">Bots</span>'),
+ array(7, 'new_group', 'FFA500', false, '<a class="username-coloured" href="' . $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=group&amp;g=7" style="color: #FFA500;">Some new group</a>'),
+ array(14, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<a class="username" href="http://www.example.org/group.php?mode=show&amp;g=14">Awesome group</a>'),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_full_data
+ */
+ public function test_get_name_string_full($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('full', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+
+ public function get_name_string_no_profile_data()
+ {
+ return array(
+ array(0, 'BOTS', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
+ array(1, 'new_group', '', false, '<span class="username">Some new group</span>'),
+ array(2, 'not_uppercase', 'FF0000', false, '<span class="username-coloured" style="color: #FF0000;">not_uppercase</span>'),
+ array(5, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<span class="username">Awesome group</span>'),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_no_profile_data
+ */
+ public function test_get_name_string_no_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('no_profile', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+}
diff --git a/tests/group/helper_get_name_test.php b/tests/group/helper_get_name_test.php
new file mode 100644
index 0000000000..b39b2cbedd
--- /dev/null
+++ b/tests/group/helper_get_name_test.php
@@ -0,0 +1,31 @@
+<?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__) . '/helper_test_case.php';
+
+class phpbb_group_helper_get_name_test extends phpbb_group_helper_test_case
+{
+ public function test_get_name()
+ {
+ // They should be totally fine
+ $this->assertEquals('Bots', $this->group_helper->get_name('Bots'));
+ $this->assertEquals('Some new group', $this->group_helper->get_name('new_group'));
+ $this->assertEquals('Should work', $this->group_helper->get_name('group_with_ümlauts'));
+
+ // This should fail (obviously)
+ $this->assertNotEquals('The key does not contain uppercase letters', $this->group_helper->get_name('not_uppercase'));
+
+ // The key doesn't exist so just return group name...
+ $this->assertEquals('Awesome group', $this->group_helper->get_name('Awesome group'));
+ }
+}
diff --git a/tests/group/helper_get_rank_test.php b/tests/group/helper_get_rank_test.php
new file mode 100644
index 0000000000..5efd8ad95e
--- /dev/null
+++ b/tests/group/helper_get_rank_test.php
@@ -0,0 +1,43 @@
+<?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__) . '/helper_test_case.php';
+
+class phpbb_group_helper_get_rank_test extends phpbb_group_helper_test_case
+{
+ public function get_rank_data()
+ {
+ global $phpbb_root_path;
+
+ return array(
+ array(
+ array('group_id' => 0, 'group_rank' => 1),
+ array(
+ 'title' => 'Site admin',
+ 'img' => '<img src="' . $phpbb_root_path . 'images/ranks/siteadmin.png' . '" alt="Site admin" title="Site admin" />',
+ 'img_src' => $phpbb_root_path . 'images/ranks/siteadmin.png',
+ )
+ ),
+ array(array('group_id' => 1, 'group_rank' => 0), array('title' => null, 'img' => null, 'img_src' => null)),
+ array(array('group_id' => 2, 'group_rank' => 2), array('title' => 'Test member', 'img' => '', 'img_src' => '')),
+ );
+ }
+
+ /**
+ * @dataProvider get_rank_data
+ */
+ public function test_get_rank($group_data, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_rank($group_data));
+ }
+}
diff --git a/tests/group/helper_test.php b/tests/group/helper_test.php
deleted file mode 100644
index 2377a6f47c..0000000000
--- a/tests/group/helper_test.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?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_group_helper_test extends phpbb_test_case
-{
- /** @var \phpbb\group\helper */
- protected $group_helper;
-
- public function setUp()
- {
- global $phpbb_root_path, $phpEx;
-
- // Set up language service
- $lang = new \phpbb\language\language(
- new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
- );
-
- // Set up language data for testing
- $reflection_class = new ReflectionClass('\phpbb\language\language');
-
- // Set default language files loaded flag to true
- $loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
- $loaded_flag->setAccessible(true);
- $loaded_flag->setValue($lang, true);
-
- // Set up test language data
- $lang_array = $reflection_class->getProperty('lang');
- $lang_array->setAccessible(true);
- $lang_array->setValue($lang, $this->get_test_language_data_set());
-
- // Set up group helper
- $this->group_helper = new \phpbb\group\helper($lang);
- }
-
- public function test_get_name()
- {
- // They should be totally fine
- $this->assertEquals('Bots', $this->group_helper->get_name('Bots'));
- $this->assertEquals('Some new group', $this->group_helper->get_name('new_group'));
- $this->assertEquals('Should work', $this->group_helper->get_name('group_with_ümlauts'));
-
- // This should fail (obviously)
- $this->assertNotEquals('They key does not contain uppercase letters', $this->group_helper->get_name('not_uppercase'));
-
- // The key doesn't exist so just return group name...
- $this->assertEquals('Awesome group', $this->group_helper->get_name('Awesome group'));
- }
-
- protected function get_test_language_data_set()
- {
- return array(
- 'G_BOTS' => 'Bots',
- 'G_NEW_GROUP' => 'Some new group',
- 'G_not_uppercase' => 'The key does not contain uppercase letters',
- 'G_GROUP_WITH_ÜMLAUTS' => 'Should work',
- );
- }
-}
diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php
new file mode 100644
index 0000000000..e298770331
--- /dev/null
+++ b/tests/group/helper_test_case.php
@@ -0,0 +1,123 @@
+<?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_group_helper_test_case extends phpbb_test_case
+{
+ /** @var \phpbb\group\helper */
+ protected $group_helper;
+
+ protected function config_defaults()
+ {
+ $defaults = array(
+ 'ranks_path' => 'images/ranks'
+ );
+ return $defaults;
+ }
+
+ protected function get_test_language_data_set()
+ {
+ return array(
+ 'G_BOTS' => 'Bots',
+ 'G_NEW_GROUP' => 'Some new group',
+ 'G_not_uppercase' => 'The key does not contain uppercase letters',
+ 'G_GROUP_WITH_ÜMLAUTS' => 'Should work',
+ );
+ }
+
+ protected function get_test_rank_data_set()
+ {
+ return array(
+ 'special' => array(
+ 1 => array(
+ 'rank_id' => 1,
+ 'rank_title' => 'Site admin',
+ 'rank_special' => 1,
+ 'rank_image' => 'siteadmin.png',
+ ),
+ 2 => array(
+ 'rank_id' => 2,
+ 'rank_title' => 'Test member',
+ 'rank_special' => 1,
+ 'rank_image' => '',
+ )
+ )
+ );
+ }
+
+ protected function setup_engine(array $new_config = array())
+ {
+ global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
+
+ // Set up authentication data for testing
+ $auth = $this->getMock('\phpbb\auth\auth');
+ $auth->expects($this->any())
+ ->method('acl_get')
+ ->with($this->stringContains('_'), $this->anything())
+ ->will($this->returnValueMap(array(
+ array('u_viewprofile', true),
+ )));
+
+ // Set up cache service
+ $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock();
+ $cache_service->expects($this->any())
+ ->method('obtain_ranks')
+ ->will($this->returnValue($this->get_test_rank_data_set()));
+
+ // Set up configuration
+ $defaults = $this->config_defaults();
+ $config = new \phpbb\config\config(array_merge($defaults, $new_config));
+
+ // Set up language service
+ $lang = new \phpbb\language\language(
+ new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
+ );
+
+ // Set up language data for testing
+ $reflection_class = new ReflectionClass('\phpbb\language\language');
+
+ // Set default language files loaded flag to true
+ $loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
+ $loaded_flag->setAccessible(true);
+ $loaded_flag->setValue($lang, true);
+
+ // Set up test language data
+ $lang_array = $reflection_class->getProperty('lang');
+ $lang_array->setAccessible(true);
+ $lang_array->setValue($lang, $this->get_test_language_data_set());
+
+ // Set up event dispatcher
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+
+ // Set up path helper
+ $path_helper = $this->getMockBuilder('\phpbb\path_helper')
+ ->disableOriginalConstructor()
+ ->setMethods(array())
+ ->getMock();
+ $path_helper->method('get_phpbb_root_path')
+ ->willReturn($phpbb_root_path);
+ $path_helper->method('get_php_ext')
+ ->willReturn($phpEx);
+ $path_helper->method('update_web_root_path')
+ ->will($this->returnArgument(0));
+
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_id'] = ANONYMOUS;
+
+ $this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user);
+ }
+
+ public function setUp()
+ {
+ $this->setup_engine();
+ }
+}
diff --git a/tests/lint_test.php b/tests/lint_test.php
index 70046bdfd2..8ab31f976c 100644
--- a/tests/lint_test.php
+++ b/tests/lint_test.php
@@ -67,6 +67,12 @@ class phpbb_lint_test extends phpbb_test_case
{
$files = array();
$dh = opendir($root);
+
+ if ($dh === false)
+ {
+ return $files;
+ }
+
while (($filename = readdir($dh)) !== false)
{
if ($filename == '.' || $filename == '..')
@@ -89,6 +95,7 @@ class phpbb_lint_test extends phpbb_test_case
// PHP Fatal error: Cannot declare class Container because the name is already in use in /var/www/projects/phpbb3/tests/../phpBB/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php on line 20
// https://gist.github.com/e003913ffd493da63cbc
dirname(__FILE__) . '/../phpBB/vendor',
+ dirname(__FILE__) . '/../node_modules',
)))
{
$files = array_merge($files, $this->check($path));
diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php
new file mode 100644
index 0000000000..af636f5d21
--- /dev/null
+++ b/tests/migrator/get_callable_from_step_test.php
@@ -0,0 +1,136 @@
+<?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 get_callable_from_step_test extends phpbb_database_test_case
+{
+ public function setUp()
+ {
+ global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log;
+
+ parent::setUp();
+
+ $phpbb_log = $this->getMockBuilder('\phpbb\log\log')->disableOriginalConstructor()->getMock();
+ $db = $this->new_dbal();
+ $factory = new \phpbb\db\tools\factory();
+ $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock();
+ $user = $this->getMockBuilder('\phpbb\user')->disableOriginalConstructor()->getMock();
+ $module_manager = new \phpbb\module\module_manager(
+ $this->getMockBuilder('\phpbb\cache\driver\dummy')->disableOriginalConstructor()->getMock(),
+ $db,
+ new phpbb_mock_extension_manager($phpbb_root_path),
+ 'phpbb_modules',
+ $phpbb_root_path,
+ $php_ext
+ );
+ $module_tools = new \phpbb\db\migration\tool\module($db, $cache_service, $user, $module_manager, $phpbb_root_path, $php_ext, 'phpbb_modules');
+ $this->migrator = new \phpbb\db\migrator(
+ new phpbb_mock_container_builder(),
+ new \phpbb\config\config(array()),
+ $db,
+ $factory->get($db),
+ 'phpbb_migrations',
+ $phpbb_root_path,
+ $php_ext,
+ $table_prefix,
+ array($module_tools),
+ new \phpbb\db\migration\helper()
+ );
+
+ if (!$module_tools->exists('acp', 0, 'new_module_langname'))
+ {
+ $module_tools->add('acp', 0, array(
+ 'module_basename' => 'new_module_basename',
+ 'module_langname' => 'new_module_langname',
+ 'module_mode' => 'settings',
+ 'module_auth' => '',
+ 'module_display' => true,
+ 'before' => false,
+ 'after' => false,
+ ));
+ $this->module_added = true;
+ }
+ }
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/../dbal/fixtures/migrator.xml');
+ }
+
+ public function get_callable_from_step_provider()
+ {
+ return array(
+ array(
+ array('if', array(
+ false,
+ array('permission.add', array('some_data')),
+ )),
+ true, // expects false
+ ),
+ array(
+ array('if', array(
+ array('module.exists', array(
+ 'mcp',
+ 'RANDOM_PARENT',
+ 'RANDOM_MODULE'
+ )),
+ array('permission.add', array('some_data')),
+ )),
+ true, // expects false
+ ),
+ array(
+ array('if', array(
+ array('module.exists', array(
+ 'acp',
+ 0,
+ 'new_module_langname'
+ )),
+ array('module.add', array(
+ 'acp',
+ 0,
+ 'module_basename' => 'new_module_basename2',
+ 'module_langname' => 'new_module_langname2',
+ 'module_mode' => 'settings',
+ 'module_auth' => '',
+ 'module_display' => true,
+ 'before' => false,
+ 'after' => false,
+ )),
+ )),
+ false, // expects false
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider get_callable_from_step_provider
+ */
+ public function test_get_callable_from_step($step, $expects_false)
+ {
+ if ($expects_false)
+ {
+ $this->assertFalse($this->call_get_callable_from_step($step));
+ }
+ else
+ {
+ $this->assertNotFalse($this->call_get_callable_from_step($step));
+ }
+ }
+
+ protected function call_get_callable_from_step($step)
+ {
+ $class = new ReflectionClass($this->migrator);
+ $method = $class->getMethod('get_callable_from_step');
+ $method->setAccessible(true);
+ return $method->invokeArgs($this->migrator, array($step));
+ }
+}
diff --git a/tests/mock/sql_insert_buffer.php b/tests/mock/sql_insert_buffer.php
index c751764d45..e57983684d 100644
--- a/tests/mock/sql_insert_buffer.php
+++ b/tests/mock/sql_insert_buffer.php
@@ -15,7 +15,7 @@ class phpbb_mock_sql_insert_buffer extends \phpbb\db\sql_insert_buffer
{
public function flush()
{
- return (sizeof($this->buffer)) ? true : false;
+ return (count($this->buffer)) ? true : false;
}
public function get_buffer()
diff --git a/tests/network/checkdnsrr_test.php b/tests/network/checkdnsrr_test.php
index 6503a4c40b..8cbd4f7e97 100644
--- a/tests/network/checkdnsrr_test.php
+++ b/tests/network/checkdnsrr_test.php
@@ -38,7 +38,7 @@ class phpbb_network_checkdnsrr_test extends phpbb_test_case
array('does-not-exist.phpbb.com', 'AAAA', false),
// Existing CNAME record
- array('news.cnet.com', 'CNAME', true),
+ array('area51.phpbb.com', 'CNAME', true),
// Non-existing CNAME record
array('does-not-exist.phpbb.com', 'CNAME', false),
diff --git a/tests/notification/base.php b/tests/notification/base.php
index b64e25cf8c..80b9a0d777 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -163,7 +163,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
'order_dir' => 'ASC',
), $options));
- $this->assertEquals(sizeof($expected), $notifications['unread_count']);
+ $this->assertEquals(count($expected), $notifications['unread_count']);
$i = 0;
foreach ($notifications['notifications'] as $notification)
diff --git a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml
index 7f069abc59..db1cef2ef6 100644
--- a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml
@@ -29,6 +29,7 @@
</row>
</table>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -37,6 +38,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>5</value>
<value>1</value>
<value>1</value>
diff --git a/tests/notification/fixtures/submit_post_notification.type.post.xml b/tests/notification/fixtures/submit_post_notification.type.post.xml
index a4bf9d3ee4..920b271525 100644
--- a/tests/notification/fixtures/submit_post_notification.type.post.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.post.xml
@@ -21,6 +21,7 @@
</row>
</table>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -29,6 +30,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>5</value>
<value>1</value>
<value>1</value>
@@ -36,6 +38,7 @@
<value></value>
</row>
<row>
+ <value>2</value>
<value>1</value>
<value>8</value>
<value>1</value>
diff --git a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml
index 0a955c48d2..12e73b0ff2 100644
--- a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -9,6 +10,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>6</value>
<value>1</value>
<value>1</value>
diff --git a/tests/notification/fixtures/submit_post_notification.type.quote.xml b/tests/notification/fixtures/submit_post_notification.type.quote.xml
index c66830fbf5..9f4ba91475 100644
--- a/tests/notification/fixtures/submit_post_notification.type.quote.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.quote.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -9,6 +10,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>5</value>
<value>1</value>
<value>1</value>
diff --git a/tests/notification/fixtures/submit_post_notification.type.topic.xml b/tests/notification/fixtures/submit_post_notification.type.topic.xml
index e0f6583f48..1f96ed2ee7 100644
--- a/tests/notification/fixtures/submit_post_notification.type.topic.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.topic.xml
@@ -21,6 +21,7 @@
</row>
</table>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -29,6 +30,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>8</value>
<value>1</value>
<value>1</value>
diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index 92e758a336..e849c66fa5 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -49,9 +49,23 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
$this->cache->get_driver()
));
$this->container->set('group_helper', new \phpbb\group\helper(
+ $this->getMock('\phpbb\auth\auth'),
+ $this->cache,
+ $this->config,
new \phpbb\language\language(
new phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
- )
+ ),
+ new phpbb_mock_event_dispatcher(),
+ new \phpbb\path_helper(
+ new \phpbb\symfony_request(
+ new phpbb_mock_request()
+ ),
+ new \phpbb\filesystem\filesystem(),
+ $this->getMock('\phpbb\request\request'),
+ $phpbb_root_path,
+ $phpEx
+ ),
+ $this->user
));
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$phpbb_log = new \phpbb\log\dummy();
diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php
index ec42aa193c..6bbabfc602 100644
--- a/tests/notification/notification_test.php
+++ b/tests/notification/notification_test.php
@@ -108,7 +108,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base
$types = array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test');
foreach ($types as $id => $type)
{
- $this->db->sql_query('INSERT INTO phpbb_notification_types ' .
+ $this->getConnection()->createQueryTable('insertNotification', 'INSERT INTO phpbb_notification_types ' .
$this->db->sql_build_array('INSERT', array(
'notification_type_id' => ($id + 1),
'notification_type_name' => $type,
diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php
index 7c7fa3f3e6..54bb406838 100644
--- a/tests/profilefields/type_string_test.php
+++ b/tests/profilefields/type_string_test.php
@@ -24,7 +24,7 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
*/
public function setUp()
{
- global $request, $user, $cache, $phpbb_root_path, $phpEx;
+ global $config, $request, $user, $cache, $phpbb_root_path, $phpEx;
$user = $this->getMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
@@ -34,6 +34,7 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
+ $config = new \phpbb\config\config([]);
$request = $this->getMock('\phpbb\request\request');
$template = $this->getMock('\phpbb\template\template');
@@ -269,6 +270,18 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
null,
'Field should simply output null for empty vlaue',
),
+ array(
+ 'http://foobar.com',
+ array('field_show_novalue' => false),
+ '<!-- l --><a class="postlink-local" href="http://foobar.com">foobar.com</a><!-- l -->',
+ 'Field should output the given value and make it clickable',
+ ),
+ array(
+ 'javascript://foobar.com',
+ array('field_show_novalue' => true),
+ 'javascript://foobar.com',
+ 'Field should output the given value but not make it clickable',
+ ),
);
}
diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php
index 1d90e2c34c..3bb5d52899 100644
--- a/tests/profilefields/type_url_test.php
+++ b/tests/profilefields/type_url_test.php
@@ -11,6 +11,10 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
+
class phpbb_profilefield_type_url_test extends phpbb_test_case
{
protected $cp;
@@ -24,8 +28,10 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
*/
public function setUp()
{
- global $phpbb_root_path, $phpEx;
+ global $config, $request, $user, $cache, $phpbb_root_path, $phpEx;
+ $config = new \phpbb\config\config([]);
+ $cache = new phpbb_mock_cache;
$user = $this->getMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
@@ -92,6 +98,19 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
'FIELD_INVALID_URL-field',
'Field should reject invalid URL having multi value parameters',
),
+ // Not allowed schemes
+ array(
+ 'ftp://example.com/',
+ array(),
+ 'FIELD_INVALID_URL-field',
+ 'Field should reject invalid URL having multi value parameters',
+ ),
+ array(
+ 'javascript://alert.com',
+ array(),
+ 'FIELD_INVALID_URL-field',
+ 'Field should reject invalid URL having multi value parameters',
+ ),
// IDN url type profilefields
array(
@@ -165,6 +184,55 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
);
}
+ public function profile_value_data()
+ {
+ return array(
+ array(
+ 'http://foobar.com',
+ array('field_show_novalue' => true),
+ '<!-- l --><a class="postlink-local" href="http://foobar.com">foobar.com</a><!-- l -->',
+ 'Field should output the given value',
+ ),
+ array(
+ 'http://foobar.com',
+ array('field_show_novalue' => false),
+ '<!-- l --><a class="postlink-local" href="http://foobar.com">foobar.com</a><!-- l -->',
+ 'Field should output the given value',
+ ),
+ array(
+ 'test',
+ array('field_show_novalue' => true),
+ null,
+ 'Field should output nothing for empty value',
+ ),
+ array(
+ 'test',
+ array('field_show_novalue' => false),
+ null,
+ 'Field should simply output null for empty value',
+ ),
+ array(
+ 'javascript://foobar.com',
+ array('field_show_novalue' => true),
+ null,
+ 'Field should output nothing for empty value',
+ ),
+ );
+ }
+
+
+ /**
+ * @dataProvider profile_value_data
+ */
+ public function test_get_profile_value($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
/**
* @dataProvider profile_value_raw_data
*/
diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php
index a9d1ea20de..428db6ac98 100644
--- a/tests/random/gen_rand_string_test.php
+++ b/tests/random/gen_rand_string_test.php
@@ -40,7 +40,10 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case
$random_string_length = strlen($random_string);
$this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH);
- $this->assertTrue($random_string_length <= $num_chars);
+ $this->assertTrue(
+ $random_string_length == $num_chars,
+ sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length)
+ );
$this->assertRegExp('#^[A-Z0-9]+$#', $random_string);
}
}
@@ -56,7 +59,10 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case
$random_string_length = strlen($random_string);
$this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH);
- $this->assertTrue($random_string_length <= $num_chars);
+ $this->assertTrue(
+ $random_string_length == $num_chars,
+ sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length)
+ );
$this->assertRegExp('#^[A-NP-Z1-9]+$#', $random_string);
}
}
diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php
index 143c05aa9c..6407dca894 100644
--- a/tests/request/type_cast_helper_test.php
+++ b/tests/request/type_cast_helper_test.php
@@ -20,16 +20,6 @@ class phpbb_type_cast_helper_test extends phpbb_test_case
$this->type_cast_helper = new \phpbb\request\type_cast_helper();
}
- public function test_addslashes_recursively()
- {
- $data = array('some"string' => array('that"' => 'really"', 'needs"' => '"escaping'));
- $expected = array('some\\"string' => array('that\\"' => 'really\\"', 'needs\\"' => '\\"escaping'));
-
- $this->type_cast_helper->addslashes_recursively($data);
-
- $this->assertEquals($expected, $data);
- }
-
public function test_simple_recursive_set_var()
{
$data = 'eviL<3';
diff --git a/tests/search/fixtures/posts.xml b/tests/search/fixtures/posts.xml
index 16232b8f39..4916cd188b 100644
--- a/tests/search/fixtures/posts.xml
+++ b/tests/search/fixtures/posts.xml
@@ -1,25 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_posts">
+ <column>post_id</column>
<column>post_username</column>
<column>post_subject</column>
<column>post_text</column>
<row>
+ <value>1</value>
<value>foo</value>
<value>foo</value>
<value>foo</value>
</row>
<row>
+ <value>2</value>
<value>bar</value>
<value>bar</value>
<value>bar</value>
</row>
<row>
+ <value>3</value>
<value>commonword</value>
<value>commonword</value>
<value>commonword</value>
</row>
<row>
+ <value>4</value>
<value>baaz</value>
<value>baaz</value>
<value>baaz</value>
diff --git a/tests/search/native_test.php b/tests/search/native_test.php
index 29d0d0a8d3..0e6f719cef 100644
--- a/tests/search/native_test.php
+++ b/tests/search/native_test.php
@@ -70,7 +70,7 @@ class phpbb_search_native_test extends phpbb_search_test_case
'ba*az',
'all',
true,
- array('\'ba%az\''),
+ array(4),
array(),
array(),
),
@@ -78,7 +78,7 @@ class phpbb_search_native_test extends phpbb_search_test_case
'ba*z',
'all',
true,
- array('\'ba%z\''),
+ array(), // <= 3 chars after removing *
array(),
array(),
),
@@ -86,7 +86,7 @@ class phpbb_search_native_test extends phpbb_search_test_case
'baa* baaz*',
'all',
true,
- array('\'baa%\'', '\'baaz%\''),
+ array('\'baa%\'', 4),
array(),
array(),
),
@@ -94,7 +94,7 @@ class phpbb_search_native_test extends phpbb_search_test_case
'ba*z baa*',
'all',
true,
- array('\'ba%z\'', '\'baa%\''),
+ array('\'baa%\''), // baz is <= 3 chars, only baa* is left
array(),
array(),
),
diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php
index 40cb7d2f04..0177eb4259 100644
--- a/tests/security/redirect_test.php
+++ b/tests/security/redirect_test.php
@@ -109,7 +109,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
if ($expected_error !== false)
{
- $this->setExpectedTriggerError(E_USER_ERROR, $user->lang[$expected_error]);
+ $this->setExpectedTriggerError(E_USER_WARNING, $user->lang[$expected_error]);
}
$result = redirect($test, true, $disable_cd_check);
diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php
index 04da5f08b9..16a65b0ade 100644
--- a/tests/session/check_ban_test.php
+++ b/tests/session/check_ban_test.php
@@ -72,7 +72,8 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
{
try
{
- $is_banned = $this->session->check_ban($user_id, $user_ips, $user_email, $return);
+ $ban = $this->session->check_ban($user_id, $user_ips, $user_email, $return);
+ $is_banned = !empty($ban);
}
catch (PHPUnit_Framework_Error_Notice $e)
{
diff --git a/tests/template/context_test.php b/tests/template/context_test.php
new file mode 100644
index 0000000000..52ce6c8fde
--- /dev/null
+++ b/tests/template/context_test.php
@@ -0,0 +1,96 @@
+<?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 context_test extends phpbb_test_case
+{
+ protected $context;
+ protected function setUp()
+ {
+ $this->context = new \phpbb\template\context();
+
+ for ($i = 0; $i < 10; $i++)
+ {
+ $this->context->assign_block_vars('block' . $i, array(
+ 'FOO' . $i => 'foo' . $i,
+ 'BAR' . $i => 'bar' . $i,
+ ));
+
+ for ($j = 0; $j < 10; $j++)
+ {
+ $this->context->assign_block_vars('block' . $i . '.subblock', array(
+ 'SUBFOO' => 'subfoo' . $j,
+ 'SUBBAR' => 'subbar' . $j,
+ ));
+
+ for ($k = 0; $k < 10; $k++)
+ {
+ $this->context->assign_block_vars('block' . $i . '.subblock.subsubblock', array(
+ 'SUBSUBFOO' => 'subsubfoo' . $k,
+ 'SUBSUBBAR' => 'subsubbar' . $k,
+ ));
+ }
+ }
+ }
+ }
+
+ public function retrieve_block_vars_data()
+ {
+ return array(
+ array('foo', array(), array()), // non-existent top-level block
+ array('block1.foo', array(), array()), // non-existent sub-level block
+ array('block1', array(), array( // top-level block, all vars
+ 'FOO1' => 'foo1',
+ 'BAR1' => 'bar1',
+ )),
+ array('block1', array('FOO1'), array( // top-level block, one var
+ 'FOO1' => 'foo1',
+ )),
+ array('block2.subblock', array(), array( // sub-level block, all vars
+ 'SUBFOO' => 'subfoo9',
+ 'SUBBAR' => 'subbar9',
+ )),
+ array('block2.subblock', array('SUBBAR'), array( // sub-level block, one var
+ 'SUBBAR' => 'subbar9',
+ )),
+ array('block2.subblock.subsubblock', array(), array( // sub-sub-level block, all vars
+ 'SUBSUBFOO' => 'subsubfoo9',
+ 'SUBSUBBAR' => 'subsubbar9',
+ )),
+ array('block2.subblock.subsubblock', array('SUBSUBBAR'), array( // sub-sub-level block, one var
+ 'SUBSUBBAR' => 'subsubbar9',
+ )),
+ array('block3.subblock[2]', array(), array( // sub-level, exact index, all vars
+ 'SUBFOO' => 'subfoo2',
+ 'SUBBAR' => 'subbar2',
+ )),
+ array('block3.subblock[2]', array('SUBBAR'), array( // sub-level, exact index, one var
+ 'SUBBAR' => 'subbar2',
+ )),
+ array('block3.subblock[3].subsubblock[5]', array(), array( // sub-sub-level, exact index, all vars
+ 'SUBSUBFOO' => 'subsubfoo5',
+ 'SUBSUBBAR' => 'subsubbar5',
+ )),
+ array('block3.subblock[4].subsubblock[6]', array('SUBSUBFOO'), array( // sub-sub-level, exact index, one var
+ 'SUBSUBFOO' => 'subsubfoo6',
+ )),
+ );
+ }
+
+ /**
+ * @dataProvider retrieve_block_vars_data
+ */
+ public function test_retrieve_block_vars($blockname, $vararray, $result)
+ {
+ $this->assertEquals($result, $this->context->retrieve_block_vars($blockname, $vararray));
+ }
+}
diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php
index bc871aa612..4eb30eda1e 100644
--- a/tests/template/template_includecss_test.php
+++ b/tests/template/template_includecss_test.php
@@ -95,19 +95,19 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
*/
array(
array('TEST' => 1),
- '<link href="tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen" />',
+ '<link href="tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" media="screen" />',
),
array(
array('TEST' => 2),
- '<link href="tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen" />',
+ '<link href="tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" media="screen" />',
),
array(
array('TEST' => 3),
- '<link href="tests/template/ext/include/css/styles/all/theme/test.css?assets_version=1" rel="stylesheet" type="text/css" media="screen" />',
+ '<link href="tests/template/ext/include/css/styles/all/theme/test.css?assets_version=1" rel="stylesheet" media="screen" />',
),
array(
array('TEST' => 4),
- '<link href="tests/template/ext/include/css/styles/all/theme/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen" />',
+ '<link href="tests/template/ext/include/css/styles/all/theme/child_only.css?assets_version=1" rel="stylesheet" media="screen" />',
),
);
}
diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php
index 232f551b4a..19c016ae5e 100644
--- a/tests/template/template_includejs_test.php
+++ b/tests/template/template_includejs_test.php
@@ -28,67 +28,67 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
*/
array(
array('TEST' => 1),
- '<script type="text/javascript" src="tests/template/templates/parent_and_child.js?assets_version=1"></script>',
+ '<script src="tests/template/templates/parent_and_child.js?assets_version=1"></script>',
),
array(
array('TEST' => 2),
- '<script type="text/javascript" src="tests/template/templates/parent_and_child.js?assets_version=0"></script>',
+ '<script src="tests/template/templates/parent_and_child.js?assets_version=0"></script>',
),
array(
array('TEST' => 3),
- '<script type="text/javascript" src="tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>',
+ '<script src="tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>',
),
array(
array('TEST' => 4),
- '<script type="text/javascript" src="tests/template/templates/parent_and_child.js?test=1&amp;assets_version=0"></script>',
+ '<script src="tests/template/templates/parent_and_child.js?test=1&amp;assets_version=0"></script>',
),
array(
array('TEST' => 6),
- '<script type="text/javascript" src="tests/template/parent_templates/parent_only.js?assets_version=1"></script>',
+ '<script src="tests/template/parent_templates/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 7),
- '<script type="text/javascript" src="tests/template/templates/child_only.js?assets_version=1"></script>',
+ '<script src="tests/template/templates/child_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 8),
- '<script type="text/javascript" src="tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
+ '<script src="tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 9),
- '<script type="text/javascript" src="tests/template/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
+ '<script src="tests/template/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 10),
- '<script type="text/javascript" src="tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
+ '<script src="tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 11),
- '<script type="text/javascript" src="tests/template/templates/child_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
+ '<script src="tests/template/templates/child_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
),
array(
array('TEST' => 12),
- '<script type="text/javascript" src="tests/template/parent_templates/parent_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
+ '<script src="tests/template/parent_templates/parent_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
),
array(
array('TEST' => 14),
- '<script type="text/javascript" src="tests/template/parent_templates/parent_only.js?test1=&quot;&amp;assets_version=1#test3"></script>',
+ '<script src="tests/template/parent_templates/parent_only.js?test1=&quot;&amp;assets_version=1#test3"></script>',
),
array(
array('TEST' => 15),
- '<script type="text/javascript" src="http://phpbb.com/b.js?c=d#f"></script>',
+ '<script src="http://phpbb.com/b.js?c=d#f"></script>',
),
array(
array('TEST' => 16),
- '<script type="text/javascript" src="http://phpbb.com/b.js?c=d&assets_version=2#f"></script>',
+ '<script src="http://phpbb.com/b.js?c=d&assets_version=2#f"></script>',
),
array(
array('TEST' => 17),
- '<script type="text/javascript" src="//phpbb.com/b.js"></script>',
+ '<script src="//phpbb.com/b.js"></script>',
),
array(
array('TEST' => 18),
- '<script type="text/javascript" src="tests/template/templates/parent_and_child.js?test=1&test2=0&amp;assets_version=1"></script>',
+ '<script src="tests/template/templates/parent_and_child.js?test=1&test2=0&amp;assets_version=1"></script>',
),
);
}
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 9f2124418d..727f35e9d2 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -364,7 +364,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array(),
array(),
- "Value'\n1 O'Clock\nValue\\x27\n1\\x20O\\x27Clock",
+ "Value'\n1 O'Clock\nValue\\u0027\n1\\u0020O\\u0027Clock",
array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"),
),
array(
@@ -998,6 +998,46 @@ EOT
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting by index out of bounds, ignored');
}
+ public function test_indexed_assign_block_vars()
+ {
+ $this->template->set_filenames(array('test' => 'loop_nested.html'));
+
+ $this->template->assign_var('TEST_MORE', true);
+
+ // @todo Change this
+ $this->template->assign_block_vars('outer', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+
+ $expect = 'outer - 0[outer|3]middle - 0[middle|1]outer - 1[outer|3]middle - 0[middle|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
+ $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification');
+
+ $this->template->assign_block_vars('outer[0].middle', array('VARIABLE' => 'test'));
+
+ $expect = 'outer - 0[outer|3]middle - 0[middle|2]middle - 1 - test[middle|2]outer - 1[outer|3]middle - 0[middle|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
+ $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Inserting at the first outer block');
+
+ $this->template->assign_block_vars('outer[1].middle[0].inner', array());
+
+ $expect = 'outer - 0[outer|3]middle - 0[middle|2]middle - 1 - test[middle|2]outer - 1[outer|3]middle - 0[middle|2]inner - 0[inner|1]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
+ $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Creating an inner block at the first middle block in the second outer block');
+
+ $this->template->assign_block_vars('outer[1].middle[0].inner', array());
+
+ $expect = 'outer - 0[outer|3]middle - 0[middle|2]middle - 1 - test[middle|2]outer - 1[outer|3]middle - 0[middle|2]inner - 0[inner|2]inner - 1[inner|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
+ $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Inserting another inner block in the same place');
+
+ $this->template->assign_block_vars('outer.middle[1].inner', array('VARIABLE' => 'test'));
+
+ $expect = 'outer - 0[outer|3]middle - 0[middle|2]middle - 1 - test[middle|2]outer - 1[outer|3]middle - 0[middle|2]inner - 0[inner|2]inner - 1[inner|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]inner - 0 - test[inner|1]middle - 2[middle|3]';
+ $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Inserting another inner block in the same place');
+ }
public function assign_block_vars_array_data()
{
diff --git a/tests/template/templates/loop_nested.html b/tests/template/templates/loop_nested.html
index cf099ecc15..5763262781 100644
--- a/tests/template/templates/loop_nested.html
+++ b/tests/template/templates/loop_nested.html
@@ -2,5 +2,8 @@
outer - {outer.S_ROW_COUNT}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF --><!-- IF TEST_MORE -->[{outer.S_BLOCK_NAME}|{outer.S_NUM_ROWS}]<!-- ENDIF -->
<!-- BEGIN middle -->
middle - {outer.middle.S_ROW_COUNT}<!-- IF outer.middle.VARIABLE --> - {outer.middle.VARIABLE}<!-- ENDIF --><!-- IF TEST_MORE -->[{outer.middle.S_BLOCK_NAME}|{outer.middle.S_NUM_ROWS}]<!-- ENDIF -->
+<!-- BEGIN inner -->
+inner - {outer.middle.inner.S_ROW_COUNT}<!-- IF outer.middle.inner.VARIABLE --> - {outer.middle.inner.VARIABLE}<!-- ENDIF --><!-- IF TEST_MORE -->[{outer.middle.inner.S_BLOCK_NAME}|{outer.middle.inner.S_NUM_ROWS}]<!-- ENDIF -->
+<!-- END inner -->
<!-- END middle -->
<!-- END outer -->
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index b7386e9a3e..606c40a623 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -142,9 +142,86 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
$manager->database_synchronisation($table_column_map);
}
+ /**
+ * Create xml data set for insertion into database
+ *
+ * @param string $path Path to fixture XML
+ * @return PHPUnit_Extensions_Database_DataSet_DefaultDataSet|PHPUnit_Extensions_Database_DataSet_XmlDataSet
+ */
public function createXMLDataSet($path)
{
$this->fixture_xml_data = parent::createXMLDataSet($path);
+
+ // Extend XML data set on MSSQL
+ if (strpos($this->get_database_config()['dbms'], 'mssql') !== false)
+ {
+ $newXmlData = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet();
+ $db = $this->new_dbal();
+ foreach ($this->fixture_xml_data as $key => $value)
+ {
+ /** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */
+ $tableMetaData = $value->getTableMetaData();
+ $columns = $tableMetaData->getColumns();
+ $primaryKeys = $tableMetaData->getPrimaryKeys();
+
+ $sql = "SELECT COLUMN_NAME AS identity_column
+ FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE COLUMNPROPERTY(object_id(TABLE_SCHEMA + '.' + TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1
+ AND TABLE_NAME = '$key'
+ ORDER BY TABLE_NAME";
+ $result = $db->sql_query($sql);
+ $identity_columns = $db->sql_fetchrowset($result);
+ $has_default_identity = false;
+ $add_primary_keys = false;
+
+ // Iterate over identity columns to check for missing primary
+ // keys in data set and special identity column 'mssqlindex'
+ // that might have been added when no default identity column
+ // exists in the current table.
+ foreach ($identity_columns as $column)
+ {
+ if (in_array($column['identity_column'], $columns) && !in_array($column['identity_column'], $primaryKeys))
+ {
+ $primaryKeys[] = $column['identity_column'];
+ $add_primary_keys = true;
+ }
+
+ if ($column['identity_column'] === 'mssqlindex')
+ {
+ $has_default_identity = true;
+ break;
+ }
+ }
+
+ if ($has_default_identity || $add_primary_keys)
+ {
+ // Add default identity column to columns list
+ if ($has_default_identity)
+ {
+ $columns[] = 'mssqlindex';
+ }
+
+ $newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $primaryKeys);
+ $newTable = new PHPUnit_Extensions_Database_DataSet_DefaultTable($newMetaData);
+ for ($i = 0; $i < $value->getRowCount(); $i++)
+ {
+ $dataRow = $value->getRow($i);
+ if ($has_default_identity)
+ {
+ $dataRow['mssqlindex'] = $i + 1;
+ }
+ $newTable->addRow($dataRow);
+ }
+ $newXmlData->addTable($newTable);
+ }
+ else
+ {
+ $newXmlData->addTable($value);
+ }
+ }
+
+ $this->fixture_xml_data = $newXmlData;
+ }
return $this->fixture_xml_data;
}
@@ -229,7 +306,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
// http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
// but one array_diff is not enough!
- if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
+ if (count(array_diff($one, $two)) || count(array_diff($two, $one)))
{
// get a nice error message
$this->assertEquals($one, $two);
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index 147029d699..f3adbefc1b 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -222,6 +222,14 @@ class phpbb_database_test_connection_manager
$this->purge_extras();
break;
+ case 'phpbb\db\driver\mssql':
+ case 'phpbb\db\driver\mssqlnative':
+ $this->connect();
+ // Drop all tables
+ $this->pdo->exec("EXEC sp_MSforeachtable 'DROP TABLE ?'");
+ $this->purge_extras();
+ break;
+
default:
$this->connect(false);
@@ -621,7 +629,7 @@ class phpbb_database_test_connection_manager
}
// Combine all of the SETVALs into one query
- if (sizeof($setval_queries))
+ if (count($setval_queries))
{
$queries[] = 'SELECT ' . implode(', ', $setval_queries);
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index eb56049515..4d294fd523 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -397,6 +397,14 @@ class phpbb_functional_test_case extends phpbb_test_case
global $phpbb_container;
$phpbb_container->reset();
+ // Purge cache to remove cached files
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT);
+ $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
+
+ $cache = new \phpbb\cache\driver\file;
+ $cache->purge();
+
$blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader'];
foreach (array_keys($GLOBALS) as $key)
@@ -425,7 +433,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$meta_refresh = $crawler->filter('meta[http-equiv="refresh"]');
// Wait for extension to be fully enabled
- while (sizeof($meta_refresh))
+ while (count($meta_refresh))
{
preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match);
$url = $match[1];
@@ -509,7 +517,6 @@ class phpbb_functional_test_case extends phpbb_test_case
else
{
$db->sql_multi_insert(STYLES_TABLE, array(array(
- 'style_id' => $style_id,
'style_name' => $style_path,
'style_copyright' => '',
'style_active' => 1,
@@ -551,9 +558,10 @@ class phpbb_functional_test_case extends phpbb_test_case
* Creates a new user with limited permissions
*
* @param string $username Also doubles up as the user's password
+ * @param string $email User email (defaults to nobody@example.com)
* @return int ID of created user
*/
- protected function create_user($username)
+ protected function create_user($username, $email = 'nobody@example.com')
{
// Required by unique_id
global $config;
@@ -572,6 +580,9 @@ class phpbb_functional_test_case extends phpbb_test_case
$config['rand_seed'] = '';
$config['rand_seed_last_update'] = time() + 600;
+ // Prevent new user to have an invalid style
+ $config['default_style'] = 1;
+
// Required by user_add
global $db, $cache, $phpbb_dispatcher, $phpbb_container;
$db = $this->get_db();
@@ -602,7 +613,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$user_row = array(
'username' => $username,
'group_id' => 2,
- 'user_email' => 'nobody@example.com',
+ 'user_email' => $email,
'user_type' => 0,
'user_lang' => 'en',
'user_timezone' => 'UTC',
@@ -909,10 +920,15 @@ class phpbb_functional_test_case extends phpbb_test_case
* status code. This assertion tries to catch that.
*
* @param int $status_code Expected status code
- * @return null
+ * @return void
*/
static public function assert_response_status_code($status_code = 200)
{
+ if ($status_code != self::$client->getResponse()->getStatus() &&
+ preg_match('/^5[0-9]{2}/', self::$client->getResponse()->getStatus()))
+ {
+ self::fail("Encountered unexpected server error:\n" . self::$client->getResponse()->getContent());
+ }
self::assertEquals($status_code, self::$client->getResponse()->getStatus(), 'HTTP status code does not match');
}
@@ -987,7 +1003,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->assertEquals(
1,
- sizeof($result),
+ count($result),
$message ?: 'Failed asserting that exactly one checkbox with name' .
" $name exists in crawler scope."
);
@@ -1169,10 +1185,6 @@ class phpbb_functional_test_case extends phpbb_test_case
}
}
- // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened)
- // is not at least 2 seconds before submission, cancel the form
- $form_data['lastclick'] = 0;
-
// I use a request because the form submission method does not allow you to send data that is not
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
// Instead, I send it as a request with the submit button "post" set to true.
diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php
index 7fb9a740b8..c792976b1e 100644
--- a/tests/test_framework/phpbb_test_case_helpers.php
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -385,7 +385,7 @@ class phpbb_test_case_helpers
$mb = $this->test_case->getMockBuilder('phpbb\\textformatter\\data_access');
$mb->setMethods(array('get_bbcodes', 'get_censored_words', 'get_smilies', 'get_styles'));
$mb->setConstructorArgs(array(
- $this->test_case->getMock('phpbb\\db\\driver\\driver'),
+ $this->test_case->getMockBuilder('phpbb\\db\\driver\\driver')->getMock(),
'phpbb_bbcodes',
'phpbb_smilies',
'phpbb_styles',
@@ -489,8 +489,11 @@ class phpbb_test_case_helpers
$request = new phpbb_mock_request;
}
+ // Get a log interface
+ $log = ($container->has('log')) ? $container->get('log') : $this->test_case->getMockBuilder('phpbb\\log\\log_interface')->getMock();
+
// Create and register the text_formatter.s9e.factory service
- $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, new \phpbb\textformatter\s9e\link_helper, $cache_dir, $cache_key_parser, $cache_key_renderer);
+ $factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, new \phpbb\textformatter\s9e\link_helper, $log, $cache_dir, $cache_key_parser, $cache_key_renderer);
$container->set('text_formatter.s9e.factory', $factory);
// Create a user if none was provided, and add the common lang strings
diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php
index b875d3212b..4d88d7d9cb 100644
--- a/tests/test_framework/phpbb_ui_test_case.php
+++ b/tests/test_framework/phpbb_ui_test_case.php
@@ -11,6 +11,7 @@
*
*/
+use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\Exception\WebDriverCurlException;
use Facebook\WebDriver\Remote\RemoteWebDriver;
@@ -79,8 +80,15 @@ class phpbb_ui_test_case extends phpbb_test_case
}
try {
- $capabilities = DesiredCapabilities::firefox();
- self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities);
+ $capabilities = DesiredCapabilities::chrome();
+ $chromeOptions = (new ChromeOptions)->addArguments(['headless', 'disable-gpu']);
+ $capabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions);
+ self::$webDriver = RemoteWebDriver::create(
+ self::$host . ':' . self::$port,
+ $capabilities,
+ 30 * 1000, // 30 seconds connection timeout
+ 30 * 1000 // 30 seconds request timeout
+ );
} catch (WebDriverCurlException $e) {
self::markTestSkipped('PhantomJS webserver is not running.');
}
@@ -192,6 +200,13 @@ class phpbb_ui_test_case extends phpbb_test_case
}
}
+ $install_config_file = $phpbb_root_path . 'store/install_config.php';
+
+ if (file_exists($install_config_file))
+ {
+ unlink($install_config_file);
+ }
+
$container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
$container = $container_builder
->with_environment('installer')
@@ -205,11 +220,14 @@ class phpbb_ui_test_case extends phpbb_test_case
],
'cache.driver.class' => 'phpbb\cache\driver\file'
])
+ ->with_config(new \phpbb\config_php_file($phpbb_root_path, $phpEx))
->without_compiled_container()
->get_container();
$container->register('installer.install_finish.notify_user')->setSynthetic(true);
$container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task());
+ $container->register('installer.install_finish.install_extensions')->setSynthetic(true);
+ $container->set('installer.install_finish.install_extensions', new phpbb_mock_null_installer_task());
$container->compile();
$language = $container->get('language');
@@ -317,7 +335,7 @@ class phpbb_ui_test_case extends phpbb_test_case
$meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
// Wait for extension to be fully enabled
- while (sizeof($meta_refresh))
+ while (count($meta_refresh))
{
preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match);
$this->getDriver()->execute(array('method' => 'post', 'url' => $match[1]));
@@ -338,6 +356,12 @@ class phpbb_ui_test_case extends phpbb_test_case
{
if (!$this->cache)
{
+ global $phpbb_container, $phpbb_root_path;
+
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT);
+ $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
+
$this->cache = new \phpbb\cache\driver\file;
}
@@ -590,4 +614,37 @@ class phpbb_ui_test_case extends phpbb_test_case
$this->getDriver()->takeScreenshot($screenshot);
}
+
+ /**
+ * Wait for AJAX. Should be called after an AJAX action is made.
+ *
+ * @param string $framework javascript frameworks jquery|prototype|dojo
+ * @throws \Facebook\WebDriver\Exception\NoSuchElementException
+ * @throws \Facebook\WebDriver\Exception\TimeOutException
+ */
+ public function waitForAjax($framework = 'jquery')
+ {
+ switch ($framework)
+ {
+ case 'jquery':
+ $code = 'return jQuery.active;';
+ break;
+ case 'prototype':
+ $code = 'return Ajax.activeRequestCount;';
+ break;
+ case 'dojo':
+ $code = 'return dojo.io.XMLHTTPTransport.inFlight.length;';
+ break;
+ default:
+ throw new \RuntimeException('Unsupported framework');
+ break;
+ }
+ // wait for at most 30s, retry every 2000ms (2s)
+ $driver = $this->getDriver();
+ $driver->wait(30, 2000)->until(
+ function () use ($driver, $code) {
+ return !$driver->executeScript($code);
+ }
+ );
+ }
}
diff --git a/tests/text_formatter/s9e/bbcode_merger_test.php b/tests/text_formatter/s9e/bbcode_merger_test.php
new file mode 100644
index 0000000000..815539056b
--- /dev/null
+++ b/tests/text_formatter/s9e/bbcode_merger_test.php
@@ -0,0 +1,280 @@
+<?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_textformatter_s9e_bbcode_merger_test extends phpbb_test_case
+{
+ /**
+ * @dataProvider get_merge_bbcodes_tests
+ */
+ public function test_merge_bbcodes($usage_without, $template_without, $usage_with, $template_with, $expected_usage, $expected_template)
+ {
+ $container = $this->get_test_case_helpers()->set_s9e_services();
+ $factory = $container->get('text_formatter.s9e.factory');
+ $bbcode_merger = new \phpbb\textformatter\s9e\bbcode_merger($factory);
+
+ $without = ['usage' => $usage_without, 'template' => $template_without];
+ $with = ['usage' => $usage_with, 'template' => $template_with];
+ $merged = $bbcode_merger->merge_bbcodes($without, $with);
+
+ // Normalize the expected template's whitespace to match the default indentation
+ $expected_template = str_replace("\n\t\t\t\t", "\n", $expected_template);
+ $expected_template = str_replace("\t", ' ', $expected_template);
+
+ $this->assertSame($expected_usage, $merged['usage']);
+ $this->assertSame($expected_template, $merged['template']);
+ }
+
+ public function get_merge_bbcodes_tests()
+ {
+ return [
+ [
+ '[x]{TEXT}[/x]',
+ '<b>{TEXT}</b>',
+
+ '[x={TEXT1}]{TEXT}[/x]',
+ '<b title="{TEXT1}">{TEXT}</b>',
+
+ '[x={TEXT1?}]{TEXT}[/x]',
+ '<b>
+ <xsl:if test="@x">
+ <xsl:attribute name="title">
+ <xsl:value-of select="@x"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates/>
+ </b>'
+ ],
+ [
+ // The tokens' numbering differs between versions
+ '[x]{TEXT}[/x]',
+ '<b>{TEXT}</b>',
+
+ '[x={TEXT1}]{TEXT2}[/x]',
+ '<b title="{TEXT1}">{TEXT2}</b>',
+
+ '[x={TEXT1?}]{TEXT2}[/x]',
+ '<b>
+ <xsl:if test="@x">
+ <xsl:attribute name="title">
+ <xsl:value-of select="@x"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates/>
+ </b>'
+ ],
+ [
+ '[x]{URL}[/x]',
+ '<a href="{URL}">{URL}</a>',
+
+ '[x={URL}]{TEXT}[/x]',
+ '<a href="{URL}">{TEXT}</a>',
+
+ '[x={URL;useContent}]{TEXT}[/x]',
+ '<a href="{@x}">
+ <xsl:apply-templates/>
+ </a>'
+ ],
+ [
+ '[x]{URL}[/x]',
+ '<a href="{URL}">{L_GO_TO}: {URL}</a>',
+
+ '[x={URL}]{TEXT}[/x]',
+ '<a href="{URL}">{L_GO_TO}: {TEXT}</a>',
+
+ '[x={URL;useContent}]{TEXT}[/x]',
+ '<a href="{@x}">{L_GO_TO}: <xsl:apply-templates/></a>'
+ ],
+ [
+ // Test that unsafe BBCodes can still be merged
+ '[script]{TEXT}[/script]',
+ '<script>{TEXT}</script>',
+
+ '[script={TEXT1}]{TEXT2}[/script]',
+ '<script type="{TEXT1}">{TEXT2}</script>',
+
+ '[script={TEXT1?}]{TEXT2}[/script]',
+ '<script>
+ <xsl:if test="@script">
+ <xsl:attribute name="type">
+ <xsl:value-of select="@script"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates/>
+ </script>'
+ ],
+ [
+ // https://www.phpbb.com/community/viewtopic.php?p=14848281#p14848281
+ '[note]{TEXT}[/note]',
+ '<span class="prime_bbcode_note_spur" onmouseover="show_note(this);" onmouseout="hide_note(this);" onclick="lock_note(this);"></span><span class="prime_bbcode_note">{TEXT}</span>',
+
+ '[note={TEXT1}]{TEXT2}[/note]',
+ '<span class="prime_bbcode_note_text" onmouseover="show_note(this);" onmouseout="hide_note(this);" onclick="lock_note(this);">{TEXT1}</span><span class="prime_bbcode_note_spur" onmouseover="show_note(this);" onmouseout="hide_note(this);" onclick="lock_note(this);"></span><span class="prime_bbcode_note">{TEXT2}</span>',
+
+ '[note={TEXT1?}]{TEXT2}[/note]',
+ '<xsl:if test="@note">
+ <span class="prime_bbcode_note_text" onmouseover="show_note(this);" onmouseout="hide_note(this);" onclick="lock_note(this);">
+ <xsl:value-of select="@note"/>
+ </span>
+ </xsl:if>
+ <span class="prime_bbcode_note_spur" onmouseover="show_note(this);" onmouseout="hide_note(this);" onclick="lock_note(this);"/>
+ <span class="prime_bbcode_note">
+ <xsl:apply-templates/>
+ </span>'
+ ],
+ [
+ // https://www.phpbb.com/community/viewtopic.php?p=14768441#p14768441
+ '[MI]{TEXT}[/MI]',
+ '<span style="color:red">MI:</span> <span style="color:#f6efe2">{TEXT}</span>',
+
+ '[MI={TEXT2}]{TEXT1}[/MI]',
+ '<span style="color:red">MI for: "{TEXT2}":</span> <span style="color:#f6efe2">{TEXT1}</span>',
+
+ '[MI={TEXT2?}]{TEXT1}[/MI]',
+ '<span style="color:red">MI<xsl:if test="@mi"> for: "<xsl:value-of select="@mi"/>"</xsl:if>:</span>
+ <xsl:text> </xsl:text>
+ <span style="color:#f6efe2">
+ <xsl:apply-templates/>
+ </span>'
+ ],
+ [
+ // https://www.phpbb.com/community/viewtopic.php?p=14700506#p14700506
+ '[spoiler]{TEXT}[/spoiler]',
+ '<span class="spoiler"> {TEXT}</span>',
+
+ '[spoiler={TEXT1}]{TEXT2}[/spoiler]',
+ '<div class="spoiler"><small> {TEXT1}</small>{TEXT2}</div>',
+
+ '[spoiler={TEXT1?}]{TEXT2}[/spoiler]',
+ '<xsl:choose>
+ <xsl:when test="@spoiler">
+ <div class="spoiler">
+ <small>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="@spoiler"/>
+ </small>
+ <xsl:apply-templates/>
+ </div>
+ </xsl:when>
+ <xsl:otherwise>
+ <span class="spoiler">
+ <xsl:text> </xsl:text>
+ <xsl:apply-templates/>
+ </span>
+ </xsl:otherwise>
+ </xsl:choose>'
+ ],
+ [
+ // https://www.phpbb.com/community/viewtopic.php?p=14859676#p14859676
+ '[AE]{TEXT}[/AE]',
+ '<table width="100%" border="1">
+ <tr><td width="100%" align="center">
+ <table width="100%" border="0">
+ <tr>
+ <td width="100%" bgcolor="#E1E4F2">
+ <table width="100%" border="0" bgcolor="#F5F5FF">
+ <tr>
+ <td width="1%" bgcolor="#000000" nowrap align="left">
+ <font color="#FFFFFF" face="Arial"><font size="1"><b>&nbsp;ACTIVE EFFECTS & CONDITIONS&nbsp;</b></font></font></td>
+ <td width="99%">&nbsp;</td>
+ </tr>
+ <tr>
+ <td width="100%" bgcolor="#FFE5BA" colspan="2">
+ <table width="100%" cellpadding="2">
+ <tr>
+ <td width="100%" align="left" valign="top">
+ {TEXT}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td></tr>
+ </table>
+ <p>&nbsp;</p>',
+
+ '[AE={TEXT1}]{TEXT2}[/AE]',
+ '<table width="100%" border="1">
+ <tr><td width="100%" align="center">
+ <table width="100%" border="0">
+ <tr>
+ <td width="100%" bgcolor="#E1E4F2">
+ <table width="100%" border="0" bgcolor="#F5F5FF">
+ <tr>
+ <td width="1%" bgcolor="#000000" nowrap align="left">
+ <font color="#FFFFFF" face="Arial"><font size="1"><b>&nbsp; {TEXT1}&nbsp;</b></font></font></td>
+ <td width="99%">&nbsp;</td>
+ </tr>
+ <tr>
+ <td width="100%" bgcolor="#FFE5BA" colspan="2">
+ <table width="100%" cellpadding="2">
+ <tr>
+ <td width="100%" align="left" valign="top">
+ {TEXT2}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td></tr>
+ </table>
+ <p>&nbsp;</p>',
+
+ '[AE={TEXT1?}]{TEXT2}[/AE]',
+ '<table width="100%" border="1">
+ <tr>
+ <td width="100%" align="center">
+ <table width="100%" border="0">
+ <tr>
+ <td width="100%" bgcolor="#E1E4F2">
+ <table width="100%" border="0" bgcolor="#F5F5FF">
+ <tr>
+ <td width="1%" bgcolor="#000000" nowrap="nowrap" align="left">
+ <font color="#FFFFFF" face="Arial">
+ <font size="1">
+ <b> <xsl:choose><xsl:when test="@ae"><xsl:text> </xsl:text><xsl:value-of select="@ae"/></xsl:when><xsl:otherwise>ACTIVE EFFECTS &amp; CONDITIONS</xsl:otherwise></xsl:choose> </b>
+ </font>
+ </font>
+ </td>
+ <td width="99%"> </td>
+ </tr>
+ <tr>
+ <td width="100%" bgcolor="#FFE5BA" colspan="2">
+ <table width="100%" cellpadding="2">
+ <tr>
+ <td width="100%" align="left" valign="top">
+ <xsl:apply-templates/>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <p> </p>'
+ ],
+ ];
+ }
+}
diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php
index a0c57214e4..a35c9138a5 100644
--- a/tests/text_formatter/s9e/default_formatting_test.php
+++ b/tests/text_formatter/s9e/default_formatting_test.php
@@ -50,27 +50,27 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
return array(
array(
'[b]bold[/b]',
- '<span style="font-weight: bold">bold</span>'
+ '<span style="font-weight:bold">bold</span>'
),
array(
'[u]underlined[/u]',
- '<span style="text-decoration: underline">underlined</span>'
+ '<span style="text-decoration:underline">underlined</span>'
),
array(
'[i]italic[/i]',
- '<span style="font-style: italic">italic</span>'
+ '<span style="font-style:italic">italic</span>'
),
array(
'[color=#FF0000]colored[/color]',
- '<span style="color: #FF0000">colored</span>'
+ '<span style="color:#FF0000">colored</span>'
),
array(
'[color=red]colored[/color]',
- '<span style="color: red">colored</span>'
+ '<span style="color:red">colored</span>'
),
array(
'[size=75]smaller[/size]',
- '<span style="font-size: 75%; line-height: normal">smaller</span>'
+ '<span style="font-size:75%;line-height:normal">smaller</span>'
),
array(
'[quote]quoted[/quote]',
@@ -102,31 +102,31 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
),
array(
'[list=1][*]item[/list]',
- '<ol style="list-style-type: decimal"><li>item</li></ol>'
+ '<ol style="list-style-type:decimal"><li>item</li></ol>'
),
array(
'[list=a][*]item[/list]',
- '<ol style="list-style-type: lower-alpha"><li>item</li></ol>'
+ '<ol style="list-style-type:lower-alpha"><li>item</li></ol>'
),
array(
'[list=i][*]item[/list]',
- '<ol style="list-style-type: lower-roman"><li>item</li></ol>'
+ '<ol style="list-style-type:lower-roman"><li>item</li></ol>'
),
array(
'[list=I][*]item[/list]',
- '<ol style="list-style-type: upper-roman"><li>item</li></ol>'
+ '<ol style="list-style-type:upper-roman"><li>item</li></ol>'
),
array(
'[list=disc][*]item[/list]',
- '<ul style="list-style-type: disc"><li>item</li></ul>'
+ '<ul style="list-style-type:disc"><li>item</li></ul>'
),
array(
'[list=circle][*]item[/list]',
- '<ul style="list-style-type: circle"><li>item</li></ul>'
+ '<ul style="list-style-type:circle"><li>item</li></ul>'
),
array(
'[list=square][*]item[/list]',
- '<ul style="list-style-type: square"><li>item</li></ul>'
+ '<ul style="list-style-type:square"><li>item</li></ul>'
),
array(
'[img]https://area51.phpbb.com/images/area51.png[/img]',
@@ -180,17 +180,17 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
array(
// Allow textual bbcodes in textual bbcodes
'[b]bold [i]bold + italic[/i][/b]',
- '<span style="font-weight: bold">bold <span style="font-style: italic">bold + italic</span></span>'
+ '<span style="font-weight:bold">bold <span style="font-style:italic">bold + italic</span></span>'
),
array(
// Allow textual bbcodes in url with description
'[url=https://area51.phpbb.com/]Area51 [i]italic[/i][/url]',
- '<a href="https://area51.phpbb.com/" class="postlink">Area51 <span style="font-style: italic">italic</span></a>'
+ '<a href="https://area51.phpbb.com/" class="postlink">Area51 <span style="font-style:italic">italic</span></a>'
),
array(
// Allow url with description in textual bbcodes
'[i]italic [url=https://area51.phpbb.com/]Area51[/url][/i]',
- '<span style="font-style: italic">italic <a href="https://area51.phpbb.com/" class="postlink">Area51</a></span>'
+ '<span style="font-style:italic">italic <a href="https://area51.phpbb.com/" class="postlink">Area51</a></span>'
),
array(
// Do not parse textual bbcodes in code
@@ -205,7 +205,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
array(
// Textual bbcode nesting into textual bbcode
'[b]bold [i]bold + italic[/b] italic[/i]',
- '<span style="font-weight: bold">bold <span style="font-style: italic">bold + italic</span></span><span style="font-style: italic"> italic</span>'
+ '<span style="font-weight:bold">bold <span style="font-style:italic">bold + italic</span></span><span style="font-style:italic"> italic</span>'
),
array(
"[code]\tline1\n line2[/code]",
@@ -254,6 +254,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
'<a href="http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" class="postlink">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</a>'
),
array(
+ '[url=http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx[/url]',
+ '<a href="http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" class="postlink">http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</a>'
+ ),
+ array(
'[quote="[url=http://example.org]xxx[/url]"]...[/quote]',
'<blockquote><div><cite><a href="http://example.org" class="postlink">xxx</a> wrote:</cite>...</div></blockquote>'
),
@@ -298,7 +302,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
),
array(
"Emoji: \xF0\x9F\x98\x80",
- 'Emoji: <img alt="' . "\xF0\x9F\x98\x80" . '" class="emoji smilies" draggable="false" src="//cdn.jsdelivr.net/emojione/assets/svg/1f600.svg">'
+ 'Emoji: <img alt="' . "\xF0\x9F\x98\x80" . '" class="emoji smilies" draggable="false" src="//twemoji.maxcdn.com/2/svg/1f600.svg">'
),
array(
"Emoji: \xF0\x9F\x98\x80",
diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php
index fd9b4e4c09..0d780a19a9 100644
--- a/tests/text_formatter/s9e/factory_test.php
+++ b/tests/text_formatter/s9e/factory_test.php
@@ -56,6 +56,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
$this->dispatcher,
new \phpbb\config\config(array('allowed_schemes_links' => 'http,https,ftp')),
new \phpbb\textformatter\s9e\link_helper,
+ $this->getMockBuilder('phpbb\\log\\log_interface')->getMock(),
$this->get_cache_dir(),
'_foo_parser',
'_foo_renderer'
@@ -248,6 +249,39 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
}
/**
+ * @testdox Accepts unsafe default BBCodes
+ */
+ public function test_unsafe_default_bbcodes()
+ {
+ $fixture = __DIR__ . '/fixtures/unsafe_default_bbcodes.xml';
+ $style_dir = __DIR__ . '/fixtures/styles/';
+ $container = $this->get_test_case_helpers()->set_s9e_services(null, $fixture, $style_dir);
+ $parser = $container->get('text_formatter.parser');
+ $renderer = $container->get('text_formatter.renderer');
+
+ $original = '[b]alert(1)[/b]';
+ $expected = '<script>alert(1)</script>';
+ $this->assertSame($expected, $renderer->render($parser->parse($original)));
+ }
+
+ /**
+ * @testdox Logs malformed BBCodes
+ */
+ public function test_malformed_bbcodes()
+ {
+ $log = $this->getMockBuilder('phpbb\\log\\log_interface')->getMock();
+ $log->expects($this->once())
+ ->method('add')
+ ->with('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, ['[x !x]{TEXT}[/x]', 'Cannot interpret the BBCode definition']);
+
+ $container = new phpbb_mock_container_builder;
+ $container->set('log', $log);
+
+ $fixture = __DIR__ . '/fixtures/malformed_bbcode.xml';
+ $this->get_test_case_helpers()->set_s9e_services($container, $fixture);
+ }
+
+ /**
* @testdox get_configurator() triggers events before and after configuration
*/
public function test_configure_events()
diff --git a/tests/text_formatter/s9e/fixtures/malformed_bbcode.xml b/tests/text_formatter/s9e/fixtures/malformed_bbcode.xml
new file mode 100644
index 0000000000..7e7aa1a39c
--- /dev/null
+++ b/tests/text_formatter/s9e/fixtures/malformed_bbcode.xml
@@ -0,0 +1,28 @@
+<?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>x</value>
+ <value></value>
+ <value>1</value>
+ <value>[x !x]{TEXT}[/x]</value>
+ <value>...</value>
+ <value/>
+ <value/>
+ <value/>
+ <value/>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html
new file mode 100644
index 0000000000..f3932f9b78
--- /dev/null
+++ b/tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html
@@ -0,0 +1,40 @@
+<!-- BEGIN ulist_open --><ul style="list-style-type: {LIST_TYPE}"><!-- END ulist_open -->
+<!-- BEGIN ulist_open_default --><ul><!-- END ulist_open_default -->
+<!-- BEGIN ulist_close --></ul><!-- END ulist_close -->
+
+<!-- BEGIN olist_open --><ol style="list-style-type: {LIST_TYPE}"><!-- END olist_open -->
+<!-- BEGIN olist_close --></ol><!-- END olist_close -->
+
+<!-- BEGIN listitem --><li><!-- END listitem -->
+<!-- BEGIN listitem_close --></li><!-- END listitem_close -->
+
+<!-- BEGIN quote_username_open --><blockquote><div><cite>{USERNAME} {L_WROTE}{L_COLON}</cite><!-- END quote_username_open -->
+<!-- BEGIN quote_open --><blockquote class="uncited"><div><!-- END quote_open -->
+<!-- BEGIN quote_close --></div></blockquote><!-- END quote_close -->
+
+<!-- BEGIN code_open --><div class="codebox"><p>{L_CODE}{L_COLON} <a href="#" onclick="selectCode(this); return false;">{L_SELECT_ALL_CODE}</a></p><code><!-- END code_open -->
+<!-- BEGIN code_close --></code></div><!-- END code_close -->
+
+<!-- BEGIN inline_attachment_open --><div class="inline-attachment"><!-- END inline_attachment_open -->
+<!-- BEGIN inline_attachment_close --></div><!-- END inline_attachment_close -->
+
+<!-- BEGIN b_open --><script><!-- END b_open -->
+<!-- BEGIN b_close --></script><!-- END b_close -->
+
+<!-- BEGIN u_open --><span style="text-decoration: underline"><!-- END u_open -->
+<!-- BEGIN u_close --></span><!-- END u_close -->
+
+<!-- BEGIN i_open --><em><!-- END i_open -->
+<!-- BEGIN i_close --></em><!-- END i_close -->
+
+<!-- BEGIN color --><span style="color: {COLOR}">{TEXT}</span><!-- END color -->
+
+<!-- BEGIN size --><span style="font-size: {SIZE}%; line-height: 116%;">{TEXT}</span><!-- END size -->
+
+<!-- BEGIN img --><img src="{URL}" class="postimage" alt="{L_IMAGE}" /><!-- END img -->
+
+<!-- BEGIN url --><a href="{URL}" class="postlink">{DESCRIPTION}</a><!-- END url -->
+
+<!-- BEGIN email --><a href="mailto:{EMAIL}">{DESCRIPTION}</a><!-- END email -->
+
+<!-- BEGIN flash --><object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0" width="{WIDTH}" height="{HEIGHT}"><param name="movie" value="{URL}" /><param name="play" value="false" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><embed src="{URL}" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="{WIDTH}" height="{HEIGHT}" play="false" loop="false" quality="high" allowscriptaccess="never" allownetworking="internal"></embed></object><!-- END flash -->
diff --git a/tests/text_formatter/s9e/fixtures/unsafe_default_bbcodes.xml b/tests/text_formatter/s9e/fixtures/unsafe_default_bbcodes.xml
new file mode 100644
index 0000000000..06524a13cc
--- /dev/null
+++ b/tests/text_formatter/s9e/fixtures/unsafe_default_bbcodes.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_styles">
+ <column>style_id</column>
+ <column>style_name</column>
+ <column>style_copyright</column>
+ <column>style_active</column>
+ <column>style_path</column>
+ <column>bbcode_bitfield</column>
+ <column>style_parent_id</column>
+ <column>style_parent_tree</column>
+
+ <row>
+ <value>1</value>
+ <value>unsafe</value>
+ <value></value>
+ <value>1</value>
+ <value>unsafe</value>
+ <value>QA==</value>
+ <value>0</value>
+ <value></value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_processing/tickets_data/PHPBB3-10122.html b/tests/text_processing/tickets_data/PHPBB3-10122.html
index f0fb6115b2..0803c895a8 100644
--- a/tests/text_processing/tickets_data/PHPBB3-10122.html
+++ b/tests/text_processing/tickets_data/PHPBB3-10122.html
@@ -1 +1 @@
-<ul style="list-style-type: none"><li>This is my indented text</li></ul> \ No newline at end of file
+<ul style="list-style-type:none"><li>This is my indented text</li></ul> \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-10268.html b/tests/text_processing/tickets_data/PHPBB3-10268.html
index c89e63f9a3..13b71b4823 100644
--- a/tests/text_processing/tickets_data/PHPBB3-10268.html
+++ b/tests/text_processing/tickets_data/PHPBB3-10268.html
@@ -1,4 +1,4 @@
<blockquote><div><cite><a href="http://phpbb.com" class="postlink">http://phpbb.com</a> wrote:</cite>...</div></blockquote>
<blockquote><div><cite><a href="http://phpbb.com" class="postlink"> http://phpbb.com</a> wrote:</cite>...</div></blockquote>
-<span style="font-weight: bold"><a href="http://phpbb.com" class="postlink">http://phpbb.com</a></span><br>
-<span style="font-weight: bold"> <a href="http://phpbb.com" class="postlink">http://phpbb.com</a></span><br>
+<span style="font-weight:bold"><a href="http://phpbb.com" class="postlink">http://phpbb.com</a></span><br>
+<span style="font-weight:bold"> <a href="http://phpbb.com" class="postlink">http://phpbb.com</a></span><br>
diff --git a/tests/text_processing/tickets_data/PHPBB3-13641.html b/tests/text_processing/tickets_data/PHPBB3-13641.html
index 1bd1c06dbb..2646bc0ea5 100644
--- a/tests/text_processing/tickets_data/PHPBB3-13641.html
+++ b/tests/text_processing/tickets_data/PHPBB3-13641.html
@@ -1 +1 @@
-<code>[color=#FF0000]</code> - <span style="color: #FF0000">red</span> \ No newline at end of file
+<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-13921.html b/tests/text_processing/tickets_data/PHPBB3-13921.html
index 6a9dc7f504..690668ef28 100644
--- a/tests/text_processing/tickets_data/PHPBB3-13921.html
+++ b/tests/text_processing/tickets_data/PHPBB3-13921.html
@@ -1 +1 @@
-<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
+<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-14706.html b/tests/text_processing/tickets_data/PHPBB3-14706.html
index b8f74c9e93..23b3304485 100644
--- a/tests/text_processing/tickets_data/PHPBB3-14706.html
+++ b/tests/text_processing/tickets_data/PHPBB3-14706.html
@@ -1 +1 @@
-<ul><li><ol style="list-style-type: lower-alpha"><li>a</li><li>b</li><li>c</li><li>d</li><li>e</li></ol></li><li>outer</li></ul> \ No newline at end of file
+<ul><li><ol style="list-style-type:lower-alpha"><li>a</li><li>b</li><li>c</li><li>d</li><li>e</li></ol></li><li>outer</li></ul> \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-14790.html b/tests/text_processing/tickets_data/PHPBB3-14790.html
index 7624b2d36c..5384098e1b 100644
--- a/tests/text_processing/tickets_data/PHPBB3-14790.html
+++ b/tests/text_processing/tickets_data/PHPBB3-14790.html
@@ -1,4 +1,4 @@
-<span style="color: #0000FF"></span><ul><li><span style="color: #0000FF">text</span></li>
-<li><span style="color: #0000FF">text</span></li>
-<li><span style="color: #0000FF">text</span></li>
-<li><span style="color: #0000FF">text</span></li></ul> \ No newline at end of file
+<span style="color:#0000FF"></span><ul><li><span style="color:#0000FF">text</span></li>
+<li><span style="color:#0000FF">text</span></li>
+<li><span style="color:#0000FF">text</span></li>
+<li><span style="color:#0000FF">text</span></li></ul> \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-14846.html b/tests/text_processing/tickets_data/PHPBB3-14846.html
index 461ca25bc6..bd4455781b 100644
--- a/tests/text_processing/tickets_data/PHPBB3-14846.html
+++ b/tests/text_processing/tickets_data/PHPBB3-14846.html
@@ -1 +1 @@
-<div style="padding: .2em .5em; font-size: .8em; width: 200px; background: #FFD;">moderator text<div style="font-weight: bold; text-align: right">- Mickroz</div></div> \ No newline at end of file
+<div style="padding:.2em .5em;font-size:.8em;width:200px;background:#ffd">moderator text<div style="font-weight:bold;text-align:right">- Mickroz</div></div> \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.html b/tests/text_processing/tickets_data/PHPBB3-15348.html
index e65925ec28..1794232d08 100644
--- a/tests/text_processing/tickets_data/PHPBB3-15348.html
+++ b/tests/text_processing/tickets_data/PHPBB3-15348.html
@@ -1 +1 @@
-<img class="smilies" src="phpBB/images/smilies/icon_e_surprised.gif" width="15" height="17" alt=":o" title="First half of :ok:"> <img class="smilies" src="phpBB/images/smilies/icon_lol.gif" width="15" height="17" alt="k:" title="Second half of :ok:"> <img alt=":ok:" class="emoji smilies" draggable="false" src="//cdn.jsdelivr.net/emojione/assets/svg/1f197.svg"> \ No newline at end of file
+<img class="smilies" src="phpBB/images/smilies/icon_e_surprised.gif" width="15" height="17" alt=":o" title="First half of :ok:"> <img class="smilies" src="phpBB/images/smilies/icon_lol.gif" width="15" height="17" alt="k:" title="Second half of :ok:"> <img alt=":ok:" class="emoji smilies" draggable="false" src="//twemoji.maxcdn.com/2/svg/1f197.svg"> \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-16053.html b/tests/text_processing/tickets_data/PHPBB3-16053.html
new file mode 100644
index 0000000000..af70ddf7eb
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-16053.html
@@ -0,0 +1 @@
+<a href="http://ea117.com" alt="Test">Test</a> \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-16053.txt b/tests/text_processing/tickets_data/PHPBB3-16053.txt
new file mode 100644
index 0000000000..c786665eb9
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-16053.txt
@@ -0,0 +1 @@
+[test=http://ea117.com]Test[/test] \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-16053.xml b/tests/text_processing/tickets_data/PHPBB3-16053.xml
new file mode 100644
index 0000000000..25f7c9e34e
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-16053.xml
@@ -0,0 +1,28 @@
+<?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>test</value>
+ <value></value>
+ <value>1</value>
+ <value>[test={URL}]{TEXT}[/test]</value>
+ <value><![CDATA[<a href="{URL}" alt="{TEXT}">{TEXT}</a>]]></value>
+ <value>((?!))</value>
+ <value></value>
+ <value>((?!))</value>
+ <value></value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_processing/tickets_data/PHPBB3-16074.html b/tests/text_processing/tickets_data/PHPBB3-16074.html
new file mode 100644
index 0000000000..b588e2ac47
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-16074.html
@@ -0,0 +1 @@
+<img alt=":man_judge:" class="emoji smilies" draggable="false" src="//twemoji.maxcdn.com/2/svg/1f468-200d-2696-fe0f.svg"> <img alt="👨‍⚖️" class="emoji smilies" draggable="false" src="//twemoji.maxcdn.com/2/svg/1f468-200d-2696-fe0f.svg"> \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-16074.txt b/tests/text_processing/tickets_data/PHPBB3-16074.txt
new file mode 100644
index 0000000000..f067a7294d
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-16074.txt
@@ -0,0 +1 @@
+:man_judge: 👨‍⚖️ \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-8419.html b/tests/text_processing/tickets_data/PHPBB3-8419.html
index 38df626a94..df91e9df50 100644
--- a/tests/text_processing/tickets_data/PHPBB3-8419.html
+++ b/tests/text_processing/tickets_data/PHPBB3-8419.html
@@ -1 +1 @@
-<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
+<span style="font-style:italic"><span style="font-weight:bold"><span style="color:red">tę </span></span></span>przykład \ No newline at end of file
diff --git a/tests/text_reparser/base_test.php b/tests/text_reparser/base_test.php
index af2d56ea51..2c6844b063 100644
--- a/tests/text_reparser/base_test.php
+++ b/tests/text_reparser/base_test.php
@@ -66,4 +66,19 @@ class phpbb_textreparser_base_test extends phpbb_database_test_case
$this->get_rows(array(1))
);
}
+
+ public function test_reparse_case_insensitive()
+ {
+ $this->get_reparser()->reparse_range(2, 2);
+
+ $this->assertEquals(
+ [
+ [
+ 'id' => '2',
+ 'text' => '<r><IMG src="img.png"><s>[IMG]</s>img.png<e>[/IMG]</e></IMG></r>'
+ ]
+ ],
+ $this->get_rows([2])
+ );
+ }
}
diff --git a/tests/text_reparser/fixtures/base.xml b/tests/text_reparser/fixtures/base.xml
index a4921a8823..532a19a8a9 100644
--- a/tests/text_reparser/fixtures/base.xml
+++ b/tests/text_reparser/fixtures/base.xml
@@ -15,5 +15,13 @@
<value></value>
<value>abcd1234</value>
</row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value><![CDATA[<r><IMG src="img.png"><s>[IMG]</s>img.png<e>[/IMG]</e></IMG></r>]]></value>
+ <value></value>
+ </row>
</table>
</dataset>
diff --git a/tests/text_reparser/plugins/fixtures/polls.xml b/tests/text_reparser/plugins/fixtures/polls.xml
index 2960d640a9..5247fb906d 100644
--- a/tests/text_reparser/plugins/fixtures/polls.xml
+++ b/tests/text_reparser/plugins/fixtures/polls.xml
@@ -44,55 +44,66 @@
<column>topic_id</column>
<column>topic_first_post_id</column>
<column>poll_title</column>
+ <column>poll_start</column>
<row>
<value>1</value>
<value>1</value>
<value>This row should be [b]ignored[/b]</value>
+ <value>1</value>
</row>
<row>
<value>2</value>
<value>1</value>
<value>[b]Not bold[/b] :) http://example.org</value>
+ <value>1</value>
</row>
<row>
<value>3</value>
<value>2</value>
<value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ <value>1</value>
</row>
<row>
<value>4</value>
<value>3</value>
<value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ <value>1</value>
</row>
<row>
<value>5</value>
<value>4</value>
<value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ <value>1</value>
</row>
<row>
<value>6</value>
<value>2</value>
<value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
+ <value>1</value>
</row>
<row>
<value>7</value>
<value>1</value>
<value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
+ <value>1</value>
</row>
<row>
<value>8</value>
<value>2</value>
<value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
+ <value>1</value>
</row>
<row>
<value>9</value>
<value>1</value>
<value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
+ <value>1</value>
</row>
<row>
<value>1000</value>
<value>1</value>
<value>This row should be [b]ignored[/b]</value>
+ <value>1</value>
</row>
</table>
</dataset>
diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php
index 3daa75b2e4..498c6a69a2 100644
--- a/tests/tree/nestedset_forum_base.php
+++ b/tests/tree/nestedset_forum_base.php
@@ -69,7 +69,7 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
static $forums;
if (empty($forums))
- {
+ {
$this->create_forum('Parent with two flat children');
$this->create_forum('Flat child #1', 1);
$this->create_forum('Flat child #2', 1);
@@ -86,7 +86,7 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
// Updating forum_parents column here so it's not empty
// This is required, so we can see whether the methods
- // correctly clear the values.
+ // correctly clear the values.
$sql = "UPDATE phpbb_forums
SET forum_parents = 'a:0:{}'";
$this->db->sql_query($sql);
@@ -100,6 +100,13 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
}
else
{
+ // Turn on identity insert on mssql to be able to insert into
+ // identity columns (e.g. forum_id)
+ if (strpos($this->db->sql_layer, 'mssql') !== false)
+ {
+ $sql = 'SET IDENTITY_INSERT phpbb_forums ON';
+ $this->db->sql_query($sql);
+ }
$buffer = new \phpbb\db\sql_insert_buffer($this->db, 'phpbb_forums');
$buffer->insert_all($forums);
$buffer->flush();
@@ -107,7 +114,14 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
$this->database_synchronisation(array(
'phpbb_forums' => array('forum_id'),
));
- }
+
+ // Disable identity insert on mssql again
+ if (strpos($this->db->sql_layer, 'mssql') !== false)
+ {
+ $sql = 'SET IDENTITY_INSERT phpbb_forums OFF';
+ $this->db->sql_query($sql);
+ }
+ }
}
protected function create_forum($name, $parent_id = 0)
diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php
index 18b6deed1f..b41b95d925 100644
--- a/tests/upload/filespec_test.php
+++ b/tests/upload/filespec_test.php
@@ -79,7 +79,7 @@ class phpbb_filespec_test extends phpbb_test_case
$this->phpbb_root_path = $phpbb_root_path;
}
- private function set_reflection_property(&$class, $property_name, $value)
+ private function set_reflection_property($class, $property_name, $value)
{
$property = new ReflectionProperty($class, $property_name);
$property->setAccessible(true);
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php
index fb72823f08..5b3357237d 100644
--- a/tests/upload/fileupload_test.php
+++ b/tests/upload/fileupload_test.php
@@ -173,7 +173,7 @@ class phpbb_fileupload_test extends phpbb_test_case
->set_max_filesize(1000);
$file = $this->gen_valid_filespec();
$upload->common_checks($file);
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
}
public function test_local_upload()
@@ -184,7 +184,7 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
$this->assertFalse($file->additional_checks());
$this->assertTrue($file->move_file('../tests/upload/fixture/copies', true));
$file->remove();
@@ -198,10 +198,10 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
$this->assertFalse($file->move_file('../tests/upload/fixture'));
$this->assertFalse($file->get('file_moved'));
- $this->assertEquals(1, sizeof($file->error));
+ $this->assertEquals(1, count($file->error));
}
public function test_move_existent_file_overwrite()
@@ -213,9 +213,9 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
$file->move_file('../tests/upload/fixture/copies', true);
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
unlink($this->path . 'copies/jpg.jpg');
}
diff --git a/tests/wrapper/version_compare_test.php b/tests/wrapper/version_compare_test.php
index 8260d99504..ee23fe779c 100644
--- a/tests/wrapper/version_compare_test.php
+++ b/tests/wrapper/version_compare_test.php
@@ -66,7 +66,7 @@ class phpbb_wrapper_version_compare_test extends phpbb_test_case
'3.2-A1',
);
- for ($i = 0, $size = sizeof($releases); $i < $size - 1; ++$i)
+ for ($i = 0, $size = count($releases); $i < $size - 1; ++$i)
{
$version1 = $releases[$i];
$version2 = $releases[$i + 1];