Commit dce54885 authored by zYne's avatar zYne

--no commit message

--no commit message
parent f44cad9c
......@@ -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
{
......
......@@ -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');
......@@ -88,7 +88,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
}
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');
......@@ -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');
......
......@@ -20,7 +20,7 @@
*/
/**
* Doctrine_Export_Oracle_TestCase
* Doctrine_Query_From_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
......@@ -34,92 +34,74 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
{
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()
{
$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()
{
$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);
}
}
?>
This diff is collapsed.
......@@ -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");
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Query_Subquery_TestCase
* This test case is used for testing DQL WHERE part functionality
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment