From c6e2086798005a3f4024ef3493f7dcf26575fa8c Mon Sep 17 00:00:00 2001 From: romanb Date: Fri, 11 Jan 2008 14:06:19 +0000 Subject: [PATCH] more small refactorings of the new joincondition tests. --- tests/Query/JoinCondition2TestCase.php | 68 ++------------------------ 1 file changed, 4 insertions(+), 64 deletions(-) diff --git a/tests/Query/JoinCondition2TestCase.php b/tests/Query/JoinCondition2TestCase.php index 10dbbbf69..ca6367d07 100755 --- a/tests/Query/JoinCondition2TestCase.php +++ b/tests/Query/JoinCondition2TestCase.php @@ -60,45 +60,15 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase $zYne->save(); } - - public function testJoinConditionsRawLeftJoins() - { - $q = Doctrine_Query::create(); - - $q->select('u.id, g.id')->from('User u')->leftJoin('u.Group g WITH g.name = ?', 'Developers')->where('u.name = ?', 'zYne'); - - $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id FROM entity e LEFT JOIN groupuser g" - . " ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id AND e2.name = ?" - . " WHERE e.name = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); - - $rs = $q->execute(); - - // Should only find zYne - $this->assertEqual($rs->count(), 1); - - // Grab the number of runned queries - $queryCount = $this->connection->count(); - - // Only one Group fetched for zYne - $this->assertEqual($rs[0]->Group->count(), 1); - - // Check if it executed any other query - $bug = ($this->connection->count() - $queryCount); - - // Should return 0 (no more queries executed) - $this->assertEqual($bug, 0); - } - - public function testJoinConditionsArgumentsLeftJoins() { $q = new Doctrine_Query($this->connection); - $q->select('u.id, g.id')->from('User u')->leftJoin('u.Group g WITH g.id = ?', 12)->where('u.id = ?', 4); + $q->select('u.id, g.id')->from('User u')->leftJoin('u.Group g WITH g.name = ?', 'Developers')->where('u.name = ?', 'zYne'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id FROM entity e" . " LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id" - . " AND e2.id = ? WHERE e.id = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); + . " AND e2.name = ? WHERE e.name = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); $rs = $q->execute(); @@ -118,45 +88,15 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase $this->assertEqual($bug, 0); } - - public function testJoinConditionsRawInnerJoins() - { - $q = new Doctrine_Query($this->connection); - - $q->select('u.id, g.id')->from('User u')->innerJoin('u.Group g WITH g.id = 12')->where('u.id = 4'); - - $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id FROM entity e" - . " INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id" - . " AND e2.id = 12 WHERE e.id = 4 AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); - - $rs = $q->execute(); - - // Should only find zYne - $this->assertEqual($rs->count(), 1); - - // Grab the number of runned queries - $queryCount = $this->connection->count(); - - // Only one Group fetched for zYne - $this->assertEqual($rs[0]->Group->count(), 1); - - // Check if it executed any other query - $bug = ($this->connection->count() - $queryCount); - - // Should return 0 (no more queries executed) - $this->assertEqual($bug, 0); - } - - public function testJoinCondifitionsArgumentsInnerJoins() { $q = new Doctrine_Query($this->connection); - $q->select('u.id, g.id')->from('User u')->innerJoin('u.Group g WITH g.id = ?', 12)->where('u.id = ?', 4); + $q->select('u.id, g.id')->from('User u')->innerJoin('u.Group g WITH g.name = ?', 'Developers')->where('u.name = ?', 'zYne'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id FROM entity e" . " INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id" - . " AND e2.id = ? WHERE e.id = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); + . " AND e2.name = ? WHERE e.name = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); $rs = $q->execute();