Commit 68147808 authored by jwage's avatar jwage

[2.0] Cleaning up tests and removing some unused files to remove any confusion

parent b8b8f85d
......@@ -12,11 +12,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once __DIR__ . '/TestInit.php';
// Suites
#require_once 'Common/AllTests.php';
#require_once 'Dbal/AllTests.php';
#require_once 'Orm/AllTests.php';
class AllTests
{
public static function main()
......
......@@ -8,9 +8,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once __DIR__ . '/../../TestInit.php';
// Tests
#require_once 'Common/Collections/CollectionTest.php';
class AllTests
{
public static function main()
......
......@@ -6,12 +6,6 @@ use Doctrine\Tests;
require_once __DIR__ . '/../../TestInit.php';
/**
* Collection tests.
*
* @author robo
* @since 2.0
*/
class CollectionTest extends \Doctrine\Tests\DoctrineTestCase
{
private $_coll;
......
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\Common;
use Doctrine\Common\EventManager;
use Doctrine\Common\EventArgs;
/**
* Description of EventManagerTest
*
* @author robo
*/
class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
{
/* Some pseudo events */
......@@ -25,7 +16,8 @@ class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
private $_eventManager;
protected function setUp() {
protected function setUp()
{
$this->_eventManager = new EventManager;
$this->_preFooInvoked = false;
$this->_postFooInvoked = false;
......@@ -56,7 +48,6 @@ class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
$this->assertFalse($this->_postFooInvoked);
}
/* Listener methods */
public function preFoo(EventArgs $e)
......@@ -69,4 +60,3 @@ class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
$this->_postFooInvoked = true;
}
}
\ No newline at end of file
......@@ -11,10 +11,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once __DIR__ . '/../TestInit.php';
// Suites
#require_once 'Dbal/Component/AllTests.php';
#require_once 'Dbal/Ticket/AllTests.php';
class AllTests
{
public static function main()
......@@ -28,8 +24,6 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\DBAL\Platforms\AbstractPlatformTest');
$suite->addTest(Ticket\AllTests::suite());
return $suite;
}
}
......
<?php
namespace Doctrine\Tests\DBAL\Ticket;
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Ticket_AllTests::main');
}
require_once __DIR__ . '/../../TestInit.php';
// Tests
#require_once 'Dbal/Ticket/1Test.php';
class AllTests
{
public static function main()
{
\PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Orm');
$suite->addTestSuite('Doctrine\Tests\DBAL\Ticket\Test1');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'Ticket_AllTests::main') {
AllTests::main();
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\DBAL\Ticket;
require_once __DIR__ . '/../../TestInit.php';
class Test1 extends \Doctrine\Tests\DbalTestCase
{
public function testTest()
{
$this->assertEquals(0, 0);
}
}
\ No newline at end of file
......@@ -6,9 +6,9 @@ class ClassMetadataMock extends \Doctrine\ORM\Mapping\ClassMetadata
{
/* Mock API */
public function setIdGeneratorType($type) {
public function setIdGeneratorType($type)
{
$this->_generatorType = $type;
}
}
\ No newline at end of file
......@@ -8,7 +8,8 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
private $_lastInsertId = 0;
private $_inserts = array();
public function __construct(array $params, $driver, $config = null, $eventManager = null) {
public function __construct(array $params, $driver, $config = null, $eventManager = null)
{
parent::__construct($params, $driver, $config, $eventManager);
$this->_platformMock = new DatabasePlatformMock();
$this->_platform = $this->_platformMock;
......@@ -72,4 +73,3 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
$this->_lastInsertId = 0;
}
}
\ No newline at end of file
......@@ -19,7 +19,8 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
/**
* @override
*/
public function prefersIdentityColumns() {
public function prefersIdentityColumns()
{
return $this->_prefersIdentityColumns;
}
......@@ -50,6 +51,4 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
{
$this->_prefersIdentityColumns = (bool)$bool;
}
}
\ No newline at end of file
......@@ -15,4 +15,3 @@ class DriverConnectionMock implements \Doctrine\DBAL\Driver\Connection
public function errorCode() {}
public function errorInfo() {}
}
\ No newline at end of file
......@@ -49,4 +49,3 @@ class DriverMock implements \Doctrine\DBAL\Driver
$this->_platformMock = $platform;
}
}
\ No newline at end of file
......@@ -87,4 +87,3 @@ class EntityManagerMock extends \Doctrine\ORM\EntityManager
return parent::getIdGenerator($className);
}
}
\ No newline at end of file
......@@ -28,7 +28,8 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\StandardEntityPersist
return null;
}
public function setMockIdGeneratorType($genType) {
public function setMockIdGeneratorType($genType)
{
$this->_mockIdGeneratorType = $genType;
}
......@@ -65,4 +66,3 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\StandardEntityPersist
$this->_deletes = array();
}
}
\ No newline at end of file
......@@ -2,11 +2,6 @@
namespace Doctrine\Tests\Mocks;
/**
* Description of Doctrine_IdentityIdGeneratorMock
*
* @author robo
*/
class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator
{
private $_mockPostInsertId;
......@@ -15,4 +10,3 @@ class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator
$this->_mockPostInsertId = $id;
}
}
\ No newline at end of file
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\Mocks;
/**
* Description of Doctrine_MetadataDriverMock
*
* @author robo
*/
class MetadataDriverMock
{
public function loadMetadataForClass($className, \Doctrine\ORM\Mapping\ClassMetadata $metadata) {
public function loadMetadataForClass($className, \Doctrine\ORM\Mapping\ClassMetadata $metadata)
{
return;
}
public function isTransient($className) {
public function isTransient($className)
{
return false;
}
}
\ No newline at end of file
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\Mocks;
/**
* Description of SchemaManagerMock
*
* @author robo
*/
class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager
{
public function __construct(\Doctrine\DBAL\Connection $conn) {
public function __construct(\Doctrine\DBAL\Connection $conn)
{
parent::__construct($conn);
}
}
\ No newline at end of file
......@@ -2,12 +2,8 @@
namespace Doctrine\Tests\Mocks;
/**
* Description of Doctrine_UnitOfWorkMock
*
* @author robo
*/
class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork {
class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork
{
private $_mockDataChangeSets = array();
private $_persisterMock;
......@@ -24,7 +20,8 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork {
* @param <type> $entity
* @override
*/
public function getEntityChangeSet($entity) {
public function getEntityChangeSet($entity)
{
$oid = spl_object_hash($entity);
return isset($this->_mockDataChangeSets[$oid]) ?
$this->_mockDataChangeSets[$oid] : parent::getEntityChangeSet($entity);
......@@ -44,7 +41,8 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork {
$this->_persisterMock[$entityName] = $persister;
}
public function setDataChangeSet($entity, array $mockChangeSet) {
public function setDataChangeSet($entity, array $mockChangeSet)
{
$this->_mockDataChangeSets[spl_object_hash($entity)] = $mockChangeSet;
}
......@@ -58,4 +56,3 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork {
$this->_originalEntityData[spl_object_hash($entity)] = $originalData;
}
}
\ No newline at end of file
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\Models\CMS;
/**
* Description of CmsAddress
* CmsAddress
*
* @author robo
* @author Roman S. Borschel
* @DoctrineEntity
* @DoctrineTable(name="cms_addresses")
*/
......@@ -21,22 +17,25 @@ class CmsAddress
* @DoctrineIdGenerator("auto")
*/
public $id;
/**
* @DoctrineColumn(type="varchar", length=50)
*/
public $country;
/**
* @DoctrineColumn(type="varchar", length=50)
*/
public $zip;
/**
* @DoctrineColumn(type="varchar", length=50)
*/
public $city;
/**
* @DoctrineOneToOne(targetEntity="CmsUser")
* @DoctrineJoinColumn(name="user_id", referencedColumnName="id")
*/
public $user;
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\Models\Company;
/**
* @DoctrineEntity
* @DoctrineTable(name="company_employee")
* @DoctrineInheritanceType("joined")
* @DoctrineDiscriminatorColumn(name="dtype", type="varchar", length=20)
* @DoctrineDiscriminatorMap({
"emp" = "Doctrine\Tests\Models\Company\CompanyEmployee",
"man" = "Doctrine\Tests\Models\Company\CompanyManager"})
* @DoctrineSubclasses({"Doctrine\Tests\Models\Company\CompanyManager"})
*/
class CompanyEmployee
{
#protected $id;
#protected $salary;
#protected $department;
public static function initMetadata($mapping)
{
// inheritance mapping
$mapping->setInheritanceType('joined', array(
'discriminatorColumn' => 'dtype',
'discriminatorMap' => array(
'emp' => 'CompanyEmployee',
'man' => 'CompanyManager')
));
// register subclasses
$mapping->setSubclasses(array('CompanyManager'));
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineIdGenerator("auto")
*/
public $id;
$mapping->mapField(array(
'fieldName' => 'id',
'type' => 'integer',
'length' => 4,
'id' => true,
'idGenerator' => 'auto'
));
$mapping->mapField(array(
'fieldName' => 'salary',
'type' => 'double'
));
//TODO: make department an entity
$mapping->mapField(array(
'fieldName' => 'department',
'type' => 'string'
));
}
/**
* @DoctrineColumn(type="double")
*/
public $salary;
/**
* @DoctrineColumn(type="varchar", length=255)
*/
public $department;
}
\ No newline at end of file
?>
\ No newline at end of file
<?php
namespace Doctrine\Tests\Models\Company;
/**
* @DoctrineEntity
*/
class CompanyManager extends CompanyEmployee
{
public static function initMetadata($mapping)
{
$mapping->mapColumn(array(
'fieldName' => 'title',
'type' => 'string'
));
}
/*
* @DoctrineColumn(type="varchar", length="255")
*/
public $title;
}
\ No newline at end of file
?>
\ No newline at end of file
<?php
require_once 'lib/DoctrineTestInit.php';
class Orm_Associations_CascadeTest extends Doctrine_OrmTestCase
{
protected function setUp() {
;
}
protected function tearDown() {
;
}
public function testDeleteCascade()
{
$container = array();
$cascade = new DeleteCascade();
$cascade->cascade($entity, $container);
}
}
abstract class Cascade
{
public function cascade(Doctrine_Entity $record, array &$container)
{
if ($this->shouldCascadeTo($record)) {
$container[$record->getOid()] = $record;
}
foreach ($record->getTable()->getRelations() as $relation) {
if ($this->doCascade($relation)) {
$this->prepareCascade($record, $relation);
$relatedObjects = $record->get($relation->getAlias());
if ($relatedObjects instanceof Doctrine_Record && $this->shouldCascadeTo($relatedObjects)
&& ! isset($container[$relatedObjects->getOid()])) {
$this->cascade($relatedObjects, $container);
} else if ($relatedObjects instanceof Doctrine_Collection && count($relatedObjects) > 0) {
foreach ($relatedObjects as $object) {
if ( ! isset($container[$object->getOid()])) {
$this->cascade($object, $container);
}
}
}
}
}
}
}
class DeleteCascade extends Cascade
{
public function doCascade($relation)
{
return $relation->isCascadeDelete();
}
public function prepareCascade($record, $relation)
{
$fieldName = $relation->getAlias();
// if it's a xToOne relation and the related object is already loaded
// we don't need to refresh, else we need to.
if ( ! ($relation->getType() == Doctrine_Relation::ONE && isset($record->$fieldName))) {
$record->refreshRelated($relation->getAlias());
}
}
public function shouldCascadeTo(Doctrine_Entity $entity)
{
//TODO: also ignore removed Entities. incorporate that in exists() with a new
// state? (DELETED?)
return ! $entity->exists();
}
}
\ No newline at end of file
......@@ -24,7 +24,6 @@ class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals('address', $oneToOneMapping->getSourceFieldName());
$this->assertTrue($oneToOneMapping->isOwningSide());
$inverseSideMapping = array(
'fieldName' => 'person',
'sourceEntity' => 'Address',
......@@ -37,7 +36,5 @@ class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals('Address', $oneToOneMapping->getSourceEntityName());
$this->assertEquals('Person', $oneToOneMapping->getTargetEntityName());
$this->assertTrue($oneToOneMapping->isInverseSide());
}
}
\ No newline at end of file
......@@ -48,6 +48,5 @@ class CommitOrderCalculatorTest extends \Doctrine\Tests\OrmTestCase
// There is only 1 valid ordering for this constellation
$correctOrder = array("node5", "node1", "node2", "node3", "node4");
$this->assertSame($correctOrder, $sorted);
}
}
\ No newline at end of file
<?php
/* CURRENTLY NOT USED */
require_once 'lib/DoctrineTestInit.php';
class Orm_Entity_AccessorTest extends Doctrine_OrmTestCase
{
public function testGetterSetterOverride()
{
$entity1 = new CustomAccessorMutatorTestEntity();
$entity1->username = 'romanb';
$this->assertEquals('romanb?!', $entity1->username);
$entity2 = new MagicAccessorMutatorTestEntity();
$entity2->username = 'romanb';
$this->assertEquals('romanb?!', $entity1->username);
}
}
/* Local test classes */
class CustomAccessorMutatorTestEntity extends Doctrine_Common_VirtualPropertyObject
{
static function construct() {
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'id', 'int');
Doctrine_Common_VirtualPropertySystem::register(__CLASS__,
'username', 'string', 'getUsernameCustom', 'setUsernameCustom');
}
public static function initMetadata($mapping)
{
$mapping->mapField(array(
'fieldName' => 'id',
'type' => 'integer',
'length' => 4,
'id' => true
));
$mapping->mapField(array(
'fieldName' => 'username',
'type' => 'string',
'length' => 50
));
}
public function getUsernameCustom()
{
return $this->_get('username') . "!";
}
public function setUsernameCustom($username)
{
$this->_set('username', $username . "?");
}
}
class MagicAccessorMutatorTestEntity extends Doctrine_Common_VirtualPropertyObject
{
static function construct() {
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'id', 'int');
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'username', 'string');
}
public static function initMetadata($mapping)
{
$mapping->mapField(array(
'fieldName' => 'id',
'type' => 'integer',
'length' => 4,
'id' => true
));
$mapping->mapField(array(
'fieldName' => 'username',
'type' => 'string',
'length' => 50
));
}
public function getUsername()
{
return $this->_get('username') . "!";
}
public function setUsername($username)
{
$this->_set('username', $username . "?");
}
}
\ No newline at end of file
......@@ -20,7 +20,6 @@ class AllTests
{
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Orm Entity Tests');
//$suite->addTestSuite('Orm_Entity_AccessorTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Entity\ConstructorTest');
return $suite;
......
......@@ -4,14 +4,12 @@ namespace Doctrine\Tests\ORM;
require_once __DIR__ . '/../TestInit.php';
/**
* EntityManager tests.
*/
class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
{
private $_em;
function setUp() {
function setUp()
{
parent::setUp();
$this->_em = $this->_getTestEntityManager();
}
......
......@@ -12,9 +12,6 @@ use Doctrine\Tests\Models\Forum\ForumAvatar;
require_once __DIR__ . '/../TestInit.php';
/**
* EntityPersister tests.
*/
class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
{
private $_connMock;
......@@ -22,7 +19,8 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
private $_idGenMock;
private $_uowMock;
protected function setUp() {
protected function setUp()
{
parent::setUp();
$this->_connMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
$this->_emMock = EntityManagerMock::create($this->_connMock);
......@@ -32,7 +30,8 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $this->_idGenMock);
}
public function testSimpleInsert() {
public function testSimpleInsert()
{
$userPersister = new \Doctrine\ORM\Persisters\StandardEntityPersister(
$this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser"));
$avatarPersister = new \Doctrine\ORM\Persisters\StandardEntityPersister(
......@@ -46,7 +45,6 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
'username' => array('', 'romanb'),
'avatar' => array('', $user->avatar)));
//insert
$avatarPersister->insert($user->avatar);
$inserts = $this->_connMock->getInserts();
......@@ -76,5 +74,4 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue(isset($inserts['forum_users'][0]['dtype']));
$this->assertEquals('user', $inserts['forum_users'][0]['dtype']);
}
}
\ No newline at end of file
......@@ -10,14 +10,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once __DIR__ . '/../../TestInit.php';
#require_once 'IdentifierRecognitionTest.php';
/*require_once 'ScannerTest.php';
require_once 'DqlGenerationTest.php';
require_once 'DeleteSqlGenerationTest.php';
require_once 'UpdateSqlGenerationTest.php';
require_once 'SelectSqlGenerationTest.php';
require_once 'LanguageRecognitionTest.php';*/
class AllTests
{
public static function main()
......
<?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.doctrine-project.org>.
*/
namespace Doctrine\Tests\ORM\Export;
......@@ -25,37 +6,24 @@ use Doctrine\ORM\Export\ClassExporter;
require_once __DIR__ . '/../../TestInit.php';
/**
* Test case for testing the ddl class exporter
*
* @package Doctrine
* @subpackage Query
* @author Jonathan H. Wage <jonwage@gmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
class ClassExporterTest extends \Doctrine\Tests\OrmTestCase
{
public function testTest()
public function testGetExportClassesSql()
{
// DDL is platform dependant. We can inject the platform to test into the driver mock.
$driver = new \Doctrine\Tests\Mocks\DriverMock;
$conn = new \Doctrine\Tests\Mocks\ConnectionMock(array(), $driver);
//$conn->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SqlitePlatform());
$conn->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform());
$em = $this->_getTestEntityManager($conn);
$classes = array(
$em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'),
$em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
$em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber')
$em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
);
$exporter = new ClassExporter($em);
$sql = $exporter->getExportClassesSql($classes);
print_r($sql);
$this->assertEquals(count($sql), 8);
}
}
\ No newline at end of file
......@@ -21,8 +21,6 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\BasicCRUDTest');
//$suite->addTest(Orm_Functional_Ticket_AllTests::suite());
return $suite;
}
}
......
......@@ -10,14 +10,10 @@ use Doctrine\Tests\Models\CMS\CmsGroup;
require_once __DIR__ . '/../../TestInit.php';
/**
* Description of BasicCRUDTest
*
* @author robo
*/
class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
public function testBasicUnitsOfWorkWithOneToManyAssociation() {
class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function testBasicUnitsOfWorkWithOneToManyAssociation()
{
$em = $this->_em;
$exporter = new ClassExporter($this->_em);
......@@ -73,7 +69,8 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
$this->assertFalse($em->getUnitOfWork()->isRegisteredRemoved($ph2));
}
public function testOneToManyAssociationModification() {
public function testOneToManyAssociationModification()
{
$user = new CmsUser;
$user->name = 'Roman';
$user->username = 'romanb';
......@@ -192,4 +189,3 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
$this->assertEquals(0, $count);
}
}
\ No newline at end of file
<?php
require_once 'lib/DoctrineTestInit.php';
class Orm_Functional_Ticket_1Test extends Doctrine_OrmTestCase
{
public function testTest()
{
$this->assertEquals(0, 0);
}
}
\ No newline at end of file
<?php
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Orm_Functional_Ticket_AllTests::main');
}
require_once 'lib/DoctrineTestInit.php';
// Tests
require_once 'Orm/Functional/Ticket/1Test.php';
class Orm_Functional_Ticket_AllTests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new Doctrine_TestSuite('Doctrine Orm');
$suite->addTestSuite('Orm_Functional_Ticket_1Test');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'Orm_Functional_Ticket_AllTests::main') {
Ticket_AllTests::main();
}
\ No newline at end of file
......@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement;
require_once __DIR__ . '/../../TestInit.php';
/**
* Description of ArrayHydratorTest
*
* @author robo
*/
class ArrayHydratorTest extends HydrationTest
{
/**
......@@ -663,7 +658,8 @@ class ArrayHydratorTest extends HydrationTest
$this->assertEquals(1, count($result[1]['boards']));
}
public function testResultIteration() {
public function testResultIteration()
{
// Faked query components
$queryComponents = array(
'u' => array(
......@@ -713,4 +709,3 @@ class ArrayHydratorTest extends HydrationTest
}
}
}
\ No newline at end of file
......@@ -4,11 +4,6 @@ namespace Doctrine\Tests\ORM\Hydration;
require_once __DIR__ . '/../../TestInit.php';
/**
* Description of HydrationTest
*
* @author robo
*/
class HydrationTest extends \Doctrine\Tests\OrmTestCase
{
protected $_em;
......@@ -29,4 +24,3 @@ class HydrationTest extends \Doctrine\Tests\OrmTestCase
return $parserResult;
}
}
\ No newline at end of file
......@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement;
require_once __DIR__ . '/../../TestInit.php';
/**
* Description of ObjectHydratorTest
*
* @author robo
*/
class ObjectHydratorTest extends HydrationTest
{
/**
......@@ -669,7 +664,8 @@ class ObjectHydratorTest extends HydrationTest
}
public function testResultIteration() {
public function testResultIteration()
{
// Faked query components
$queryComponents = array(
'u' => array(
......@@ -728,7 +724,7 @@ class ObjectHydratorTest extends HydrationTest
*
* @dataProvider hydrationModeProvider
*/
/*public function testNewHydrationMixedQueryFetchJoinPerformance()
public function testNewHydrationMixedQueryFetchJoinPerformance()
{
// Faked query components
$queryComponents = array(
......@@ -740,7 +736,7 @@ class ObjectHydratorTest extends HydrationTest
'agg' => array('0' => 'nameUpper')
),
'p' => array(
'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'),
'metadata' => $this->_em->getClassMetadata('\Doctrine\Tests\Models\CMS\CmsPhonenumber'),
'parent' => 'u',
'relation' => $this->_em->getClassMetadata('\Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers'),
'map' => null
......@@ -775,7 +771,8 @@ class ObjectHydratorTest extends HydrationTest
'p__phonenumber' => '91'
)
);
for ($i=4; $i<300; $i++) {
for ($i = 4; $i < 300; $i++) {
$resultSet[] = array(
'u__id' => $i,
'u__status' => 'developer',
......@@ -784,12 +781,10 @@ class ObjectHydratorTest extends HydrationTest
);
}
$stmt = new Doctrine_HydratorMockStatement($resultSet);
$hydrator = new Doctrine_ORM_Internal_Hydration_ObjectHydrator($this->_em);
$stmt = new HydratorMockStatement($resultSet);
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
$queryComponents, $tableAliasMap, true));
}*/
}
}
\ No newline at end of file
......@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement;
require_once __DIR__ . '/../../TestInit.php';
/**
* Description of ScalarHydratorTest
*
* @author robo
*/
class ScalarHydratorTest extends HydrationTest
{
/**
......@@ -60,4 +55,3 @@ class ScalarHydratorTest extends HydrationTest
$this->assertEquals(2, $result[1]['u_id']);
}
}
\ No newline at end of file
......@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement;
require_once __DIR__ . '/../../TestInit.php';
/**
* Description of SingleScalarHydratorTest
*
* @author robo
*/
class SingleScalarHydratorTest extends HydrationTest
{
/** Result set provider for the HYDRATE_SINGLE_SCALAR tests */
......@@ -91,7 +86,5 @@ class SingleScalarHydratorTest extends HydrationTest
$this->fail();
} catch (\Doctrine\ORM\Internal\Hydration\HydrationException $ex) {}
}
}
}
\ No newline at end of file
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\ORM\Mapping;
......@@ -12,14 +8,11 @@ use Doctrine\ORM\Mapping\ClassMetadata;
require_once __DIR__ . '/../../TestInit.php';
/**
* Description of ClassMetadataFactoryTest
*
* @author robo
*/
class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase {
class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
{
public function testGetMetadataForSingleClass() {
public function testGetMetadataForSingleClass()
{
$mockPlatform = new DatabasePlatformMock();
$mockDriver = new MetadataDriverMock();
......@@ -52,7 +45,8 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase {
$this->assertEquals('table', $cm1->getIdGeneratorType());
}
public function testGetMetadataForClassInHierarchy() {
public function testGetMetadataForClassInHierarchy()
{
$mockPlatform = new DatabasePlatformMock();
$mockPlatform->setPrefersIdentityColumns(true);
$mockDriver = new MetadataDriverMock();
......@@ -120,29 +114,39 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase {
}
/* Test subject class with overriden factory method for mocking purposes */
class ClassMetadataFactoryTestSubject extends \Doctrine\ORM\Mapping\ClassMetadataFactory {
class ClassMetadataFactoryTestSubject extends \Doctrine\ORM\Mapping\ClassMetadataFactory
{
private $_mockMetadata = array();
private $_requestedClasses = array();
/** @override */
protected function _newClassMetadataInstance($className) {
protected function _newClassMetadataInstance($className)
{
$this->_requestedClasses[] = $className;
if ( ! isset($this->_mockMetadata[$className])) {
throw new InvalidArgumentException("No mock metadata found for class $className.");
}
return $this->_mockMetadata[$className];
}
public function setMetadataForClass($className, $metadata) {
public function setMetadataForClass($className, $metadata)
{
$this->_mockMetadata[$className] = $metadata;
}
public function getRequestedClasses() { return $this->_requestedClasses; }
public function getRequestedClasses()
{
return $this->_requestedClasses;
}
}
/* Test classes */
class TestEntity1 {
class TestEntity1
{
protected $name;
protected $other;
}
class TestEntity2 extends TestEntity1 {}
class TestEntity3 extends TestEntity2 {}
\ No newline at end of file
......@@ -8,7 +8,8 @@ require_once __DIR__ . '/../../TestInit.php';
class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
{
public function testClassMetadataInstanceSerialization() {
public function testClassMetadataInstanceSerialization()
{
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
// Test initial state
......
<?php
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Orm_Performance_AllTests::main');
}
require_once 'lib/DoctrineTestInit.php';
// Tests
//...
class Orm_Performance_AllTests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new Doctrine_TestSuite('Doctrine Orm Performance');
//$suite->addTestSuite('Orm_Performance_xxxTest');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'Orm_Performance_AllTests::main') {
Orm_Performance_AllTests::main();
}
......@@ -2,22 +2,12 @@
namespace Doctrine\Tests\ORM\Query;
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Orm_Query_AllTests::main');
}
require_once __DIR__ . '/../../TestInit.php';
#require_once 'IdentifierRecognitionTest.php';
/*require_once 'ScannerTest.php';
require_once 'DqlGenerationTest.php';
require_once 'DeleteSqlGenerationTest.php';
require_once 'UpdateSqlGenerationTest.php';
require_once 'SelectSqlGenerationTest.php';
require_once 'LanguageRecognitionTest.php';*/
class AllTests
{
public static function main()
......@@ -31,8 +21,9 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\Query\IdentifierRecognitionTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\SelectSqlGenerationTest');
/*
$suite->addTestSuite('Orm_Query_LanguageRecognitionTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\LanguageRecognitionTest');
$suite->addTestSuite('Orm_Query_ScannerTest');
$suite->addTestSuite('Orm_Query_DqlGenerationTest');
$suite->addTestSuite('Orm_Query_DeleteSqlGenerationTest');
......
<?php
namespace Doctrine\Tests\ORM\Query;
/*
* $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.org>.
*/
require_once 'lib/DoctrineTestInit.php';
/**
* Test case for testing the saving and referencing of query identifiers.
*
* @package Doctrine
* @subpackage Query
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
* @todo 1) [romanb] We might want to split the SQL generation tests into multiple
* testcases later since we'll have a lot of them and we might want to have special SQL
* generation tests for some dbms specific SQL syntaxes.
*/
class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
require_once __DIR__ . '/../../TestInit.php';
class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
{
private $_em;
protected function setUp()
{
$this->_em = $this->_getTestEntityManager();
}
public function assertValidDql($dql, $debug = false)
{
try {
......@@ -78,147 +52,134 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
public function testPlainFromClauseWithoutAlias()
{
$this->assertValidDql('SELECT * FROM CmsUser');
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser');
$this->assertValidDql('SELECT id FROM CmsUser');
$this->assertValidDql('SELECT id FROM Doctrine\Tests\Models\CMS\CmsUser');
}
public function testPlainFromClauseWithAlias()
{
$this->assertValidDql('SELECT u.id FROM CmsUser u');
$this->assertValidDql('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testSelectSingleComponentWithAsterisk()
{
$this->assertValidDql('SELECT u.* FROM CmsUser u');
$this->assertValidDql('SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testInvalidSelectSingleComponentWithAsterisk()
{
$this->assertInvalidDql('SELECT p.* FROM CmsUser u');
$this->assertInvalidDql('SELECT p.* FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testSelectSingleComponentWithMultipleColumns()
{
$this->assertValidDql('SELECT u.name, u.username FROM CmsUser u');
$this->assertValidDql('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testSelectMultipleComponentsWithAsterisk()
{
$this->assertValidDql('SELECT u.*, p.* FROM CmsUser u, u.phonenumbers p');
$this->assertValidDql('SELECT u.*, p.* FROM Doctrine\Tests\Models\CMS\CmsUser u, u.phonenumbers p');
}
public function testSelectDistinctIsSupported()
{
$this->assertValidDql('SELECT DISTINCT u.name FROM CmsUser u');
$this->assertValidDql('SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testAggregateFunctionInSelect()
{
$this->assertValidDql('SELECT COUNT(u.id) FROM CmsUser u');
$this->assertValidDql('SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testAggregateFunctionWithDistinctInSelect()
{
$this->assertValidDql('SELECT COUNT(DISTINCT u.name) FROM CmsUser u');
$this->assertValidDql('SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testFunctionalExpressionsSupportedInWherePart()
{
$this->assertValidDql("SELECT u.name FROM CmsUser u WHERE TRIM(u.name) = 'someone'");
$this->assertValidDql("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
}
public function testArithmeticExpressionsSupportedInWherePart()
{
$this->assertValidDql('SELECT u.* FROM CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000');
$this->assertValidDql('SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000');
}
public function testInExpressionSupportedInWherePart()
{
$this->assertValidDql('SELECT * FROM CmsUser WHERE CmsUser.id IN (1, 2)');
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser WHERE CmsUser.id IN (1, 2)');
}
public function testNotInExpressionSupportedInWherePart()
{
$this->assertValidDql('SELECT * FROM CmsUser WHERE CmsUser.id NOT IN (1)');
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)');
}
public function testExistsExpressionSupportedInWherePart()
{
$this->assertValidDql('SELECT u.* FROM CmsUser u WHERE EXISTS (SELECT p.user_id FROM CmsPhonenumber p WHERE p.user_id = u.id)');
$this->assertValidDql('SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.user_id FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user_id = u.id)');
}
public function testNotExistsExpressionSupportedInWherePart()
{
$this->assertValidDql('SELECT u.* FROM CmsUser u WHERE NOT EXISTS (SELECT p.user_id FROM CmsPhonenumber p WHERE p.user_id = u.id)');
$this->assertValidDql('SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT EXISTS (SELECT p.user_id FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user_id = u.id)');
}
public function testLiteralValueAsInOperatorOperandIsSupported()
{
$this->assertValidDql('SELECT u.id FROM CmsUser u WHERE 1 IN (1, 2)');
$this->assertValidDql('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE 1 IN (1, 2)');
}
public function testUpdateWorksWithOneColumn()
{
$this->assertValidDql("UPDATE CmsUser u SET u.name = 'someone'");
$this->assertValidDql("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone'");
}
public function testUpdateWorksWithMultipleColumns()
{
$this->assertValidDql("UPDATE CmsUser u SET u.name = 'someone', u.username = 'some'");
$this->assertValidDql("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone', u.username = 'some'");
}
public function testUpdateSupportsConditions()
{
$this->assertValidDql("UPDATE CmsUser u SET u.name = 'someone' WHERE u.id = 5");
$this->assertValidDql("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone' WHERE u.id = 5");
}
public function testDeleteAll()
{
$this->assertValidDql('DELETE FROM CmsUser');
$this->assertValidDql('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser');
}
public function testDeleteWithCondition()
{
$this->assertValidDql('DELETE FROM CmsUser WHERE id = 3');
}
/*
public function testDeleteWithLimit()
{
// LIMIT is not supported in DELETE
$this->assertValidDql('DELETE FROM CmsUser LIMIT 20');
$this->assertValidDql('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser WHERE id = 3');
}
public function testDeleteWithLimitAndOffset()
{
// LIMIT and OFFSET are not supported in DELETE
$this->assertValidDql('DELETE FROM CmsUser LIMIT 10 OFFSET 20');
}
*/
public function testAdditionExpression()
{
$this->assertValidDql('SELECT u.*, (u.id + u.id) addition FROM CmsUser u');
$this->assertValidDql('SELECT u.*, (u.id + u.id) addition FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testSubtractionExpression()
{
$this->assertValidDql('SELECT u.*, (u.id - u.id) subtraction FROM CmsUser u');
$this->assertValidDql('SELECT u.*, (u.id - u.id) subtraction FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testDivisionExpression()
{
$this->assertValidDql('SELECT u.*, (u.id/u.id) division FROM CmsUser u');
$this->assertValidDql('SELECT u.*, (u.id/u.id) division FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testMultiplicationExpression()
{
$this->assertValidDql('SELECT u.*, (u.id * u.id) multiplication FROM CmsUser u');
$this->assertValidDql('SELECT u.*, (u.id * u.id) multiplication FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testNegationExpression()
{
$this->assertValidDql('SELECT u.*, -u.id negation FROM CmsUser u');
$this->assertValidDql('SELECT u.*, -u.id negation FROM Doctrine\Tests\Models\CMS\CmsUser u');
}
public function testExpressionWithPrecedingPlusSign()
......@@ -228,78 +189,78 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
public function testAggregateFunctionInHavingClause()
{
$this->assertValidDql('SELECT u.name FROM CmsUser u LEFT JOIN u.phonenumbers p HAVING COUNT(p.phonenumber) > 2');
$this->assertValidDql("SELECT u.name FROM CmsUser u LEFT JOIN u.phonenumbers p HAVING MAX(u.name) = 'zYne'");
$this->assertValidDql('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING COUNT(p.phonenumber) > 2');
$this->assertValidDql("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING MAX(u.name) = 'zYne'");
}
public function testMultipleAggregateFunctionsInHavingClause()
{
$this->assertValidDql("SELECT u.name FROM CmsUser u LEFT JOIN u.phonenumbers p HAVING MAX(u.name) = 'zYne'");
$this->assertValidDql("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING MAX(u.name) = 'zYne'");
}
public function testLeftJoin()
{
$this->assertValidDql('SELECT u.*, p.* FROM CmsUser u LEFT JOIN u.phonenumbers p');
$this->assertValidDql('SELECT u.*, p.* FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p');
}
public function testJoin()
{
$this->assertValidDql('SELECT u.* FROM CmsUser u JOIN u.phonenumbers');
$this->assertValidDql('SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers');
}
public function testInnerJoin()
{
$this->assertValidDql('SELECT u.*, u.phonenumbers.* FROM CmsUser u INNER JOIN u.phonenumbers');
$this->assertValidDql('SELECT u.*, u.phonenumbers.* FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers');
}
public function testMultipleLeftJoin()
{
$this->assertValidDql('SELECT u.articles.*, u.phonenumbers.* FROM CmsUser u LEFT JOIN u.articles LEFT JOIN u.phonenumbers');
$this->assertValidDql('SELECT u.articles.*, u.phonenumbers.* FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles LEFT JOIN u.phonenumbers');
}
public function testMultipleInnerJoin()
{
$this->assertValidDql('SELECT u.name FROM CmsUser u INNER JOIN u.articles INNER JOIN u.phonenumbers');
$this->assertValidDql('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles INNER JOIN u.phonenumbers');
}
public function testMultipleInnerJoin2()
{
$this->assertValidDql('SELECT u.name FROM CmsUser u INNER JOIN u.articles, u.phonenumbers');
$this->assertValidDql('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles, u.phonenumbers');
}
public function testMixingOfJoins()
{
$this->assertValidDql('SELECT u.name, a.topic, p.phonenumber FROM CmsUser u INNER JOIN u.articles a LEFT JOIN u.phonenumbers p');
$this->assertValidDql('SELECT u.name, a.topic, p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a LEFT JOIN u.phonenumbers p');
}
public function testMixingOfJoins2()
{
$this->assertInvalidDql('SELECT u.name, u.articles.topic, c.text FROM CmsUser u INNER JOIN u.articles.comments c');
$this->assertInvalidDql('SELECT u.name, u.articles.topic, c.text FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles.comments c');
}
public function testOrderBySingleColumn()
{
$this->assertValidDql('SELECT u.name FROM CmsUser u ORDER BY u.name');
$this->assertValidDql('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name');
}
public function testOrderBySingleColumnAscending()
{
$this->assertValidDql('SELECT u.name FROM CmsUser u ORDER BY u.name ASC');
$this->assertValidDql('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name ASC');
}
public function testOrderBySingleColumnDescending()
{
$this->assertValidDql('SELECT u.name FROM CmsUser u ORDER BY u.name DESC');
$this->assertValidDql('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name DESC');
}
public function testOrderByMultipleColumns()
{
$this->assertValidDql('SELECT u.name, u.username FROM CmsUser u ORDER BY u.username DESC, u.name DESC');
$this->assertValidDql('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username DESC, u.name DESC');
}
public function testOrderByWithFunctionExpression()
{
$this->assertValidDql('SELECT u.name FROM CmsUser u ORDER BY COALESCE(u.id, u.name) DESC');
$this->assertValidDql('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY COALESCE(u.id, u.name) DESC');
}
/*
public function testSubselectInInExpression()
......@@ -315,12 +276,12 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
*/
public function testPositionalInputParameter()
{
$this->assertValidDql('SELECT * FROM CmsUser u WHERE u.id = ?');
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?');
}
public function testNamedInputParameter()
{
$this->assertValidDql('SELECT * FROM CmsUser u WHERE u.id = :id');
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id');
}
/*
public function testCustomJoinsAndWithKeywordSupported()
......@@ -332,32 +293,32 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
public function testJoinConditionsSupported()
{
$this->assertValidDql("SELECT u.name, p.* FROM CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'");
$this->assertValidDql("SELECT u.name, p.* FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'");
}
public function testIndexByClauseWithOneComponent()
{
$this->assertValidDql('SELECT * FROM CmsUser u INDEX BY id');
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY id');
}
public function testIndexBySupportsJoins()
{
$this->assertValidDql('SELECT u.*, u.articles.* FROM CmsUser u LEFT JOIN u.articles INDEX BY id'); // INDEX BY is now referring to articles
$this->assertValidDql('SELECT u.*, u.articles.* FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles INDEX BY id'); // INDEX BY is now referring to articles
}
public function testIndexBySupportsJoins2()
{
$this->assertValidDql('SELECT u.*, p.* FROM CmsUser u INDEX BY id LEFT JOIN u.phonenumbers p INDEX BY phonenumber');
$this->assertValidDql('SELECT u.*, p.* FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY id LEFT JOIN u.phonenumbers p INDEX BY phonenumber');
}
public function testBetweenExpressionSupported()
{
$this->assertValidDql("SELECT * FROM CmsUser u WHERE u.name BETWEEN 'jepso' AND 'zYne'");
$this->assertValidDql("SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name BETWEEN 'jepso' AND 'zYne'");
}
public function testNotBetweenExpressionSupported()
{
$this->assertValidDql("SELECT * FROM CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'");
$this->assertValidDql("SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'");
}
/* public function testAllExpressionWithCorrelatedSubquery()
......@@ -380,17 +341,17 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
*/
public function testLikeExpression()
{
$this->assertValidDql("SELECT u.id FROM CmsUser u WHERE u.name LIKE 'z%'");
$this->assertValidDql("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z%'");
}
public function testNotLikeExpression()
{
$this->assertValidDql("SELECT u.id FROM CmsUser u WHERE u.name NOT LIKE 'z%'");
$this->assertValidDql("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT LIKE 'z%'");
}
public function testLikeExpressionWithCustomEscapeCharacter()
{
$this->assertValidDql("SELECT u.id FROM CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'");
$this->assertValidDql("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'");
}
/**
......@@ -403,7 +364,7 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
*/
public function testImplicitJoinWithCartesianProductAndConditionInWhere()
{
$this->assertValidDql("SELECT u.*, a.* FROM CmsUser u, CmsArticle a WHERE u.name = a.topic");
$this->assertValidDql("SELECT u.*, a.* FROM Doctrine\Tests\Models\CMS\CmsUser u, CmsArticle a WHERE u.name = a.topic");
}
public function testImplicitJoinInWhereOnSingleValuedAssociationPathExpression()
......@@ -416,24 +377,23 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
public function testImplicitJoinInWhereOnCollectionValuedPathExpression()
{
// This should be forbidden, because articles is a collection
$this->assertInvalidDql("SELECT u.* FROM CmsUser u WHERE u.articles.title = ?");
$this->assertInvalidDql("SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.articles.title = ?");
}
public function testInvalidSyntaxIsRejected()
{
$this->assertInvalidDql("FOOBAR CmsUser");
$this->assertInvalidDql("DELETE FROM CmsUser.articles");
$this->assertInvalidDql("DELETE FROM CmsUser cu WHERE cu.articles.id > ?");
$this->assertInvalidDql("SELECT user FROM CmsUser user");
$this->assertInvalidDql("DELETE FROM Doctrine\Tests\Models\CMS\CmsUser.articles");
$this->assertInvalidDql("DELETE FROM Doctrine\Tests\Models\CMS\CmsUser cu WHERE cu.articles.id > ?");
$this->assertInvalidDql("SELECT user FROM Doctrine\Tests\Models\CMS\CmsUser user");
// Error message here is: Relation 'comments' does not exist in component 'CmsUser'
// This means it is intepreted as:
// SELECT u.* FROM CmsUser u JOIN u.articles JOIN u.comments
// This seems wrong. "JOIN u.articles.comments" should not be allowed.
$this->assertInvalidDql("SELECT u.* FROM CmsUser u JOIN u.articles.comments");
$this->assertInvalidDql("SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles.comments");
// Currently UNDEFINED OFFSET error
//$this->assertInvalidDql("SELECT * FROM CmsUser.articles.comments");
}
}
\ No newline at end of file
<?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.doctrine-project.org>.
*/
namespace Doctrine\Tests\ORM\Query;
require_once __DIR__ . '/../../TestInit.php';
/**
* Test case for testing the saving and referencing of query identifiers.
*
* @package Doctrine
* @subpackage Query
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
* @todo 1) [romanb] We might want to split the SQL generation tests into multiple
* testcases later since we'll have a lot of them and we might want to have special SQL
* generation tests for some dbms specific SQL syntaxes.
*/
class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
private $_em;
protected function setUp() {
protected function setUp()
{
$this->_em = $this->_getTestEntityManager();
}
......
<?php
require_once 'lib/DoctrineTestInit.php';
class Orm_Ticket_1Test extends Doctrine_OrmTestCase
{
public function testTest()
{
$this->assertEquals(0, 0);
}
}
\ No newline at end of file
<?php
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Ticket_AllTests::main');
}
require_once 'lib/DoctrineTestInit.php';
// Tests
require_once 'Orm/Ticket/1Test.php';
class Orm_Ticket_AllTests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new Doctrine_TestSuite('Doctrine Orm');
$suite->addTestSuite('Orm_Ticket_1Test');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'Ticket_AllTests::main') {
Ticket_AllTests::main();
}
\ No newline at end of file
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