aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal
diff options
context:
space:
mode:
authorlavigor <lavigor@users.noreply.github.com>2017-07-06 02:37:35 +0300
committerlavigor <lavigor@users.noreply.github.com>2017-07-06 02:37:35 +0300
commit24bde10028a1a7d8d479e2a381bec047485b4273 (patch)
treee26605d35b8b05251cef666c9dfdd865a5323f46 /tests/dbal
parentb7ce395fbe6e2087a400487cb2431dc9ea66b8a9 (diff)
downloadforums-24bde10028a1a7d8d479e2a381bec047485b4273.tar
forums-24bde10028a1a7d8d479e2a381bec047485b4273.tar.gz
forums-24bde10028a1a7d8d479e2a381bec047485b4273.tar.bz2
forums-24bde10028a1a7d8d479e2a381bec047485b4273.tar.xz
forums-24bde10028a1a7d8d479e2a381bec047485b4273.zip
[ticket/15259] Fatal error on SQLite/Oracle database update
Add a test. PHPBB3-15259
Diffstat (limited to 'tests/dbal')
-rw-r--r--tests/dbal/db_tools_test.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index b884b4ab95..f9243e7266 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -421,4 +421,41 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2')));
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));
}
+
+ public function test_create_index_with_long_name()
+ {
+ // This constant is being used for checking table prefix.
+ $table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config)
+
+ if (strlen($table_prefix) > 20)
+ {
+ $this->markTestIncomplete('The table prefix length is too long for proper testing of index shortening function.');
+ }
+
+ $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));
+ $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);
+ $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);
+ $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'));
+ }
}