1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-19 15:01:33 +02:00

Merge pull request #6838 from rxu/ticket/17535

[ticket/17535] Upgrade PHPUnit to version 10
This commit is contained in:
Marc Alexander
2025-07-30 13:48:49 +02:00
committed by GitHub
248 changed files with 1637 additions and 1555 deletions

View File

@@ -31,15 +31,21 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case
// Failure to connect results in a trigger_error call in dbal.
// phpunit converts triggered errors to exceptions.
// In particular there should be no fatals here.
try
if ($db->get_sql_layer() === 'mysqli')
{
$db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']);
$this->assertFalse(true);
$this->setExpectedTriggerError(E_WARNING);
}
catch (Exception $e)
else if ($db->get_sql_layer() !== 'sqlite3')
{
// should have a legitimate message
$this->assertNotEmpty($e->getMessage());
$this->setExpectedTriggerError(E_USER_ERROR);
}
// For SQLite3, connection will be successful anyway as phpBB driver uses SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE flags
$result = $db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']);
if ($db->get_sql_layer() === 'sqlite3')
{
$this->assertTrue($result);
}
}
}

View File

@@ -404,11 +404,19 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
->will($this->returnValue(true));
// drop tables
$db_tools->expects($this->exactly(2))->method('schema_drop_table')
->withConsecutive(
[$this->isInstanceOf(Schema::class), 'dropped_table_1', true],
[$this->isInstanceOf(Schema::class), 'dropped_table_2', true]
);
$matcher = $this->exactly(2);
$db_tools->expects($matcher)->method('schema_drop_table')
->willReturnCallback(function() use ($matcher) {
$args = func_get_args();
$schema = array_shift($args);
$this->assertInstanceOf(\Doctrine\DBAL\Schema\Schema::class, $schema);
match($matcher->numberOfInvocations())
{
1 => $this->assertEquals($args, ['dropped_table_1', true]),
2 => $this->assertEquals($args, ['dropped_table_2', true]),
};
}
);
$db_tools->perform_schema_changes(array(
'drop_tables' => array(
@@ -432,11 +440,18 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
->will($this->returnValue(true));
// drop columns
$db_tools->expects($this->exactly(2))->method('schema_column_remove')
->withConsecutive(
[$this->isInstanceOf(Schema::class), 'existing_table', 'dropped_column_1', true],
[$this->isInstanceOf(Schema::class), 'existing_table', 'dropped_column_2', true]
);
$matcher = $this->exactly(2);
$db_tools->expects($matcher)->method('schema_column_remove')
->willReturnCallback(function() use ($matcher) {
$args = func_get_args();
$schema = array_shift($args);
$this->assertInstanceOf(\Doctrine\DBAL\Schema\Schema::class, $schema);
match($matcher->numberOfInvocations()) {
1 => $this->assertEquals($args, ['existing_table', 'dropped_column_1', true]),
2 => $this->assertEquals($args, ['existing_table', 'dropped_column_2', true]),
};
}
);
$db_tools->perform_schema_changes(array(
'drop_columns' => array(

View File

@@ -13,6 +13,10 @@
class phpbb_dbal_migrator_tool_config_text_test extends phpbb_database_test_case
{
protected $db;
protected $config_text;
protected $tool;
public function getDataSet()
{
return $this->createXMLDataSet(__DIR__.'/fixtures/migrator_config_text.xml');

View File

@@ -16,6 +16,11 @@ require_once __DIR__ . '/ext/foo/bar/ucp/ucp_test_info.php';
class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
{
protected $db;
protected $cache;
protected $user;
protected $tool;
public function getDataSet()
{
return $this->createXMLDataSet(__DIR__.'/fixtures/migrator_module.xml');
@@ -51,7 +56,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$this->tool = new \phpbb\db\migration\tool\module($this->db, $this->user, $module_manager, 'phpbb_modules');
}
public function exists_data_acp()
public static function exists_data_acp()
{
return array(
// Test the existing category
@@ -184,7 +189,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$this->assertEquals($expected, $this->tool->exists('acp', $parent, $module, $lazy));
}
public function exists_data_ucp()
public static function exists_data_ucp()
{
return array(
// Test the existing category

View File

@@ -22,6 +22,12 @@ class phpbb_dbal_migrator_tool_permission_role_test extends phpbb_database_test_
/** @var \phpbb\db\migration\tool\permission */
protected $tool;
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/** @var \phpbb\cache\service */
protected $cache;
public $group_ids = [
'REGISTERED' => 2,
'GLOBAL_MODERATORS' => 4,
@@ -102,7 +108,7 @@ class phpbb_dbal_migrator_tool_permission_role_test extends phpbb_database_test_
$this->auth_admin = new \auth_admin();
}
public function data_test_new_role_exists()
public static function data_test_new_role_exists()
{
return [
['ROLE_ADMIN_NEW', true],
@@ -119,7 +125,7 @@ class phpbb_dbal_migrator_tool_permission_role_test extends phpbb_database_test_
$this->assertEquals($expected, (bool) $this->tool->role_exists($role_name));
}
public function data_test_permission_assign_new_roles()
public static function data_test_permission_assign_new_roles()
{
return [
[

View File

@@ -16,6 +16,12 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
/** @var \phpbb\auth\auth */
protected $auth;
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/** @var \phpbb\cache\service */
protected $cache;
/** @var \phpbb\db\migration\tool\permission */
protected $tool;
@@ -45,7 +51,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
$this->tool = new \phpbb\db\migration\tool\permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx);
}
public function exists_data()
public static function exists_data()
{
return array(
array(
@@ -170,7 +176,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
$this->assertFalse($this->tool->exists('global_test', true));
}
public function data_test_permission_set()
public static function data_test_permission_set()
{
return array(
array(
@@ -226,7 +232,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
}
}
public function data_test_permission_role_exists()
public static function data_test_permission_role_exists()
{
return array(
array('ROLE_MOD_FULL', true),

View File

@@ -18,7 +18,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
return $this->createXMLDataSet(__DIR__.'/fixtures/three_users.xml');
}
public function return_on_error_select_data()
public static function return_on_error_select_data()
{
return array(
array('phpbb_users', "username_clean = 'bertie'", array(array('username_clean' => 'bertie'))),
@@ -45,7 +45,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $db->sql_fetchrowset($result));
}
public function fetchrow_data()
public static function fetchrow_data()
{
return array(
array('', array(array('username_clean' => 'barfoo'),
@@ -96,7 +96,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function fetchfield_data()
public static function fetchfield_data()
{
return array(
array('', array('barfoo', 'foobar', 'bertie')),
@@ -126,7 +126,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $ary);
}
static public function fetchfield_seek_data()
public static function fetchfield_seek_data()
{
return array(
array(1, 'foobar'),
@@ -152,7 +152,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $field);
}
static public function query_limit_data()
public static function query_limit_data()
{
return array(
array(0, 0, array(array('username_clean' => 'barfoo'),
@@ -193,7 +193,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $ary);
}
public function like_expression_data()
public static function like_expression_data()
{
// * = any_char; # = one_char
return array(
@@ -230,7 +230,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function not_like_expression_data()
public static function not_like_expression_data()
{
// * = any_char; # = one_char
return array(
@@ -290,7 +290,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function in_set_data()
public static function in_set_data()
{
return array(
array('user_id', 3, false, false, array(array('username_clean' => 'bertie'))),
@@ -364,7 +364,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function build_array_data()
public static function build_array_data()
{
return array(
array(array('username_clean' => 'barfoo'), array(array('username_clean' => 'barfoo'))),

View File

@@ -18,7 +18,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
return $this->createXMLDataSet(__DIR__.'/fixtures/config.xml');
}
public function build_array_insert_data()
public static function build_array_insert_data()
{
return array(
array(array(
@@ -167,7 +167,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function update_data()
public static function update_data()
{
return array(
array(