From fae059c8e0eed4c0d2581c48169b468833cd1d57 Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Mon, 25 Jun 2007 21:00:37 +0000 Subject: [PATCH] Added failing unit test for count() --- tests/Query/SubqueryTestCase.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Query/SubqueryTestCase.php b/tests/Query/SubqueryTestCase.php index 9f6a112e9..33ea398d0 100644 --- a/tests/Query/SubqueryTestCase.php +++ b/tests/Query/SubqueryTestCase.php @@ -108,5 +108,25 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase $this->assertEqual($q->getSql(), 'SELECT e.id AS e__id, e.name AS e__name, COUNT(DISTINCT a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a__0 LIMIT 5) AND (e.type = 0) GROUP BY e.id ORDER BY a__0'); } + + public function testAggregateFunctionsInOrderByAndHavingWithCount() + { + $q = new Doctrine_Query(); + + $q->select('u.*, COUNT(a.id) num_albums') + ->from('User u') + ->leftJoin('u.Album a') + ->orderby('num_albums desc') + ->groupby('u.id') + ->having('num_albums > 0') + ->limit(5); + + try { + $q->count(); + } catch (Doctrine_Exception $e) { + + $this->fail(); + } + } } ?>