diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index bbc530750d..f5637b1f5e 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -1010,7 +1010,7 @@ function make_clickable($text, $server_url = false, string $class = 'postlink')
if (preg_match($magic_args[0], $text, $matches))
{
// Only apply $class from the corresponding function call argument (excepting emails which never has a class)
- if ($magic_args[3] != $static_class && $magic_args[1] != MAGIC_URL_EMAIL)
+ if ($magic_args[1] != MAGIC_URL_EMAIL && $magic_args[3] != $static_class)
{
continue;
}
diff --git a/tests/acp_board/select_auth_method_test.php b/tests/acp_board/select_auth_method_test.php
index 0ca3384469..b651fbedf9 100644
--- a/tests/acp_board/select_auth_method_test.php
+++ b/tests/acp_board/select_auth_method_test.php
@@ -21,23 +21,31 @@ class phpbb_acp_board_select_auth_method_test extends phpbb_test_case
public static function select_auth_method_data()
{
- return array(
- array('acp_board_valid', ''),
- array('acp_board_invalid', ''),
- );
+ return [
+ ['acp_board_valid', ''],
+ ['acp_board_invalid', ''],
+ ];
}
protected function setUp(): void
{
parent::setUp();
- global $phpbb_container;
+ global $phpbb_container, $config;
$phpbb_container = new phpbb_mock_container_builder();
+ $config = new \phpbb\config\config([]);
- $phpbb_container->set('auth.provider_collection', array(
- 'auth.provider.acp_board_valid' => new phpbb\auth\provider\acp\board_valid,
- 'auth.provider.acp_board_invalid' => new phpbb\auth\provider\acp\board_invalid,
- ));
+ // Create auth provider service collection
+ $auth_provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
+ $phpbb_container->set('auth.provider_collection', $auth_provider_collection);
+
+ // Create auth provider services
+ $phpbb_container->set('auth.provider.acp_board_valid', new phpbb\auth\provider\acp\board_valid);
+ $phpbb_container->set('auth.provider.acp_board_invalid', new phpbb\auth\provider\acp\board_invalid);
+
+ // Add auth provider servives to the service collection
+ $auth_provider_collection->add('auth.provider.acp_board_valid');
+ $auth_provider_collection->add('auth.provider.acp_board_invalid');
$this->acp_board = new acp_board();
}
diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php
index ae2c96ba84..69714d93f9 100644
--- a/tests/attachment/upload_test.php
+++ b/tests/attachment/upload_test.php
@@ -144,6 +144,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$this->temp = new \phpbb\filesystem\temp($this->filesystem, '');
$this->user = new \phpbb\user($this->language, '\phpbb\datetime');
+ $this->user->data['user_id'] = ANONYMOUS;
$this->upload = new \phpbb\attachment\upload(
$this->auth,
@@ -187,7 +188,14 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
)
),
array('foobar', 1, true,
- array(),
+ // Instead of setting to false or empty array, set default filedata array
+ // as otherwise it throws PHP undefined array key warnings
+ // in different file upload related services
+ array(
+ 'realname' => null,
+ 'type' => null,
+ 'size' => null,
+ ),
array(
'error' => array(
'NOT_UPLOADED',
@@ -250,7 +258,16 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->user
);
- $filedata = $this->upload->upload('foobar', 1, true);
+ // Instead of setting to false or empty array, set default filedata array
+ // as otherwise it throws PHP undefined array key warnings
+ // in different file upload related services
+ $filedata = $this->upload->upload('foobar', 1, true, '', false,
+ [
+ 'realname' => null,
+ 'type' => null,
+ 'size' => null,
+ ]
+ );
$this->assertSame(array(
'error' => array(),
diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php
index 5b4c8ff9db..f09115c9d3 100644
--- a/tests/auth/provider_apache_test.php
+++ b/tests/auth/provider_apache_test.php
@@ -72,14 +72,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
->with('PHP_AUTH_USER',
\phpbb\request\request_interface::SERVER)
->will($this->returnValue(true));
- $this->request->expects($this->at(1))
+ $this->request->expects($this->exactly(2))
->method('server')
- ->with('PHP_AUTH_USER')
- ->will($this->returnValue('foobar'));
- $this->request->expects($this->at(2))
- ->method('server')
- ->with('PHP_AUTH_PW')
- ->will($this->returnValue('example'));
+ ->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW'])
+ ->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example')));
$expected = array(
'status' => LOGIN_SUCCESS,
@@ -104,14 +100,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
->with('PHP_AUTH_USER',
\phpbb\request\request_interface::SERVER)
->will($this->returnValue(true));
- $this->request->expects($this->at(1))
+ $this->request->expects($this->exactly(2))
->method('server')
- ->with('PHP_AUTH_USER')
- ->will($this->returnValue('foobar'));
- $this->request->expects($this->at(2))
- ->method('server')
- ->with('PHP_AUTH_PW')
- ->will($this->returnValue('example'));
+ ->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW'])
+ ->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example')));
$expected = array(
'user_id' => 1,
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index a94ba102f5..a1e43646e7 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -330,7 +330,9 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
'avatar_type' => '',
'avatar_width' => 0,
'avatar_height' => 0,
- ), 1, array(
+ ),
+ array(
+ 'id' => 1,
'avatar' => 'foobar@example.com',
'avatar_type' => 'avatar.driver.gravatar',
'avatar_width' => '16',
@@ -343,7 +345,9 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
'avatar_type' => '',
'avatar_width' => 0,
'avatar_height' => 0,
- ), 5, array(
+ ),
+ array(
+ 'id' => 5,
'avatar' => 'g5_1414350991.jpg',
'avatar_type' => 'avatar.driver.upload',
'avatar_width' => '80',
@@ -356,13 +360,13 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
/**
* @dataProvider data_handle_avatar_delete
*/
- public function test_handle_avatar_delete($expected, $id, $avatar_data, $table, $prefix)
+ public function test_handle_avatar_delete($expected, $avatar_data, $table, $prefix)
{
$this->config['allow_avatar_gravatar'] = true;
$this->assertNull($this->manager->handle_avatar_delete($this->db, $this->user, $avatar_data, $table, $prefix));
$sql = 'SELECT * FROM ' . $table . '
- WHERE ' . $prefix . 'id = ' . $id;
+ WHERE ' . $prefix . 'id = ' . (int) $avatar_data['id'];
$result = $this->db->sql_query_limit($sql, 1);
$row = $this->manager->clean_row($this->db->sql_fetchrow($result), substr($prefix, 0, -1));
diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php
index d3df5492a2..bc5b5cf160 100644
--- a/tests/cache/apcu_driver_test.php
+++ b/tests/cache/apcu_driver_test.php
@@ -24,7 +24,7 @@ class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
if (!extension_loaded('apcu'))
{
diff --git a/tests/cache/cache_memory.php b/tests/cache/cache_memory.php
index 565e9a48eb..1f7b31a86b 100644
--- a/tests/cache/cache_memory.php
+++ b/tests/cache/cache_memory.php
@@ -31,7 +31,7 @@ class phpbb_cache_memory extends \phpbb\cache\driver\memory
*/
function _read($var)
{
- return $this->data[$var];
+ return $this->data[$var] ?? false;
}
/**
diff --git a/tests/cache/cache_memory_test.php b/tests/cache/cache_memory_test.php
index b3d19f1782..3a465aef7e 100644
--- a/tests/cache/cache_memory_test.php
+++ b/tests/cache/cache_memory_test.php
@@ -123,7 +123,7 @@ class phpbb_cache_memory_test extends phpbb_database_test_case
foreach ($sql_queries as $query)
{
- $this->assertNotEquals(false, $this->cache->sql_load($query[0]));
+ $this->assertFalse($this->cache->sql_load($query[0]));
}
}
}
diff --git a/tests/cache/memcached_test.php b/tests/cache/memcached_test.php
index 650b72ea18..14499e7423 100644
--- a/tests/cache/memcached_test.php
+++ b/tests/cache/memcached_test.php
@@ -22,7 +22,7 @@ class phpbb_cache_memcached_driver_test extends \phpbb_cache_common_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
if (!extension_loaded('memcached'))
{
diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php
index a2288cf9a8..c5ec7880fd 100644
--- a/tests/cache/redis_driver_test.php
+++ b/tests/cache/redis_driver_test.php
@@ -22,7 +22,7 @@ class phpbb_cache_redis_driver_test extends \phpbb_cache_common_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
if (!extension_loaded('redis'))
{
diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php
index b828be2ec4..8321680547 100644
--- a/tests/console/config/config_test.php
+++ b/tests/console/config/config_test.php
@@ -159,7 +159,7 @@ class phpbb_console_command_config_test extends phpbb_test_case
'--no-newline' => false,
));
- $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay());
+ $this->assertStringContainsString('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay());
}
public function test_increment_dynamic()
@@ -175,7 +175,7 @@ class phpbb_console_command_config_test extends phpbb_test_case
'--dynamic' => true,
));
- $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay());
+ $this->assertStringContainsString('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay());
$this->assertSame(2, $this->config['test_key']);
}
@@ -192,7 +192,7 @@ class phpbb_console_command_config_test extends phpbb_test_case
'--dynamic' => false,
));
- $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay());
+ $this->assertStringContainsString('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay());
$this->assertSame(2, $this->config['test_key']);
}
@@ -208,7 +208,7 @@ class phpbb_console_command_config_test extends phpbb_test_case
'--dynamic' => true,
));
- $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay());
+ $this->assertStringContainsString('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay());
$this->assertSame(2, $this->config['test_key']);
}
@@ -223,7 +223,7 @@ class phpbb_console_command_config_test extends phpbb_test_case
'key' => 'test_key',
));
- $this->assertContains('CLI_CONFIG_DELETE_SUCCESS', $command_tester->getDisplay());
+ $this->assertStringContainsString('CLI_CONFIG_DELETE_SUCCESS', $command_tester->getDisplay());
$this->assertEmpty($this->config);
}
@@ -237,7 +237,7 @@ class phpbb_console_command_config_test extends phpbb_test_case
'key' => 'wrong_key',
));
- $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay());
+ $this->assertStringContainsString('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay());
$this->assertEmpty($this->config);
}
diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php
index aaa3e260e6..8a0c47f8de 100644
--- a/tests/console/cron/cron_list_test.php
+++ b/tests/console/cron/cron_list_test.php
@@ -41,19 +41,19 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case
public function test_no_task()
{
$this->initiate_test(0, 0);
- $this->assertContains('CRON_NO_TASKS', $this->command_tester->getDisplay());
+ $this->assertStringContainsString('CRON_NO_TASKS', $this->command_tester->getDisplay());
}
public function test_only_ready()
{
$this->initiate_test(2, 0);
- $this->assertContains('TASKS_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay())));
+ $this->assertStringContainsString('TASKS_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay())));
}
public function test_only_not_ready()
{
$this->initiate_test(0, 2);
- $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay())));
+ $this->assertStringContainsString('TASKS_NOT_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay())));
}
public function test_both_ready()
diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php
index cdad4c13e6..ac202af5b2 100644
--- a/tests/console/cron/run_test.php
+++ b/tests/console/cron/run_test.php
@@ -99,23 +99,22 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$command_tester = $this->get_command_tester();
$exit_status = $command_tester->execute(array('command' => $this->command_name, '--verbose' => true));
- $this->assertContains('RUNNING_TASK', $command_tester->getDisplay());
+ $this->assertStringContainsString('RUNNING_TASK', $command_tester->getDisplay());
$this->assertSame(true, $this->task->executed);
$this->assertSame(0, $exit_status);
$this->assertSame(false, $this->lock->owns_lock());
}
- /**
- * @expectedException \phpbb\exception\runtime_exception
- * @expectedExceptionMessage CRON_LOCK_ERROR
- */
public function test_error_lock()
{
+ $this->expectException(\phpbb\exception\runtime_exception::class);
+ $this->expectExceptionMessage('CRON_LOCK_ERROR');
+
$this->lock->acquire();
$command_tester = $this->get_command_tester();
$exit_status = $command_tester->execute(array('command' => $this->command_name));
- $this->assertContains('CRON_LOCK_ERROR', $command_tester->getDisplay());
+ $this->assertStringContainsString('CRON_LOCK_ERROR', $command_tester->getDisplay());
$this->assertSame(false, $this->task->executed);
$this->assertSame(1, $exit_status);
}
@@ -209,7 +208,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$command_tester = $this->get_command_tester();
$exit_status = $command_tester->execute(array('command' => $this->command_name, '--verbose' => true));
- $this->assertContains('CRON_NO_TASK', $command_tester->getDisplay());
+ $this->assertStringContainsString('CRON_NO_TASK', $command_tester->getDisplay());
$this->assertSame(0, $exit_status);
$this->assertSame(false, $this->lock->owns_lock());
}
@@ -225,16 +224,15 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$this->assertSame(false, $this->lock->owns_lock());
}
- /**
- * @expectedException \phpbb\exception\runtime_exception
- * @expectedExceptionMessage CRON_NO_SUCH_TASK
- */
public function test_arg_invalid()
{
+ $this->expectException(\phpbb\exception\runtime_exception::class);
+ $this->expectExceptionMessage('CRON_NO_SUCH_TASK');
+
$command_tester = $this->get_command_tester();
$exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'foo'));
- $this->assertContains('CRON_NO_SUCH_TASK', $command_tester->getDisplay());
+ $this->assertStringContainsString('CRON_NO_SUCH_TASK', $command_tester->getDisplay());
$this->assertSame(false, $this->task->executed);
$this->assertSame(2, $exit_status);
$this->assertSame(false, $this->lock->owns_lock());
@@ -245,7 +243,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$command_tester = $this->get_command_tester();
$exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple', '--verbose' => true));
- $this->assertContains('RUNNING_TASK', $command_tester->getDisplay());
+ $this->assertStringContainsString('RUNNING_TASK', $command_tester->getDisplay());
$this->assertSame(true, $this->task->executed);
$this->assertSame(0, $exit_status);
$this->assertSame(false, $this->lock->owns_lock());
diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php
index 555c9454e1..cc434f5583 100644
--- a/tests/console/update/check_test.php
+++ b/tests/console/update/check_test.php
@@ -43,7 +43,7 @@ class phpbb_console_command_check_test extends phpbb_test_case
{
$command_tester = $this->get_command_tester('100000');
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true));
- $this->assertContains($this->language->lang('UPDATE_NOT_NEEDED'), $command_tester->getDisplay());
+ $this->assertStringContainsString($this->language->lang('UPDATE_NOT_NEEDED'), $command_tester->getDisplay());
$this->assertSame($status, 0);
}
@@ -52,7 +52,7 @@ class phpbb_console_command_check_test extends phpbb_test_case
{
$command_tester = $this->get_command_tester('0');
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true));
- $this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay());
+ $this->assertStringContainsString($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay());
$this->assertSame($status, 1);
}
@@ -60,21 +60,20 @@ class phpbb_console_command_check_test extends phpbb_test_case
{
$command_tester = $this->get_command_tester('0');
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true));
- $this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay());
- $this->assertContains($this->language->lang('UPDATES_AVAILABLE'), $command_tester->getDisplay());
+ $this->assertStringContainsString($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay());
+ $this->assertStringContainsString($this->language->lang('UPDATES_AVAILABLE'), $command_tester->getDisplay());
$this->assertSame($status, 1);
}
- /**
- * @expectedException phpbb\exception\runtime_exception
- */
public function test_error()
{
+ $this->expectException(\phpbb\exception\runtime_exception::class);
+
$command_tester = $this->get_command_tester('1');
$this->version_helper->set_file_location('acme.corp','foo', 'bar.json');
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true));
- $this->assertContains('VERSIONCHECK_FAIL', $command_tester->getDisplay());
+ $this->assertStringContainsString('VERSIONCHECK_FAIL', $command_tester->getDisplay());
$this->assertSame($status, 2);
}
diff --git a/tests/console/user/activate_test.php b/tests/console/user/activate_test.php
index 261eac152a..01f38e5ed9 100644
--- a/tests/console/user/activate_test.php
+++ b/tests/console/user/activate_test.php
@@ -80,6 +80,6 @@ class phpbb_console_user_activate_test extends phpbb_console_user_base
'--deactivate' => $deactivate,
));
- $this->assertContains($expected, $command_tester->getDisplay());
+ $this->assertStringContainsString($expected, $command_tester->getDisplay());
}
}
diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php
index cc86cb27d3..126771c7c6 100644
--- a/tests/console/user/add_test.php
+++ b/tests/console/user/add_test.php
@@ -93,7 +93,7 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
));
$this->assertNotEquals(null, $this->get_user_id('foo'));
- $this->assertContains('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay());
+ $this->assertStringContainsString('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay());
}
public function test_add_dialog()
@@ -113,7 +113,7 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
));
$this->assertNotEquals(null, $this->get_user_id('bar'));
- $this->assertContains('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay());
+ $this->assertStringContainsString('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay());
}
@@ -130,8 +130,8 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
'--email' => 'foo'
));
- $this->assertContains('USERNAME_TAKEN', $command_tester->getDisplay());
- $this->assertContains('TOO_SHORT', $command_tester->getDisplay());
- $this->assertContains('EMAIL_INVALID', $command_tester->getDisplay());
+ $this->assertStringContainsString('USERNAME_TAKEN', $command_tester->getDisplay());
+ $this->assertStringContainsString('TOO_SHORT', $command_tester->getDisplay());
+ $this->assertStringContainsString('EMAIL_INVALID', $command_tester->getDisplay());
}
}
diff --git a/tests/console/user/base.php b/tests/console/user/base.php
index c40a0070ac..fd8acf935c 100644
--- a/tests/console/user/base.php
+++ b/tests/console/user/base.php
@@ -62,7 +62,12 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
$this->language->expects($this->any())
->method('lang')
->will($this->returnArgument(0));
- $user = $this->user = $this->createMock('\phpbb\user');
+
+ $user = $this->user = $this->createMock('\phpbb\user', array(), array(
+ $this->language,
+ '\phpbb\datetime'
+ ));
+ $user->data['user_email'] = '';
$this->user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
diff --git a/tests/console/user/delete_test.php b/tests/console/user/delete_test.php
index 4535c4e295..f010fc6356 100644
--- a/tests/console/user/delete_test.php
+++ b/tests/console/user/delete_test.php
@@ -53,7 +53,7 @@ class phpbb_console_user_delete_test extends phpbb_console_user_base
));
$this->assertNull($this->get_user_id('Test'));
- $this->assertContains('USER_DELETED', $command_tester->getDisplay());
+ $this->assertStringContainsString('USER_DELETED', $command_tester->getDisplay());
}
public function test_delete_non_user()
@@ -70,7 +70,7 @@ class phpbb_console_user_delete_test extends phpbb_console_user_base
'--delete-posts' => false,
));
- $this->assertContains('NO_USER', $command_tester->getDisplay());
+ $this->assertStringContainsString('NO_USER', $command_tester->getDisplay());
}
public function test_delete_cancel()
diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php
index 35a8eedb80..f888fd001a 100644
--- a/tests/content_visibility/delete_post_test.php
+++ b/tests/content_visibility/delete_post_test.php
@@ -311,6 +311,8 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_id'] = ANONYMOUS;
+
$attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage);
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index 1a36464add..0a408bf351 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -107,7 +107,10 @@ class phpbb_controller_controller_test extends phpbb_test_case
array(new foo\controller(), array(), array()),
array(array(new foo\controller(), 'handle_fail'), array(), array(), '\phpbb\controller\exception', 'CONTROLLER_ARGUMENT_VALUE_MISSING'),
array('', array(), array(), '\ReflectionException', 'Function () does not exist'),
- array(new phpbb\controller\foo, array(), array(), '\ReflectionException', 'Method __invoke does not exist'),
+ // Before PHP 8: 'Method __invoke does not exist'
+ // As of PHP 8: 'Method phpbb\controller\foo::__invoke() does not exist'
+ array(new phpbb\controller\foo, array(), array(), '\ReflectionException',
+ 'Method ' . (version_compare(PHP_VERSION, '8', '>=') ? 'phpbb\controller\foo::__invoke()' : '__invoke') . ' does not exist'),
);
}
diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php
index 5f1acac2ae..5d77c158ec 100644
--- a/tests/cron/manager_test.php
+++ b/tests/cron/manager_test.php
@@ -21,7 +21,7 @@ require_once dirname(__FILE__) . '/tasks/simple_should_not_run.php';
class phpbb_cron_manager_test extends \phpbb_test_case
{
protected $manager;
- protected $tast_name;
+ protected $task_name;
protected function setUp(): void
{
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index ba5f40003d..4d896f3014 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -356,11 +356,8 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
->will($this->returnValue(true));
// drop tables
- $db_tools->expects($this->exactly(2))->method('sql_table_drop');
- $db_tools->expects($this->at(1))->method('sql_table_drop')
- ->with($this->equalTo('dropped_table_1'));
- $db_tools->expects($this->at(3))->method('sql_table_drop')
- ->with($this->equalTo('dropped_table_2'));
+ $db_tools->expects($this->exactly(2))->method('sql_table_drop')
+ ->withConsecutive([$this->equalTo('dropped_table_1')], [$this->equalTo('dropped_table_2')]);
$db_tools->perform_schema_changes(array(
'drop_tables' => array(
@@ -384,11 +381,11 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
->will($this->returnValue(true));
// drop columns
- $db_tools->expects($this->exactly(2))->method('sql_column_remove');
- $db_tools->expects($this->at(1))->method('sql_column_remove')
- ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_1'));
- $db_tools->expects($this->at(3))->method('sql_column_remove')
- ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_2'));
+ $db_tools->expects($this->exactly(2))->method('sql_column_remove')
+ ->withConsecutive(
+ [$this->equalTo('existing_table'), $this->equalTo('dropped_column_1')],
+ [$this->equalTo('existing_table'), $this->equalTo('dropped_column_2')]
+ );
$db_tools->perform_schema_changes(array(
'drop_columns' => array(
@@ -425,7 +422,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_create_int_default_null()
{
$this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));
- $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2')));
+ $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2', null)));
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));
}
diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php
index be61d82bde..5c4844927e 100644
--- a/tests/email/email_parsing_test.php
+++ b/tests/email/email_parsing_test.php
@@ -52,6 +52,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_lang'] = 'en';
$phpbb_container->set('user', $user);
$extension_manager = new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
@@ -137,13 +138,13 @@ class phpbb_email_parsing_test extends phpbb_test_case
$reflection_template = $this->reflection_template_property->getValue($this->messenger);
$msg = trim($reflection_template->assign_display('body'));
- $this->assertContains($author_name, $msg);
- $this->assertContains($forum_name, $msg);
- $this->assertContains($topic_title, $msg);
- $this->assertContains($username, $msg);
- $this->assertContains(htmlspecialchars_decode($config['sitename']), $msg);
- $this->assertContains(str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), $msg);
- $this->assertNotContains('EMAIL_SIG', $msg);
- $this->assertNotContains('U_STOP_WATCHING_FORUM', $msg);
+ $this->assertStringContainsString($author_name, $msg);
+ $this->assertStringContainsString($forum_name, $msg);
+ $this->assertStringContainsString($topic_title, $msg);
+ $this->assertStringContainsString($username, $msg);
+ $this->assertStringContainsString(htmlspecialchars_decode($config['sitename']), $msg);
+ $this->assertStringContainsString(str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), $msg);
+ $this->assertStringNotContainsString('EMAIL_SIG', $msg);
+ $this->assertStringNotContainsString('U_STOP_WATCHING_FORUM', $msg);
}
}
diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php
index 7b73679fda..6073eac6fe 100644
--- a/tests/error_collector_test.php
+++ b/tests/error_collector_test.php
@@ -28,7 +28,8 @@ class phpbb_error_collector_test extends phpbb_test_case
$collector->install();
// Cause a warning
- 1/0; $line = __LINE__;
+ // Division by zero was promoted to fatal error and throws DivisionByZeroError exception in PHP 8+
+ version_compare(PHP_VERSION, '8', '>=') ? '1b'['0xFF'] : 1/0; $line = __LINE__;
$collector->uninstall();
@@ -39,7 +40,7 @@ class phpbb_error_collector_test extends phpbb_test_case
// Unfortunately $error_contents will contain the full path here,
// because the tests directory is outside of phpbb root path.
- $this->assertStringStartsWith('Errno 2: Division by zero at ', $error_contents);
+ $this->assertStringStartsWith(version_compare(PHP_VERSION, '8', '>=') ? 'Errno 2: Illegal string offset "0xFF" at ' : 'Errno 2: Division by zero at ', $error_contents);
$this->assertStringEndsWith(" line $line", $error_contents);
}
@@ -49,16 +50,19 @@ class phpbb_error_collector_test extends phpbb_test_case
$collector->install();
// Cause a warning
- 1/0; $line = __LINE__;
+ // Division by zero was promoted to fatal error and throws DivisionByZeroError exception in PHP 8+
+ version_compare(PHP_VERSION, '8', '>=') ? '1b'['0xFF'] : 1/0; $line = __LINE__;
- // Cause a notice
- $array = array(0 => 'value');
- $value = $array[1]; $line2 = __LINE__;
+ // Cause a "Notice: unserialize(): Error at offset 0 of 27 bytes in ..."
+ // "Undefined array index" used earlier was promoted to warning in PHP 8.0,
+ // see https://github.com/php/php-src/commit/c48b745f0090c944e77c1fbcfb6c4df3b54356ad
+ unserialize("obvious non-serialized data"); $line2 = __LINE__;
$collector->uninstall();
// The notice should not be collected
- $this->assertEmpty($collector->errors[1]);
+ $this->assertFalse(isset($collector->errors[1]));
+ $this->assertEquals(count($collector->errors), 1);
list($errno, $msg_text, $errfile, $errline) = $collector->errors[0];
$error_contents = $collector->format_errors();
@@ -67,7 +71,7 @@ class phpbb_error_collector_test extends phpbb_test_case
// Unfortunately $error_contents will contain the full path here,
// because the tests directory is outside of phpbb root path.
- $this->assertStringStartsWith('Errno 2: Division by zero at ', $error_contents);
+ $this->assertStringStartsWith(version_compare(PHP_VERSION, '8', '>=') ? 'Errno 2: Illegal string offset "0xFF" at ' : 'Errno 2: Division by zero at ', $error_contents);
$this->assertStringEndsWith(" line $line", $error_contents);
}
}
diff --git a/tests/event/exception_listener_test.php b/tests/event/exception_listener_test.php
index fbae9e25b7..346bc5f3ec 100644
--- a/tests/event/exception_listener_test.php
+++ b/tests/event/exception_listener_test.php
@@ -94,7 +94,7 @@ class exception_listener extends phpbb_test_case
if (isset($expected['content']))
{
- $this->assertContains($expected['content'], $response->getContent());
+ $this->assertStringContainsString($expected['content'], $response->getContent());
}
}
}
diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php
index 2cc2b0c7a0..e93b8a7876 100644
--- a/tests/event/php_exporter_test.php
+++ b/tests/event/php_exporter_test.php
@@ -169,10 +169,10 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
/**
* @dataProvider validate_since_throws_data
- * @expectedException LogicException
*/
public function test_validate_since_throws($since)
{
+ $this->expectException('LogicException');
$this->exporter->validate_since($since);
}
@@ -203,7 +203,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
/**
* @dataProvider validate_event_throws_data
- * @expectedException LogicException
*/
public function test_validate_event_throws($event_name, $event, $exception_code)
{
@@ -240,10 +239,10 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
/**
* @dataProvider validate_vars_docblock_array_throws_data
- * @expectedException LogicException
*/
public function test_validate_vars_docblock_array_throws($vars_array, $vars_docblock)
{
+ $this->expectException('LogicException');
$this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock);
}
@@ -282,10 +281,10 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
/**
* @dataProvider get_dispatch_name_throws_data
- * @expectedException LogicException
*/
public function test_get_dispatch_name_throws($event_line)
{
+ $this->expectException('LogicException');
$this->exporter->set_content(array($event_line));
$this->exporter->get_event_name(0, true);
}
@@ -328,10 +327,10 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
/**
* @dataProvider get_trigger_event_name_throws_data
- * @expectedException LogicException
*/
public function test_get_trigger_event_name_throws($event_line)
{
+ $this->expectException('LogicException');
$this->exporter->set_content(array($event_line));
$this->exporter->get_event_name(0, false);
}
@@ -459,7 +458,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
/**
* @dataProvider get_vars_from_array_throws_data
- * @expectedException LogicException
*/
public function test_get_vars_from_array_throws($lines, $event_line, $exception_code)
{
@@ -545,7 +543,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
/**
* @dataProvider get_vars_from_docblock_throws_data
- * @expectedException LogicException
*/
public function test_get_vars_from_docblock_throws($lines, $event_line, $exception_code)
{
@@ -649,7 +646,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
/**
* @dataProvider find_since_throws_data
- * @expectedException LogicException
*/
public function test_find_since_throws($lines, $event_line, $exception_code)
{
@@ -751,7 +747,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
/**
* @dataProvider find_description_throws_data
- * @expectedException LogicException
*/
public function test_find_description_throws($lines, $event_line, $exception_code)
{
diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php
index ab85d3f02e..03d5547c7c 100644
--- a/tests/extension/extension_base_test.php
+++ b/tests/extension/extension_base_test.php
@@ -21,7 +21,7 @@ class phpbb_extension_extension_base_test extends phpbb_test_case
/** @var phpbb_mock_extension_manager */
protected $extension_manager;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/tests/files/types_local_test.php b/tests/files/types_local_test.php
index 106f8cda2f..e4cfd49064 100644
--- a/tests/files/types_local_test.php
+++ b/tests/files/types_local_test.php
@@ -102,6 +102,7 @@ class phpbb_files_types_local_test extends phpbb_test_case
array(
'foo',
array(
+ 'realname' => null,
'tmp_name' => 'foo',
'size' => 500,
'type' => 'image/png',
@@ -110,13 +111,17 @@ class phpbb_files_types_local_test extends phpbb_test_case
),
array(
'none',
- false,
+ array(
+ 'realname' => null,
+ 'size' => null,
+ 'type' => null,
+ ),
array('PHP_SIZE_OVERRUN'),
),
array(
'tests/upload/fixture/png',
array(
- 'realname' => 'foo.png',
+ 'realname' => 'foo.png',
'size' => 500,
'type' => 'image/png',
'local_mode' => true,
@@ -151,7 +156,6 @@ class phpbb_files_types_local_test extends phpbb_test_case
$upload->set_allowed_extensions(array('png'));
$type_local->set_upload($upload);
-
$file = $type_local->upload($filename, $upload_ary);
$this->assertSame($expected, $file->error);
$this->assertInstanceOf('\phpbb\files\filespec', $file);
diff --git a/tests/filesystem/helper_realpath_test.php b/tests/filesystem/helper_realpath_test.php
index f3c7742cd5..2f28909a82 100644
--- a/tests/filesystem/helper_realpath_test.php
+++ b/tests/filesystem/helper_realpath_test.php
@@ -17,7 +17,7 @@ class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
{
protected static $filesystem_helper_phpbb_own_realpath;
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/tests/filesystem/realpath_test.php b/tests/filesystem/realpath_test.php
index 58291dac93..145ded7cfa 100644
--- a/tests/filesystem/realpath_test.php
+++ b/tests/filesystem/realpath_test.php
@@ -18,7 +18,7 @@ class phpbb_filesystem_realpath_test extends phpbb_test_case
/** @var \phpbb\filesystem\filesystem_interface */
protected $filesystem;
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/tests/functional/acp_bbcodes_test.php b/tests/functional/acp_bbcodes_test.php
index cc6397fdfd..bdf7920615 100644
--- a/tests/functional/acp_bbcodes_test.php
+++ b/tests/functional/acp_bbcodes_test.php
@@ -38,10 +38,10 @@ class phpbb_functional_acp_bbcodes_test extends phpbb_functional_test_case
$crawler = self::submit($form);
$html = $crawler->filter('#preview')->html();
- $this->assertContains('
a
', $html);
- $this->assertContains('b
', $html);
- $this->assertContains('c
', $html);
- $this->assertContains('d
', $html);
+ $this->assertStringContainsString('a
', $html);
+ $this->assertStringContainsString('b
', $html);
+ $this->assertStringContainsString('c
', $html);
+ $this->assertStringContainsString('d
', $html);
}
/**
diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php
index 9dfdc93474..06001fd262 100644
--- a/tests/functional/acp_groups_test.php
+++ b/tests/functional/acp_groups_test.php
@@ -105,7 +105,7 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_te
}
}
$crawler = self::submit($form);
- $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
+ $this->assertStringContainsString($this->lang('GROUP_UPDATED'), $crawler->text());
$form = $this->get_group_manage_form($group_id);
if (!isset($tick_legend) && !isset($tick_teampage))
@@ -117,8 +117,10 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_te
else
{
$this->form_data = $form->getValues();
- $this->assertEquals($tick_legend, $this->form_data['group_legend']);
- $this->assertEquals($tick_teampage, $this->form_data['group_teampage']);
+ // form_data[] values can be bool or null if not ticked, $tick_* value can be bool or null if not set.
+ // Cast both to the same type to correctly compare the values.
+ $this->assertEquals((bool) $tick_legend, (bool) ($this->form_data['group_legend'] ?? false));
+ $this->assertEquals((bool) $tick_teampage, (bool) ($this->form_data['group_teampage'] ?? false));
}
}
}
diff --git a/tests/functional/acp_permissions_test.php b/tests/functional/acp_permissions_test.php
index 41fa03639e..36cbbf2359 100644
--- a/tests/functional/acp_permissions_test.php
+++ b/tests/functional/acp_permissions_test.php
@@ -31,21 +31,21 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
// XXX hardcoded id
$crawler = self::request('GET', 'adm/index.php?i=16&sid=' . $this->sid);
// these language strings are html
- $this->assertContains($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->get_content());
+ $this->assertStringContainsString($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->get_content());
}
public function test_select_user()
{
// User permissions
$crawler = self::request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
- $this->assertContains($this->lang('ACP_USERS_PERMISSIONS_EXPLAIN'), $this->get_content());
+ $this->assertStringContainsString($this->lang('ACP_USERS_PERMISSIONS_EXPLAIN'), $this->get_content());
// Select admin
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$data = array('username[0]' => 'admin');
$form->setValues($data);
$crawler = self::submit($form);
- $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
+ $this->assertStringContainsString($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
}
public function permissions_data()
@@ -93,7 +93,7 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
{
// Get the form
$crawler = self::request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=$mode&${object_name}[0]=$object_id&type=$permission_type&sid=" . $this->sid);
- $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
+ $this->assertStringContainsString($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
// XXX globals for \phpbb\auth\auth, refactor it later
global $db, $cache;
@@ -115,7 +115,7 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
$data = array("setting[$object_id][0][$permission]" => '0');
$form->setValues($data);
$crawler = self::submit($form);
- $this->assertContains($this->lang('AUTH_UPDATED'), $crawler->text());
+ $this->assertStringContainsString($this->lang('AUTH_UPDATED'), $crawler->text());
// check acl again
$auth = new \phpbb\auth\auth;
diff --git a/tests/functional/acp_users_test.php b/tests/functional/acp_users_test.php
index 5c10f809d6..2470b55f06 100644
--- a/tests/functional/acp_users_test.php
+++ b/tests/functional/acp_users_test.php
@@ -34,7 +34,7 @@ class phpbb_functional_acp_users_test extends phpbb_functional_test_case
$crawler = self::request('GET', "adm/index.php?i=users&mode=overview&u=$user_id&sid={$this->sid}");
$form = $crawler->filter('#user_delete')->selectButton($this->lang('SUBMIT'))->form();
$crawler = self::submit($form);
- $this->assertContains($this->lang('CANNOT_REMOVE_FOUNDER'), $this->get_content());
+ $this->assertStringContainsString($this->lang('CANNOT_REMOVE_FOUNDER'), $this->get_content());
}
protected function make_founder($user_id)
@@ -44,6 +44,6 @@ class phpbb_functional_acp_users_test extends phpbb_functional_test_case
$data = array('user_founder' => '1');
$form->setValues($data);
$crawler = self::submit($form);
- $this->assertContains($this->lang('USER_OVERVIEW_UPDATED'), $this->get_content());
+ $this->assertStringContainsString($this->lang('USER_OVERVIEW_UPDATED'), $this->get_content());
}
}
diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php
index 76e1709afb..3e22a5b651 100644
--- a/tests/functional/auth_test.php
+++ b/tests/functional/auth_test.php
@@ -22,7 +22,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
// check for logout link
$crawler = self::request('GET', 'index.php');
- $this->assertContains($this->lang('LOGOUT', 'admin'), $crawler->filter('.navbar')->text());
+ $this->assertStringContainsString($this->lang('LOGOUT', 'admin'), $crawler->filter('.navbar')->text());
}
public function test_login_other()
@@ -30,7 +30,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
$this->create_user('anothertestuser');
$this->login('anothertestuser');
$crawler = self::request('GET', 'index.php');
- $this->assertContains('anothertestuser', $crawler->filter('#username_logged_in')->text());
+ $this->assertStringContainsString('anothertestuser', $crawler->filter('#username_logged_in')->text());
}
/**
@@ -46,7 +46,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
$config['auth_method'] = 'foobar';
$this->login('anothertestuser');
$crawler = self::request('GET', 'index.php');
- $this->assertContains('anothertestuser', $crawler->filter('#username_logged_in')->text());
+ $this->assertStringContainsString('anothertestuser', $crawler->filter('#username_logged_in')->text());
$sql = 'UPDATE ' . CONFIG_TABLE . " SET config_value = 'db' WHERE config_name = 'auth_method'";
$db->sql_query($sql);
$config['auth_method'] = 'db';
@@ -65,7 +65,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
// look for a register link, which should be visible only when logged out
$crawler = self::request('GET', 'index.php');
- $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
+ $this->assertStringContainsString($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
}
public function test_acp_login()
@@ -75,6 +75,6 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
// check that we are logged in
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid);
- $this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text());
+ $this->assertStringContainsString($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text());
}
}
diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php
index ca8c84ab2e..f9251fd2f0 100644
--- a/tests/functional/avatar_acp_groups_test.php
+++ b/tests/functional/avatar_acp_groups_test.php
@@ -80,6 +80,6 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av
$crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid);
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$form_data = $form->getValues();
- $this->assertEmpty($form_data['avatar_type']);
+ $this->assertFalse(isset($form_data['avatar_type']));
}
}
diff --git a/tests/functional/common_avatar_test_case.php b/tests/functional/common_avatar_test_case.php
index 36987a0c45..0ead7f9f24 100644
--- a/tests/functional/common_avatar_test_case.php
+++ b/tests/functional/common_avatar_test_case.php
@@ -83,7 +83,7 @@ abstract class phpbb_functional_common_avatar_test_case extends phpbb_functional
}
catch (Exception $e)
{
- $this->assertContains($expected, $crawler->text());
+ $this->assertStringContainsString($expected, $crawler->text());
}
if ($delete)
diff --git a/tests/functional/common_groups_test_case.php b/tests/functional/common_groups_test_case.php
index 521b7c84d2..fdca908239 100644
--- a/tests/functional/common_groups_test_case.php
+++ b/tests/functional/common_groups_test_case.php
@@ -47,9 +47,9 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional
$crawler = self::request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid);
// Check the default entries we should have
- $this->assertContains($this->lang('ALLOW_REMOTE_UPLOAD'), $crawler->text());
- $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text());
- $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text());
+ $this->assertStringContainsString($this->lang('ALLOW_REMOTE_UPLOAD'), $crawler->text());
+ $this->assertStringContainsString($this->lang('ALLOW_AVATARS'), $crawler->text());
+ $this->assertStringContainsString($this->lang('ALLOW_LOCAL'), $crawler->text());
// Now start setting the needed settings
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
@@ -57,7 +57,7 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional
$form['config[allow_avatar_remote]']->select(1);
$form['config[allow_avatar_remote_upload]']->select(1);
$crawler = self::submit($form);
- $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text());
+ $this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->text());
}
public function groups_manage_test_data()
@@ -82,7 +82,7 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional
$form = $this->get_group_manage_form();
$form['group_colour']->setValue($input);
$crawler = self::submit($form);
- $this->assertContains($this->lang($expected), $crawler->text());
+ $this->assertStringContainsString($this->lang($expected), $crawler->text());
}
public function group_avatar_min_max_data()
@@ -112,6 +112,6 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional
$form['avatar_driver']->setValue($avatar_type);
$form[$form_name]->setValue($input);
$crawler = self::submit($form);
- $this->assertContains($this->lang($expected), $crawler->text());
+ $this->assertStringContainsString($this->lang($expected), $crawler->text());
}
}
diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php
index 3d4f316d72..6b58a9fff4 100644
--- a/tests/functional/download_test.php
+++ b/tests/functional/download_test.php
@@ -49,7 +49,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
$post = $this->create_topic($this->data['forums']['Download #1'], 'Download Topic #1', 'This is a test topic posted by the testing framework.', array('upload_files' => 1));
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('Download Topic #1', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Download Topic #1', $crawler->filter('html')->text());
$this->data['topics']['Download Topic #1'] = (int) $post['topic_id'];
$this->data['posts']['Download Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
@@ -57,7 +57,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
$post2 = $this->create_post($this->data['forums']['Download #1'], $post['topic_id'], 'Re: Download Topic #1-#2', 'This is a test post posted by the testing framework.', array('upload_files' => 1));
$crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- $this->assertContains('Re: Download Topic #1-#2', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Re: Download Topic #1-#2', $crawler->filter('html')->text());
$this->data['posts']['Re: Download Topic #1-#2'] = (int) $post2['post_id'];
}
@@ -115,7 +115,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
$this->assertContainsLang('POST_DELETED', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Download Topic #1']}&sid={$this->sid}");
- $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
+ $this->assertStringContainsString($this->lang('POST_DISPLAY', '', ''), $crawler->text());
}
public function test_download_softdeleted_post()
@@ -182,7 +182,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
$this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Download Topic #1']}&sid={$this->sid}");
- $this->assertContains('Download Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Download Topic #1', $crawler->filter('h2')->text());
}
public function test_download_softdeleted_topic()
diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php
index 1e6cd955d8..4ad2cb0e3f 100644
--- a/tests/functional/extension_acp_test.php
+++ b/tests/functional/extension_acp_test.php
@@ -22,7 +22,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
'./',
);
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -30,7 +30,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/../extension/ext/', self::$fixtures);
}
- static public function tearDownAfterClass()
+ static public function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
@@ -88,27 +88,27 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$this->assertCount(1, $crawler->filter('.ext_enabled'));
$this->assertCount(7, $crawler->filter('.ext_disabled'));
- $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text());
+ $this->assertStringContainsString('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text());
$this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text());
- $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertStringContainsString('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text());
$this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text());
$this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text());
$this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(2)->text());
- $this->assertContains('The “vendor/test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text());
+ $this->assertStringContainsString('The “vendor/test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text());
- $this->assertContains('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text());
+ $this->assertStringContainsString('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text());
- $this->assertContains('phpBB Bar Extension', $crawler->filter('.ext_disabled')->eq(3)->text());
+ $this->assertStringContainsString('phpBB Bar Extension', $crawler->filter('.ext_disabled')->eq(3)->text());
$this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(3)->text());
$this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(3)->text());
// Check that invalid extensions are not listed.
- $this->assertNotContains('phpBB BarFoo Extension', $crawler->filter('.table1')->text());
- $this->assertNotContains('barfoo', $crawler->filter('.table1')->text());
+ $this->assertStringNotContainsString('phpBB BarFoo Extension', $crawler->filter('.table1')->text());
+ $this->assertStringNotContainsString('barfoo', $crawler->filter('.table1')->text());
- $this->assertNotContains('vendor3/bar', $crawler->filter('.table1')->text());
+ $this->assertStringNotContainsString('vendor3/bar', $crawler->filter('.table1')->text());
}
public function test_details()
@@ -143,7 +143,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
{
$match = true;
- $this->assertContains($expected, $text);
+ $this->assertStringContainsString($expected, $text);
}
}
@@ -163,7 +163,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
- $this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('#main')->text());
+ $this->assertStringContainsString($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('#main')->text());
// Correctly submit the enable form, default not enableable message
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor3%2Ffoo&sid=' . $this->sid);
@@ -171,8 +171,8 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
// Custom reason messages returned by not enableable extension
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor5%2Ffoo&sid=' . $this->sid);
- $this->assertContains('Reason 1', $crawler->filter('.errorbox')->text());
- $this->assertContains('Reason 2', $crawler->filter('.errorbox')->text());
+ $this->assertStringContainsString('Reason 1', $crawler->filter('.errorbox')->text());
+ $this->assertStringContainsString('Reason 2', $crawler->filter('.errorbox')->text());
}
public function test_disable_pre()
@@ -184,14 +184,14 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid);
- $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('#main')->text());
+ $this->assertStringContainsString($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('#main')->text());
}
public function test_delete_data_pre()
{
// test2 is not available (error)
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=test2&sid=' . $this->sid);
- $this->assertContains($this->lang('FILE_NOT_FOUND', ''), $crawler->filter('.errorbox')->text());
+ $this->assertStringContainsString($this->lang('FILE_NOT_FOUND', ''), $crawler->filter('.errorbox')->text());
// foo is not disabled (redirect to list)
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid);
@@ -200,7 +200,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
- $this->assertContains('Are you sure that you wish to delete the data associated with “phpBB Moo Extension”?', $crawler->filter('.errorbox')->text());
+ $this->assertStringContainsString('Are you sure that you wish to delete the data associated with “phpBB Moo Extension”?', $crawler->filter('.errorbox')->text());
}
public function test_actions()
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 92a9d2af6d..17b5803041 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -30,7 +30,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
'foo/foo/controller/',
);
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -38,7 +38,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
- static public function tearDownAfterClass()
+ static public function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
@@ -62,7 +62,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$this->phpbb_extension_manager->enable('foo/bar');
$crawler = self::request('GET', 'app.php/foo/bar', array(), false);
self::assert_response_status_code();
- $this->assertContains("foo/bar controller handle() method", $crawler->filter('body')->text());
+ $this->assertStringContainsString("foo/bar controller handle() method", $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
@@ -74,7 +74,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$this->phpbb_extension_manager->enable('foo/foo');
$crawler = self::request('GET', 'app.php/foo/foo', array(), false);
self::assert_response_status_code();
- $this->assertContains("foo/foo controller handle() method", $crawler->filter('body')->text());
+ $this->assertStringContainsString("foo/foo controller handle() method", $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/foo');
}
@@ -85,7 +85,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
{
$this->phpbb_extension_manager->enable('foo/bar');
$crawler = self::request('GET', 'app.php/foo/template');
- $this->assertContains("I am a variable", $crawler->filter('#content')->text());
+ $this->assertStringContainsString("I am a variable", $crawler->filter('#content')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
@@ -95,7 +95,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function test_controller_template_include_js_css()
{
$crawler = self::request('GET', 'app.php/help/faq');
- $this->assertContains("./../../assets/javascript/core.js", $crawler->filter('body')->html());
+ $this->assertStringContainsString("./../../assets/javascript/core.js", $crawler->filter('body')->html());
}
/**
@@ -107,7 +107,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$this->phpbb_extension_manager->enable('foo/bar');
$crawler = self::request('GET', 'app.php/foo/baz', array(), false);
$this->assert_response_html(500);
- $this->assertContains('Missing value for argument #1: test in class foo\bar\controller\controller:baz', $crawler->filter('body')->text());
+ $this->assertStringContainsString('Missing value for argument #1: test in class foo\bar\controller\controller:baz', $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
@@ -119,7 +119,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$this->phpbb_extension_manager->enable('foo/bar');
$crawler = self::request('GET', 'app.php/foo/exception', array(), false);
$this->assert_response_html(500);
- $this->assertContains('Exception thrown from foo/exception route', $crawler->filter('body')->text());
+ $this->assertStringContainsString('Exception thrown from foo/exception route', $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
@@ -136,7 +136,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
{
$crawler = self::request('GET', 'app.php/does/not/exist', array(), false);
$this->assert_response_html(404);
- $this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
+ $this->assertStringContainsString('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
}
/**
@@ -157,7 +157,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$this->assertStringStartsWith('./app.php/foo/login_redirect', $form->get('redirect')->getValue());
$crawler = self::submit($form);
- $this->assertContains("I am a variable", $crawler->filter('#content')->text(), 'Unsuccessful redirect after using login_box()');
+ $this->assertStringContainsString("I am a variable", $crawler->filter('#content')->text(), 'Unsuccessful redirect after using login_box()');
$this->phpbb_extension_manager->purge('foo/bar');
}
diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php
index 248f05e220..0cd096e867 100644
--- a/tests/functional/extension_global_lang_test.php
+++ b/tests/functional/extension_global_lang_test.php
@@ -26,7 +26,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
'foo/bar/language/en/',
);
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -34,7 +34,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
- static public function tearDownAfterClass()
+ static public function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
@@ -67,9 +67,9 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
$crawler = self::request('GET', 'index.php');
// language from language/en/common.php
- $this->assertNotContains('Skip to content', $crawler->filter('.skiplink')->text());
+ $this->assertStringNotContainsString('Skip to content', $crawler->filter('.skiplink')->text());
// language from ext/foo/bar/language/en/foo_global.php
- $this->assertContains('Overwritten by foo', $crawler->filter('.skiplink')->text());
+ $this->assertStringContainsString('Overwritten by foo', $crawler->filter('.skiplink')->text());
}
}
diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php
index fa7bc63a69..d9c01175ea 100644
--- a/tests/functional/extension_module_test.php
+++ b/tests/functional/extension_module_test.php
@@ -25,7 +25,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
'./',
);
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -33,7 +33,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
- static public function tearDownAfterClass()
+ static public function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
@@ -118,7 +118,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
$this->admin_login();
$crawler = self::request('GET', 'adm/index.php?i=foo%5cbar%5cacp%5cmain_module&mode=mode&sid=' . $this->sid);
- $this->assertContains('Bertie rulez!', $crawler->filter('#main')->text());
+ $this->assertStringContainsString('Bertie rulez!', $crawler->filter('#main')->text());
}
public function test_ucp()
@@ -126,11 +126,11 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
$this->login();
$crawler = self::request('GET', 'ucp.php?sid=' . $this->sid);
- $this->assertContains('UCP_FOOBAR_TITLE', $crawler->filter('#tabs')->text());
+ $this->assertStringContainsString('UCP_FOOBAR_TITLE', $crawler->filter('#tabs')->text());
$link = $crawler->selectLink('UCP_FOOBAR_TITLE')->link()->getUri();
$crawler = self::request('GET', substr($link, strpos($link, 'ucp.')));
- $this->assertContains('UCP Extension Template Test Passed!', $crawler->filter('#content')->text());
+ $this->assertStringContainsString('UCP Extension Template Test Passed!', $crawler->filter('#content')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php
index 52bed0a64b..5c57c37146 100644
--- a/tests/functional/extension_permission_lang_test.php
+++ b/tests/functional/extension_permission_lang_test.php
@@ -26,7 +26,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
'foo/bar/language/en/',
);
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -34,7 +34,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
- static public function tearDownAfterClass()
+ static public function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
@@ -78,9 +78,9 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
$crawler = self::submit($form);
// language from language/en/acp/permissions_phpbb.php
- $this->assertContains('Can attach files', $crawler->filter('body')->text());
+ $this->assertStringContainsString('Can attach files', $crawler->filter('body')->text());
// language from ext/foo/bar/language/en/permissions_foo.php
- $this->assertContains('Can view foobar', $crawler->filter('body')->text());
+ $this->assertStringContainsString('Can view foobar', $crawler->filter('body')->text());
}
}
diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php
index bf871ec02a..16ef468eea 100644
--- a/tests/functional/feed_test.php
+++ b/tests/functional/feed_test.php
@@ -30,7 +30,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
{
parent::__construct($name, $data, $dataName);
- $this->backupStaticAttributesBlacklist['phpbb_functional_feed_test'] = array('init_values');
+ $this->excludeBackupStaticAttributes([
+ 'phpbb_functional_feed_test' => ['init_values'],
+ ]);
$this->purge_cache();
}
@@ -74,7 +76,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$this->add_lang('acp/permissions');
$crawler = self::request('GET', "adm/index.php?i=acp_permissions&sid={$this->sid}&icat=16&mode=setting_group_global&group_id[0]=1");
- self::assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
+ self::assertStringContainsString($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
$form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form();
$form['setting[1][0][u_download]']->select(-1);
@@ -338,7 +340,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #2', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- self::assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text());
+ self::assertStringContainsString('Feeds #news - Topic #2', $crawler->filter('html')->text());
$this->data['topics']['Feeds #news - Topic #2'] = (int) $post['topic_id'];
$this->data['posts']['Feeds #news - Topic #2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
@@ -346,7 +348,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post2 = $this->create_post($this->data['forums']['Feeds #news'], $post['topic_id'], 'Re: Feeds #news - Topic #2', 'This is a test post posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- self::assertContains('Re: Feeds #news - Topic #2', $crawler->filter('html')->text());
+ self::assertStringContainsString('Re: Feeds #news - Topic #2', $crawler->filter('html')->text());
$this->data['posts']['Re: Feeds #news - Topic #2'] = (int) $post2['post_id'];
}
@@ -502,7 +504,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- self::assertContains('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text());
+ self::assertStringContainsString('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text());
$this->data['posts']['Re: Feeds #1 - Topic #2'] = (int) $post2['post_id'];
}
@@ -530,7 +532,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
self::assertContainsLang('POST_DELETED', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}");
- self::assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
+ self::assertStringContainsString($this->lang('POST_DISPLAY', '', ''), $crawler->text());
}
public function test_feeds_softdeleted_post_admin()
@@ -630,7 +632,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
self::assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}");
- self::assertContains('Feeds #1 - Topic #2', $crawler->filter('h2')->text());
+ self::assertStringContainsString('Feeds #1 - Topic #2', $crawler->filter('h2')->text());
}
public function test_feeds_softdeleted_topic_admin()
@@ -769,7 +771,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$this->create_post($this->data['forums']['Feeds #1.1'], $post['topic_id'], 'Re: Feeds #1.1 - Topic #2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1.1 - Topic #2']}&sid={$this->sid}");
- self::assertNotContains('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text());
+ self::assertStringNotContainsString('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text());
}
public function test_feeds_unapproved_post_admin()
@@ -860,7 +862,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}");
- self::assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text());
+ self::assertStringNotContainsString('Feeds #1.1 - Topic #3', $crawler->filter('html')->text());
$this->logout();
$this->set_flood_interval(15);
@@ -1012,7 +1014,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #3', 'This is a test topic posted by the testing framework. [attachment=0]Attachment #0[/attachment]', array('upload_files' => 1));
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- self::assertContains('Feeds #1 - Topic #3', $crawler->filter('html')->text());
+ self::assertStringContainsString('Feeds #1 - Topic #3', $crawler->filter('html')->text());
$this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id'];
}
@@ -1230,7 +1232,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post2 = $this->create_post($this->data['forums']['Feeds #1'], $this->data['topics']['Feeds #1 - Topic #3'], 'Re: Feeds #1 - Topic #3-1', 'This is a test post posted by the testing framework. [attachment=0]Attachment #0[/attachment]');
$crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- self::assertContains('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text());
+ self::assertStringContainsString('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text());
$this->data['posts']['Re: Feeds #1 - Topic #3-1'] = (int) $post2['post_id'];
}
@@ -1395,7 +1397,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
foreach($data['contents'] as $entry_id => $string)
{
$content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text();
- self::assertContains($string, $content, "Tested feed : 'app.php/feed{$params}'");
+ self::assertStringContainsString($string, $content, "Tested feed : 'app.php/feed{$params}'");
}
}
@@ -1420,13 +1422,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
if ($attachment['displayed'])
{
- self::assertContains($url, $content, "Tested feed : 'app.php/feed{$params}'");
- self::assertNotContains($string, $content, "Tested feed : 'app.php/feed{$params}'");
+ self::assertStringContainsString($url, $content, "Tested feed : 'app.php/feed{$params}'");
+ self::assertStringNotContainsString($string, $content, "Tested feed : 'app.php/feed{$params}'");
}
else
{
- self::assertContains($string, $content, "Tested feed : 'app.php/feed{$params}'");
- self::assertNotContains($url, $content, "Tested feed : 'app.php/feed{$params}'");
+ self::assertStringContainsString($string, $content, "Tested feed : 'app.php/feed{$params}'");
+ self::assertStringNotContainsString($url, $content, "Tested feed : 'app.php/feed{$params}'");
}
}
}
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index a08ec4ee43..e81c0b6e1e 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -143,7 +143,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
$crawler = $this->upload_file('valid.jpg', 'image/jpeg');
// Ensure there was no error message rendered
- $this->assertNotContains('' . $this->lang('INFORMATION') . '
', $this->get_content());
+ $this->assertStringNotContainsString('' . $this->lang('INFORMATION') . '
', $this->get_content());
// Also the file name should be in the first row of the files table
$this->assertEquals('valid.jpg', $crawler->filter('span.file-name')->eq(1)->text());
diff --git a/tests/functional/forgot_password_test.php b/tests/functional/forgot_password_test.php
index b5309aa5be..554b503470 100644
--- a/tests/functional/forgot_password_test.php
+++ b/tests/functional/forgot_password_test.php
@@ -40,7 +40,7 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case
$this->logout();
$crawler = self::request('GET', 'app.php/user/forgot_password');
- $this->assertContains($this->lang('UCP_PASSWORD_RESET_DISABLED', '', ''), $crawler->text());
+ $this->assertStringContainsString($this->lang('UCP_PASSWORD_RESET_DISABLED', '', ''), $crawler->text());
}
diff --git a/tests/functional/forum_style_test.php b/tests/functional/forum_style_test.php
index 0f969cd602..c397c9d7fb 100644
--- a/tests/functional/forum_style_test.php
+++ b/tests/functional/forum_style_test.php
@@ -19,13 +19,13 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case
public function test_default_forum_style()
{
$crawler = self::request('GET', 'viewtopic.php?t=1&f=2');
- $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
+ $this->assertStringContainsString('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1');
- $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
+ $this->assertStringContainsString('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1&view=next');
- $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
+ $this->assertStringContainsString('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
}
public function test_custom_forum_style()
@@ -35,13 +35,13 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2');
$crawler = self::request('GET', 'viewtopic.php?t=1&f=2');
- $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
+ $this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1');
- $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
+ $this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1&view=next');
- $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
+ $this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2');
$this->delete_style(2, 'test_style');
diff --git a/tests/functional/jumpbox_test.php b/tests/functional/jumpbox_test.php
index f5a671b1b9..9e2938f9e2 100644
--- a/tests/functional/jumpbox_test.php
+++ b/tests/functional/jumpbox_test.php
@@ -30,6 +30,6 @@ class phpbb_functional_jumpbox_test extends phpbb_functional_test_case
protected function check_valid_jump($forum)
{
- $this->assertContains($this->lang('FORUM') . ": $forum", $this->crawler->filter('#cp-main h2')->text(), $this->crawler->text());
+ $this->assertStringContainsString($this->lang('FORUM') . ": $forum", $this->crawler->filter('#cp-main h2')->text(), $this->crawler->text());
}
}
diff --git a/tests/functional/lang_test.php b/tests/functional/lang_test.php
index 7cffd0ef61..ed3b6786d2 100644
--- a/tests/functional/lang_test.php
+++ b/tests/functional/lang_test.php
@@ -22,11 +22,9 @@ class phpbb_functional_lang_test extends phpbb_functional_test_case
$this->assertEquals('Board index', $this->lang('FORUM_INDEX'));
}
- /**
- * @expectedException RuntimeException
- */
public function test_lang_missing()
{
+ $this->expectException('RuntimeException');
$this->assertEquals('Your account has now been activated. Thank you for registering.', $this->lang('ACCOUNT_ACTIVE'));
}
diff --git a/tests/functional/mcp_test.php b/tests/functional/mcp_test.php
index 40615d66a5..87a98dae74 100644
--- a/tests/functional/mcp_test.php
+++ b/tests/functional/mcp_test.php
@@ -24,7 +24,7 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case
$post = $this->create_topic(2, 'Test Topic 2', 'Testing move post with "Move posts" option from Quick-Moderator Tools.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('Testing move post with "Move posts" option from Quick-Moderator Tools.', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Testing move post with "Move posts" option from Quick-Moderator Tools.', $crawler->filter('html')->text());
return $crawler;
}
@@ -49,7 +49,7 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case
));
$form['post_id_list'][0]->tick();
$crawler = self::submit($form);
- $this->assertContains($this->lang('MERGE_POSTS'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('MERGE_POSTS'), $crawler->filter('html')->text());
return $crawler;
}
@@ -62,7 +62,7 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case
$this->add_lang('mcp');
$form = $crawler->selectButton('Yes')->form();
$crawler = self::submit($form);
- $this->assertContains($this->lang('POSTS_MERGED_SUCCESS'), $crawler->text());
+ $this->assertStringContainsString($this->lang('POSTS_MERGED_SUCCESS'), $crawler->text());
}
public function test_delete_logs()
diff --git a/tests/functional/memberlist_test.php b/tests/functional/memberlist_test.php
index 1da5c39401..3e40ddc528 100644
--- a/tests/functional/memberlist_test.php
+++ b/tests/functional/memberlist_test.php
@@ -22,15 +22,15 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
// logs in as admin
$this->login();
$crawler = self::request('GET', 'memberlist.php?sid=' . $this->sid);
- $this->assertContains('memberlist-test-user', $crawler->text());
+ $this->assertStringContainsString('memberlist-test-user', $crawler->text());
// restrict by first character
$crawler = self::request('GET', 'memberlist.php?first_char=m&sid=' . $this->sid);
- $this->assertContains('memberlist-test-user', $crawler->text());
+ $this->assertStringContainsString('memberlist-test-user', $crawler->text());
// make sure results for wrong character are not returned
$crawler = self::request('GET', 'memberlist.php?first_char=a&sid=' . $this->sid);
- $this->assertNotContains('memberlist-test-user', $crawler->text());
+ $this->assertStringNotContainsString('memberlist-test-user', $crawler->text());
}
public function test_viewprofile()
@@ -38,7 +38,7 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
$this->login();
// XXX hardcoded user id
$crawler = self::request('GET', 'memberlist.php?mode=viewprofile&u=2&sid=' . $this->sid);
- $this->assertContains('admin', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('admin', $crawler->filter('h2')->text());
}
protected function get_memberlist_leaders_table_crawler()
@@ -55,16 +55,16 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
$crawler = $this->get_memberlist_leaders_table_crawler();
// Admin in admin group, but not in moderators
- $this->assertContains('admin', $crawler->eq(0)->text());
- $this->assertNotContains('admin', $crawler->eq(1)->text());
+ $this->assertStringContainsString('admin', $crawler->eq(0)->text());
+ $this->assertStringNotContainsString('admin', $crawler->eq(1)->text());
// memberlist-test-user in neither group
- $this->assertNotContains('memberlist-test-user', $crawler->eq(0)->text());
- $this->assertNotContains('memberlist-test-user', $crawler->eq(1)->text());
+ $this->assertStringNotContainsString('memberlist-test-user', $crawler->eq(0)->text());
+ $this->assertStringNotContainsString('memberlist-test-user', $crawler->eq(1)->text());
// memberlist-test-moderator in neither group
- $this->assertNotContains('memberlist-test-moderator', $crawler->eq(0)->text());
- $this->assertNotContains('memberlist-test-moderator', $crawler->eq(1)->text());
+ $this->assertStringNotContainsString('memberlist-test-moderator', $crawler->eq(0)->text());
+ $this->assertStringNotContainsString('memberlist-test-moderator', $crawler->eq(1)->text());
}
public function test_leaders_remove_users()
@@ -74,14 +74,14 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
// Remove admin from admins, but is now in moderators
$this->remove_user_group('ADMINISTRATORS', array('admin'));
$crawler = $this->get_memberlist_leaders_table_crawler();
- $this->assertNotContains('admin', $crawler->eq(0)->text());
- $this->assertContains('admin', $crawler->eq(1)->text());
+ $this->assertStringNotContainsString('admin', $crawler->eq(0)->text());
+ $this->assertStringContainsString('admin', $crawler->eq(1)->text());
// Remove admin from moderators, should not be visible anymore
$this->remove_user_group('GLOBAL_MODERATORS', array('admin'));
$crawler = $this->get_memberlist_leaders_table_crawler();
- $this->assertNotContains('admin', $crawler->eq(0)->text());
- $this->assertNotContains('admin', $crawler->eq(1)->text());
+ $this->assertStringNotContainsString('admin', $crawler->eq(0)->text());
+ $this->assertStringNotContainsString('admin', $crawler->eq(1)->text());
}
public function test_leaders_add_users()
@@ -91,20 +91,20 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
// Add memberlist-test-moderator to moderators
$this->add_user_group('GLOBAL_MODERATORS', array('memberlist-test-moderator'));
$crawler = $this->get_memberlist_leaders_table_crawler();
- $this->assertNotContains('memberlist-test-moderator', $crawler->eq(0)->text());
- $this->assertContains('memberlist-test-moderator', $crawler->eq(1)->text());
+ $this->assertStringNotContainsString('memberlist-test-moderator', $crawler->eq(0)->text());
+ $this->assertStringContainsString('memberlist-test-moderator', $crawler->eq(1)->text());
// Add admin to moderators, should be visible as moderator
$this->add_user_group('GLOBAL_MODERATORS', array('admin'), true);
$crawler = $this->get_memberlist_leaders_table_crawler();
- $this->assertNotContains('admin', $crawler->eq(0)->text());
- $this->assertContains('admin', $crawler->eq(1)->text());
+ $this->assertStringNotContainsString('admin', $crawler->eq(0)->text());
+ $this->assertStringContainsString('admin', $crawler->eq(1)->text());
// Add admin to admins as leader, should be visible as admin, not moderator
$this->add_user_group('ADMINISTRATORS', array('admin'), true, true);
$crawler = $this->get_memberlist_leaders_table_crawler();
- $this->assertContains('admin', $crawler->eq(0)->text());
- $this->assertNotContains('admin', $crawler->eq(1)->text());
+ $this->assertStringContainsString('admin', $crawler->eq(0)->text());
+ $this->assertStringNotContainsString('admin', $crawler->eq(1)->text());
}
public function test_group_rank()
@@ -130,7 +130,7 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
$this->assertContainsLang('RANK_UPDATED', $crawler->filter('.successbox')->text());
$crawler = self::request('GET', 'memberlist.php?mode=group&g=2');
- $this->assertContains('memberlist-test-user', $crawler->text());
+ $this->assertStringContainsString('memberlist-test-user', $crawler->text());
unlink(__DIR__ . '/../../phpBB/images/ranks/valid.jpg');
}
diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php
index 3ffed7f66d..4ecbdd37ca 100644
--- a/tests/functional/metadata_manager_test.php
+++ b/tests/functional/metadata_manager_test.php
@@ -31,7 +31,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
parent::tearDown();
}
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -39,7 +39,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
- static public function tearDownAfterClass()
+ static public function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
@@ -63,9 +63,9 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
public function test_extensions_list()
{
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
- $this->assertContains($this->lang('EXTENSIONS_EXPLAIN'), $crawler->filter('#main')->text());
- $this->assertContains('phpBB 3.1 Extension Testing', $crawler->filter('#main')->text());
- $this->assertContains('Details', $crawler->filter('#main')->text());
+ $this->assertStringContainsString($this->lang('EXTENSIONS_EXPLAIN'), $crawler->filter('#main')->text());
+ $this->assertStringContainsString('phpBB 3.1 Extension Testing', $crawler->filter('#main')->text());
+ $this->assertStringContainsString('Details', $crawler->filter('#main')->text());
}
public function test_extensions_details()
@@ -73,15 +73,15 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo%2Fbar&sid=' . $this->sid);
// Test whether the details are displayed
- $this->assertContains($this->lang('CLEAN_NAME'), $crawler->filter('#main')->text());
- $this->assertContains('foo/bar', $crawler->filter('#meta_name')->text());
+ $this->assertStringContainsString($this->lang('CLEAN_NAME'), $crawler->filter('#main')->text());
+ $this->assertStringContainsString('foo/bar', $crawler->filter('#meta_name')->text());
- $this->assertContains($this->lang('PHP_VERSION'), $crawler->filter('#main')->text());
- $this->assertContains('>=5.3', $crawler->filter('#require_php')->text());
+ $this->assertStringContainsString($this->lang('PHP_VERSION'), $crawler->filter('#main')->text());
+ $this->assertStringContainsString('>=5.3', $crawler->filter('#require_php')->text());
// Details should be html escaped
// However, text() only returns the displayed text, so HTML Special Chars are decoded.
// So we test this directly on the content of the response.
- $this->assertContains('>=5.3', $this->get_content());
+ $this->assertStringContainsString('>=5.3', $this->get_content());
}
public function test_extensions_details_notexists()
@@ -89,6 +89,6 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=not%2Fexists&sid=' . $this->sid);
// Error message because the files do not exist
- $this->assertContains($this->lang('FILE_NOT_FOUND', ''), $crawler->filter('#main')->text());
+ $this->assertStringContainsString($this->lang('FILE_NOT_FOUND', ''), $crawler->filter('#main')->text());
}
}
diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php
index 4ca1d4b637..62355bf493 100644
--- a/tests/functional/notification_test.php
+++ b/tests/functional/notification_test.php
@@ -67,7 +67,7 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
// Post a new post that needs approval
$this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}");
- $this->assertNotContains('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text());
// Login as admin
$this->logout();
diff --git a/tests/functional/paging_test.php b/tests/functional/paging_test.php
index cfaf9104a8..f6d6960919 100644
--- a/tests/functional/paging_test.php
+++ b/tests/functional/paging_test.php
@@ -27,17 +27,17 @@ class phpbb_functional_paging_test extends phpbb_functional_test_case
$this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post no' . $post_id . ' posted by the testing framework.');
}
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('post no4', $crawler->text());
- $this->assertNotContains('post no16', $crawler->text());
+ $this->assertStringContainsString('post no4', $crawler->text());
+ $this->assertStringNotContainsString('post no16', $crawler->text());
$next_link = $crawler->filter('.pagination > ul > li.next > a')->attr('href');
$crawler = self::request('GET', $next_link);
- $this->assertNotContains('post no4', $crawler->text());
- $this->assertContains('post no16', $crawler->text());
+ $this->assertStringNotContainsString('post no4', $crawler->text());
+ $this->assertStringContainsString('post no16', $crawler->text());
$prev_link = $crawler->filter('.pagination > ul > li.previous > a')->attr('href');
$crawler = self::request('GET', $prev_link);
- $this->assertContains('post no4', $crawler->text());
- $this->assertNotContains('post no16', $crawler->text());
+ $this->assertStringContainsString('post no4', $crawler->text());
+ $this->assertStringNotContainsString('post no16', $crawler->text());
}
}
diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php
index 990983985e..f28b3f621e 100644
--- a/tests/functional/plupload_test.php
+++ b/tests/functional/plupload_test.php
@@ -111,7 +111,7 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
if ($i < self::CHUNKS - 1)
{
- $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::get_content());
+ $this->assertStringContainsString('{"jsonrpc":"2.0","id":"id","result":null}', self::get_content());
}
else
{
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index 49447e1133..38edcf6767 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -24,17 +24,17 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('This is a test topic posted by the testing framework.', $crawler->filter('html')->text());
+ $this->assertStringContainsString('This is a test topic posted by the testing framework.', $crawler->filter('html')->text());
// Test creating a reply with bbcode
$post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test [b]post[/b] posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
+ $this->assertStringContainsString('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
// Test quoting a message
$crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}");
- $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
+ $this->assertStringContainsString('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
}
public function test_unsupported_characters()
@@ -44,7 +44,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$post = $this->create_topic(2, "Test Topic \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji character in the topic title.');
$this->create_post(2, $post['topic_id'], "Re: Test Topic 1 \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji characters in the topic title.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains("\xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", $crawler->text());
+ $this->assertStringContainsString("\xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", $crawler->text());
}
public function test_supported_unicode_characters()
@@ -54,7 +54,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
$this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', "This is a test with these weird characters: \xF0\x9F\x84\x90 \xF0\x9F\x84\x91");
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains("\xF0\x9F\x84\x90 \xF0\x9F\x84\x91", $crawler->text());
+ $this->assertStringContainsString("\xF0\x9F\x84\x90 \xF0\x9F\x84\x91", $crawler->text());
}
public function test_html_entities()
@@ -64,7 +64,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
$this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', '😀');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('😀', $crawler->text());
+ $this->assertStringContainsString('😀', $crawler->text());
}
public function test_quote()
@@ -96,7 +96,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$form->setValues(array('message' => 'Edited post'));
$crawler = self::submit($form);
- $this->assertContains('Edited post', $crawler->filter("#post_content{$post_id} .content")->text());
+ $this->assertStringContainsString('Edited post', $crawler->filter("#post_content{$post_id} .content")->text());
}
/**
@@ -163,11 +163,11 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$text_content = $crawler->filter('#p' . $post['post_id'])->text();
foreach ($contains[$quote_depth] as $contains_text)
{
- $this->assertContains($contains_text, $text_content);
+ $this->assertStringContainsString($contains_text, $text_content);
}
foreach ($not_contains[$quote_depth] as $not_contains_text)
{
- $this->assertNotContains($not_contains_text, $text_content);
+ $this->assertStringNotContainsString($not_contains_text, $text_content);
}
}
}
@@ -229,7 +229,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
'message' => 'My post',
));
$crawler = self::submit($form);
- $this->assertContains(
+ $this->assertStringContainsString(
'My signature',
$crawler->filter('#preview .signature')->html()
);
@@ -274,7 +274,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
'message' => $text,
));
$crawler = self::submit($form);
- $this->assertContains(
+ $this->assertStringContainsString(
'http://example.org/ tcp://localhost:22/ServiceName',
$crawler->filter('#preview .content')->html()
);
@@ -295,7 +295,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
'message' => $text,
));
$crawler = self::submit($form);
- $this->assertContains(
+ $this->assertStringContainsString(
'http://example.org/ tcp://localhost:22/ServiceName',
$crawler->filter('#preview .content')->html()
);
diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php
index ce709524a9..6f94eac35c 100644
--- a/tests/functional/private_messages_test.php
+++ b/tests/functional/private_messages_test.php
@@ -32,7 +32,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
$form->setValues($values);
$crawler = self::submit($form);
- $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text());
+ $this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text());
}
public function test_inbox_full()
@@ -41,12 +41,12 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
$message_id = $this->create_private_message('Test private message #1', 'This is a test private message sent by the testing framework.', array(2));
$crawler = self::request('GET', "ucp.php?i=pm&mode=view&sid{$this->sid}&p={$message_id}");
- $this->assertContains($this->lang('UCP_PM_VIEW'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('UCP_PM_VIEW'), $crawler->filter('html')->text());
$message_id = $this->create_private_message('Test private message #2', 'This is a test private message sent by the testing framework.', array(2));
$crawler = self::request('GET', "ucp.php?i=pm&mode=view&sid{$this->sid}&p={$message_id}");
- $this->assertContains($this->lang('NO_AUTH_READ_HOLD_MESSAGE'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('NO_AUTH_READ_HOLD_MESSAGE'), $crawler->filter('html')->text());
}
public function test_restore_config()
@@ -64,7 +64,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
$form->setValues($values);
$crawler = self::submit($form);
- $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text());
+ $this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text());
}
public function test_quote_post()
@@ -105,6 +105,6 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
$crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid);
- $this->assertContains($expected, $crawler->filter('textarea#message')->text());
+ $this->assertStringContainsString($expected, $crawler->filter('textarea#message')->text());
}
}
diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php
index 9bf54fcb19..698acc7550 100644
--- a/tests/functional/prune_shadow_topic_test.php
+++ b/tests/functional/prune_shadow_topic_test.php
@@ -61,7 +61,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas
$this->post = $this->create_topic($this->data['forums']['Prune Shadow'], 'Prune Shadow #1', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$this->post['topic_id']}&sid={$this->sid}");
- $this->assertContains('Prune Shadow #1', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Prune Shadow #1', $crawler->filter('html')->text());
$this->data['topics']['Prune Shadow #1'] = (int) $this->post['topic_id'];
$this->data['posts']['Prune Shadow #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
@@ -79,7 +79,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas
$post2 = $this->create_post($this->data['forums']['Prune Shadow'], $this->post['topic_id'], 'Re: Prune Shadow #1-#2', 'This is a test post posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- $this->assertContains('Re: Prune Shadow #1-#2', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Re: Prune Shadow #1-#2', $crawler->filter('html')->text());
$this->data['posts']['Re: Prune Shadow #1-#2'] = (int) $post2['post_id'];
$this->assert_forum_details($this->data['forums']['Prune Shadow'], array(
diff --git a/tests/functional/report_post_captcha_test.php b/tests/functional/report_post_captcha_test.php
index 36a1a9ee4d..e4c2ff6ab7 100644
--- a/tests/functional/report_post_captcha_test.php
+++ b/tests/functional/report_post_captcha_test.php
@@ -21,11 +21,11 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca
$crawler = self::request('GET', 'app.php/post/1/report', array(), false);
$this->assert_response_html(403);
$this->add_lang('mcp');
- $this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text());
$this->set_reporting_guest(1);
$crawler = self::request('GET', 'app.php/post/1/report');
- $this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());
$this->set_reporting_guest(-1);
}
@@ -33,12 +33,12 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca
{
$this->login();
$crawler = self::request('GET', 'app.php/post/1/report');
- $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());
+ $this->assertStringNotContainsString($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());
$this->add_lang('mcp');
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$crawler = self::submit($form);
- $this->assertContains($this->lang('POST_REPORTED_SUCCESS'), $crawler->text());
+ $this->assertStringContainsString($this->lang('POST_REPORTED_SUCCESS'), $crawler->text());
}
protected function set_reporting_guest($report_post_allowed)
diff --git a/tests/functional/subforum_test.php b/tests/functional/subforum_test.php
index 6ce4f53c20..493c2053da 100644
--- a/tests/functional/subforum_test.php
+++ b/tests/functional/subforum_test.php
@@ -64,8 +64,8 @@ class phpbb_functional_subforum_test extends phpbb_functional_test_case
public function test_display_subforums()
{
$crawler = self::request('GET', "index.php?sid={$this->sid}");
- $this->assertContains('Subforum Test #1.1', $crawler->html());
- $this->assertContains('Subforum Test #1.1.1', $crawler->html());
+ $this->assertStringContainsString('Subforum Test #1.1', $crawler->html());
+ $this->assertStringContainsString('Subforum Test #1.1.1', $crawler->html());
}
/**
@@ -85,8 +85,8 @@ class phpbb_functional_subforum_test extends phpbb_functional_test_case
self::submit($form);
$crawler = self::request('GET', "index.php?sid={$this->sid}");
- $this->assertContains('Subforum Test #1.1', $crawler->html());
- $this->assertNotContains('Subforum Test #1.1.1', $crawler->html());
+ $this->assertStringContainsString('Subforum Test #1.1', $crawler->html());
+ $this->assertStringNotContainsString('Subforum Test #1.1.1', $crawler->html());
}
protected function get_forum_id($forum_name)
diff --git a/tests/functional/ucp_allow_pm_test.php b/tests/functional/ucp_allow_pm_test.php
index 2d41296ddf..01418b25b1 100644
--- a/tests/functional/ucp_allow_pm_test.php
+++ b/tests/functional/ucp_allow_pm_test.php
@@ -22,9 +22,9 @@ class phpbb_functional_ucp_allow_pm_test extends phpbb_functional_test_case
{
parent::__construct();
- $this->backupStaticAttributesBlacklist += array(
- 'phpbb_functional_ucp_allow_pm_test' => array('data'),
- );
+ $this->excludeBackupStaticAttributes([
+ 'phpbb_functional_ucp_allow_pm_test' => ['data'],
+ ]);
}
// user A sends a PM to user B where B accepts PM
diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php
index 445c124158..f8e801dcf7 100644
--- a/tests/functional/ucp_groups_test.php
+++ b/tests/functional/ucp_groups_test.php
@@ -51,7 +51,7 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te
$form = $this->get_group_manage_form();
$teampage_settings = $this->get_teampage_settings();
$crawler = self::submit($form);
- $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
+ $this->assertStringContainsString($this->lang('GROUP_UPDATED'), $crawler->text());
$this->assertEquals($teampage_settings, $this->get_teampage_settings());
}
diff --git a/tests/functional/ucp_profile_test.php b/tests/functional/ucp_profile_test.php
index 10d3cb2da1..18839a5a68 100644
--- a/tests/functional/ucp_profile_test.php
+++ b/tests/functional/ucp_profile_test.php
@@ -86,14 +86,14 @@ class phpbb_functional_ucp_profile_test extends phpbb_functional_test_case
$key_id = substr($db->sql_fetchfield('key_id'), 0, 8);
$db->sql_freeresult($result);
- $this->assertContains($key_id, $crawler->filter('label[for="' . $key_id . '"]')->text());
+ $this->assertStringContainsString($key_id, $crawler->filter('label[for="' . $key_id . '"]')->text());
$form = $crawler->selectButton('submit')->form();
$form['keys'][0]->tick();
$crawler = self::submit($form);
- $this->assertContains($this->lang('AUTOLOGIN_SESSION_KEYS_DELETED'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('AUTOLOGIN_SESSION_KEYS_DELETED'), $crawler->filter('html')->text());
$crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=autologin_keys');
- $this->assertContains($this->lang('PROFILE_NO_AUTOLOGIN_KEYS'), $crawler->filter('tbody > tr > td[class="bg1"]')->text());
+ $this->assertStringContainsString($this->lang('PROFILE_NO_AUTOLOGIN_KEYS'), $crawler->filter('tbody > tr > td[class="bg1"]')->text());
}
}
diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php
index 2c8be363e7..eb6631bf28 100644
--- a/tests/functional/user_password_reset_test.php
+++ b/tests/functional/user_password_reset_test.php
@@ -25,7 +25,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
// test without email
$crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
- $this->assertContains('app.php/user/forgot_password', $crawler->getUri());
+ $this->assertStringContainsString('app.php/user/forgot_password', $crawler->getUri());
$form = $crawler->selectButton('submit')->form();
$crawler = self::submit($form);
$this->assertContainsLang('NO_EMAIL_USER', $crawler->text());
@@ -143,11 +143,11 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
{
$this->add_lang('ucp');
$crawler = self::request('GET', 'ucp.php');
- $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
$crawler = self::submit($form, array('username' => 'reset-password-test-user', 'password' => 'reset-password-test-user'));
- $this->assertNotContains($this->lang('LOGIN'), $crawler->filter('.navbar')->text());
+ $this->assertStringNotContainsString($this->lang('LOGIN'), $crawler->filter('.navbar')->text());
$cookies = self::$cookieJar->all();
@@ -163,12 +163,12 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
$this->logout();
$crawler = self::request('GET', 'ucp.php');
- $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
// Try logging in with the old password
$crawler = self::submit($form, array('username' => 'reset-password-test-user', 'password' => 'reset-password-test-userreset-password-test-user'));
- $this->assertContains($this->lang('LOGIN_ERROR_PASSWORD', '', ''), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('LOGIN_ERROR_PASSWORD', '', ''), $crawler->filter('html')->text());
}
/**
diff --git a/tests/functional/viewforum_paging_test.php b/tests/functional/viewforum_paging_test.php
index 4a574bebbb..2ba29cecc6 100644
--- a/tests/functional/viewforum_paging_test.php
+++ b/tests/functional/viewforum_paging_test.php
@@ -127,8 +127,8 @@ class viewforum_paging_test extends phpbb_functional_test_case
$this->assertEquals(2, $crawler->filter('div.pagination')->count());
$top_pagination = $crawler->filter('div.pagination')->eq(0);
$this->assertEquals(3, $top_pagination->filter('li')->count(), 'Number of pagination items on page 1 does not match');
- $this->assertContains('1', $top_pagination->filter('li')->eq(0)->text());
- $this->assertContains('2', $top_pagination->filter('li')->eq(1)->text());
+ $this->assertStringContainsString('1', $top_pagination->filter('li')->eq(0)->text());
+ $this->assertStringContainsString('2', $top_pagination->filter('li')->eq(1)->text());
$this->assertContainsLang('NEXT', $top_pagination->filter('li')->eq(2)->text());
}
@@ -157,8 +157,8 @@ class viewforum_paging_test extends phpbb_functional_test_case
$top_pagination = $crawler->filter('div.pagination')->eq(0);
$this->assertEquals(3, $top_pagination->filter('li')->count(), 'Number of pagination items on page 2 does not match');
$this->assertContainsLang('PREVIOUS', $top_pagination->filter('li')->eq(0)->text());
- $this->assertContains('1', $top_pagination->filter('li')->eq(1)->text());
- $this->assertContains('2', $top_pagination->filter('li')->eq(2)->text());
+ $this->assertStringContainsString('1', $top_pagination->filter('li')->eq(1)->text());
+ $this->assertStringContainsString('2', $top_pagination->filter('li')->eq(2)->text());
}
protected function assert_forum_details($forum_id, $details, $additional_error_message = '')
diff --git a/tests/functional/visibility_disapprove_test.php b/tests/functional/visibility_disapprove_test.php
index 6f6edba422..cb38f64aed 100644
--- a/tests/functional/visibility_disapprove_test.php
+++ b/tests/functional/visibility_disapprove_test.php
@@ -60,7 +60,7 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_
$post = $this->create_topic($this->data['forums']['Disapprove Test #1'], 'Disapprove Test Topic #1', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('Disapprove Test Topic #1', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Disapprove Test Topic #1', $crawler->filter('html')->text());
$this->data['topics']['Disapprove Test Topic #1'] = (int) $post['topic_id'];
$this->data['posts']['Disapprove Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
@@ -83,7 +83,7 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_
$post2 = $this->create_post($this->data['forums']['Disapprove Test #1'], $post['topic_id'], 'Re: Disapprove Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #1']}&sid={$this->sid}");
- $this->assertNotContains('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text());
$this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
'forum_posts_approved' => 1,
@@ -99,7 +99,7 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_
$post = $this->create_topic($this->data['forums']['Disapprove Test #1'], 'Disapprove Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Disapprove Test #1']}&sid={$this->sid}");
- $this->assertNotContains('Disapprove Test Topic #2', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('Disapprove Test Topic #2', $crawler->filter('html')->text());
$this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
'forum_posts_approved' => 1,
@@ -155,8 +155,8 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_
$this->add_lang('viewtopic');
$this->add_lang('mcp');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #1']}&sid={$this->sid}");
- $this->assertContains('Disapprove Test Topic #1', $crawler->filter('html')->text());
- $this->assertContains('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Disapprove Test Topic #1', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text());
$form = $crawler->selectButton($this->lang('DISAPPROVE'))->form();
$crawler = self::submit($form);
@@ -176,11 +176,11 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_
$link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link();
$link_url = $link->getUri();
- $this->assertContains('viewtopic.php?f=' . $this->data['forums']['Disapprove Test #1'] . '&t=' . $this->data['topics']['Disapprove Test Topic #1'], $link_url);
+ $this->assertStringContainsString('viewtopic.php?f=' . $this->data['forums']['Disapprove Test #1'] . '&t=' . $this->data['topics']['Disapprove Test Topic #1'], $link_url);
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #1']}&sid={$this->sid}");
- $this->assertContains('Disapprove Test Topic #1', $crawler->filter('html')->text());
- $this->assertNotContains('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Disapprove Test Topic #1', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text());
}
public function test_disapprove_topic()
@@ -214,7 +214,7 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_
$this->add_lang('viewtopic');
$this->add_lang('mcp');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #2']}&sid={$this->sid}");
- $this->assertContains('Disapprove Test Topic #2', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Disapprove Test Topic #2', $crawler->filter('html')->text());
$form = $crawler->selectButton($this->lang('DISAPPROVE'))->form();
$crawler = self::submit($form);
@@ -234,11 +234,11 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_
$link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link();
$link_url = $link->getUri();
- $this->assertContains('viewforum.php?f=' . $this->data['forums']['Disapprove Test #1'], $link_url);
+ $this->assertStringContainsString('viewforum.php?f=' . $this->data['forums']['Disapprove Test #1'], $link_url);
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #2']}&sid={$this->sid}", array(), false);
self::assert_response_html(404);
- $this->assertNotContains('Disapprove Test Topic #2', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('Disapprove Test Topic #2', $crawler->filter('html')->text());
}
protected function assert_forum_details($forum_id, $details, $additional_error_message = '')
diff --git a/tests/functional/visibility_reapprove_test.php b/tests/functional/visibility_reapprove_test.php
index 6a6e2edf18..555e6d7f9d 100644
--- a/tests/functional/visibility_reapprove_test.php
+++ b/tests/functional/visibility_reapprove_test.php
@@ -60,7 +60,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$post = $this->create_topic($this->data['forums']['Reapprove Test #1'], 'Reapprove Test Topic #1', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Reapprove Test Topic #1', $crawler->filter('h2')->text());
$this->data['topics']['Reapprove Test Topic #1'] = (int) $post['topic_id'];
$this->data['posts']['Reapprove Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
@@ -83,7 +83,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$post2 = $this->create_post($this->data['forums']['Reapprove Test #1'], $post['topic_id'], 'Re: Reapprove Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
- $this->assertNotContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringNotContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 1,
@@ -99,7 +99,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$post = $this->create_topic($this->data['forums']['Reapprove Test #1'], 'Reapprove Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Reapprove Test #1']}&sid={$this->sid}");
- $this->assertNotContains('Reapprove Test Topic #2', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('Reapprove Test Topic #2', $crawler->filter('html')->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 1,
@@ -146,8 +146,8 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$this->add_lang('viewtopic');
$this->add_lang('mcp');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
- $this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text());
- $this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('Reapprove Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
$form = $crawler->selectButton($this->lang('APPROVE'))->form();
$crawler = self::submit($form);
@@ -167,11 +167,11 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link();
$link_url = $link->getUri();
- $this->assertContains('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'] . '&t=' . $this->data['topics']['Reapprove Test Topic #1'], $link_url);
+ $this->assertStringContainsString('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'] . '&t=' . $this->data['topics']['Reapprove Test Topic #1'], $link_url);
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
- $this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text());
- $this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('Reapprove Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
}
public function test_approve_topic()
@@ -206,7 +206,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$this->add_lang('viewtopic');
$this->add_lang('mcp');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}");
- $this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Reapprove Test Topic #2', $crawler->filter('h2')->text());
$form = $crawler->selectButton($this->lang('APPROVE'))->form();
$crawler = self::submit($form);
@@ -226,10 +226,10 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link();
$link_url = $link->getUri();
- $this->assertContains('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'], $link_url);
+ $this->assertStringContainsString('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'], $link_url);
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}");
- $this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Reapprove Test Topic #2', $crawler->filter('h2')->text());
}
public function test_edit_posts()
@@ -273,8 +273,8 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$this->submit_post($posting_url, 'EDIT_POST', $form_data, 'POST_EDITED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
- $this->assertNotContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
- $this->assertNotContains('Post edited by testing framework', $crawler->filter('#page-body')->text());
+ $this->assertStringNotContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringNotContainsString('Post edited by testing framework', $crawler->filter('#page-body')->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 2,
@@ -297,8 +297,8 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}", array(), false);
self::assert_response_html(404);
- $this->assertNotContains('Reapprove Test Topic #2', $crawler->filter('#page-body')->text());
- $this->assertNotContains('Post edited by testing framework', $crawler->filter('#page-body')->text());
+ $this->assertStringNotContainsString('Reapprove Test Topic #2', $crawler->filter('#page-body')->text());
+ $this->assertStringNotContainsString('Post edited by testing framework', $crawler->filter('#page-body')->text());
$this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array(
'forum_posts_approved' => 1,
@@ -314,8 +314,8 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
$this->login();
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}");
- $this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
- $this->assertContains('Post edited by testing framework', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('Post edited by testing framework', $crawler->filter('#page-body')->text());
}
public function test_approve_post_again()
diff --git a/tests/functional/visibility_softdelete_test.php b/tests/functional/visibility_softdelete_test.php
index fd994361a5..4eba77ba1b 100644
--- a/tests/functional/visibility_softdelete_test.php
+++ b/tests/functional/visibility_softdelete_test.php
@@ -81,7 +81,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$post = $this->create_topic($this->data['forums']['Soft Delete #1'], 'Soft Delete Topic #1', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('Soft Delete Topic #1', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('html')->text());
$this->data['topics']['Soft Delete Topic #1'] = (int) $post['topic_id'];
$this->data['posts']['Soft Delete Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
@@ -99,7 +99,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$post2 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#2', 'This is a test post posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- $this->assertContains('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text());
$this->data['posts']['Re: Soft Delete Topic #1-#2'] = (int) $post2['post_id'];
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
@@ -116,7 +116,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$post3 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#3', 'This is another test post posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?p={$post3['post_id']}&sid={$this->sid}");
- $this->assertContains('Re: Soft Delete Topic #1-#3', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Re: Soft Delete Topic #1-#3', $crawler->filter('html')->text());
$this->data['posts']['Re: Soft Delete Topic #1-#3'] = (int) $post3['post_id'];
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
@@ -177,7 +177,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
), 'after softdelete');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
- $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
+ $this->assertStringContainsString($this->lang('POST_DISPLAY', '', ''), $crawler->text());
}
public function test_softdelete_post_no_m_delete()
@@ -227,7 +227,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
), 'after softdelete without m_delete');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
- $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
+ $this->assertStringContainsString($this->lang('POST_DISPLAY', '', ''), $crawler->text());
}
public function test_move_softdeleted_post()
@@ -278,8 +278,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
- $this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text());
- $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Soft Delete #2', $crawler->filter('.navlinks')->text());
+ $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text());
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 0,
@@ -350,8 +350,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
- $this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text());
- $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Soft Delete #2', $crawler->filter('.navlinks')->text());
+ $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text());
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 0,
@@ -422,8 +422,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
- $this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text());
- $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Soft Delete #1', $crawler->filter('.navlinks')->text());
+ $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text());
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 0,
@@ -496,8 +496,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('POST_RESTORED_SUCCESS', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
- $this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text());
- $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Soft Delete #1', $crawler->filter('.navlinks')->text());
+ $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text());
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
@@ -575,8 +575,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('TOPIC_SPLIT_SUCCESS', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
- $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
- $this->assertNotContains('Re: Soft Delete Topic #1-#2', $crawler->text());
+ $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringNotContainsString('Re: Soft Delete Topic #1-#2', $crawler->text());
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
@@ -601,7 +601,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
// Assert new topic title is indexed as well
$this->add_lang('search');
self::request('GET', "search.php?keywords=bang&sid={$this->sid}");
- $this->assertContains(sprintf($this->lang['FOUND_SEARCH_MATCHES'][1], 1), self::get_content());
+ $this->assertStringContainsString(sprintf($this->lang['FOUND_SEARCH_MATCHES'][1], 1), self::get_content());
}
public function test_move_topic_back()
@@ -689,7 +689,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('POSTS_MERGED_SUCCESS', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
- $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text());
$this->assertContainsLang('POST_DELETED_ACTION', $crawler->filter('body')->text());
$this->assertContainsLang('BOOKMARK_TOPIC_REMOVE', $crawler->filter('body')->text());
diff --git a/tests/functional/visibility_unapproved_posts_test.php b/tests/functional/visibility_unapproved_posts_test.php
index 8d56af2c4e..52161ff58a 100644
--- a/tests/functional/visibility_unapproved_posts_test.php
+++ b/tests/functional/visibility_unapproved_posts_test.php
@@ -60,7 +60,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #1', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
$this->data['topics']['Unapproved Posts Test Topic #1'] = (int) $post['topic_id'];
$this->data['posts']['Unapproved Posts Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
@@ -83,7 +83,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$post2 = $this->create_post($this->data['forums']['Unapproved Posts Test #1'], $post['topic_id'], 'Re: Unapproved Posts Test Topic #1-#2', 'This is a test post posted by the testing framework.', [], 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
- $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringNotContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
@@ -99,7 +99,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #2', 'This is a test topic posted by the testing framework.', [], 'POST_STORED_MOD');
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
- $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
$this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
@@ -149,13 +149,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
// should be able to see topic 1 but not unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
- $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
- $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
- $this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringNotContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringNotContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
// should not be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
- $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
$this->logout();
// another user
@@ -166,13 +166,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
// should be able to see topic 1 but not unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
- $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
- $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
- $this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringNotContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringNotContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
// should not be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
- $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
}
public function test_view_unapproved_post_enabled()
@@ -212,18 +212,18 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
// should be able to see topic 1 and unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
- $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
- $this->assertContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
- $this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
// should be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
- $this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+ $this->assertStringContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
// should be able to see post in topic 2
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #2']}&sid={$this->sid}");
- $this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('#page-body')->text());
- $this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('Unapproved Posts Test Topic #2', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
$this->logout();
// another user
@@ -235,13 +235,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
// should be able to see topic 1 but not unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
- $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
- $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
- $this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+ $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertStringNotContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertStringNotContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
// should not be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
- $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+ $this->assertStringNotContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
$this->logout();
}
diff --git a/tests/functional/visit_installer_test.php b/tests/functional/visit_installer_test.php
index b4a75c0b51..742007fa5f 100644
--- a/tests/functional/visit_installer_test.php
+++ b/tests/functional/visit_installer_test.php
@@ -19,12 +19,12 @@ class phpbb_functional_visit_installer_test extends phpbb_functional_test_case
public function test_visit_installer()
{
self::request('GET', 'install/', [], false);
- $this->assertContains('', $this->get_content());
+ $this->assertStringContainsString('', $this->get_content());
self::request('GET', 'install/index.html', [], false);
- $this->assertContains('', $this->get_content());
+ $this->assertStringContainsString('', $this->get_content());
self::request('GET', 'install/app.php');
- $this->assertContains('installation system', $this->get_content());
+ $this->assertStringContainsString('installation system', $this->get_content());
}
}
diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php
index b783e3c297..c0330d01f8 100644
--- a/tests/functions/get_remote_file_test.php
+++ b/tests/functions/get_remote_file_test.php
@@ -74,7 +74,7 @@ class phpbb_functions_get_remote_file extends phpbb_test_case
'Failed asserting that the second line of the version file is a valid URL.'
);
- $this->assertContains('http', $lines[1]);
- $this->assertContains('phpbb.com', $lines[1], '', true);
+ $this->assertStringContainsString('http', $lines[1]);
+ $this->assertStringContainsString('phpbb.com', $lines[1], '', true);
}
}
diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php
index 27e1acefdd..93006124d8 100644
--- a/tests/functions/user_delete_test.php
+++ b/tests/functions/user_delete_test.php
@@ -33,6 +33,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_id'] = 2;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container = new phpbb_mock_container_builder();
$config = new \phpbb\config\config(array(
diff --git a/tests/functions/validate_num_test.php b/tests/functions/validate_num_test.php
index acbdc49614..26470d12f4 100644
--- a/tests/functions/validate_num_test.php
+++ b/tests/functions/validate_num_test.php
@@ -30,7 +30,7 @@ class phpbb_functions_validate_num_test extends phpbb_test_case
$this->helper->assert_valid_data(array(
'empty' => array(
array(),
- '',
+ null, // '' < 0 is true since PHP 8.0, hence use null instead of '' (empty string)
array('num'),
),
'zero' => array(
@@ -54,7 +54,7 @@ class phpbb_functions_validate_num_test extends phpbb_test_case
array('num', false, 2, 3),
),
'string' => array(
- array(),
+ version_compare(PHP_VERSION, '7.5', '<=') ? [] : ['TOO_LARGE'], // See https://wiki.php.net/rfc/string_to_number_comparison
'foobar',
array('num'),
),
diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php
index eeb5bfc2a9..fc22b7ac64 100644
--- a/tests/functions/validate_user_email_test.php
+++ b/tests/functions/validate_user_email_test.php
@@ -38,6 +38,7 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$language = new phpbb\language\language(new phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->user = new phpbb\user($language, '\phpbb\datetime');
+ $this->user->data['user_email'] = '';
$this->helper = new phpbb_functions_validate_data_helper($this);
}
diff --git a/tests/functions_content/phpbb_format_quote_test.php b/tests/functions_content/phpbb_format_quote_test.php
index eed1ec5e46..2f19c198e7 100644
--- a/tests/functions_content/phpbb_format_quote_test.php
+++ b/tests/functions_content/phpbb_format_quote_test.php
@@ -25,6 +25,7 @@ class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case
$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');
+ $user->data['user_options'] = 230271;
$cache = new phpbb_mock_cache();
parent::setUp();
diff --git a/tests/functions_privmsgs/get_max_setting_from_group_test.php b/tests/functions_privmsgs/get_max_setting_from_group_test.php
index b96f490c88..6a9018b6d3 100644
--- a/tests/functions_privmsgs/get_max_setting_from_group_test.php
+++ b/tests/functions_privmsgs/get_max_setting_from_group_test.php
@@ -54,11 +54,9 @@ class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_dat
$this->assertEquals($expected, phpbb_get_max_setting_from_group($this->db, $user_id, $setting));
}
- /**
- * @expectedException InvalidArgumentException
- */
public function test_get_max_setting_from_group_throws()
{
+ $this->expectException('InvalidArgumentException');
phpbb_get_max_setting_from_group($this->db, ANONYMOUS, 'not_a_setting');
}
}
diff --git a/tests/functions_user/whois_test.php b/tests/functions_user/whois_test.php
index b99854ba60..0ab5bc0ef6 100644
--- a/tests/functions_user/whois_test.php
+++ b/tests/functions_user/whois_test.php
@@ -11,7 +11,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
class phpbb_functions_user_whois_test extends phpbb_test_case
{
- public function setUp()
+ public function setUp(): void
{
global $config, $phpbb_dispatcher, $user, $request, $symfony_request, $phpbb_root_path, $phpEx;
diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php
index 99d36197ac..c7abaea76e 100644
--- a/tests/group/helper_test_case.php
+++ b/tests/group/helper_test_case.php
@@ -116,7 +116,7 @@ class phpbb_group_helper_test_case extends phpbb_test_case
$this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user);
}
- protected function setUp()
+ protected function setUp(): void
{
$this->setup_engine();
}
diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php
index e841a23a53..02695806b6 100644
--- a/tests/help/manager_test.php
+++ b/tests/help/manager_test.php
@@ -64,44 +64,33 @@ class phpbb_help_manager_test extends phpbb_test_case
*/
public function test_add_block($block_name, $switch, $questions, $switch_expected)
{
- $this->language->expects($this->at(0))
- ->method('lang')
- ->with($block_name)
- ->willReturn(strtoupper($block_name));
- $lang_call_count = 1;
+ $question_ary = $question_ary_upper = $template_call_args = [];
foreach ($questions as $question => $answer)
{
- $this->language->expects($this->at($lang_call_count))
- ->method('lang')
- ->with($question)
- ->willReturn(strtoupper($question));
- $lang_call_count++;
-
- $this->language->expects($this->at($lang_call_count))
- ->method('lang')
- ->with($answer)
- ->willReturn(strtoupper($answer));
- $lang_call_count++;
- }
-
- $this->template->expects($this->at(0))
- ->method('assign_block_vars')
- ->with('faq_block', array(
- 'BLOCK_TITLE' => strtoupper($block_name),
- 'SWITCH_COLUMN' => $switch_expected,
- ));
- $template_call_count = 1;
- foreach ($questions as $question => $answer)
- {
- $this->template->expects($this->at($template_call_count))
- ->method('assign_block_vars')
- ->with('faq_block.faq_row', array(
+ $question_ary = array_merge($question_ary, [[$question], [$answer]]);
+ $question_ary_upper = array_merge($question_ary_upper, [strtoupper($question), strtoupper($answer)]);
+ $template_call_args = array_merge($template_call_args, [['faq_block.faq_row', [
'FAQ_QUESTION' => strtoupper($question),
'FAQ_ANSWER' => strtoupper($answer),
- ));
- $template_call_count++;
+ ]
+ ]]);
}
+ $this->language->expects($this->exactly(count($questions)*2 + 1))
+ ->method('lang')
+ ->withConsecutive([$block_name], ...$question_ary)
+ ->will($this->onConsecutiveCalls(strtoupper($block_name), ...$question_ary_upper));
+
+ $this->template->expects($this->exactly(count($questions) + 1))
+ ->method('assign_block_vars')
+ ->withConsecutive(
+ ['faq_block', [
+ 'BLOCK_TITLE' => strtoupper($block_name),
+ 'SWITCH_COLUMN' => $switch_expected,
+ ]],
+ ...$template_call_args
+ );
+
$this->manager->add_block($block_name, $switch, $questions);
$this->assertEquals($switch_expected, $this->manager->switched_column());
@@ -110,8 +99,8 @@ class phpbb_help_manager_test extends phpbb_test_case
public function add_question_data()
{
return array(
- array('abc', false, false),
- array('def', true, true),
+ array('question1', 'answer1'),
+ array('question2', 'answer2'),
);
}
@@ -123,14 +112,13 @@ class phpbb_help_manager_test extends phpbb_test_case
*/
public function test_add_question($question, $answer)
{
- $this->language->expects($this->at(0))
+ $this->language->expects($this->exactly(2))
->method('lang')
- ->with($question)
- ->willReturn(strtoupper($question));
- $this->language->expects($this->at(1))
- ->method('lang')
- ->with($answer)
- ->willReturn(strtoupper($answer));
+ ->withConsecutive(
+ [$question],
+ [$answer]
+ )
+ ->will($this->onConsecutiveCalls(strtoupper($question), strtoupper($answer)));
$this->template->expects($this->once())
->method('assign_block_vars')
@@ -144,41 +132,33 @@ class phpbb_help_manager_test extends phpbb_test_case
public function test_add_block_double_switch()
{
- $block_name = 'abc';
- $switch_expected = true;
+ $block_name = ['abc', 'def'];
+ $switch_expected = [true, false];
- $this->language->expects($this->at(0))
+ $this->language->expects($this->exactly(2))
->method('lang')
- ->with($block_name)
- ->willReturn(strtoupper($block_name));
+ ->withConsecutive([$block_name[0]], [$block_name[1]])
+ ->will($this->onConsecutiveCalls(strtoupper($block_name[0]), strtoupper($block_name[1])));
- $this->template->expects($this->at(0))
+ $this->template->expects($this->exactly(2))
->method('assign_block_vars')
- ->with('faq_block', array(
- 'BLOCK_TITLE' => strtoupper($block_name),
- 'SWITCH_COLUMN' => $switch_expected,
- ));
+ ->withConsecutive(
+ ['faq_block', [
+ 'BLOCK_TITLE' => strtoupper($block_name[0]),
+ 'SWITCH_COLUMN' => $switch_expected[0],
+ ]],
+ ['faq_block', [
+ 'BLOCK_TITLE' => strtoupper($block_name[1]),
+ 'SWITCH_COLUMN' => $switch_expected[1],
+ ]]
+
+ );
- $this->manager->add_block($block_name, true);
+ $this->manager->add_block($block_name[0], true);
$this->assertTrue($this->manager->switched_column());
// Add a second block with switch
- $block_name = 'def';
- $switch_expected = false;
-
- $this->language->expects($this->at(0))
- ->method('lang')
- ->with($block_name)
- ->willReturn(strtoupper($block_name));
-
- $this->template->expects($this->at(0))
- ->method('assign_block_vars')
- ->with('faq_block', array(
- 'BLOCK_TITLE' => strtoupper($block_name),
- 'SWITCH_COLUMN' => $switch_expected,
- ));
-
- $this->manager->add_block($block_name, true);
+ $this->manager->add_block($block_name[1], true);
$this->assertTrue($this->manager->switched_column());
}
}
diff --git a/tests/lint_test.php b/tests/lint_test.php
index 2df572777a..43c0d8c057 100644
--- a/tests/lint_test.php
+++ b/tests/lint_test.php
@@ -11,11 +11,11 @@
*
*/
-class phpbb_lint_test extends phpbb_test_case
+class lint_test extends phpbb_test_case
{
static protected $php_binary;
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
// Try to use PHP_BINARY constant if available so lint tests are run
// using the same php binary as phpunit. If not available (pre PHP
diff --git a/tests/migrations/migrations_check_config_added_test.php b/tests/migrations/migrations_check_config_added_test.php
index cf3f8e9ea0..4d7c0e1e3a 100644
--- a/tests/migrations/migrations_check_config_added_test.php
+++ b/tests/migrations/migrations_check_config_added_test.php
@@ -13,7 +13,7 @@
class migrations_check_config_added_test extends phpbb_test_case
{
- public function setUp(): void
+ protected function setUp(): void
{
global $phpbb_root_path;
@@ -36,6 +36,10 @@ class migrations_check_config_added_test extends phpbb_test_case
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $phpEx;
+ $tools = [
+ new \phpbb\db\migration\tool\config($this->config),
+ ];
+
$this->container = new phpbb_mock_container_builder();
$this->migrator = new \phpbb\db\migrator(
@@ -48,7 +52,7 @@ class migrations_check_config_added_test extends phpbb_test_case
$this->php_ext,
$this->table_prefix,
[],
- [],
+ $tools,
new \phpbb\db\migration\helper()
);
$this->container->set('migrator', $this->migrator);
diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php
index 2ef5c2e5e1..52f2330dc0 100644
--- a/tests/migrator/schema_generator_test.php
+++ b/tests/migrator/schema_generator_test.php
@@ -46,11 +46,9 @@ class schema_generator_test extends phpbb_test_case
return $this->generator;
}
- /**
- * @expectedException \UnexpectedValueException
- */
public function test_check_dependencies_fail()
{
+ $this->expectException(\UnexpectedValueException::class);
$this->get_schema_generator(array('\phpbb\db\migration\data\v310\forgot_password'));
$this->generator->get_schema();
diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php
index 7ba5d80ea6..2b6423f1ee 100644
--- a/tests/mimetype/guesser_test.php
+++ b/tests/mimetype/guesser_test.php
@@ -123,11 +123,10 @@ class guesser_test extends \phpbb_test_case
/**
* @dataProvider data_incorrect_guessers
- *
- * @expectedException \LogicException
*/
public function test_incorrect_guesser($guessers)
{
+ $this->expectException(\LogicException::class);
$guesser = new \phpbb\mimetype\guesser($guessers);
}
diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php
index 17c4ae22dd..31513d0f31 100644
--- a/tests/mock/container_builder.php
+++ b/tests/mock/container_builder.php
@@ -59,7 +59,7 @@ class phpbb_mock_container_builder implements ContainerInterface
if ($this->has($id))
{
$service = $this->services[$id];
- if (is_array($service) && is_callable($service[0]))
+ if (is_array($service) && isset($service[0]) && is_callable($service[0]))
{
return call_user_func_array($service[0], $service[1]);
}
diff --git a/tests/network/ftp_fsock_pasv_epsv_test.php b/tests/network/ftp_fsock_pasv_epsv_test.php
index 4ec21b6f75..f615888efe 100644
--- a/tests/network/ftp_fsock_pasv_epsv_test.php
+++ b/tests/network/ftp_fsock_pasv_epsv_test.php
@@ -20,7 +20,7 @@ class phpbb_network_ftp_fsock_pasv_epsv_test extends phpbb_test_case
{
static protected $ipv4;
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
$hostname = 'ftp.debian.org.';
self::$ipv4 = gethostbyname($hostname);
@@ -55,7 +55,7 @@ class phpbb_network_ftp_fsock_pasv_epsv_test extends phpbb_test_case
{
$this->markTestSkipped("Failed to connect to $hostname: $result");
}
- $this->assertContains('debian', $o->_ls());
+ $this->assertStringContainsString('debian', $o->_ls());
$o->_close();
}
diff --git a/tests/notification/base.php b/tests/notification/base.php
index 1622d12363..e9de0daac1 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -74,6 +74,8 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_id'] = 0;
+ $user->data['user_type'] = USER_NORMAL;
$this->user = $user;
$this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
$auth = $this->auth = new phpbb_mock_notifications_auth();
diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml
index c83d8bd323..470768d986 100644
--- a/tests/notification/fixtures/services_notification.yml
+++ b/tests/notification/fixtures/services_notification.yml
@@ -38,9 +38,6 @@ services:
groupposition.teampage:
synthetic: true
- groupposition.teampage:
- synthetic: true
-
text_formatter.s9e.factory:
synthetic: true
diff --git a/tests/notification/notification_method_email_test.php b/tests/notification/notification_method_email_test.php
index cf84ddc795..d944846f76 100644
--- a/tests/notification/notification_method_email_test.php
+++ b/tests/notification/notification_method_email_test.php
@@ -34,7 +34,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
];
}
- protected function setUp() : void
+ protected function setUp(): void
{
phpbb_database_test_case::setUp();
@@ -249,7 +249,16 @@ class notification_method_email_test extends phpbb_tests_notification_base
*/
public function test_notification_email($notification_type, $post_data, $expected_users)
{
- $post_data = array_merge(['post_time' => 1349413322], $post_data);
+ $post_data = array_merge([
+ 'post_time' => 1349413322,
+ 'poster_id' => 1,
+ 'topic_title' => '',
+ 'post_subject' => '',
+ 'post_username' => '',
+ 'forum_name' => '',
+ ],
+
+ $post_data);
$notification_options = [
'item_id' => $post_data['post_id'],
'item_parent_id' => $post_data['topic_id'],
diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php
index 24a9d2e686..307f67ac10 100644
--- a/tests/notification/notification_test.php
+++ b/tests/notification/notification_test.php
@@ -160,6 +160,8 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'post_subject' => 'Re: test-title',
'forum_id' => 2,
'forum_name' => 'Your first forum',
+ 'post_username' => '',
+ 'post_text' => 'test text',
));
$this->db->sql_query('INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
@@ -176,6 +178,8 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'post_subject' => 'Re: test-title',
'forum_id' => 2,
'forum_name' => 'Your first forum',
+ 'post_username' => '',
+ 'post_text' => 'test text',
));
$this->notifications->delete_subscription('test');
@@ -267,6 +271,9 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'post_subject' => 'Re: test-title2', // change post_subject
'forum_id' => 3, // change forum_id
'forum_name' => 'Your second forum', // change forum_name
+ 'post_username' => '',
+ 'post_text' => 'test text2',
+ 'post_time' => 1349413325,
));
$this->assert_notifications(
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 032b8a25fe..f144e486a3 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -39,6 +39,9 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
'bbcode_bitfield' => '',
'bbcode_uid' => '',
'post_edit_locked' => false,
+ 'notify_set' => 0,
+ 'notify' => false,
+ 'forum_name' => 'Test forum name',
//'force_approved_state' => 1,
);
@@ -102,6 +105,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
'username' => 'user-name',
'is_registered' => true,
'user_colour' => '',
+ 'user_lastmark' => 0,
);
// Request
diff --git a/tests/notification/submit_post_type_topic_test.php b/tests/notification/submit_post_type_topic_test.php
index a2adfcdda8..e5da423903 100644
--- a/tests/notification/submit_post_type_topic_test.php
+++ b/tests/notification/submit_post_type_topic_test.php
@@ -135,9 +135,10 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_
$this->db->sql_freeresult($result);
$result = $this->db->sql_query(
- 'SELECT *
- FROM ' . POSTS_TABLE . '
- WHERE post_id = ' . $reply_id);
+ 'SELECT p.*, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_first_post_id, t.topic_last_post_id
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
+ WHERE p.topic_id = t.topic_id
+ AND p.post_id = ' . $reply_id);
$reply_edit_data = array_merge($this->post_data, $this->db->sql_fetchrow($result), array(
'force_approved_state' => false,
'post_edit_reason' => 'PHPBB3-12370',
diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php
index 0542d6ab78..f4cebda515 100644
--- a/tests/notification/user_list_trim_test.php
+++ b/tests/notification/user_list_trim_test.php
@@ -51,7 +51,10 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
- $user->data = array('user_lang' => 'en');
+ $user->data = [
+ 'user_id' => 1,
+ 'user_lang' => 'en',
+ ];
$lang->add_lang('common');
$user_loader = new phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
diff --git a/tests/profilefields/manager_test.php b/tests/profilefields/manager_test.php
index 1bf40550ca..efb91dea84 100644
--- a/tests/profilefields/manager_test.php
+++ b/tests/profilefields/manager_test.php
@@ -63,6 +63,8 @@ class manager_test extends phpbb_database_test_case
$language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$collection = new \phpbb\di\service_collection($container);
$user = new \phpbb\user($language, '\phpbb\datetime');
+ $user->data['user_id'] = 2;
+ $user->ip = '';
$this->log = new \phpbb\log\log($this->db, $user, $auth, $dispatcher, $phpbb_root_path, 'adm/', $phpEx, $table_prefix . 'log');
diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php
index 8806e2fadd..cfdec04eda 100644
--- a/tests/profilefields/type_bool_test.php
+++ b/tests/profilefields/type_bool_test.php
@@ -65,8 +65,10 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
'lang_id' => 1,
'lang_name' => 'field',
'field_required' => false,
- 'field_default_value' => 1,
- 'field_length' => 1,
+ 'field_default_value' => 1,
+ 'field_length' => 1,
+ 'field_show_novalue' => null,
+ 'field_novalue' => null,
);
$this->options = array(
diff --git a/tests/profilefields/type_date_test.php b/tests/profilefields/type_date_test.php
index 7b2d4112dc..75de0773d2 100644
--- a/tests/profilefields/type_date_test.php
+++ b/tests/profilefields/type_date_test.php
@@ -55,6 +55,8 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
'lang_id' => 1,
'lang_name' => 'field',
'field_required' => false,
+ 'field_show_novalue' => null,
+ 'field_novalue' => null,
);
}
diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php
index 86cd413240..8919fbb6a4 100644
--- a/tests/profilefields/type_dropdown_test.php
+++ b/tests/profilefields/type_dropdown_test.php
@@ -66,6 +66,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
'field_required' => false,
'field_validation' => '.*',
'field_novalue' => 0,
+ 'field_show_novalue' => null,
);
$this->dropdown_options = array(
@@ -153,7 +154,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
'Field should output nothing for empty value',
),
array(
- '',
+ null, // Since PHP 8, '' == 0 returns false, hence use null instead of '' (empty string)
array('field_show_novalue' => false),
null,
'Field should simply output null for empty value',
@@ -184,7 +185,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
'Field should return the correct raw value',
),
array(
- '',
+ null, // Since PHP 8, '' == 0 returns false, hence use null instead of '' (empty string)
array('field_show_novalue' => false),
null,
'Field should null for empty value without show_novalue',
diff --git a/tests/profilefields/type_int_test.php b/tests/profilefields/type_int_test.php
index 733f397911..a4161ce412 100644
--- a/tests/profilefields/type_int_test.php
+++ b/tests/profilefields/type_int_test.php
@@ -44,6 +44,10 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
'lang_id' => 1,
'lang_name' => 'field',
'field_required' => false,
+ 'field_show_novalue' => null,
+ 'field_novalue' => null,
+ 'field_minlen' => null,
+ 'field_maxlen' => null,
);
}
diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php
index a8d0399fd4..a813cc248b 100644
--- a/tests/profilefields/type_string_test.php
+++ b/tests/profilefields/type_string_test.php
@@ -49,6 +49,10 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
'lang_name' => 'field',
'field_required' => false,
'field_validation' => '.*',
+ 'field_show_novalue' => null,
+ 'field_novalue' => null,
+ 'field_minlen' => null,
+ 'field_maxlen' => null,
);
}
diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php
index d203234f2a..581257ad53 100644
--- a/tests/profilefields/type_url_test.php
+++ b/tests/profilefields/type_url_test.php
@@ -52,6 +52,10 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
'lang_id' => 1,
'lang_name' => 'field',
'field_required' => false,
+ 'field_show_novalue' => null,
+ 'field_novalue' => null,
+ 'field_minlen' => null,
+ 'field_maxlen' => null,
);
}
diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php
index 96e550609e..ef92ad5451 100644
--- a/tests/session/check_ban_test.php
+++ b/tests/session/check_ban_test.php
@@ -43,6 +43,16 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
parent::setUp();
// Get session here so that config is mocked correctly
$this->session = $this->session_factory->get_session($this->db);
+ $this->session->data['user_id'] = ANONYMOUS; // Don't get into the session_kill() procedure
+ $this->session->lang = [
+ 'BOARD_BAN_TIME' => 'BOARD_BAN_TIME',
+ 'BOARD_BAN_PERM' => 'BOARD_BAN_PERM',
+ 'BOARD_BAN_REASON' => 'BOARD_BAN_REASON',
+ 'BAN_TRIGGERED_BY_EMAIL' => 'BAN_TRIGGERED_BY_EMAIL',
+ 'BAN_TRIGGERED_BY_IP' => 'BAN_TRIGGERED_BY_IP',
+ 'BAN_TRIGGERED_BY_USER' => 'BAN_TRIGGERED_BY_USER',
+ ];
+
global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_filesystem;
$phpbb_filesystem = new \phpbb\filesystem\filesystem();
diff --git a/tests/session/session_key_test.php b/tests/session/session_key_test.php
index 2499ea1d55..2a62da2eb5 100644
--- a/tests/session/session_key_test.php
+++ b/tests/session/session_key_test.php
@@ -34,6 +34,8 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case
$session->cookie_data['k'] = $this->key_id;
// Try to access session with the session key
+ global $request, $symfony_request, $phpbb_filesystem, $phpbb_root_path;
+ $session->page = $session->extract_current_page($phpbb_root_path);
$session->session_create(false, false, false);
$this->assertEquals($this->user_id, $session->data['user_id'], 'User should be logged in by the session key');
}
@@ -45,6 +47,8 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case
$session = $this->session_factory->get_session($this->db);
// Reset of the keys for this user
+ $session->cookie_data['k'] = $this->key_id;
+ $session->data['user_id'] = $this->user_id;
$session->reset_login_keys($this->user_id);
// Using a user_id and key that was in the database (before reset)
@@ -52,6 +56,8 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case
$session->cookie_data['k'] = $this->key_id;
// Try to access session with the session key
+ global $request, $symfony_request, $phpbb_filesystem, $phpbb_root_path;
+ $session->page = $session->extract_current_page($phpbb_root_path);
$session->session_create(false, false, $this->user_id);
$this->assertNotEquals($this->user_id, $session->data['user_id'], 'User is not logged in because the session key is invalid');
diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php
index 05858c8a63..2a2b24fb27 100644
--- a/tests/session/testable_facade.php
+++ b/tests/session/testable_facade.php
@@ -94,10 +94,12 @@ class phpbb_session_testable_facade
$this->session_factory->merge_config_data($config_overrides);
// Bots
$this->session_factory->merge_cache_data(array('_bots' => $bot_overrides));
- global $request;
+ global $request, $symfony_request, $phpbb_filesystem, $phpbb_root_path;
$session = $this->session_factory->get_session($this->db);
$session->browser = $user_agent;
$session->ip = $ip_address;
+ $session->page = $session->extract_current_page($phpbb_root_path);
+
// Uri sid
if ($uri_sid)
{
diff --git a/tests/template/extension_test.php b/tests/template/extension_test.php
index a00a89ee46..b350a0d905 100644
--- a/tests/template/extension_test.php
+++ b/tests/template/extension_test.php
@@ -29,10 +29,13 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
$this->lang = $lang = new \phpbb\language\language($lang_loader);
$this->user = new \phpbb\user($lang, '\phpbb\datetime');
$this->user->style['style_path'] = 'chameleon';
+ $this->user->style['style_parent_id'] = 0;
global $auth, $request, $symfony_request, $user;
$user = new phpbb_mock_user();
$user->optionset('user_id', 2);
+ $user->style['style_path'] = '';
+ $user->data['user_id'] = 2;
$auth = $this->getMockBuilder('phpbb\auth\auth')
->disableOriginalConstructor()
->setMethods(['acl_get'])
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 01c132e032..fa84cb9770 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -493,7 +493,8 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(
'loop_expressions.html',
array(),
- array('loop' => array(array(),array(),array(),array(),array(),array()),),
+ // Do not use 'loop' as a block name to not override Twig's internal 'loop' object
+ array('loop1' => array(array(),array(),array(),array(),array(),array()),),
array(),
'yesnononoyesnoyesnonoyesnono',
),
@@ -1073,11 +1074,9 @@ EOT
$this->assertEquals("outer - 0 - Test assigning block vars array loop 0:outer - 1 - Test assigning block vars array loop 1:middle - 0 - 1st iterationmiddle - 1 - 2nd iterationmiddle - 2 - 3rd iteration", $this->display('test'), 'Ensuring assigning block vars array to template is working correctly');
}
- /**
- * @expectedException Twig_Error_Syntax
- */
public function test_define_error()
{
+ $this->expectException('Twig_Error_Syntax');
$this->run_template('define_error.html', array(), array(), array(), '');
}
}
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 18b067bb30..3bac42be92 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -25,7 +25,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
static protected $language_reflection_lang;
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
diff --git a/tests/template/templates/loop_expressions.html b/tests/template/templates/loop_expressions.html
index ddb9fd52fa..e983c0cc42 100644
--- a/tests/template/templates/loop_expressions.html
+++ b/tests/template/templates/loop_expressions.html
@@ -1,11 +1,11 @@
-
+
-yesno
+yesno
-
+
-
+
-yesno
+yesno
-
+
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index b73baaeb94..b6bfb40598 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -29,21 +29,35 @@ abstract class phpbb_database_test_case extends TestCase
static protected $install_schema_file;
- public function __construct($name = NULL, array $data = array(), $dataName = '')
+ static protected $phpunit_version;
+
+ public function __construct($name = NULL, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);
- $this->backupStaticAttributesBlacklist += array(
- 'SebastianBergmann\CodeCoverage\CodeCoverage' => array('instance'),
- 'SebastianBergmann\CodeCoverage\Filter' => array('instance'),
- 'SebastianBergmann\CodeCoverage\Util' => array('ignoredLines', 'templateMethods'),
- 'SebastianBergmann\Timer\Timer' => array('startTimes',),
- 'PHP_Token_Stream' => array('customTokens'),
- 'PHP_Token_Stream_CachingFactory' => array('cache'),
- 'phpbb_database_test_case' => array('already_connected'),
- );
+ self::$phpunit_version = PHPUnit\Runner\Version::id();
- $this->db_connections = array();
+ $backupStaticAttributesBlacklist = [
+ 'SebastianBergmann\CodeCoverage\CodeCoverage' => ['instance'],
+ 'SebastianBergmann\CodeCoverage\Filter' => ['instance'],
+ 'SebastianBergmann\CodeCoverage\Util' => ['ignoredLines', 'templateMethods'],
+ 'SebastianBergmann\Timer\Timer' => ['startTimes'],
+ 'PHP_Token_Stream' => ['customTokens'],
+ 'PHP_Token_Stream_CachingFactory' => ['cache'],
+
+ 'phpbb_database_test_case' => ['already_connected'],
+ ];
+
+ if (version_compare(self::$phpunit_version, '9.0', '>='))
+ {
+ $this->backupStaticAttributesExcludeList += $backupStaticAttributesBlacklist;
+ }
+ else
+ {
+ $this->backupStaticAttributesBlacklist += $backupStaticAttributesBlacklist;
+ }
+
+ $this->db_connections = [];
}
/**
@@ -54,7 +68,7 @@ abstract class phpbb_database_test_case extends TestCase
return array();
}
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
global $phpbb_root_path, $phpEx;
@@ -90,7 +104,7 @@ abstract class phpbb_database_test_case extends TestCase
parent::setUpBeforeClass();
}
- static public function tearDownAfterClass()
+ static public function tearDownAfterClass(): void
{
if (file_exists(self::$install_schema_file))
{
@@ -371,4 +385,56 @@ abstract class phpbb_database_test_case extends TestCase
return $core_tables;
}
+
+ /**
+ * PHPUnit deprecates several methods and properties in its recent versions
+ * Provide BC layer to be able to test in multiple environment settings
+ */
+ public function expectException(string $exception): void
+ {
+ if (version_compare(self::$phpunit_version, '9.0', '>='))
+ {
+ switch ($exception) {
+ case PHPUnit\Framework\Error\Deprecated::class:
+ parent::expectDeprecation();
+ break;
+
+ case PHPUnit\Framework\Error\Error::class:
+ parent::expectError();
+ break;
+
+ case PHPUnit\Framework\Error\Notice::class:
+ parent::expectNotice();
+ break;
+
+ case PHPUnit\Framework\Error\Warning::class:
+ parent::expectWarning();
+ break;
+
+ default:
+ parent::expectException($exception);
+ break;
+ }
+ }
+ else
+ {
+ parent::expectException($exception);
+ }
+ }
+
+ /**
+ * PHPUnit deprecates several methods and properties in its recent versions
+ * Provide BC layer to be able to test in multiple environment settings
+ */
+ public static function assertFileNotExists(string $filename, string $message = ''): void
+ {
+ if (version_compare(self::$phpunit_version, '9.0', '>='))
+ {
+ parent::assertFileDoesNotExist($filename, $message);
+ }
+ else
+ {
+ parent::assertFileNotExists($filename, $message);
+ }
+ }
}
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index e4c1a194cc..dce9d849e1 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -393,12 +393,16 @@ class phpbb_database_test_connection_manager
{
$this->pdo->beginTransaction();
}
- else if ($query === 'commit')
+ else if ($query === 'commit' && $this->pdo->inTransaction())
{
$this->pdo->commit();
}
else
{
+ if (!$this->pdo->inTransaction())
+ {
+ $this->pdo->beginTransaction();
+ }
$this->pdo->exec($query);
}
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index d107ce47d1..97ff1f62cc 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -42,7 +42,7 @@ class phpbb_functional_test_case extends phpbb_test_case
static protected $already_installed = false;
static protected $last_post_timestamp = 0;
- static public function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -183,13 +183,14 @@ class phpbb_functional_test_case extends phpbb_test_case
{
}
- public function __construct($name = NULL, array $data = array(), $dataName = '')
+ public function __construct($name = NULL, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);
- $this->backupStaticAttributesBlacklist += array(
- 'phpbb_functional_test_case' => array('config', 'already_installed'),
- );
+ $backupStaticAttributesBlacklist = [
+ 'phpbb_functional_test_case' => ['config', 'already_installed'],
+ ];
+ $this->excludeBackupStaticAttributes($backupStaticAttributesBlacklist);
}
protected function get_db()
@@ -720,7 +721,14 @@ class phpbb_functional_test_case extends phpbb_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->createMock('\phpbb\user');
+
+ $user = $this->createMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
+ $user->data['user_id'] = 2; // admin
+ $user->ip = '';
+
$auth = $this->createMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
@@ -754,7 +762,14 @@ class phpbb_functional_test_case extends phpbb_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->createMock('\phpbb\user');
+
+ $user = $this->createMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
+ $user->data['user_id'] = 2; // admin
+ $user->ip = '';
+
$auth = $this->createMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
@@ -787,7 +802,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->add_lang('ucp');
$crawler = self::request('GET', 'ucp.php');
- $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
if ($autologin)
@@ -795,7 +810,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$form['autologin']->tick();
}
$crawler = self::submit($form, array('username' => $username, 'password' => $username . $username));
- $this->assertNotContains($this->lang('LOGIN'), $crawler->filter('.navbar')->text());
+ $this->assertStringNotContainsString($this->lang('LOGIN'), $crawler->filter('.navbar')->text());
$cookies = self::$cookieJar->all();
@@ -814,7 +829,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->add_lang('ucp');
$crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
- $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
+ $this->assertStringContainsString($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
unset($this->sid);
}
@@ -835,7 +850,7 @@ class phpbb_functional_test_case extends phpbb_test_case
}
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid);
- $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text());
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
@@ -844,7 +859,7 @@ class phpbb_functional_test_case extends phpbb_test_case
if (strpos($field, 'password_') === 0)
{
$crawler = self::submit($form, array('username' => $username, $field => $username . $username));
- $this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text());
+ $this->assertStringContainsString($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text());
$cookies = self::$cookieJar->all();
@@ -934,7 +949,7 @@ class phpbb_functional_test_case extends phpbb_test_case
*/
public function assertContainsLang($needle, $haystack, $message = '')
{
- $this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
+ $this->assertStringContainsString(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
}
/**
@@ -946,7 +961,7 @@ class phpbb_functional_test_case extends phpbb_test_case
*/
public function assertNotContainsLang($needle, $haystack, $message = '')
{
- $this->assertNotContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
+ $this->assertStringNotContainsString(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
}
/*
@@ -961,7 +976,7 @@ class phpbb_functional_test_case extends phpbb_test_case
{
// Any output before the doc type means there was an error
$content = self::get_content();
- self::assertNotContains('[phpBB Debug]', $content);
+ self::assertStringNotContainsString('[phpBB Debug]', $content);
self::assertStringStartsWith('assertContains($expected, $crawler->filter('html')->text());
+ $this->assertStringContainsString($expected, $crawler->filter('html')->text());
}
return null;
}
@@ -1206,7 +1221,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$crawler = self::submit_message($posting_url, 'POST_NEW_PM', $form_data);
- $this->assertContains($this->lang('MESSAGE_STORED'), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang('MESSAGE_STORED'), $crawler->filter('html')->text());
$url = $crawler->selectLink($this->lang('VIEW_PRIVATE_MESSAGE', '', ''))->link()->getUri();
return $this->get_parameter_from_link($url, 'p');
@@ -1230,7 +1245,7 @@ class phpbb_functional_test_case extends phpbb_test_case
self::$last_post_timestamp = time();
$crawler = self::request('GET', $posting_url);
- $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
+ $this->assertStringContainsString($this->lang($posting_contains), $crawler->filter('html')->text());
if (!empty($form_data['upload_files']))
{
diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php
index 8e09f17ede..726f6671ae 100644
--- a/tests/test_framework/phpbb_test_case.php
+++ b/tests/test_framework/phpbb_test_case.php
@@ -16,20 +16,25 @@ use PHPUnit\Framework\TestCase;
class phpbb_test_case extends TestCase
{
protected $test_case_helpers;
+ static protected $phpunit_version;
public function __construct($name = NULL, array $data = array(), $dataName = '')
{
parent::__construct($name, $data, $dataName);
- $this->backupStaticAttributesBlacklist += array(
- 'SebastianBergmann\CodeCoverage\CodeCoverage' => array('instance'),
- 'SebastianBergmann\CodeCoverage\Filter' => array('instance'),
- 'SebastianBergmann\CodeCoverage\Util' => array('ignoredLines', 'templateMethods'),
- 'SebastianBergmann\Timer\Timer' => array('startTimes',),
- 'PHP_Token_Stream' => array('customTokens'),
- 'PHP_Token_Stream_CachingFactory' => array('cache'),
- 'phpbb_database_test_case' => array('already_connected', 'last_post_timestamp'),
- );
+ self::$phpunit_version = PHPUnit\Runner\Version::id();
+
+ $backupStaticAttributesBlacklist = [
+ 'SebastianBergmann\CodeCoverage\CodeCoverage' => ['instance'],
+ 'SebastianBergmann\CodeCoverage\Filter' => ['instance'],
+ 'SebastianBergmann\CodeCoverage\Util' => ['ignoredLines', 'templateMethods'],
+ 'SebastianBergmann\Timer\Timer' => ['startTimes'],
+ 'PHP_Token_Stream' => ['customTokens'],
+ 'PHP_Token_Stream_CachingFactory' => ['cache'],
+
+ 'phpbb_database_test_case' => ['already_connected', 'last_post_timestamp'],
+ ];
+ $this->excludeBackupStaticAttributes($backupStaticAttributesBlacklist);
}
public function get_test_case_helpers()
@@ -46,4 +51,88 @@ class phpbb_test_case extends TestCase
{
$this->get_test_case_helpers()->setExpectedTriggerError($errno, $message);
}
+
+ /**
+ * PHPUnit deprecates several methods and properties in its recent versions
+ * Provide BC layer to be able to test in multiple environment settings
+ */
+ public function excludeBackupStaticAttributes($attributes_array)
+ {
+ if (version_compare(self::$phpunit_version, '9.0', '>='))
+ {
+ $this->backupStaticAttributesExcludeList += $attributes_array;
+ }
+ else
+ {
+ $this->backupStaticAttributesBlacklist += $attributes_array;
+ }
+ }
+
+ /**
+ * PHPUnit deprecates several methods and properties in its recent versions
+ * Provide BC layer to be able to test in multiple environment settings
+ */
+ public static function assertRegExp(string $pattern, string $string, string $message = ''): void
+ {
+ if (version_compare(self::$phpunit_version, '9.0', '>='))
+ {
+ parent::assertMatchesRegularExpression($pattern, $string, $message);
+ }
+ else
+ {
+ parent::assertRegExp($pattern, $string, $message);
+ }
+ }
+
+ /**
+ * PHPUnit deprecates several methods and properties in its recent versions
+ * Provide BC layer to be able to test in multiple environment settings
+ */
+ public function expectException(string $exception): void
+ {
+ if (version_compare(self::$phpunit_version, '9.0', '>='))
+ {
+ switch ($exception) {
+ case PHPUnit\Framework\Error\Deprecated::class:
+ parent::expectDeprecation();
+ break;
+
+ case PHPUnit\Framework\Error\Error::class:
+ parent::expectError();
+ break;
+
+ case PHPUnit\Framework\Error\Notice::class:
+ parent::expectNotice();
+ break;
+
+ case PHPUnit\Framework\Error\Warning::class:
+ parent::expectWarning();
+ break;
+
+ default:
+ parent::expectException($exception);
+ break;
+ }
+ }
+ else
+ {
+ parent::expectException($exception);
+ }
+ }
+
+ /**
+ * PHPUnit deprecates several methods and properties in its recent versions
+ * Provide BC layer to be able to test in multiple environment settings
+ */
+ public static function assertFileNotExists(string $filename, string $message = ''): void
+ {
+ if (version_compare(self::$phpunit_version, '9.0', '>='))
+ {
+ parent::assertFileDoesNotExist($filename, $message);
+ }
+ else
+ {
+ parent::assertFileNotExists($filename, $message);
+ }
+ }
}
diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php
index ce394fc510..347f70f3c9 100644
--- a/tests/test_framework/phpbb_test_case_helpers.php
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -531,6 +531,14 @@ class phpbb_test_case_helpers
if ($container->has('user'))
{
$user = $container->get('user');
+
+ // Set default required user data if not set
+ $user->data['is_bot'] = $user->data['is_bot'] ?? false;
+ $user->data['is_registered'] = $user->data['is_registered'] ?? false;
+ $user->data['style_id'] = $user->data['style_id'] ?? 1;
+ $user->data['user_id'] = $user->data['user_id'] ?? ANONYMOUS;
+ $user->data['user_options'] = $user->data['user_options'] ?? 230271;
+ $user->style['style_id'] = $user->style['style_id'] ?? 1;
}
else
{
@@ -545,6 +553,14 @@ class phpbb_test_case_helpers
->method('format_date')
->will($this->test_case->returnCallback(__CLASS__ . '::format_date'));
+ // Set default required user data
+ $user->data['is_bot'] = false;
+ $user->data['is_registered'] = false;
+ $user->data['style_id'] = 1;
+ $user->data['user_id'] = ANONYMOUS;
+ $user->data['user_options'] = 230271;
+ $user->style['style_id'] = 1;
+
$user->date_format = 'Y-m-d H:i:s';
$user->optionset('viewcensors', true);
$user->optionset('viewflash', true);
@@ -555,11 +571,6 @@ class phpbb_test_case_helpers
}
$user->add_lang('common');
- if (!isset($user->style))
- {
- $user->style = array('style_id' => 1);
- }
-
// Create and register a quote_helper
$quote_helper = new \phpbb\textformatter\s9e\quote_helper(
$container->get('user'),
diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php
index f57bbdd6dc..d9ba86b05d 100644
--- a/tests/text_formatter/s9e/factory_test.php
+++ b/tests/text_formatter/s9e/factory_test.php
@@ -288,22 +288,13 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
{
$this->dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$this->dispatcher
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('trigger_event')
- ->with(
- 'core.text_formatter_s9e_configure_before',
- $this->callback(array($this, 'configure_event_callback'))
+ ->withConsecutive(
+ ['core.text_formatter_s9e_configure_before', $this->callback(array($this, 'configure_event_callback'))],
+ ['core.text_formatter_s9e_configure_after', $this->callback(array($this, 'configure_event_callback'))]
)
->will($this->returnArgument(1));
- $this->dispatcher
- ->expects($this->at(1))
- ->method('trigger_event')
- ->with(
- 'core.text_formatter_s9e_configure_after',
- $this->callback(array($this, 'configure_event_callback'))
- )
- ->will($this->returnArgument(1));
-
$this->get_factory()->get_configurator();
}
diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php
index e10ebd29ee..ef9a1184ee 100644
--- a/tests/text_formatter/s9e/parser_test.php
+++ b/tests/text_formatter/s9e/parser_test.php
@@ -101,15 +101,19 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
public function test_options($adapter_method, $adapter_arg, $concrete_method, $concrete_arg)
{
$mock = $this->getMockBuilder('s9e\\TextFormatter\\Parser')
- ->setMethods(array($concrete_method))
+ ->setMethods([$concrete_method])
->disableOriginalConstructor()
->getMock();
- foreach ((array) $concrete_arg as $i => $concrete_arg)
- {
- $mock->expects($this->at($i))
- ->method($concrete_method)
- ->with($concrete_arg);
- }
+
+ $concrete_args = (array) $concrete_arg;
+ array_walk($concrete_args, function(&$value)
+ {
+ $value = (array) $value;
+ }
+ );
+ $mock->expects($this->exactly(count($concrete_args)))
+ ->method($concrete_method)
+ ->withConsecutive(...$concrete_args);
$cache = new phpbb_mock_cache;
$cache->put('_foo_parser', $mock);
@@ -141,11 +145,11 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
),
array(
'disable_magic_url', null,
- 'disablePlugin', array('Autoemail', 'Autolink')
+ 'disablePlugin', ['Autoemail', 'Autolink']
),
array(
'disable_smilies', null,
- 'disablePlugin', 'Emoticons'
+ 'disablePlugin', ['Emoticons', 'Emoji']
),
array(
'enable_bbcode', 'url',
@@ -157,11 +161,11 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
),
array(
'enable_magic_url', null,
- 'enablePlugin', array('Autoemail', 'Autolink')
+ 'enablePlugin', ['Autoemail', 'Autolink']
),
array(
'enable_smilies', null,
- 'enablePlugin', 'Emoticons'
+ 'enablePlugin', ['Emoticons', 'Emoji']
)
);
}
@@ -207,22 +211,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
->expects($this->any())
->method('trigger_event')
->will($this->returnArgument(1));
- $dispatcher
- ->expects($this->at(1))
- ->method('trigger_event')
- ->with(
- 'core.text_formatter_s9e_parse_before',
- $this->callback(array($this, 'parse_before_event_callback'))
- )
- ->will($this->returnArgument(1));
- $dispatcher
- ->expects($this->at(2))
- ->method('trigger_event')
- ->with(
- 'core.text_formatter_s9e_parse_after',
- $this->callback(array($this, 'parse_after_event_callback'))
- )
- ->will($this->returnArgument(1));
$parser = new \phpbb\textformatter\s9e\parser(
$container->get('cache.driver'),
@@ -230,6 +218,16 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
$container->get('text_formatter.s9e.factory'),
$dispatcher
);
+
+ $dispatcher
+ ->expects($this->exactly(2))
+ ->method('trigger_event')
+ ->withConsecutive(
+ ['core.text_formatter_s9e_parse_before', $this->callback(array($this, 'parse_before_event_callback'))],
+ ['core.text_formatter_s9e_parse_after', $this->callback(array($this, 'parse_after_event_callback'))]
+ )
+ ->will($this->returnArgument(1));
+
$parser->parse('...');
}
diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php
index 672069590a..69075ebaca 100644
--- a/tests/text_formatter/s9e/renderer_test.php
+++ b/tests/text_formatter/s9e/renderer_test.php
@@ -61,7 +61,10 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
->getMock();
$factory->expects($this->once())
->method('regenerate')
- ->will($this->returnValue(array('parser' => $mock)));
+ ->will($this->returnValue([
+ 'parser' => $mock,
+ 'renderer' => $mock,
+ ]));
$renderer = new \phpbb\textformatter\s9e\renderer(
$cache,
@@ -160,6 +163,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_options'] = 230271;
$user->optionset('viewcensors', false);
$phpbb_container->set('user', $user);
@@ -175,6 +179,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_options'] = 230271;
$user->optionset('viewcensors', false);
$config = new \phpbb\config\config(array('allow_nocensors' => true));
@@ -193,6 +198,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_options'] = 230271;
$user->optionset('viewcensors', false);
$config = new \phpbb\config\config(array('allow_nocensors' => true));
@@ -222,6 +228,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_options'] = 230271;
$user->optionset('viewflash', false);
$phpbb_container->set('user', $user);
@@ -241,6 +248,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_options'] = 230271;
$user->optionset('viewimg', false);
$phpbb_container->set('user', $user);
@@ -260,7 +268,8 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
- $user->optionset('smilies', false);
+ $user->data['user_options'] = 230271;
+ $user->optionset('viewsmilies', false);
$phpbb_container->set('user', $user);
}
@@ -429,22 +438,6 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
->expects($this->any())
->method('trigger_event')
->will($this->returnArgument(1));
- $dispatcher
- ->expects($this->at(1))
- ->method('trigger_event')
- ->with(
- 'core.text_formatter_s9e_render_before',
- $this->callback(array($this, 'render_before_event_callback'))
- )
- ->will($this->returnArgument(1));
- $dispatcher
- ->expects($this->at(2))
- ->method('trigger_event')
- ->with(
- 'core.text_formatter_s9e_render_after',
- $this->callback(array($this, 'render_after_event_callback'))
- )
- ->will($this->returnArgument(1));
$renderer = new \phpbb\textformatter\s9e\renderer(
$container->get('cache.driver'),
@@ -453,6 +446,16 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$container->get('text_formatter.s9e.factory'),
$dispatcher
);
+
+ $dispatcher
+ ->expects($this->exactly(2))
+ ->method('trigger_event')
+ ->withConsecutive(
+ ['core.text_formatter_s9e_render_before', $this->callback(array($this, 'render_before_event_callback'))],
+ ['core.text_formatter_s9e_render_after', $this->callback(array($this, 'render_after_event_callback'))]
+ )
+ ->will($this->returnArgument(1));
+
$renderer->render('...');
}
diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php
index 8429c16c3a..64ab695c6e 100644
--- a/tests/text_processing/generate_text_for_display_test.php
+++ b/tests/text_processing/generate_text_for_display_test.php
@@ -37,6 +37,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_options'] = 230271;
$user->optionset('viewcensors', true);
$user->optionset('viewflash', true);
$user->optionset('viewimg', true);
@@ -72,6 +73,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_options'] = 230271;
// Do not ignore word censoring by user (switch censoring on in UCP)
$user->optionset('viewcensors', true);
@@ -172,6 +174,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_options'] = 230271;
$user->optionset('viewflash', false);
$phpbb_container->set('user', $user);
@@ -192,6 +195,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_options'] = 230271;
$user->optionset('viewimg', false);
$phpbb_container->set('user', $user);
@@ -212,7 +216,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
- $user->optionset('smilies', false);
+ $user->data['user_options'] = 230271;
+ $user->optionset('viewsmilies', false);
$phpbb_container->set('user', $user);
}
diff --git a/tests/text_processing/message_parser_test.php b/tests/text_processing/message_parser_test.php
index d302ee9504..3b81ab9d9d 100644
--- a/tests/text_processing/message_parser_test.php
+++ b/tests/text_processing/message_parser_test.php
@@ -16,7 +16,7 @@ require_once __DIR__ . '/../../phpBB/includes/message_parser.php';
class phpbb_text_processing_message_parser_test extends phpbb_test_case
{
- public static function setUpBeforeClass()
+ static public function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
@@ -25,7 +25,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case
stream_wrapper_register('http', __CLASS__ . '_proxy');
}
- public static function tearDownAfterClass()
+ static public function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
stream_wrapper_restore('http');
diff --git a/tests/tree/nestedset_forum_insert_delete_test.php b/tests/tree/nestedset_forum_insert_delete_test.php
index 6393752010..79ba12b353 100644
--- a/tests/tree/nestedset_forum_insert_delete_test.php
+++ b/tests/tree/nestedset_forum_insert_delete_test.php
@@ -66,12 +66,11 @@ class phpbb_tests_tree_nestedset_forum_add_remove_test extends phpbb_tests_tree_
/**
* @dataProvider delete_throws_data
- *
- * @expectedException OutOfBoundsException
- * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_ITEM
*/
public function test_delete_throws($explain, $forum_id)
{
+ $this->expectException('OutOfBoundsException');
+ $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_ITEM');
$this->set->delete($forum_id);
}
diff --git a/tests/tree/nestedset_forum_move_test.php b/tests/tree/nestedset_forum_move_test.php
index 108faf5b71..d884117fa0 100644
--- a/tests/tree/nestedset_forum_move_test.php
+++ b/tests/tree/nestedset_forum_move_test.php
@@ -386,12 +386,11 @@ class phpbb_tests_tree_nestedset_forum_move_test extends phpbb_tests_tree_nested
/**
* @dataProvider move_children_throws_item_data
- *
- * @expectedException OutOfBoundsException
- * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_ITEM
*/
public function test_move_children_throws_item($explain, $forum_id, $target_id)
{
+ $this->expectException('OutOfBoundsException');
+ $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_ITEM');
$this->set->move_children($forum_id, $target_id);
}
@@ -406,12 +405,11 @@ class phpbb_tests_tree_nestedset_forum_move_test extends phpbb_tests_tree_nested
/**
* @dataProvider move_children_throws_parent_data
- *
- * @expectedException OutOfBoundsException
- * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_PARENT
*/
public function test_move_children_throws_parent($explain, $forum_id, $target_id)
{
+ $this->expectException('OutOfBoundsException');
+ $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_PARENT');
$this->set->move_children($forum_id, $target_id);
}
@@ -542,12 +540,11 @@ class phpbb_tests_tree_nestedset_forum_move_test extends phpbb_tests_tree_nested
/**
* @dataProvider change_parent_throws_item_data
- *
- * @expectedException OutOfBoundsException
- * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_ITEM
*/
public function test_change_parent_throws_item($explain, $forum_id, $target_id)
{
+ $this->expectException('OutOfBoundsException');
+ $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_ITEM');
$this->set->change_parent($forum_id, $target_id);
}
@@ -562,12 +559,11 @@ class phpbb_tests_tree_nestedset_forum_move_test extends phpbb_tests_tree_nested
/**
* @dataProvider change_parent_throws_parent_data
- *
- * @expectedException OutOfBoundsException
- * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_PARENT
*/
public function test_change_parent_throws_parent($explain, $forum_id, $target_id)
{
+ $this->expectException('OutOfBoundsException');
+ $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_PARENT');
$this->set->change_parent($forum_id, $target_id);
}
}
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php
index a5b897d180..f72187167f 100644
--- a/tests/upload/fileupload_test.php
+++ b/tests/upload/fileupload_test.php
@@ -186,7 +186,13 @@ class phpbb_fileupload_test extends phpbb_test_case
->set_max_filesize(1000);
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
- $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
+ // Upload file data should be set to prevent "Undefined array key" PHP 8 warning
+ $filedata = [
+ 'size' => 519,
+ 'realname' => $this->path . 'jpg.jpg',
+ 'type' => false,
+ ];
+ $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg', $filedata);
$this->assertEquals(0, count($file->error));
$this->assertFalse($file->additional_checks());
$this->assertTrue($file->move_file('../tests/upload/fixture/copies', true));
@@ -200,7 +206,13 @@ class phpbb_fileupload_test extends phpbb_test_case
->set_max_filesize(1000);
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
- $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
+ // Upload file data should be set to prevent "Undefined array key" PHP 8 warning
+ $filedata = [
+ 'size' => 519,
+ 'realname' => $this->path . 'jpg.jpg',
+ 'type' => false,
+ ];
+ $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg', $filedata);
$this->assertEquals(0, count($file->error));
$this->assertFalse($file->move_file('../tests/upload/fixture'));
$this->assertFalse($file->get('file_moved'));
@@ -215,7 +227,13 @@ 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');
+ // Upload file data should be set to prevent "Undefined array key" PHP 8 warning
+ $filedata = [
+ 'size' => 519,
+ 'realname' => $this->path . 'jpg.jpg',
+ 'type' => false,
+ ];
+ $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg', $filedata);
$this->assertEquals(0, count($file->error));
$file->move_file('../tests/upload/fixture/copies', true);
$this->assertEquals(0, count($file->error));
diff --git a/tests/version/version_test.php b/tests/version/version_test.php
index 561367fd03..f162d12d44 100644
--- a/tests/version/version_test.php
+++ b/tests/version/version_test.php
@@ -15,7 +15,7 @@ class phpbb_version_helper_test extends phpbb_test_case
{
protected $cache;
protected $version_helper;
-
+
protected function setUp(): void
{
parent::setUp();
@@ -353,13 +353,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -367,9 +373,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -379,13 +389,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1-a2',
+ 'eol' => false,
+ 'security' => false,
),
'1.1' => array(
'current' => '1.1.0',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.0.1-a2',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -393,13 +409,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -407,9 +429,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -419,13 +445,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'1.1' => array(
'current' => '1.1.0-a2',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.0-a2',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -439,14 +471,18 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
+ 'eol' => false,
'security' => '1.0.1',
),
'1.1' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.0.1',
+ 'eol' => false,
'security' => '1.0.1',
),
),
@@ -456,14 +492,18 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
+ 'eol' => false,
'security' => '1.0.0',
),
'1.1' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.0.1',
+ 'eol' => false,
'security' => '1.0.0',
),
),
@@ -473,14 +513,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
+ 'eol' => false,
'security' => '1.1.0',
),
'1.1' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
// Latest 1.0 release is EOL
@@ -490,13 +535,18 @@ class phpbb_version_helper_test extends phpbb_test_case
'1.0' => array(
'current' => '1.0.1',
'eol' => true,
+ 'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
// All are EOL -- somewhat undefined behavior
@@ -506,10 +556,12 @@ class phpbb_version_helper_test extends phpbb_test_case
'1.0' => array(
'current' => '1.0.1',
'eol' => true,
+ 'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
'eol' => true,
+ 'security' => false,
),
),
array(),
@@ -560,10 +612,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -572,6 +628,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -582,10 +640,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -594,6 +656,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -605,10 +669,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -617,6 +685,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -627,10 +697,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -639,6 +713,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -649,10 +725,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -661,6 +741,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -672,13 +754,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -687,9 +775,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -700,9 +792,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -713,13 +809,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -728,13 +830,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -743,9 +851,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
@@ -757,13 +869,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -772,13 +890,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -787,13 +911,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(
@@ -802,9 +932,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
+ 'eol' => false,
+ 'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
+ 'eol' => false,
+ 'security' => false,
),
),
array(),
diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh
index 0fcb63c311..9731bad584 100755
--- a/travis/setup-phpbb.sh
+++ b/travis/setup-phpbb.sh
@@ -44,4 +44,9 @@ fi
cd phpBB
php ../composer.phar install --dev --no-interaction
+if [ "$TRAVIS_PHP_VERSION" == "nightly" ]
+then
+ php ../composer.phar remove phpunit/dbunit --dev --update-with-dependencies \
+ && php ../composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-all-dependencies --ignore-platform-reqs
+fi
cd ..