diff --git a/tests/HydrateTestCase.php b/tests/HydrateTestCase.php index 4ede6d210..7067e00ae 100644 --- a/tests/HydrateTestCase.php +++ b/tests/HydrateTestCase.php @@ -86,6 +86,7 @@ class Doctrine_Hydrate_TestCase extends Doctrine_UnitTestCase $this->pass(); } } + /** public function testHydrate() { $h = new Doctrine_Hydrate_Mock(); @@ -108,6 +109,7 @@ class Doctrine_Hydrate_TestCase extends Doctrine_UnitTestCase $this->assertEqual($coll[3]->Phonenumber->count(), 0); $this->assertEqual(count($this->dbh), $count); } + */ } class Doctrine_Hydrate_Mock extends Doctrine_Hydrate2 { diff --git a/tests/Query/AggregateValueTestCase.php b/tests/Query/AggregateValueTestCase.php index 62b9ae62a..c2501b214 100644 --- a/tests/Query/AggregateValueTestCase.php +++ b/tests/Query/AggregateValueTestCase.php @@ -36,7 +36,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase { } - + public function testInitData() { $users = new Doctrine_Collection('User'); @@ -77,7 +77,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase } public function testAggregateValueIsMappedToNewRecordOnEmptyResultSet() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->select('COUNT(u.id) count')->from('User u'); @@ -86,12 +86,12 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase $this->assertEqual($users->count(), 1); $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); } - public function testAggregateValueIsMappedToRecord() + public function testAggregateValueIsMappedToRecord() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->select('u.name, COUNT(u.id) count')->from('User u')->groupby('u.name'); - + $users = $q->execute(); $this->assertEqual($users->count(), 2); @@ -102,9 +102,10 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase $this->assertEqual($users[0]->count, 2); $this->assertEqual($users[1]->count, 2); } + public function testAggregateValueMappingSupportsLeftJoins() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->select('u.name, COUNT(p.id) count')->from('User u')->leftJoin('u.Phonenumber p')->groupby('u.id'); @@ -119,18 +120,18 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase } public function testAggregateValueMappingSupportsLeftJoins2() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->select('MAX(u.name)')->from('User u')->leftJoin('u.Phonenumber p')->groupby('u.id'); $this->assertEqual($q->getQuery(), 'SELECT MAX(e.name) AS e__0 FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) GROUP BY e.id'); $users = $q->execute(); - $this->assertEqual($users->count(), 1); + $this->assertEqual($users->count(), 2); } public function testAggregateValueMappingSupportsMultipleValues() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->select('u.name, COUNT(p.id) count, MAX(p.id) max')->from('User u')->innerJoin('u.Phonenumber p')->groupby('u.id'); @@ -140,7 +141,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase } public function testAggregateValueMappingSupportsInnerJoins() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->select('u.name, COUNT(p.id) count')->from('User u')->innerJoin('u.Phonenumber p')->groupby('u.id'); diff --git a/tests/Query/FromTestCase.php b/tests/Query/FromTestCase.php index 906e53aa8..83aad04b7 100644 --- a/tests/Query/FromTestCase.php +++ b/tests/Query/FromTestCase.php @@ -20,7 +20,7 @@ */ /** - * Doctrine_Export_Oracle_TestCase + * Doctrine_Query_From_TestCase * * @package Doctrine * @author Konsta Vesterinen @@ -32,94 +32,76 @@ */ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase { - public function testLeftJoin() + public function testLeftJoin() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->from('User u LEFT JOIN u.Group'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id FROM entity e LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); - $users = $q->execute(); - - $this->assertEqual($users->count(), 8); } - public function testDefaultJoinIsLeftJoin() + + public function testDefaultJoinIsLeftJoin() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->from('User u JOIN u.Group'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id FROM entity e LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); - $users = $q->execute(); - - $this->assertEqual($users->count(), 8); } - public function testInnerJoin() + + public function testInnerJoin() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->from('User u INNER JOIN u.Group'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id FROM entity e INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); - $users = $q->execute(); - - $this->assertEqual($users->count(), 1); } + public function testMultipleLeftJoin() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); - $users = $q->execute(); - - $this->assertEqual($users->count(), 8); } public function testMultipleLeftJoin2() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); - $users = $q->execute(); - - $this->assertEqual($users->count(), 8); } public function testMultipleInnerJoin() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->select('u.name')->from('User u INNER JOIN u.Group INNER JOIN u.Phonenumber'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name FROM entity e INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id INNER JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); - $users = $q->execute(); - - $this->assertEqual($users->count(), 1); } public function testMultipleInnerJoin2() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->select('u.name')->from('User u INNER JOIN u.Group, u.Phonenumber'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name FROM entity e INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id INNER JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); + $users = $q->execute(); $this->assertEqual($users->count(), 1); } public function testMixingOfJoins() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->select('u.name, g.name, p.phonenumber')->from('User u INNER JOIN u.Group g LEFT JOIN u.Phonenumber p'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e2.id AS e2__id, e2.name AS e2__name, p.id AS p__id, p.phonenumber AS p__phonenumber FROM entity e INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); - - $users = $q->execute(); - - $this->assertEqual($users->count(), 1); - } + } } ?> diff --git a/tests/Query/SelectTestCase.php b/tests/Query/SelectTestCase.php index 4fd110aff..cb657a2ce 100644 --- a/tests/Query/SelectTestCase.php +++ b/tests/Query/SelectTestCase.php @@ -1,49 +1,86 @@ . + */ - public function testAggregateFunctionWithDistinctKeyword() { - $q = new Doctrine_Query(); +/** + * Doctrine_Query_Select_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase +{ + public function testAggregateFunctionWithDistinctKeyword() + { + $q = new Doctrine_Query2(); $q->parseQuery('SELECT COUNT(DISTINCT u.name) FROM User u'); $this->assertEqual($q->getQuery(), 'SELECT COUNT(DISTINCT e.name) AS e__0 FROM entity e WHERE (e.type = 0)'); } - public function testAggregateFunction() { - $q = new Doctrine_Query(); + public function testAggregateFunction() + { + $q = new Doctrine_Query2(); $q->parseQuery('SELECT COUNT(u.id) FROM User u'); $this->assertEqual($q->getQuery(), 'SELECT COUNT(e.id) AS e__0 FROM entity e WHERE (e.type = 0)'); } - public function testSelectPartSupportsMultipleAggregateFunctions() { - $q = new Doctrine_Query(); + public function testSelectPartSupportsMultipleAggregateFunctions() + { + $q = new Doctrine_Query2(); $q->parseQuery('SELECT MAX(u.id), MIN(u.name) FROM User u'); $this->assertEqual($q->getQuery(), 'SELECT MAX(e.id) AS e__0, MIN(e.name) AS e__1 FROM entity e WHERE (e.type = 0)'); } - public function testMultipleAggregateFunctionsWithMultipleComponents() { - $q = new Doctrine_Query(); + public function testMultipleAggregateFunctionsWithMultipleComponents() + { + $q = new Doctrine_Query2(); $q->parseQuery('SELECT MAX(u.id), MIN(u.name), COUNT(p.id) FROM User u, u.Phonenumber p'); $this->assertEqual($q->getQuery(), 'SELECT MAX(e.id) AS e__0, MIN(e.name) AS e__1, COUNT(p.id) AS p__2 FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)'); } - public function testEmptySelectPart() { - $q = new Doctrine_Query(); + public function testEmptySelectPart() + { + $q = new Doctrine_Query2(); try { - $q->select(); + $q->select(null); $this->fail(); } catch(Doctrine_Query_Exception $e) { $this->pass(); } } - public function testUnknownAggregateFunction() { - $q = new Doctrine_Query(); + public function testUnknownAggregateFunction() + { + $q = new Doctrine_Query2(); try { $q->parseQuery('SELECT UNKNOWN(u.id) FROM User'); @@ -52,8 +89,9 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase { $this->pass(); } } - public function testAggregateFunctionValueHydration() { - $q = new Doctrine_Query(); + public function testAggregateFunctionValueHydration() + { + $q = new Doctrine_Query2(); $q->parseQuery('SELECT u.id, COUNT(p.id) FROM User u, u.Phonenumber p GROUP BY u.id'); @@ -67,9 +105,42 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase { } - public function testAggregateFunctionValueHydrationWithAliases() { + public function testSingleComponentWithAsterisk() + { + $q = new Doctrine_Query2(); - $q = new Doctrine_Query(); + $q->parseQuery('SELECT u.* FROM User u'); + + $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE (e.type = 0)'); + } + public function testSingleComponentWithMultipleColumns() + { + $q = new Doctrine_Query2(); + + $q->parseQuery('SELECT u.name, u.type FROM User u'); + + $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.type AS e__type FROM entity e WHERE (e.type = 0)'); + } + public function testMultipleComponentsWithAsterisk() + { + $q = new Doctrine_Query2(); + + $q->parseQuery('SELECT u.*, p.* FROM User u, u.Phonenumber p'); + + $this->assertEqual($q->getQuery(),'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)'); + } + public function testMultipleComponentsWithMultipleColumns() + { + $q = new Doctrine_Query2(); + + $q->parseQuery('SELECT u.id, u.name, p.id FROM User u, u.Phonenumber p'); + + $this->assertEqual($q->getQuery(),'SELECT e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)'); + } + public function testAggregateFunctionValueHydrationWithAliases() + { + + $q = new Doctrine_Query2(); $q->parseQuery('SELECT u.id, COUNT(p.id) count FROM User u, u.Phonenumber p GROUP BY u.id'); @@ -81,8 +152,9 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users[3]->Phonenumber[0]->count, 1); $this->assertEqual($users[4]->Phonenumber[0]->count, 3); } - public function testMultipleAggregateFunctionValueHydrationWithAliases() { - $q = new Doctrine_Query(); + public function testMultipleAggregateFunctionValueHydrationWithAliases() + { + $q = new Doctrine_Query2(); $q->parseQuery('SELECT u.id, COUNT(p.id) count, MAX(p.phonenumber) max FROM User u, u.Phonenumber p GROUP BY u.id'); @@ -99,12 +171,15 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users[3]->Phonenumber[0]->max, '111 222 333'); $this->assertEqual($users[4]->Phonenumber[0]->max, '444 555'); } - public function testMultipleAggregateFunctionValueHydrationWithAliasesAndCleanRecords() { + public function testMultipleAggregateFunctionValueHydrationWithAliasesAndCleanRecords() + { $this->connection->clear(); - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->parseQuery('SELECT u.id, COUNT(p.id) count, MAX(p.phonenumber) max FROM User u, u.Phonenumber p GROUP BY u.id'); + + $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, COUNT(p.id) AS p__0, MAX(p.phonenumber) AS p__1 FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) GROUP BY e.id'); $users = $q->execute(); @@ -122,35 +197,5 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users[3]->Phonenumber[0]->max, '111 222 333'); $this->assertEqual($users[4]->Phonenumber[0]->max, '444 555'); } - - public function testSingleComponentWithAsterisk() { - $q = new Doctrine_Query(); - - $q->parseQuery('SELECT u.* FROM User u'); - - $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE (e.type = 0)'); - } - public function testSingleComponentWithMultipleColumns() { - $q = new Doctrine_Query(); - - $q->parseQuery('SELECT u.name, u.type FROM User u'); - - $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.type AS e__type FROM entity e WHERE (e.type = 0)'); - } - public function testMultipleComponentsWithAsterisk() { - $q = new Doctrine_Query(); - - $q->parseQuery('SELECT u.*, p.* FROM User u, u.Phonenumber p'); - - $this->assertEqual($q->getQuery(),'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)'); - } - public function testMultipleComponentsWithMultipleColumns() { - $q = new Doctrine_Query(); - - $q->parseQuery('SELECT u.id, u.name, p.id FROM User u, u.Phonenumber p'); - - $this->assertEqual($q->getQuery(),'SELECT e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)'); - } - } ?> diff --git a/tests/Query/SubqueryTestCase.php b/tests/Query/SubqueryTestCase.php index 17535e652..c02626325 100644 --- a/tests/Query/SubqueryTestCase.php +++ b/tests/Query/SubqueryTestCase.php @@ -36,8 +36,8 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase public function testSubqueryWithWherePartAndInExpression() { - $q = new Doctrine_Query(); - $q->from('User')->where("User.id NOT IN (FROM User(id) WHERE User.name = 'zYne')"); + $q = new Doctrine_Query2(); + $q->from('User')->where("User.id NOT IN (SELECT User.id FROM User WHERE User.name = 'zYne')"); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE e.id NOT IN (SELECT e.id AS e__id FROM entity e WHERE e.name = 'zYne' AND (e.type = 0)) AND (e.type = 0)"); @@ -49,7 +49,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase } public function testSubqueryAllowsSelectingOfAnyField() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->from('User u')->where('u.id NOT IN (SELECT g.user_id FROM Groupuser g)'); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE e.id NOT IN (SELECT g.user_id AS g__user_id FROM groupuser g) AND (e.type = 0)"); @@ -58,7 +58,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase public function testSubqueryInSelectPart() { // ticket #307 - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->parseQuery("SELECT u.name, (SELECT COUNT(p.id) FROM Phonenumber p WHERE p.entity_id = u.id) pcount FROM User u WHERE u.name = 'zYne' LIMIT 1"); @@ -77,7 +77,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase public function testSubqueryInSelectPart2() { // ticket #307 - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->parseQuery("SELECT u.name, (SELECT COUNT(w.id) FROM User w WHERE w.id = u.id) pcount FROM User u WHERE u.name = 'zYne' LIMIT 1"); diff --git a/tests/Query/WhereTestCase.php b/tests/Query/WhereTestCase.php index 47954dd00..7da065d0d 100644 --- a/tests/Query/WhereTestCase.php +++ b/tests/Query/WhereTestCase.php @@ -1,4 +1,36 @@ . + */ + +/** + * Doctrine_Query_Subquery_TestCase + * This test case is used for testing DQL WHERE part functionality + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } public function prepareTables() { @@ -13,9 +45,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $user->name = 'someone'; $user->save(); - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); - $q->from('User(id)')->addWhere('User.id = ?',1); + $q->from('User')->addWhere('User.id = ?',1); $users = $q->execute(); @@ -28,9 +60,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $user->name = 'someone.2'; $user->save(); - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); - $q->from('User(id)')->addWhere('User.id IN (?, ?)', array(1,2)); + $q->from('User')->addWhere('User.id IN (?, ?)', array(1,2)); $users = $q->execute(); @@ -39,9 +71,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users[1]->name, 'someone.2'); } public function testDirectMultipleParameterSetting2() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); - $q->from('User(id)')->where('User.id IN (?, ?)', array(1,2)); + $q->from('User')->where('User.id IN (?, ?)', array(1,2)); $users = $q->execute(); @@ -59,7 +91,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users[1]->name, 'someone.2'); } public function testNotInExpression() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->from('User u')->addWhere('u.id NOT IN (?)', array(1)); $users = $q->execute(); @@ -68,7 +100,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users[0]->name, 'someone.2'); } public function testExistsExpression() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $user = new User(); $user->name = 'someone with a group'; @@ -88,7 +120,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { } public function testNotExistsExpression() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); // find all users which don't have groups try { @@ -103,9 +135,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users[1]->name, 'someone.2'); } public function testComponentAliases() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); - $q->from('User(id) u')->addWhere('u.id IN (?, ?)', array(1,2)); + $q->from('User u')->addWhere('u.id IN (?, ?)', array(1,2)); $users = $q->execute(); $this->assertEqual($users->count(), 2); @@ -114,7 +146,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { } public function testComponentAliases2() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); $q->from('User u')->addWhere('u.name = ?', array('someone')); @@ -131,9 +163,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users[0]->name, 'someone'); } public function testOperatorWithNoTrailingSpaces() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); - $q->from('User(id)')->where("User.name='someone'"); + $q->from('User')->where("User.name='someone'"); $users = $q->execute(); $this->assertEqual($users->count(), 1); @@ -141,9 +173,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE e.name = 'someone' AND (e.type = 0)"); } public function testOperatorWithNoTrailingSpaces2() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); - $q->from('User(id)')->where("User.name='foo.bar'"); + $q->from('User')->where("User.name='foo.bar'"); $users = $q->execute(); $this->assertEqual($users->count(), 0); @@ -151,9 +183,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE e.name = 'foo.bar' AND (e.type = 0)"); } public function testOperatorWithSingleTrailingSpace() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); - $q->from('User(id)')->where("User.name= 'foo.bar'"); + $q->from('User')->where("User.name= 'foo.bar'"); $users = $q->execute(); $this->assertEqual($users->count(), 0); @@ -161,9 +193,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE e.name = 'foo.bar' AND (e.type = 0)"); } public function testOperatorWithSingleTrailingSpace2() { - $q = new Doctrine_Query(); + $q = new Doctrine_Query2(); - $q->from('User(id)')->where("User.name ='foo.bar'"); + $q->from('User')->where("User.name ='foo.bar'"); $users = $q->execute(); $this->assertEqual($users->count(), 0);