diff options
author | Marc Alexander <admin@m-a-styles.de> | 2017-12-31 14:00:36 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2018-01-01 18:57:50 +0100 |
commit | ee8b72d733a3e096f35ec65a7eaf3c63a237cb4b (patch) | |
tree | 92bea6ae93a3f3d9c90523256c80b07c496a903e /tests/dbal | |
parent | [ticket/15055] Run phantomjs for UI tests (diff) | |
download | phpbb-ee8b72d733a3e096f35ec65a7eaf3c63a237cb4b.tar.gz phpbb-ee8b72d733a3e096f35ec65a7eaf3c63a237cb4b.tar.bz2 phpbb-ee8b72d733a3e096f35ec65a7eaf3c63a237cb4b.zip |
[ticket/15055] Properly support index length check on mssql
PHPBB3-15055
Diffstat (limited to 'tests/dbal')
-rw-r--r-- | tests/dbal/db_tools_test.php | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 72a3718662..0365463a48 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -439,29 +439,39 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case $this->markTestIncomplete('The table prefix length is too long for proper testing of index shortening function.'); } + $max_index_length = 30; + + if ($this->tools instanceof \phpbb\db\tools\mssql) + { + $max_length_method = new ReflectionMethod('\phpbb\db\tools\mssql', 'get_max_index_name_length'); + $max_length_method->setAccessible(true); + $max_index_length = $max_length_method->invoke($this->tools); + } + $table_suffix = str_repeat('a', 25 - strlen($table_prefix)); $table_name = $table_prefix . $table_suffix; $this->tools->sql_create_table($table_name, $this->table_data); - // Index name and table suffix and table prefix have > 30 chars in total. - // Index name and table suffix have <= 30 chars in total. - $long_index_name = str_repeat('i', 30 - strlen($table_suffix)); + // Index name and table suffix and table prefix have > maximum index length chars in total. + // Index name and table suffix have <= maximum index length chars in total. + $long_index_name = str_repeat('i', $max_index_length - strlen($table_suffix)); $this->assertFalse($this->tools->sql_index_exists($table_name, $long_index_name)); $this->assertTrue($this->tools->sql_create_index($table_name, $long_index_name, array('c_timestamp'))); $this->assertTrue($this->tools->sql_index_exists($table_name, $long_index_name)); - // Index name and table suffix have > 30 chars in total. - $very_long_index_name = str_repeat('i', 30); + // Index name and table suffix have > maximum index length chars in total. + $very_long_index_name = str_repeat('i', $max_index_length); $this->assertFalse($this->tools->sql_index_exists($table_name, $very_long_index_name)); $this->assertTrue($this->tools->sql_create_index($table_name, $very_long_index_name, array('c_timestamp'))); $this->assertTrue($this->tools->sql_index_exists($table_name, $very_long_index_name)); $this->tools->sql_table_drop($table_name); - // Index name has > 30 chars - that should not be possible. - $too_long_index_name = str_repeat('i', 31); + // Index name has > maximum index length chars - that should not be possible. + $too_long_index_name = str_repeat('i', $max_index_length + 1); $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', $too_long_index_name)); + $this->setExpectedTriggerError(E_USER_ERROR); $this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp')); } } |