diff options
author | Marc Alexander <admin@m-a-styles.de> | 2017-12-25 18:49:31 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2018-01-01 18:55:12 +0100 |
commit | 400fc0f73d03010d3bf28d2b1db5d789dc085334 (patch) | |
tree | bb12ab982bbcbb232f62023592f892047c5886a7 /tests/test_framework/phpbb_database_test_case.php | |
parent | f4381a20d4ec6201a00cd618c24fd29b67f77965 (diff) | |
download | forums-400fc0f73d03010d3bf28d2b1db5d789dc085334.tar forums-400fc0f73d03010d3bf28d2b1db5d789dc085334.tar.gz forums-400fc0f73d03010d3bf28d2b1db5d789dc085334.tar.bz2 forums-400fc0f73d03010d3bf28d2b1db5d789dc085334.tar.xz forums-400fc0f73d03010d3bf28d2b1db5d789dc085334.zip |
[ticket/15055] Only drop dependent PK indexes and fix more tests for mssql
PHPBB3-15055
Diffstat (limited to 'tests/test_framework/phpbb_database_test_case.php')
-rw-r--r-- | tests/test_framework/phpbb_database_test_case.php | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 670d39ed69..bbcb8d9a48 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -151,6 +151,11 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $db = $this->new_dbal(); foreach ($this->fixture_xml_data as $key => $value) { + /** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */ + $tableMetaData = $value->getTableMetaData(); + $columns = $tableMetaData->getColumns(); + $primaryKeys = $tableMetaData->getPrimaryKeys(); + $sql = "SELECT COLUMN_NAME AS identity_column FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMNPROPERTY(object_id(TABLE_SCHEMA + '.' + TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1 @@ -159,8 +164,15 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $result = $db->sql_query($sql); $identity_columns = $db->sql_fetchrowset($result); $has_default_identity = false; + $add_primary_keys = false; foreach ($identity_columns as $column) { + if (in_array($column['identity_column'], $columns) && !in_array($column['identity_column'], $primaryKeys)) + { + $primaryKeys[] = $column['identity_column']; + $add_primary_keys = true; + } + if ($column['identity_column'] === 'mssqlindex') { $has_default_identity = true; @@ -168,18 +180,22 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test } } - if ($has_default_identity) + if ($has_default_identity || $add_primary_keys) { - /** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */ - $tableMetaData = $value->getTableMetaData(); - $columns = $tableMetaData->getColumns(); - $columns[] = 'mssqlindex'; - $newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $tableMetaData->getPrimaryKeys()); + if ($has_default_identity) + { + $columns[] = 'mssqlindex'; + } + + $newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $primaryKeys); $newTable = new PHPUnit_Extensions_Database_DataSet_DefaultTable($newMetaData); for ($i = 0; $i < $value->getRowCount(); $i++) { $dataRow = $value->getRow($i); - $dataRow['mssqlindex'] = $i + 1; + if ($has_default_identity) + { + $dataRow['mssqlindex'] = $i + 1; + } $newTable->addRow($dataRow); } $newXmlData->addTable($newTable); |