summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-11-08 04:45:36 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-11-08 04:45:36 +0000
commit1632855a9f72a01edf9e8fea44b734cdbb0086a7 (patch)
treef2d724a56d162088fd5a82eed080513c97df2d08 /modules
parent6159c302e13aac5a6a1152064fda236edd9f04d0 (diff)
downloadbrdo-1632855a9f72a01edf9e8fea44b734cdbb0086a7.tar.gz
brdo-1632855a9f72a01edf9e8fea44b734cdbb0086a7.tar.bz2
#325895 by chx and hswong3i: Fix queryTemporary and add test case.
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/tests/database_test.module24
-rw-r--r--modules/simpletest/tests/database_test.test33
2 files changed, 57 insertions, 0 deletions
diff --git a/modules/simpletest/tests/database_test.module b/modules/simpletest/tests/database_test.module
index 48239fcbf..067e684ca 100644
--- a/modules/simpletest/tests/database_test.module
+++ b/modules/simpletest/tests/database_test.module
@@ -35,3 +35,27 @@ function database_test_query_alter(SelectQuery $query) {
$expressions['double_age']['expression'] = 'age*3';
}
}
+
+/**
+ * Implementation of hook_menu().
+ */
+function database_test_menu() {
+ $items['database_test_db_query_temporary'] = array(
+ 'access callback' => TRUE,
+ 'page callback' => 'database_test_db_query_temporary',
+ );
+ return $items;
+}
+
+/**
+ * Run a db_query_temporary and print the number of rows in the resulting table.
+ *
+ * We need to test that the table created is temporary, so we run it here, in a
+ * separate menu callback request; After this request is done, the temporary
+ * table should automatically dropped.
+ */
+function database_test_db_query_temporary() {
+ db_query_temporary('SELECT status FROM {system}', array(), 'temporary');
+ print db_query('SELECT COUNT(*) FROM temporary')->fetchField();
+ exit;
+}
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index fa17db442..752b772f8 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -1884,3 +1884,36 @@ class DatabaseLoggingTestCase extends DatabaseTestCase {
}
}
}
+
+/**
+ * Temporary query tests.
+ */
+class DatabaseTemporaryQueryTestCase extends DrupalWebTestCase {
+
+ /**
+ * Define metadata for this test subclass.
+ */
+ function getInfo() {
+ return array(
+ 'name' => t('Temporary query test'),
+ 'description' => t('Test the temporary query functionality.'),
+ 'group' => t('Database'),
+ );
+ }
+
+ /**
+ * Implementation of setUp().
+ */
+ function setUp() {
+ parent::setUp('database_test');
+ }
+
+ /**
+ * 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->_content, 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.'));
+ }
+}