summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2011-01-10 18:04:23 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2011-01-10 18:04:23 +0000
commitfa622be169820e8c1f0dd3b32d2b911ffbd76eb4 (patch)
treec6edeb5ecc8c3ef624a1961015947c64b29ca07f /modules
parentb793fc9eba00cd06de9ce7d3f7cebec96e29fbf9 (diff)
downloadbrdo-fa622be169820e8c1f0dd3b32d2b911ffbd76eb4.tar.gz
brdo-fa622be169820e8c1f0dd3b32d2b911ffbd76eb4.tar.bz2
#1001242 follow-up by bfroehle, Steven Jones: Fix EXISTS tests for SQLite and PostgreSQL.
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/tests/database_test.test17
1 files changed, 11 insertions, 6 deletions
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index 243dbba31..1107f3df4 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -1687,6 +1687,9 @@ class DatabaseSelectSubqueryTestCase extends DatabaseTestCase {
/**
* Test EXISTS subquery conditionals on SELECT statements.
+ *
+ * We essentially select all rows from the {test} table that have matching
+ * rows in the {test_people} table based on the shared name column.
*/
function testExistsSubquerySelect() {
// Put George into {test_people}.
@@ -1703,7 +1706,7 @@ class DatabaseSelectSubqueryTestCase extends DatabaseTestCase {
// Subquery to {test_people}.
$subquery = db_select('test_people', 'tp')
->fields('tp', array('name'))
- ->condition('name', 'George');
+ ->where('tp.name = t.name');
$query->exists($subquery);
$result = $query->execute();
@@ -1714,6 +1717,9 @@ class DatabaseSelectSubqueryTestCase extends DatabaseTestCase {
/**
* Test NOT EXISTS subquery conditionals on SELECT statements.
+ *
+ * We essentially select all rows from the {test} table that don't have
+ * matching rows in the {test_people} table based on the shared name column.
*/
function testNotExistsSubquerySelect() {
// Put George into {test_people}.
@@ -1731,13 +1737,12 @@ class DatabaseSelectSubqueryTestCase extends DatabaseTestCase {
// Subquery to {test_people}.
$subquery = db_select('test_people', 'tp')
->fields('tp', array('name'))
- ->condition('name', 'George');
+ ->where('tp.name = t.name');
$query->notExists($subquery);
- $result = $query->execute();
- // Ensure that we got the right record.
- $record = $result->fetch();
- $this->assertFalse($record, t('NOT EXISTS query returned no results.'));
+ // Ensure that we got the right number of records.
+ $people = $query->execute()->fetchCol();
+ $this->assertEqual(count($people), 3, t('NOT EXISTS query returned the correct results.'));
}
}