This commit is contained in:
parent
f44cad9c4e
commit
dce54885e4
@ -86,6 +86,7 @@ class Doctrine_Hydrate_TestCase extends Doctrine_UnitTestCase
|
|||||||
$this->pass();
|
$this->pass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
public function testHydrate()
|
public function testHydrate()
|
||||||
{
|
{
|
||||||
$h = new Doctrine_Hydrate_Mock();
|
$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($coll[3]->Phonenumber->count(), 0);
|
||||||
$this->assertEqual(count($this->dbh), $count);
|
$this->assertEqual(count($this->dbh), $count);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
class Doctrine_Hydrate_Mock extends Doctrine_Hydrate2
|
class Doctrine_Hydrate_Mock extends Doctrine_Hydrate2
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testInitData()
|
public function testInitData()
|
||||||
{
|
{
|
||||||
$users = new Doctrine_Collection('User');
|
$users = new Doctrine_Collection('User');
|
||||||
@ -77,7 +77,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
|
|||||||
}
|
}
|
||||||
public function testAggregateValueIsMappedToNewRecordOnEmptyResultSet()
|
public function testAggregateValueIsMappedToNewRecordOnEmptyResultSet()
|
||||||
{
|
{
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->select('COUNT(u.id) count')->from('User u');
|
$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->count(), 1);
|
||||||
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN);
|
$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');
|
$q->select('u.name, COUNT(u.id) count')->from('User u')->groupby('u.name');
|
||||||
|
|
||||||
$users = $q->execute();
|
$users = $q->execute();
|
||||||
|
|
||||||
$this->assertEqual($users->count(), 2);
|
$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[0]->count, 2);
|
||||||
$this->assertEqual($users[1]->count, 2);
|
$this->assertEqual($users[1]->count, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAggregateValueMappingSupportsLeftJoins()
|
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');
|
$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()
|
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');
|
$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');
|
$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();
|
$users = $q->execute();
|
||||||
|
|
||||||
$this->assertEqual($users->count(), 1);
|
$this->assertEqual($users->count(), 2);
|
||||||
}
|
}
|
||||||
public function testAggregateValueMappingSupportsMultipleValues()
|
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');
|
$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()
|
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');
|
$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
|
* @package Doctrine
|
||||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||||
@ -32,94 +32,76 @@
|
|||||||
*/
|
*/
|
||||||
class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
|
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');
|
$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))");
|
$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');
|
$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))");
|
$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');
|
$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))");
|
$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()
|
public function testMultipleLeftJoin()
|
||||||
{
|
{
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber');
|
$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))");
|
$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()
|
public function testMultipleLeftJoin2()
|
||||||
{
|
{
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber');
|
$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))");
|
$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()
|
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');
|
$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))");
|
$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()
|
public function testMultipleInnerJoin2()
|
||||||
{
|
{
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->select('u.name')->from('User u INNER JOIN u.Group, u.Phonenumber');
|
$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))");
|
$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();
|
$users = $q->execute();
|
||||||
|
|
||||||
$this->assertEqual($users->count(), 1);
|
$this->assertEqual($users->count(), 1);
|
||||||
}
|
}
|
||||||
public function testMixingOfJoins()
|
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');
|
$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))");
|
$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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,49 +1,86 @@
|
|||||||
<?php
|
<?php
|
||||||
class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase {
|
/*
|
||||||
|
* $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>.
|
||||||
|
*/
|
||||||
|
|
||||||
public function testAggregateFunctionWithDistinctKeyword() {
|
/**
|
||||||
$q = new Doctrine_Query();
|
* Doctrine_Query_Select_TestCase
|
||||||
|
*
|
||||||
|
* @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_Select_TestCase extends Doctrine_UnitTestCase
|
||||||
|
{
|
||||||
|
public function testAggregateFunctionWithDistinctKeyword()
|
||||||
|
{
|
||||||
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->parseQuery('SELECT COUNT(DISTINCT u.name) FROM User u');
|
$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)');
|
$this->assertEqual($q->getQuery(), 'SELECT COUNT(DISTINCT e.name) AS e__0 FROM entity e WHERE (e.type = 0)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAggregateFunction() {
|
public function testAggregateFunction()
|
||||||
$q = new Doctrine_Query();
|
{
|
||||||
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->parseQuery('SELECT COUNT(u.id) FROM User u');
|
$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)');
|
$this->assertEqual($q->getQuery(), 'SELECT COUNT(e.id) AS e__0 FROM entity e WHERE (e.type = 0)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSelectPartSupportsMultipleAggregateFunctions() {
|
public function testSelectPartSupportsMultipleAggregateFunctions()
|
||||||
$q = new Doctrine_Query();
|
{
|
||||||
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->parseQuery('SELECT MAX(u.id), MIN(u.name) FROM User u');
|
$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)');
|
$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() {
|
public function testMultipleAggregateFunctionsWithMultipleComponents()
|
||||||
$q = new Doctrine_Query();
|
{
|
||||||
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->parseQuery('SELECT MAX(u.id), MIN(u.name), COUNT(p.id) FROM User u, u.Phonenumber p');
|
$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)');
|
$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() {
|
public function testEmptySelectPart()
|
||||||
$q = new Doctrine_Query();
|
{
|
||||||
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$q->select();
|
$q->select(null);
|
||||||
|
|
||||||
$this->fail();
|
$this->fail();
|
||||||
} catch(Doctrine_Query_Exception $e) {
|
} catch(Doctrine_Query_Exception $e) {
|
||||||
$this->pass();
|
$this->pass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function testUnknownAggregateFunction() {
|
public function testUnknownAggregateFunction()
|
||||||
$q = new Doctrine_Query();
|
{
|
||||||
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$q->parseQuery('SELECT UNKNOWN(u.id) FROM User');
|
$q->parseQuery('SELECT UNKNOWN(u.id) FROM User');
|
||||||
@ -52,8 +89,9 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->pass();
|
$this->pass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function testAggregateFunctionValueHydration() {
|
public function testAggregateFunctionValueHydration()
|
||||||
$q = new Doctrine_Query();
|
{
|
||||||
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->parseQuery('SELECT u.id, COUNT(p.id) FROM User u, u.Phonenumber p GROUP BY u.id');
|
$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');
|
$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[3]->Phonenumber[0]->count, 1);
|
||||||
$this->assertEqual($users[4]->Phonenumber[0]->count, 3);
|
$this->assertEqual($users[4]->Phonenumber[0]->count, 3);
|
||||||
}
|
}
|
||||||
public function testMultipleAggregateFunctionValueHydrationWithAliases() {
|
public function testMultipleAggregateFunctionValueHydrationWithAliases()
|
||||||
$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');
|
$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[3]->Phonenumber[0]->max, '111 222 333');
|
||||||
$this->assertEqual($users[4]->Phonenumber[0]->max, '444 555');
|
$this->assertEqual($users[4]->Phonenumber[0]->max, '444 555');
|
||||||
}
|
}
|
||||||
public function testMultipleAggregateFunctionValueHydrationWithAliasesAndCleanRecords() {
|
public function testMultipleAggregateFunctionValueHydrationWithAliasesAndCleanRecords()
|
||||||
|
{
|
||||||
$this->connection->clear();
|
$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');
|
$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();
|
$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[3]->Phonenumber[0]->max, '111 222 333');
|
||||||
$this->assertEqual($users[4]->Phonenumber[0]->max, '444 555');
|
$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)');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -36,8 +36,8 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
public function testSubqueryWithWherePartAndInExpression()
|
public function testSubqueryWithWherePartAndInExpression()
|
||||||
{
|
{
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query2();
|
||||||
$q->from('User')->where("User.id NOT IN (FROM User(id) WHERE User.name = 'zYne')");
|
$q->from('User')->where("User.id NOT IN (SELECT User.id FROM User WHERE User.name = 'zYne')");
|
||||||
|
|
||||||
$this->assertEqual($q->getQuery(),
|
$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)");
|
"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()
|
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)');
|
$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)");
|
$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()
|
public function testSubqueryInSelectPart()
|
||||||
{
|
{
|
||||||
// ticket #307
|
// 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");
|
$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()
|
public function testSubqueryInSelectPart2()
|
||||||
{
|
{
|
||||||
// ticket #307
|
// 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");
|
$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");
|
||||||
|
|
||||||
|
@ -1,4 +1,36 @@
|
|||||||
<?php
|
<?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 {
|
class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
|
||||||
public function prepareData() { }
|
public function prepareData() { }
|
||||||
public function prepareTables() {
|
public function prepareTables() {
|
||||||
@ -13,9 +45,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$user->name = 'someone';
|
$user->name = 'someone';
|
||||||
$user->save();
|
$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();
|
$users = $q->execute();
|
||||||
|
|
||||||
@ -28,9 +60,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$user->name = 'someone.2';
|
$user->name = 'someone.2';
|
||||||
$user->save();
|
$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();
|
$users = $q->execute();
|
||||||
|
|
||||||
@ -39,9 +71,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->assertEqual($users[1]->name, 'someone.2');
|
$this->assertEqual($users[1]->name, 'someone.2');
|
||||||
}
|
}
|
||||||
public function testDirectMultipleParameterSetting2() {
|
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();
|
$users = $q->execute();
|
||||||
|
|
||||||
@ -59,7 +91,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->assertEqual($users[1]->name, 'someone.2');
|
$this->assertEqual($users[1]->name, 'someone.2');
|
||||||
}
|
}
|
||||||
public function testNotInExpression() {
|
public function testNotInExpression() {
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->from('User u')->addWhere('u.id NOT IN (?)', array(1));
|
$q->from('User u')->addWhere('u.id NOT IN (?)', array(1));
|
||||||
$users = $q->execute();
|
$users = $q->execute();
|
||||||
@ -68,7 +100,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->assertEqual($users[0]->name, 'someone.2');
|
$this->assertEqual($users[0]->name, 'someone.2');
|
||||||
}
|
}
|
||||||
public function testExistsExpression() {
|
public function testExistsExpression() {
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$user->name = 'someone with a group';
|
$user->name = 'someone with a group';
|
||||||
@ -88,7 +120,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testNotExistsExpression() {
|
public function testNotExistsExpression() {
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
// find all users which don't have groups
|
// find all users which don't have groups
|
||||||
try {
|
try {
|
||||||
@ -103,9 +135,9 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->assertEqual($users[1]->name, 'someone.2');
|
$this->assertEqual($users[1]->name, 'someone.2');
|
||||||
}
|
}
|
||||||
public function testComponentAliases() {
|
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();
|
$users = $q->execute();
|
||||||
|
|
||||||
$this->assertEqual($users->count(), 2);
|
$this->assertEqual($users->count(), 2);
|
||||||
@ -114,7 +146,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
public function testComponentAliases2() {
|
public function testComponentAliases2() {
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query2();
|
||||||
|
|
||||||
$q->from('User u')->addWhere('u.name = ?', array('someone'));
|
$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');
|
$this->assertEqual($users[0]->name, 'someone');
|
||||||
}
|
}
|
||||||
public function testOperatorWithNoTrailingSpaces() {
|
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();
|
$users = $q->execute();
|
||||||
$this->assertEqual($users->count(), 1);
|
$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)");
|
$this->assertEqual($q->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE e.name = 'someone' AND (e.type = 0)");
|
||||||
}
|
}
|
||||||
public function testOperatorWithNoTrailingSpaces2() {
|
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();
|
$users = $q->execute();
|
||||||
$this->assertEqual($users->count(), 0);
|
$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)");
|
$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() {
|
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();
|
$users = $q->execute();
|
||||||
$this->assertEqual($users->count(), 0);
|
$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)");
|
$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() {
|
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();
|
$users = $q->execute();
|
||||||
$this->assertEqual($users->count(), 0);
|
$this->assertEqual($users->count(), 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user