summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/database_test.test
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-12-09 15:30:48 +0000
committerDries Buytaert <dries@buytaert.net>2009-12-09 15:30:48 +0000
commit13dba19e6af207c16235d383e8f1d23d883b6f45 (patch)
treea996d1941401d5097aafec5c4f3448c2191bddab /modules/simpletest/tests/database_test.test
parent3254e88fdef94b82012f0ff5c7f3fd55a4766361 (diff)
downloadbrdo-13dba19e6af207c16235d383e8f1d23d883b6f45.tar.gz
brdo-13dba19e6af207c16235d383e8f1d23d883b6f45.tar.bz2
- Patch #652420 by sun: fixed some problems in the tests.
Diffstat (limited to 'modules/simpletest/tests/database_test.test')
-rw-r--r--modules/simpletest/tests/database_test.test28
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index f217d650d..bcba352d5 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -1883,6 +1883,34 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
}
/**
+ * Test that countQuery properly removes 'all_fields' statements and
+ * ordering clauses.
+ */
+ function testCountQueryRemovals() {
+ $query = db_select('test');
+ $query->fields('test');
+ $query->orderBy('name');
+ $count = $query->countQuery();
+
+ // Check that the 'all_fields' statement is handled properly.
+ $tables = $query->getTables();
+ $this->assertEqual($tables['test']['all_fields'], 1, t('Query correctly sets \'all_fields\' statement.'));
+ $tables = $count->getTables();
+ $this->assertFalse(isset($tables['test']['all_fields']), t('Count query correctly unsets \'all_fields\' statement.'));
+
+ // Check that the ordering clause is handled properly.
+ $orderby = $query->getOrderBy();
+ $this->assertEqual($orderby['name'], 'ASC', t('Query correctly sets ordering clause.'));
+ $orderby = $count->getOrderBy();
+ $this->assertFalse(isset($orderby['name']), t('Count query correctly unsets ordering caluse.'));
+
+ // Make sure that the count query works.
+ $count = $count->execute()->fetchField();
+
+ $this->assertEqual($count, 4, t('Counted the correct number of records.'));
+ }
+
+ /**
* Confirm that we can properly nest conditional clauses.
*/
function testNestedConditions() {