diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index 231355c..f419c40 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -1513,6 +1513,28 @@ class DatabaseSelectTestCase extends DatabaseTestCase {
   }
 
   /**
+   * Test that we can get a count query for a UNION Select query.
+   */
+  function testUnionCount() {
+    $query_1 = db_select('test', 't')
+      ->fields('t', array('name', 'age'))
+      ->condition('age', array(27, 28), 'IN');
+
+    $query_2 = db_select('test', 't')
+      ->fields('t', array('name', 'age'))
+      ->condition('age', 28);
+
+    $query_1->union($query_2, 'ALL');
+    $names = $query_1->execute()->fetchCol();
+
+    $query_3 = $query_1->countQuery();
+    $count = $query_3->execute()->fetchField();
+
+    // Ensure the counts match.
+    $this->assertEqual(count($names), $count, t("The count query's result matched the number of rows in the UNION query."));
+  }
+
+  /**
    * Test that random ordering of queries works.
    *
    * We take the approach of testing the Drupal layer only, rather than trying
