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')) { ...@@ -12,11 +12,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once __DIR__ . '/TestInit.php'; require_once __DIR__ . '/TestInit.php';
// Suites
#require_once 'Common/AllTests.php';
#require_once 'Dbal/AllTests.php';
#require_once 'Orm/AllTests.php';
class AllTests class AllTests
{ {
public static function main() public static function main()
......
<?php <?php
class ClassLoaderTest_ClassA class ClassLoaderTest_ClassA
{ {
......
<?php <?php
class ClassLoaderTest_ClassB class ClassLoaderTest_ClassB
{ {
......
...@@ -8,9 +8,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) { ...@@ -8,9 +8,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
// Tests
#require_once 'Common/Collections/CollectionTest.php';
class AllTests class AllTests
{ {
public static function main() public static function main()
......
...@@ -6,12 +6,6 @@ use Doctrine\Tests; ...@@ -6,12 +6,6 @@ use Doctrine\Tests;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
/**
* Collection tests.
*
* @author robo
* @since 2.0
*/
class CollectionTest extends \Doctrine\Tests\DoctrineTestCase class CollectionTest extends \Doctrine\Tests\DoctrineTestCase
{ {
private $_coll; private $_coll;
......
<?php <?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\Common; namespace Doctrine\Tests\Common;
use Doctrine\Common\EventManager; use Doctrine\Common\EventManager;
use Doctrine\Common\EventArgs; use Doctrine\Common\EventArgs;
/**
* Description of EventManagerTest
*
* @author robo
*/
class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
{ {
/* Some pseudo events */ /* Some pseudo events */
...@@ -25,7 +16,8 @@ class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -25,7 +16,8 @@ class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
private $_eventManager; private $_eventManager;
protected function setUp() { protected function setUp()
{
$this->_eventManager = new EventManager; $this->_eventManager = new EventManager;
$this->_preFooInvoked = false; $this->_preFooInvoked = false;
$this->_postFooInvoked = false; $this->_postFooInvoked = false;
...@@ -56,7 +48,6 @@ class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -56,7 +48,6 @@ class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
$this->assertFalse($this->_postFooInvoked); $this->assertFalse($this->_postFooInvoked);
} }
/* Listener methods */ /* Listener methods */
public function preFoo(EventArgs $e) public function preFoo(EventArgs $e)
...@@ -68,5 +59,4 @@ class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -68,5 +59,4 @@ class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
{ {
$this->_postFooInvoked = true; $this->_postFooInvoked = true;
} }
} }
\ No newline at end of file
...@@ -11,10 +11,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) { ...@@ -11,10 +11,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once __DIR__ . '/../TestInit.php'; require_once __DIR__ . '/../TestInit.php';
// Suites
#require_once 'Dbal/Component/AllTests.php';
#require_once 'Dbal/Ticket/AllTests.php';
class AllTests class AllTests
{ {
public static function main() public static function main()
...@@ -27,8 +23,6 @@ class AllTests ...@@ -27,8 +23,6 @@ class AllTests
$suite = new \Doctrine\Tests\DbalTestSuite('Doctrine DBAL'); $suite = new \Doctrine\Tests\DbalTestSuite('Doctrine DBAL');
$suite->addTestSuite('Doctrine\Tests\DBAL\Platforms\AbstractPlatformTest'); $suite->addTestSuite('Doctrine\Tests\DBAL\Platforms\AbstractPlatformTest');
$suite->addTest(Ticket\AllTests::suite());
return $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 ...@@ -6,9 +6,9 @@ class ClassMetadataMock extends \Doctrine\ORM\Mapping\ClassMetadata
{ {
/* Mock API */ /* Mock API */
public function setIdGeneratorType($type) { public function setIdGeneratorType($type)
{
$this->_generatorType = $type; $this->_generatorType = $type;
} }
} }
\ No newline at end of file
...@@ -8,7 +8,8 @@ class ConnectionMock extends \Doctrine\DBAL\Connection ...@@ -8,7 +8,8 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
private $_lastInsertId = 0; private $_lastInsertId = 0;
private $_inserts = array(); 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); parent::__construct($params, $driver, $config, $eventManager);
$this->_platformMock = new DatabasePlatformMock(); $this->_platformMock = new DatabasePlatformMock();
$this->_platform = $this->_platformMock; $this->_platform = $this->_platformMock;
...@@ -71,5 +72,4 @@ class ConnectionMock extends \Doctrine\DBAL\Connection ...@@ -71,5 +72,4 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
$this->_inserts = array(); $this->_inserts = array();
$this->_lastInsertId = 0; $this->_lastInsertId = 0;
} }
} }
\ No newline at end of file
...@@ -19,7 +19,8 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform ...@@ -19,7 +19,8 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
/** /**
* @override * @override
*/ */
public function prefersIdentityColumns() { public function prefersIdentityColumns()
{
return $this->_prefersIdentityColumns; return $this->_prefersIdentityColumns;
} }
...@@ -50,6 +51,4 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform ...@@ -50,6 +51,4 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
{ {
$this->_prefersIdentityColumns = (bool)$bool; $this->_prefersIdentityColumns = (bool)$bool;
} }
}
} \ No newline at end of file
...@@ -14,5 +14,4 @@ class DriverConnectionMock implements \Doctrine\DBAL\Driver\Connection ...@@ -14,5 +14,4 @@ class DriverConnectionMock implements \Doctrine\DBAL\Driver\Connection
public function rollBack() {} public function rollBack() {}
public function errorCode() {} public function errorCode() {}
public function errorInfo() {} public function errorInfo() {}
} }
\ No newline at end of file
...@@ -48,5 +48,4 @@ class DriverMock implements \Doctrine\DBAL\Driver ...@@ -48,5 +48,4 @@ class DriverMock implements \Doctrine\DBAL\Driver
{ {
$this->_platformMock = $platform; $this->_platformMock = $platform;
} }
} }
\ No newline at end of file
...@@ -86,5 +86,4 @@ class EntityManagerMock extends \Doctrine\ORM\EntityManager ...@@ -86,5 +86,4 @@ class EntityManagerMock extends \Doctrine\ORM\EntityManager
return parent::getIdGenerator($className); return parent::getIdGenerator($className);
} }
} }
\ No newline at end of file
...@@ -28,7 +28,8 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\StandardEntityPersist ...@@ -28,7 +28,8 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\StandardEntityPersist
return null; return null;
} }
public function setMockIdGeneratorType($genType) { public function setMockIdGeneratorType($genType)
{
$this->_mockIdGeneratorType = $genType; $this->_mockIdGeneratorType = $genType;
} }
...@@ -64,5 +65,4 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\StandardEntityPersist ...@@ -64,5 +65,4 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\StandardEntityPersist
$this->_updates = array(); $this->_updates = array();
$this->_deletes = array(); $this->_deletes = array();
} }
} }
\ No newline at end of file
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Description of Doctrine_IdentityIdGeneratorMock
*
* @author robo
*/
class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator
{ {
private $_mockPostInsertId; private $_mockPostInsertId;
...@@ -14,5 +9,4 @@ class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator ...@@ -14,5 +9,4 @@ class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator
public function setMockPostInsertId($id) { public function setMockPostInsertId($id) {
$this->_mockPostInsertId = $id; $this->_mockPostInsertId = $id;
} }
} }
\ No newline at end of file
<?php <?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Description of Doctrine_MetadataDriverMock
*
* @author robo
*/
class MetadataDriverMock class MetadataDriverMock
{ {
public function loadMetadataForClass($className, \Doctrine\ORM\Mapping\ClassMetadata $metadata) { public function loadMetadataForClass($className, \Doctrine\ORM\Mapping\ClassMetadata $metadata)
{
return; return;
} }
public function isTransient($className) {
public function isTransient($className)
{
return false; return false;
} }
} }
\ No newline at end of file
<?php <?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Description of SchemaManagerMock
*
* @author robo
*/
class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager
{ {
public function __construct(\Doctrine\DBAL\Connection $conn) { public function __construct(\Doctrine\DBAL\Connection $conn)
{
parent::__construct($conn); parent::__construct($conn);
} }
} }
\ No newline at end of file
...@@ -2,12 +2,8 @@ ...@@ -2,12 +2,8 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/** class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork
* Description of Doctrine_UnitOfWorkMock {
*
* @author robo
*/
class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork {
private $_mockDataChangeSets = array(); private $_mockDataChangeSets = array();
private $_persisterMock; private $_persisterMock;
...@@ -24,7 +20,8 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork { ...@@ -24,7 +20,8 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork {
* @param <type> $entity * @param <type> $entity
* @override * @override
*/ */
public function getEntityChangeSet($entity) { public function getEntityChangeSet($entity)
{
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
return isset($this->_mockDataChangeSets[$oid]) ? return isset($this->_mockDataChangeSets[$oid]) ?
$this->_mockDataChangeSets[$oid] : parent::getEntityChangeSet($entity); $this->_mockDataChangeSets[$oid] : parent::getEntityChangeSet($entity);
...@@ -44,7 +41,8 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork { ...@@ -44,7 +41,8 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork {
$this->_persisterMock[$entityName] = $persister; $this->_persisterMock[$entityName] = $persister;
} }
public function setDataChangeSet($entity, array $mockChangeSet) { public function setDataChangeSet($entity, array $mockChangeSet)
{
$this->_mockDataChangeSets[spl_object_hash($entity)] = $mockChangeSet; $this->_mockDataChangeSets[spl_object_hash($entity)] = $mockChangeSet;
} }
...@@ -57,5 +55,4 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork { ...@@ -57,5 +55,4 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork {
{ {
$this->_originalEntityData[spl_object_hash($entity)] = $originalData; $this->_originalEntityData[spl_object_hash($entity)] = $originalData;
} }
} }
\ No newline at end of file
<?php <?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\Models\CMS; namespace Doctrine\Tests\Models\CMS;
/** /**
* Description of CmsAddress * CmsAddress
* *
* @author robo * @author Roman S. Borschel
* @DoctrineEntity * @DoctrineEntity
* @DoctrineTable(name="cms_addresses") * @DoctrineTable(name="cms_addresses")
*/ */
...@@ -21,22 +17,25 @@ class CmsAddress ...@@ -21,22 +17,25 @@ class CmsAddress
* @DoctrineIdGenerator("auto") * @DoctrineIdGenerator("auto")
*/ */
public $id; public $id;
/** /**
* @DoctrineColumn(type="varchar", length=50) * @DoctrineColumn(type="varchar", length=50)
*/ */
public $country; public $country;
/** /**
* @DoctrineColumn(type="varchar", length=50) * @DoctrineColumn(type="varchar", length=50)
*/ */
public $zip; public $zip;
/** /**
* @DoctrineColumn(type="varchar", length=50) * @DoctrineColumn(type="varchar", length=50)
*/ */
public $city; public $city;
/** /**
* @DoctrineOneToOne(targetEntity="CmsUser") * @DoctrineOneToOne(targetEntity="CmsUser")
* @DoctrineJoinColumn(name="user_id", referencedColumnName="id") * @DoctrineJoinColumn(name="user_id", referencedColumnName="id")
*/ */
public $user; public $user;
} }
\ No newline at end of file
<?php <?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 class CompanyEmployee
{ {
#protected $id; /**
#protected $salary; * @DoctrineId
#protected $department; * @DoctrineColumn(type="integer")
* @DoctrineIdGenerator("auto")
public static function initMetadata($mapping) */
{ public $id;
// inheritance mapping
$mapping->setInheritanceType('joined', array( /**
'discriminatorColumn' => 'dtype', * @DoctrineColumn(type="double")
'discriminatorMap' => array( */
'emp' => 'CompanyEmployee', public $salary;
'man' => 'CompanyManager')
));
// register subclasses
$mapping->setSubclasses(array('CompanyManager'));
$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'
));
}
}
?> /**
\ No newline at end of file * @DoctrineColumn(type="varchar", length=255)
*/
public $department;
}
\ No newline at end of file
<?php <?php
namespace Doctrine\Tests\Models\Company;
/**
* @DoctrineEntity
*/
class CompanyManager extends CompanyEmployee class CompanyManager extends CompanyEmployee
{ {
public static function initMetadata($mapping) /*
{ * @DoctrineColumn(type="varchar", length="255")
$mapping->mapColumn(array( */
'fieldName' => 'title', public $title;
'type' => 'string' }
)); \ No newline at end of file
}
}
?>
\ No newline at end of file
...@@ -47,4 +47,4 @@ class AllTests ...@@ -47,4 +47,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_AllTests::main') { if (PHPUnit_MAIN_METHOD == 'Orm_AllTests::main') {
AllTests::main(); AllTests::main();
} }
\ No newline at end of file
...@@ -27,4 +27,4 @@ class AllTests ...@@ -27,4 +27,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_Associations_AllTests::main') { if (PHPUnit_MAIN_METHOD == 'Orm_Associations_AllTests::main') {
AllTests::main(); AllTests::main();
} }
\ 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
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Doctrine\Tests\ORM\Associations; namespace Doctrine\Tests\ORM\Associations;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase
{ {
public function testCorrectOneToOneBidirectionalMapping() public function testCorrectOneToOneBidirectionalMapping()
...@@ -23,8 +23,7 @@ class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase ...@@ -23,8 +23,7 @@ class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals('Person', $oneToOneMapping->getSourceEntityName()); $this->assertEquals('Person', $oneToOneMapping->getSourceEntityName());
$this->assertEquals('address', $oneToOneMapping->getSourceFieldName()); $this->assertEquals('address', $oneToOneMapping->getSourceFieldName());
$this->assertTrue($oneToOneMapping->isOwningSide()); $this->assertTrue($oneToOneMapping->isOwningSide());
$inverseSideMapping = array( $inverseSideMapping = array(
'fieldName' => 'person', 'fieldName' => 'person',
'sourceEntity' => 'Address', 'sourceEntity' => 'Address',
...@@ -37,7 +36,5 @@ class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase ...@@ -37,7 +36,5 @@ class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals('Address', $oneToOneMapping->getSourceEntityName()); $this->assertEquals('Address', $oneToOneMapping->getSourceEntityName());
$this->assertEquals('Person', $oneToOneMapping->getTargetEntityName()); $this->assertEquals('Person', $oneToOneMapping->getTargetEntityName());
$this->assertTrue($oneToOneMapping->isInverseSide()); $this->assertTrue($oneToOneMapping->isInverseSide());
} }
}
} \ No newline at end of file
...@@ -48,6 +48,5 @@ class CommitOrderCalculatorTest extends \Doctrine\Tests\OrmTestCase ...@@ -48,6 +48,5 @@ class CommitOrderCalculatorTest extends \Doctrine\Tests\OrmTestCase
// There is only 1 valid ordering for this constellation // There is only 1 valid ordering for this constellation
$correctOrder = array("node5", "node1", "node2", "node3", "node4"); $correctOrder = array("node5", "node1", "node2", "node3", "node4");
$this->assertSame($correctOrder, $sorted); $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 ...@@ -20,7 +20,6 @@ class AllTests
{ {
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Orm Entity Tests'); $suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Orm Entity Tests');
//$suite->addTestSuite('Orm_Entity_AccessorTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Entity\ConstructorTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Entity\ConstructorTest');
return $suite; return $suite;
......
...@@ -4,14 +4,12 @@ namespace Doctrine\Tests\ORM; ...@@ -4,14 +4,12 @@ namespace Doctrine\Tests\ORM;
require_once __DIR__ . '/../TestInit.php'; require_once __DIR__ . '/../TestInit.php';
/**
* EntityManager tests.
*/
class EntityManagerTest extends \Doctrine\Tests\OrmTestCase class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
{ {
private $_em; private $_em;
function setUp() { function setUp()
{
parent::setUp(); parent::setUp();
$this->_em = $this->_getTestEntityManager(); $this->_em = $this->_getTestEntityManager();
} }
......
...@@ -12,9 +12,6 @@ use Doctrine\Tests\Models\Forum\ForumAvatar; ...@@ -12,9 +12,6 @@ use Doctrine\Tests\Models\Forum\ForumAvatar;
require_once __DIR__ . '/../TestInit.php'; require_once __DIR__ . '/../TestInit.php';
/**
* EntityPersister tests.
*/
class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
{ {
private $_connMock; private $_connMock;
...@@ -22,7 +19,8 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase ...@@ -22,7 +19,8 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
private $_idGenMock; private $_idGenMock;
private $_uowMock; private $_uowMock;
protected function setUp() { protected function setUp()
{
parent::setUp(); parent::setUp();
$this->_connMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock()); $this->_connMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
$this->_emMock = EntityManagerMock::create($this->_connMock); $this->_emMock = EntityManagerMock::create($this->_connMock);
...@@ -32,7 +30,8 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase ...@@ -32,7 +30,8 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $this->_idGenMock); $this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $this->_idGenMock);
} }
public function testSimpleInsert() { public function testSimpleInsert()
{
$userPersister = new \Doctrine\ORM\Persisters\StandardEntityPersister( $userPersister = new \Doctrine\ORM\Persisters\StandardEntityPersister(
$this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser")); $this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser"));
$avatarPersister = new \Doctrine\ORM\Persisters\StandardEntityPersister( $avatarPersister = new \Doctrine\ORM\Persisters\StandardEntityPersister(
...@@ -46,7 +45,6 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase ...@@ -46,7 +45,6 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
'username' => array('', 'romanb'), 'username' => array('', 'romanb'),
'avatar' => array('', $user->avatar))); 'avatar' => array('', $user->avatar)));
//insert //insert
$avatarPersister->insert($user->avatar); $avatarPersister->insert($user->avatar);
$inserts = $this->_connMock->getInserts(); $inserts = $this->_connMock->getInserts();
...@@ -76,5 +74,4 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase ...@@ -76,5 +74,4 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue(isset($inserts['forum_users'][0]['dtype'])); $this->assertTrue(isset($inserts['forum_users'][0]['dtype']));
$this->assertEquals('user', $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')) { ...@@ -10,14 +10,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once __DIR__ . '/../../TestInit.php'; 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 class AllTests
{ {
public static function main() public static function main()
...@@ -37,4 +29,4 @@ class AllTests ...@@ -37,4 +29,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_Export_AllTests::main') { if (PHPUnit_MAIN_METHOD == 'Orm_Export_AllTests::main') {
AllTests::main(); AllTests::main();
} }
\ No newline at end of file
<?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.doctrine-project.org>.
*/
namespace Doctrine\Tests\ORM\Export; namespace Doctrine\Tests\ORM\Export;
...@@ -25,37 +6,24 @@ use Doctrine\ORM\Export\ClassExporter; ...@@ -25,37 +6,24 @@ use Doctrine\ORM\Export\ClassExporter;
require_once __DIR__ . '/../../TestInit.php'; 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 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; $driver = new \Doctrine\Tests\Mocks\DriverMock;
$conn = new \Doctrine\Tests\Mocks\ConnectionMock(array(), $driver); $conn = new \Doctrine\Tests\Mocks\ConnectionMock(array(), $driver);
//$conn->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SqlitePlatform());
$conn->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform()); $conn->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform());
$em = $this->_getTestEntityManager($conn); $em = $this->_getTestEntityManager($conn);
$classes = array( $classes = array(
$em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'),
$em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), $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); $exporter = new ClassExporter($em);
$sql = $exporter->getExportClassesSql($classes); $sql = $exporter->getExportClassesSql($classes);
print_r($sql); $this->assertEquals(count($sql), 8);
} }
} }
\ No newline at end of file
...@@ -21,8 +21,6 @@ class AllTests ...@@ -21,8 +21,6 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\BasicCRUDTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Functional\BasicCRUDTest');
//$suite->addTest(Orm_Functional_Ticket_AllTests::suite());
return $suite; return $suite;
} }
} }
......
...@@ -10,14 +10,10 @@ use Doctrine\Tests\Models\CMS\CmsGroup; ...@@ -10,14 +10,10 @@ use Doctrine\Tests\Models\CMS\CmsGroup;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
/** class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase
* Description of BasicCRUDTest {
* public function testBasicUnitsOfWorkWithOneToManyAssociation()
* @author robo {
*/
class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
public function testBasicUnitsOfWorkWithOneToManyAssociation() {
$em = $this->_em; $em = $this->_em;
$exporter = new ClassExporter($this->_em); $exporter = new ClassExporter($this->_em);
...@@ -73,7 +69,8 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase { ...@@ -73,7 +69,8 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
$this->assertFalse($em->getUnitOfWork()->isRegisteredRemoved($ph2)); $this->assertFalse($em->getUnitOfWork()->isRegisteredRemoved($ph2));
} }
public function testOneToManyAssociationModification() { public function testOneToManyAssociationModification()
{
$user = new CmsUser; $user = new CmsUser;
$user->name = 'Roman'; $user->name = 'Roman';
$user->username = 'romanb'; $user->username = 'romanb';
...@@ -191,5 +188,4 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase { ...@@ -191,5 +188,4 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
array())->fetchColumn(); array())->fetchColumn();
$this->assertEquals(0, $count); $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
...@@ -31,4 +31,4 @@ class AllTests ...@@ -31,4 +31,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_Hydration_AllTests::main') { if (PHPUnit_MAIN_METHOD == 'Orm_Hydration_AllTests::main') {
AllTests::main(); AllTests::main();
} }
\ No newline at end of file
...@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement; ...@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
/**
* Description of ArrayHydratorTest
*
* @author robo
*/
class ArrayHydratorTest extends HydrationTest class ArrayHydratorTest extends HydrationTest
{ {
/** /**
...@@ -663,7 +658,8 @@ class ArrayHydratorTest extends HydrationTest ...@@ -663,7 +658,8 @@ class ArrayHydratorTest extends HydrationTest
$this->assertEquals(1, count($result[1]['boards'])); $this->assertEquals(1, count($result[1]['boards']));
} }
public function testResultIteration() { public function testResultIteration()
{
// Faked query components // Faked query components
$queryComponents = array( $queryComponents = array(
'u' => array( 'u' => array(
...@@ -712,5 +708,4 @@ class ArrayHydratorTest extends HydrationTest ...@@ -712,5 +708,4 @@ class ArrayHydratorTest extends HydrationTest
++$rowNum; ++$rowNum;
} }
} }
} }
\ No newline at end of file
...@@ -4,11 +4,6 @@ namespace Doctrine\Tests\ORM\Hydration; ...@@ -4,11 +4,6 @@ namespace Doctrine\Tests\ORM\Hydration;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
/**
* Description of HydrationTest
*
* @author robo
*/
class HydrationTest extends \Doctrine\Tests\OrmTestCase class HydrationTest extends \Doctrine\Tests\OrmTestCase
{ {
protected $_em; protected $_em;
...@@ -28,5 +23,4 @@ class HydrationTest extends \Doctrine\Tests\OrmTestCase ...@@ -28,5 +23,4 @@ class HydrationTest extends \Doctrine\Tests\OrmTestCase
$parserResult->setMixedQuery($isMixedQuery); $parserResult->setMixedQuery($isMixedQuery);
return $parserResult; return $parserResult;
} }
} }
\ No newline at end of file
...@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement; ...@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
/**
* Description of ObjectHydratorTest
*
* @author robo
*/
class ObjectHydratorTest extends HydrationTest class ObjectHydratorTest extends HydrationTest
{ {
/** /**
...@@ -669,7 +664,8 @@ class ObjectHydratorTest extends HydrationTest ...@@ -669,7 +664,8 @@ class ObjectHydratorTest extends HydrationTest
} }
public function testResultIteration() { public function testResultIteration()
{
// Faked query components // Faked query components
$queryComponents = array( $queryComponents = array(
'u' => array( 'u' => array(
...@@ -728,7 +724,7 @@ class ObjectHydratorTest extends HydrationTest ...@@ -728,7 +724,7 @@ class ObjectHydratorTest extends HydrationTest
* *
* @dataProvider hydrationModeProvider * @dataProvider hydrationModeProvider
*/ */
/*public function testNewHydrationMixedQueryFetchJoinPerformance() public function testNewHydrationMixedQueryFetchJoinPerformance()
{ {
// Faked query components // Faked query components
$queryComponents = array( $queryComponents = array(
...@@ -738,20 +734,20 @@ class ObjectHydratorTest extends HydrationTest ...@@ -738,20 +734,20 @@ class ObjectHydratorTest extends HydrationTest
'relation' => null, 'relation' => null,
'map' => null, 'map' => null,
'agg' => array('0' => 'nameUpper') 'agg' => array('0' => 'nameUpper')
), ),
'p' => array( 'p' => array(
'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'), 'metadata' => $this->_em->getClassMetadata('\Doctrine\Tests\Models\CMS\CmsPhonenumber'),
'parent' => 'u', 'parent' => 'u',
'relation' => $this->_em->getClassMetadata('\Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers'), 'relation' => $this->_em->getClassMetadata('\Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers'),
'map' => null 'map' => null
) )
); );
// Faked table alias map // Faked table alias map
$tableAliasMap = array( $tableAliasMap = array(
'u' => 'u', 'u' => 'u',
'p' => 'p' 'p' => 'p'
); );
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
...@@ -761,21 +757,22 @@ class ObjectHydratorTest extends HydrationTest ...@@ -761,21 +757,22 @@ class ObjectHydratorTest extends HydrationTest
'u__status' => 'developer', 'u__status' => 'developer',
'u__0' => 'ROMANB', 'u__0' => 'ROMANB',
'p__phonenumber' => '42', 'p__phonenumber' => '42',
), ),
array( array(
'u__id' => '1', 'u__id' => '1',
'u__status' => 'developer', 'u__status' => 'developer',
'u__0' => 'ROMANB', 'u__0' => 'ROMANB',
'p__phonenumber' => '43', 'p__phonenumber' => '43',
), ),
array( array(
'u__id' => '2', 'u__id' => '2',
'u__status' => 'developer', 'u__status' => 'developer',
'u__0' => 'JWAGE', 'u__0' => 'JWAGE',
'p__phonenumber' => '91' 'p__phonenumber' => '91'
) )
); );
for ($i=4; $i<300; $i++) {
for ($i = 4; $i < 300; $i++) {
$resultSet[] = array( $resultSet[] = array(
'u__id' => $i, 'u__id' => $i,
'u__status' => 'developer', 'u__status' => 'developer',
...@@ -784,12 +781,10 @@ class ObjectHydratorTest extends HydrationTest ...@@ -784,12 +781,10 @@ class ObjectHydratorTest extends HydrationTest
); );
} }
$stmt = new Doctrine_HydratorMockStatement($resultSet); $stmt = new HydratorMockStatement($resultSet);
$hydrator = new Doctrine_ORM_Internal_Hydration_ObjectHydrator($this->_em); $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult( $result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
$queryComponents, $tableAliasMap, true)); $queryComponents, $tableAliasMap, true));
}
}*/ }
} \ No newline at end of file
...@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement; ...@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
/**
* Description of ScalarHydratorTest
*
* @author robo
*/
class ScalarHydratorTest extends HydrationTest class ScalarHydratorTest extends HydrationTest
{ {
/** /**
...@@ -59,5 +54,4 @@ class ScalarHydratorTest extends HydrationTest ...@@ -59,5 +54,4 @@ class ScalarHydratorTest extends HydrationTest
$this->assertEquals('jwage', $result[1]['u_name']); $this->assertEquals('jwage', $result[1]['u_name']);
$this->assertEquals(2, $result[1]['u_id']); $this->assertEquals(2, $result[1]['u_id']);
} }
} }
\ No newline at end of file
...@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement; ...@@ -6,11 +6,6 @@ use Doctrine\Tests\Mocks\HydratorMockStatement;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
/**
* Description of SingleScalarHydratorTest
*
* @author robo
*/
class SingleScalarHydratorTest extends HydrationTest class SingleScalarHydratorTest extends HydrationTest
{ {
/** Result set provider for the HYDRATE_SINGLE_SCALAR tests */ /** Result set provider for the HYDRATE_SINGLE_SCALAR tests */
...@@ -91,7 +86,5 @@ class SingleScalarHydratorTest extends HydrationTest ...@@ -91,7 +86,5 @@ class SingleScalarHydratorTest extends HydrationTest
$this->fail(); $this->fail();
} catch (\Doctrine\ORM\Internal\Hydration\HydrationException $ex) {} } catch (\Doctrine\ORM\Internal\Hydration\HydrationException $ex) {}
} }
} }
} }
\ No newline at end of file
...@@ -28,4 +28,4 @@ class AllTests ...@@ -28,4 +28,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_Mapping_AllTests::main') { if (PHPUnit_MAIN_METHOD == 'Orm_Mapping_AllTests::main') {
AllTests::main(); AllTests::main();
} }
\ No newline at end of file
<?php <?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\Tests\ORM\Mapping; namespace Doctrine\Tests\ORM\Mapping;
...@@ -12,14 +8,11 @@ use Doctrine\ORM\Mapping\ClassMetadata; ...@@ -12,14 +8,11 @@ use Doctrine\ORM\Mapping\ClassMetadata;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
/** class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
* Description of ClassMetadataFactoryTest {
*
* @author robo
*/
class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase {
public function testGetMetadataForSingleClass() { public function testGetMetadataForSingleClass()
{
$mockPlatform = new DatabasePlatformMock(); $mockPlatform = new DatabasePlatformMock();
$mockDriver = new MetadataDriverMock(); $mockDriver = new MetadataDriverMock();
...@@ -52,7 +45,8 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase { ...@@ -52,7 +45,8 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase {
$this->assertEquals('table', $cm1->getIdGeneratorType()); $this->assertEquals('table', $cm1->getIdGeneratorType());
} }
public function testGetMetadataForClassInHierarchy() { public function testGetMetadataForClassInHierarchy()
{
$mockPlatform = new DatabasePlatformMock(); $mockPlatform = new DatabasePlatformMock();
$mockPlatform->setPrefersIdentityColumns(true); $mockPlatform->setPrefersIdentityColumns(true);
$mockDriver = new MetadataDriverMock(); $mockDriver = new MetadataDriverMock();
...@@ -120,29 +114,39 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase { ...@@ -120,29 +114,39 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase {
} }
/* Test subject class with overriden factory method for mocking purposes */ /* 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 $_mockMetadata = array();
private $_requestedClasses = array(); private $_requestedClasses = array();
/** @override */ /** @override */
protected function _newClassMetadataInstance($className) { protected function _newClassMetadataInstance($className)
{
$this->_requestedClasses[] = $className; $this->_requestedClasses[] = $className;
if ( ! isset($this->_mockMetadata[$className])) { if ( ! isset($this->_mockMetadata[$className])) {
throw new InvalidArgumentException("No mock metadata found for class $className."); throw new InvalidArgumentException("No mock metadata found for class $className.");
} }
return $this->_mockMetadata[$className]; return $this->_mockMetadata[$className];
} }
public function setMetadataForClass($className, $metadata) {
public function setMetadataForClass($className, $metadata)
{
$this->_mockMetadata[$className] = $metadata; $this->_mockMetadata[$className] = $metadata;
} }
public function getRequestedClasses() { return $this->_requestedClasses; }
public function getRequestedClasses()
{
return $this->_requestedClasses;
}
} }
/* Test classes */ /* Test classes */
class TestEntity1 { class TestEntity1
{
protected $name; protected $name;
protected $other; protected $other;
} }
class TestEntity2 extends TestEntity1 {}
class TestEntity3 extends TestEntity2 {}
class TestEntity2 extends TestEntity1 {}
class TestEntity3 extends TestEntity2 {}
\ No newline at end of file
...@@ -8,7 +8,8 @@ require_once __DIR__ . '/../../TestInit.php'; ...@@ -8,7 +8,8 @@ require_once __DIR__ . '/../../TestInit.php';
class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
{ {
public function testClassMetadataInstanceSerialization() { public function testClassMetadataInstanceSerialization()
{
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
// Test initial state // 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 @@ ...@@ -2,22 +2,12 @@
namespace Doctrine\Tests\ORM\Query; namespace Doctrine\Tests\ORM\Query;
if (!defined('PHPUnit_MAIN_METHOD')) { if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Orm_Query_AllTests::main'); define('PHPUnit_MAIN_METHOD', 'Orm_Query_AllTests::main');
} }
require_once __DIR__ . '/../../TestInit.php'; 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 class AllTests
{ {
public static function main() public static function main()
...@@ -31,8 +21,9 @@ class AllTests ...@@ -31,8 +21,9 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\Query\IdentifierRecognitionTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Query\IdentifierRecognitionTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\SelectSqlGenerationTest'); $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_ScannerTest');
$suite->addTestSuite('Orm_Query_DqlGenerationTest'); $suite->addTestSuite('Orm_Query_DqlGenerationTest');
$suite->addTestSuite('Orm_Query_DeleteSqlGenerationTest'); $suite->addTestSuite('Orm_Query_DeleteSqlGenerationTest');
...@@ -44,4 +35,4 @@ class AllTests ...@@ -44,4 +35,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_Query_AllTests::main') { if (PHPUnit_MAIN_METHOD == 'Orm_Query_AllTests::main') {
AllTests::main(); AllTests::main();
} }
\ No newline at end of file
<?php <?php
namespace Doctrine\Tests\ORM\Query;
/* require_once __DIR__ . '/../../TestInit.php';
* $Id$
* class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
* 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
{ {
private $_em;
protected function setUp()
{
$this->_em = $this->_getTestEntityManager();
}
public function assertValidDql($dql, $debug = false) public function assertValidDql($dql, $debug = false)
{ {
try { try {
...@@ -78,147 +52,134 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase ...@@ -78,147 +52,134 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
public function testPlainFromClauseWithoutAlias() 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() 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() public function testSelectSingleComponentWithAsterisk()
{ {
$this->assertValidDql('SELECT u.* FROM CmsUser u'); $this->assertValidDql('SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u');
} }
public function testInvalidSelectSingleComponentWithAsterisk() public function testInvalidSelectSingleComponentWithAsterisk()
{ {
$this->assertInvalidDql('SELECT p.* FROM CmsUser u'); $this->assertInvalidDql('SELECT p.* FROM Doctrine\Tests\Models\CMS\CmsUser u');
} }
public function testSelectSingleComponentWithMultipleColumns() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() public function testDeleteAll()
{ {
$this->assertValidDql('DELETE FROM CmsUser'); $this->assertValidDql('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser');
} }
public function testDeleteWithCondition() public function testDeleteWithCondition()
{ {
$this->assertValidDql('DELETE FROM CmsUser WHERE id = 3'); $this->assertValidDql('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser WHERE id = 3');
}
/*
public function testDeleteWithLimit()
{
// LIMIT is not supported in DELETE
$this->assertValidDql('DELETE FROM CmsUser LIMIT 20');
} }
public function testDeleteWithLimitAndOffset()
{
// LIMIT and OFFSET are not supported in DELETE
$this->assertValidDql('DELETE FROM CmsUser LIMIT 10 OFFSET 20');
}
*/
public function testAdditionExpression() 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() 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() 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() 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() 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() public function testExpressionWithPrecedingPlusSign()
...@@ -228,78 +189,78 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase ...@@ -228,78 +189,78 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
public function testAggregateFunctionInHavingClause() 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 Doctrine\Tests\Models\CMS\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 MAX(u.name) = 'zYne'");
} }
public function testMultipleAggregateFunctionsInHavingClause() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() public function testSubselectInInExpression()
...@@ -315,12 +276,12 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase ...@@ -315,12 +276,12 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
*/ */
public function testPositionalInputParameter() 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() 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() public function testCustomJoinsAndWithKeywordSupported()
...@@ -332,32 +293,32 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase ...@@ -332,32 +293,32 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
public function testJoinConditionsSupported() 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() 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() 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() 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() 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() 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() /* public function testAllExpressionWithCorrelatedSubquery()
...@@ -380,17 +341,17 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase ...@@ -380,17 +341,17 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
*/ */
public function testLikeExpression() 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() 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() 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 ...@@ -403,7 +364,7 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
*/ */
public function testImplicitJoinWithCartesianProductAndConditionInWhere() 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() public function testImplicitJoinInWhereOnSingleValuedAssociationPathExpression()
...@@ -416,24 +377,23 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase ...@@ -416,24 +377,23 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
public function testImplicitJoinInWhereOnCollectionValuedPathExpression() public function testImplicitJoinInWhereOnCollectionValuedPathExpression()
{ {
// This should be forbidden, because articles is a collection // 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() public function testInvalidSyntaxIsRejected()
{ {
$this->assertInvalidDql("FOOBAR CmsUser"); $this->assertInvalidDql("FOOBAR CmsUser");
$this->assertInvalidDql("DELETE FROM CmsUser.articles"); $this->assertInvalidDql("DELETE FROM Doctrine\Tests\Models\CMS\CmsUser.articles");
$this->assertInvalidDql("DELETE FROM CmsUser cu WHERE cu.articles.id > ?"); $this->assertInvalidDql("DELETE FROM Doctrine\Tests\Models\CMS\CmsUser cu WHERE cu.articles.id > ?");
$this->assertInvalidDql("SELECT user FROM CmsUser user"); $this->assertInvalidDql("SELECT user FROM Doctrine\Tests\Models\CMS\CmsUser user");
// Error message here is: Relation 'comments' does not exist in component 'CmsUser' // Error message here is: Relation 'comments' does not exist in component 'CmsUser'
// This means it is intepreted as: // This means it is intepreted as:
// SELECT u.* FROM CmsUser u JOIN u.articles JOIN u.comments // SELECT u.* FROM CmsUser u JOIN u.articles JOIN u.comments
// This seems wrong. "JOIN u.articles.comments" should not be allowed. // 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 // Currently UNDEFINED OFFSET error
//$this->assertInvalidDql("SELECT * FROM CmsUser.articles.comments"); //$this->assertInvalidDql("SELECT * FROM CmsUser.articles.comments");
} }
}
} \ No newline at end of file
<?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.doctrine-project.org>.
*/
namespace Doctrine\Tests\ORM\Query; namespace Doctrine\Tests\ORM\Query;
require_once __DIR__ . '/../../TestInit.php'; 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 class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{ {
private $_em; private $_em;
protected function setUp() { protected function setUp()
{
$this->_em = $this->_getTestEntityManager(); $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