summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/database_test.test
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-01-11 10:57:20 +0000
committerDries Buytaert <dries@buytaert.net>2009-01-11 10:57:20 +0000
commitf80c6184276793e60cd67ef0bad39c2c1914e10e (patch)
tree1d2d678aa64b8d080941cfe8b4e2dcec6c79747d /modules/simpletest/tests/database_test.test
parent08f263fb23b2f6a59085dcf39ca8647982c49446 (diff)
downloadbrdo-f80c6184276793e60cd67ef0bad39c2c1914e10e.tar.gz
brdo-f80c6184276793e60cd67ef0bad39c2c1914e10e.tar.bz2
- Patch #349500 by Damien Tournoud et al: made db_query_temporary() generate its own temporary table names.
Diffstat (limited to 'modules/simpletest/tests/database_test.test')
-rw-r--r--modules/simpletest/tests/database_test.test26
1 files changed, 23 insertions, 3 deletions
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index 5df638346..8451f83f1 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -1934,12 +1934,32 @@ class DatabaseTemporaryQueryTestCase extends DrupalWebTestCase {
}
/**
+ * Return the number of rows of a table.
+ */
+ function countTableRows($table_name) {
+ return db_select($table_name)->countQuery()->execute()->fetchField();
+ }
+
+ /**
* Confirm that temporary tables work and are limited to one request.
*/
function testTemporaryQuery() {
- $this->drupalGet('database_test_db_query_temporary');
- $this->assertEqual(db_query('SELECT COUNT(*) FROM {system}')->fetchField(), $this->drupalGetContent(), t('The temporary table exists and contains the correct amount of rows.'));
- $this->assertFalse(db_table_exists('temporary'), t('The temporary table is, indeed, temporary.'));
+ $this->drupalGet('database_test/db_query_temporary');
+ $data = json_decode($this->drupalGetContent());
+ if ($data) {
+ $this->assertEqual($this->countTableRows("system"), $data->row_count, t('The temporary table contains the correct amount of rows.'));
+ $this->assertFalse(db_table_exists($data->table_name), t('The temporary table is, indeed, temporary.'));
+ }
+ else {
+ $this->fail(t("The creation of the temporary table failed."));
+ }
+
+ // Now try to run two db_query_temporary() in the same request.
+ $table_name_system = db_query_temporary('SELECT status FROM {system}', array());
+ $table_name_users = db_query_temporary('SELECT uid FROM {users}', array());
+
+ $this->assertEqual($this->countTableRows($table_name_system), $this->countTableRows("system"), t('A temporary table was created successfully in this request.'));
+ $this->assertEqual($this->countTableRows($table_name_users), $this->countTableRows("users"), t('A second temporary table was created successfully in this request.'));
}
}