1 database_test.test DatabaseSelectComplexTestCase::testCountQueryFieldRemovals()

Test that countQuery properly removes fields and expressions.


core/modules/simpletest/tests/database_test.test, line 2131
Database tests.


Test more complex select statements.


function testCountQueryFieldRemovals() {
  // countQuery should remove all fields and expressions, so this can be
  // tested by adding a non-existent field and expression: if it ends
  // up in the query, an error will be thrown. If not, it will return the
  // number of records, which in this case happens to be 4 (there are four
  // records in the {test} table).
  $query = db_select('test');
  $query->fields('test', array('fail'));
  $this->assertEqual(4, $query->countQuery()->execute()->fetchField(), 'Count Query removed fields');

  $query = db_select('test');
  $this->assertEqual(4, $query->countQuery()->execute()->fetchField(), 'Count Query removed expressions');