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)
......@@ -68,5 +59,4 @@ 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()
......@@ -27,8 +23,6 @@ class AllTests
$suite = new \Doctrine\Tests\DbalTestSuite('Doctrine DBAL');
$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;
......@@ -71,5 +72,4 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
$this->_inserts = array();
$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
......@@ -14,5 +14,4 @@ class DriverConnectionMock implements \Doctrine\DBAL\Driver\Connection
public function rollBack() {}
public function errorCode() {}
public function errorInfo() {}
}
}
\ No newline at end of file
......@@ -48,5 +48,4 @@ class DriverMock implements \Doctrine\DBAL\Driver
{
$this->_platformMock = $platform;
}
}
}
\ No newline at end of file
......@@ -86,5 +86,4 @@ 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;
}
......@@ -64,5 +65,4 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\StandardEntityPersist
$this->_updates = array();
$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;
......@@ -14,5 +9,4 @@ class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator
public function setMockPostInsertId($id) {
$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;
}
......@@ -57,5 +55,4 @@ 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'));
$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'
));
}
}
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineIdGenerator("auto")
*/
public $id;
/**
* @DoctrineColumn(type="double")
*/
public $salary;
?>
\ No newline at end of file
/**
* @DoctrineColumn(type="varchar", length=255)
*/
public $department;
}
\ 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'
));
}
}
?>
\ No newline at end of file
/*
* @DoctrineColumn(type="varchar", length="255")
*/
public $title;
}
\ No newline at end of file
......@@ -47,4 +47,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_AllTests::main') {
AllTests::main();
}
}
\ No newline at end of file
......@@ -27,4 +27,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_Associations_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 @@
namespace Doctrine\Tests\ORM\Associations;
require_once __DIR__ . '/../../TestInit.php';
class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase
{
public function testCorrectOneToOneBidirectionalMapping()
......@@ -23,8 +23,7 @@ class OneToOneMappingTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals('Person', $oneToOneMapping->getSourceEntityName());
$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()
......@@ -37,4 +29,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_Export_AllTests::main') {
AllTests::main();
}
}
\ 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\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';
......@@ -191,5 +188,4 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
array())->fetchColumn();
$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
if (PHPUnit_MAIN_METHOD == 'Orm_Hydration_AllTests::main') {
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(
......@@ -712,5 +708,4 @@ class ArrayHydratorTest extends HydrationTest
++$rowNum;
}
}
}
}
\ 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;
......@@ -28,5 +23,4 @@ class HydrationTest extends \Doctrine\Tests\OrmTestCase
$parserResult->setMixedQuery($isMixedQuery);
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(
......@@ -738,20 +734,20 @@ class ObjectHydratorTest extends HydrationTest
'relation' => null,
'map' => null,
'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
)
);
)
);
// Faked table alias map
$tableAliasMap = array(
'u' => 'u',
'p' => 'p'
);
);
// Faked result set
$resultSet = array(
......@@ -761,21 +757,22 @@ class ObjectHydratorTest extends HydrationTest
'u__status' => 'developer',
'u__0' => 'ROMANB',
'p__phonenumber' => '42',
),
),
array(
'u__id' => '1',
'u__status' => 'developer',
'u__0' => 'ROMANB',
'p__phonenumber' => '43',
),
),
array(
'u__id' => '2',
'u__status' => 'developer',
'u__0' => 'JWAGE',
'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
{
/**
......@@ -59,5 +54,4 @@ class ScalarHydratorTest extends HydrationTest
$this->assertEquals('jwage', $result[1]['u_name']);
$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
......@@ -28,4 +28,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_Mapping_AllTests::main') {
AllTests::main();
}
}
\ 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 {}
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');
......@@ -44,4 +35,4 @@ class AllTests
if (PHPUnit_MAIN_METHOD == 'Orm_Query_AllTests::main') {
AllTests::main();
}
}
\ 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