diff options
Diffstat (limited to 'tests')
11 files changed, 55 insertions, 9 deletions
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index f78cebdec7..dbe2c2909a 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -462,7 +462,10 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case // 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); + if (strpos($this->tools->sql_layer, 'mssql') === false) + { + $this->setExpectedTriggerError(E_USER_ERROR); + } $this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp')); } } diff --git a/tests/functions/fixtures/validate_username.xml b/tests/functions/fixtures/validate_username.xml index 1b85a2f06d..add8f76553 100644 --- a/tests/functions/fixtures/validate_username.xml +++ b/tests/functions/fixtures/validate_username.xml @@ -1,9 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <dataset> <table name="phpbb_groups"> + <column>group_id</column> <column>group_name</column> <column>group_desc</column> <row> + <value>10</value> <value>foobar_group</value> <value>test123</value> </row> diff --git a/tests/functions_user/fixtures/delete_user.xml b/tests/functions_user/fixtures/delete_user.xml index 56014b35d1..8de2659722 100644 --- a/tests/functions_user/fixtures/delete_user.xml +++ b/tests/functions_user/fixtures/delete_user.xml @@ -515,35 +515,44 @@ </table> <table name="phpbb_privmsgs_folder"> <column>user_id</column> + <column>folder_id</column> <row> <value>2</value> + <value>1</value> </row> <row> <value>3</value> + <value>2</value> </row> </table> <table name="phpbb_privmsgs_rules"> <column>user_id</column> <column>rule_string</column> + <column>rule_id</column> <row> <value>2</value> <value></value> + <value>1</value> </row> <row> <value>3</value> <value></value> + <value>2</value> </row> </table> <table name="phpbb_drafts"> <column>user_id</column> <column>draft_message</column> + <column>draft_id</column> <row> <value>2</value> <value></value> + <value>1</value> </row> <row> <value>3</value> <value></value> + <value>2</value> </row> </table> </dataset> diff --git a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml index 7f069abc59..db1cef2ef6 100644 --- a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml +++ b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml @@ -29,6 +29,7 @@ </row> </table> <table name="phpbb_notifications"> + <column>notification_id</column> <column>notification_type_id</column> <column>user_id</column> <column>item_id</column> @@ -37,6 +38,7 @@ <column>notification_data</column> <row> <value>1</value> + <value>1</value> <value>5</value> <value>1</value> <value>1</value> diff --git a/tests/notification/fixtures/submit_post_notification.type.post.xml b/tests/notification/fixtures/submit_post_notification.type.post.xml index a4bf9d3ee4..920b271525 100644 --- a/tests/notification/fixtures/submit_post_notification.type.post.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post.xml @@ -21,6 +21,7 @@ </row> </table> <table name="phpbb_notifications"> + <column>notification_id</column> <column>notification_type_id</column> <column>user_id</column> <column>item_id</column> @@ -29,6 +30,7 @@ <column>notification_data</column> <row> <value>1</value> + <value>1</value> <value>5</value> <value>1</value> <value>1</value> @@ -36,6 +38,7 @@ <value></value> </row> <row> + <value>2</value> <value>1</value> <value>8</value> <value>1</value> diff --git a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml index 0a955c48d2..12e73b0ff2 100644 --- a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <dataset> <table name="phpbb_notifications"> + <column>notification_id</column> <column>notification_type_id</column> <column>user_id</column> <column>item_id</column> @@ -9,6 +10,7 @@ <column>notification_data</column> <row> <value>1</value> + <value>1</value> <value>6</value> <value>1</value> <value>1</value> diff --git a/tests/notification/fixtures/submit_post_notification.type.quote.xml b/tests/notification/fixtures/submit_post_notification.type.quote.xml index c66830fbf5..9f4ba91475 100644 --- a/tests/notification/fixtures/submit_post_notification.type.quote.xml +++ b/tests/notification/fixtures/submit_post_notification.type.quote.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <dataset> <table name="phpbb_notifications"> + <column>notification_id</column> <column>notification_type_id</column> <column>user_id</column> <column>item_id</column> @@ -9,6 +10,7 @@ <column>notification_data</column> <row> <value>1</value> + <value>1</value> <value>5</value> <value>1</value> <value>1</value> diff --git a/tests/notification/fixtures/submit_post_notification.type.topic.xml b/tests/notification/fixtures/submit_post_notification.type.topic.xml index e0f6583f48..1f96ed2ee7 100644 --- a/tests/notification/fixtures/submit_post_notification.type.topic.xml +++ b/tests/notification/fixtures/submit_post_notification.type.topic.xml @@ -21,6 +21,7 @@ </row> </table> <table name="phpbb_notifications"> + <column>notification_id</column> <column>notification_type_id</column> <column>user_id</column> <column>item_id</column> @@ -29,6 +30,7 @@ <column>notification_data</column> <row> <value>1</value> + <value>1</value> <value>8</value> <value>1</value> <value>1</value> diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index ec42aa193c..6bbabfc602 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -108,7 +108,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base $types = array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test'); foreach ($types as $id => $type) { - $this->db->sql_query('INSERT INTO phpbb_notification_types ' . + $this->getConnection()->createQueryTable('insertNotification', 'INSERT INTO phpbb_notification_types ' . $this->db->sql_build_array('INSERT', array( 'notification_type_id' => ($id + 1), 'notification_type_name' => $type, diff --git a/tests/search/fixtures/posts.xml b/tests/search/fixtures/posts.xml index 16232b8f39..4916cd188b 100644 --- a/tests/search/fixtures/posts.xml +++ b/tests/search/fixtures/posts.xml @@ -1,25 +1,30 @@ <?xml version="1.0" encoding="UTF-8" ?> <dataset> <table name="phpbb_posts"> + <column>post_id</column> <column>post_username</column> <column>post_subject</column> <column>post_text</column> <row> + <value>1</value> <value>foo</value> <value>foo</value> <value>foo</value> </row> <row> + <value>2</value> <value>bar</value> <value>bar</value> <value>bar</value> </row> <row> + <value>3</value> <value>commonword</value> <value>commonword</value> <value>commonword</value> </row> <row> + <value>4</value> <value>baaz</value> <value>baaz</value> <value>baaz</value> 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); |