From 868b5350f70faefeef886fe4ed698f03b86cce86 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 6 Jul 2025 09:00:39 +0700 Subject: [PATCH] [ticket/17524] Fix tests PHPBB-17524 --- tests/dbal/migrator_test.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index fee4cd6699..b6541b8a11 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -57,11 +57,12 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case parent::setUp(); + $this->table_prefix = $table_prefix; $this->db = $this->new_dbal(); $this->doctrine_db = $this->new_doctrine_dbal(); $factory = new \phpbb\db\tools\factory(); $this->db_tools = $factory->get($this->doctrine_db); - $this->db_tools->set_table_prefix($table_prefix); + $this->db_tools->set_table_prefix($this->table_prefix); $this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache, 'phpbb_config'); @@ -412,21 +413,24 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->assertTrue($this->db_tools->sql_column_exists('phpbb_config', 'test_column1')); $this->assertTrue($this->db_tools->sql_table_exists('phpbb_foobar')); + $short_table_name = \phpbb\db\doctrine\table_helper::generate_shortname('foobar'); $index_data_row = $this->db_tools->sql_get_table_index_data('phpbb_foobar'); $this->assertEquals(4, count($index_data_row)); - $this->assertTrue(isset($index_data_row['i_simple'])); - $this->assertTrue(isset($index_data_row['i_uniq'])); - $this->assertTrue(isset($index_data_row['i_auth'])); + $this->assertTrue(isset($index_data_row[$short_table_name . '_i_simple'])); + $this->assertTrue(isset($index_data_row[$short_table_name . '_i_uniq'])); + $this->assertTrue(isset($index_data_row[$short_table_name . '_i_auth'])); $is_mysql = $this->db->get_sql_layer() === 'mysqli'; // Key 'lengths' option only applies to MySQL indexes + // MSSQL primary index key has 'clustered' flag, 'nonclustered' otherwise // See https://learn.microsoft.com/en-us/sql/relational-databases/indexes/clustered-and-nonclustered-indexes-described?view=sql-server-ver17#indexes-and-constraints $is_mssql = in_array($this->db->get_sql_layer(), ['mssqlnative', 'mssql_odbc']); + foreach ($index_data_row as $index_name => $index_data) { switch ($index_name) { - case 'i_simple': + case $short_table_name . '_i_simple': $this->assertEquals(['user_id', 'endpoint'], $index_data['columns']); $this->assertEquals($is_mssql ? ['nonclustered'] : [], $index_data['flags']); $this->assertFalse($index_data['is_primary']); @@ -436,7 +440,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->assertEmpty($index_data['options']['lengths'][0]); $this->assertEquals($is_mysql ? 191 : null, $index_data['options']['lengths'][1]); break; - case 'i_uniq': + case $short_table_name . '_i_uniq': $this->assertEquals(['expiration_time', 'p256dh'], $index_data['columns']); $this->assertEquals($is_mssql ? ['nonclustered'] : [], $index_data['flags']); $this->assertFalse($index_data['is_primary']); @@ -446,7 +450,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->assertEmpty($index_data['options']['lengths'][0]); $this->assertEquals($is_mysql ? 100 : null, $index_data['options']['lengths'][1]); break; - case 'i_auth': + case $short_table_name . '_i_auth': $this->assertEquals(['auth'], $index_data['columns']); $this->assertEquals($is_mssql ? ['nonclustered'] : [], $index_data['flags']); $this->assertFalse($index_data['is_primary']);