|
|
@ -13,6 +13,7 @@ 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');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
// Test initial state
|
|
|
|
// Test initial state
|
|
|
|
$this->assertTrue(count($cm->getReflectionProperties()) == 0);
|
|
|
|
$this->assertTrue(count($cm->getReflectionProperties()) == 0);
|
|
|
@ -61,6 +62,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testFieldIsNullable()
|
|
|
|
public function testFieldIsNullable()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
// Explicit Nullable
|
|
|
|
// Explicit Nullable
|
|
|
|
$cm->mapField(array('fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50));
|
|
|
|
$cm->mapField(array('fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50));
|
|
|
@ -83,6 +85,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php";
|
|
|
|
require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php";
|
|
|
|
|
|
|
|
|
|
|
|
$cm = new ClassMetadata('DoctrineGlobal_Article');
|
|
|
|
$cm = new ClassMetadata('DoctrineGlobal_Article');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
$cm->mapManyToMany(array(
|
|
|
|
$cm->mapManyToMany(array(
|
|
|
|
'fieldName' => 'author',
|
|
|
|
'fieldName' => 'author',
|
|
|
|
'targetEntity' => 'DoctrineGlobal_User',
|
|
|
|
'targetEntity' => 'DoctrineGlobal_User',
|
|
|
@ -99,6 +102,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testMapManyToManyJoinTableDefaults()
|
|
|
|
public function testMapManyToManyJoinTableDefaults()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
$cm->mapManyToMany(
|
|
|
|
$cm->mapManyToMany(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'fieldName' => 'groups',
|
|
|
|
'fieldName' => 'groups',
|
|
|
@ -118,6 +122,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testSerializeManyToManyJoinTableCascade()
|
|
|
|
public function testSerializeManyToManyJoinTableCascade()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
$cm->mapManyToMany(
|
|
|
|
$cm->mapManyToMany(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'fieldName' => 'groups',
|
|
|
|
'fieldName' => 'groups',
|
|
|
@ -139,6 +144,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php";
|
|
|
|
require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php";
|
|
|
|
|
|
|
|
|
|
|
|
$cm = new ClassMetadata('DoctrineGlobal_User');
|
|
|
|
$cm = new ClassMetadata('DoctrineGlobal_User');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
$cm->setDiscriminatorMap(array('descr' => 'DoctrineGlobal_Article', 'foo' => 'DoctrineGlobal_User'));
|
|
|
|
$cm->setDiscriminatorMap(array('descr' => 'DoctrineGlobal_Article', 'foo' => 'DoctrineGlobal_User'));
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals("DoctrineGlobal_Article", $cm->discriminatorMap['descr']);
|
|
|
|
$this->assertEquals("DoctrineGlobal_Article", $cm->discriminatorMap['descr']);
|
|
|
@ -153,6 +159,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php";
|
|
|
|
require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php";
|
|
|
|
|
|
|
|
|
|
|
|
$cm = new ClassMetadata('DoctrineGlobal_User');
|
|
|
|
$cm = new ClassMetadata('DoctrineGlobal_User');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
$cm->setSubclasses(array('DoctrineGlobal_Article'));
|
|
|
|
$cm->setSubclasses(array('DoctrineGlobal_Article'));
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals("DoctrineGlobal_Article", $cm->subClasses[0]);
|
|
|
|
$this->assertEquals("DoctrineGlobal_Article", $cm->subClasses[0]);
|
|
|
@ -168,6 +175,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
$field['type'] = 'string';
|
|
|
|
$field['type'] = 'string';
|
|
|
|
|
|
|
|
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
$cm->setVersionMapping($field);
|
|
|
|
$cm->setVersionMapping($field);
|
|
|
@ -176,6 +184,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testGetSingleIdentifierFieldName_MultipleIdentifierEntity_ThrowsException()
|
|
|
|
public function testGetSingleIdentifierFieldName_MultipleIdentifierEntity_ThrowsException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
$cm->isIdentifierComposite = true;
|
|
|
|
$cm->isIdentifierComposite = true;
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
@ -185,6 +194,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testDuplicateAssociationMappingException()
|
|
|
|
public function testDuplicateAssociationMappingException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$a1 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo');
|
|
|
|
$a1 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo');
|
|
|
|
$a2 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo');
|
|
|
|
$a2 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo');
|
|
|
|
|
|
|
|
|
|
|
@ -196,6 +207,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testDuplicateColumnName_ThrowsMappingException()
|
|
|
|
public function testDuplicateColumnName_ThrowsMappingException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->mapField(array('fieldName' => 'name', 'columnName' => 'name'));
|
|
|
|
$cm->mapField(array('fieldName' => 'name', 'columnName' => 'name'));
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
@ -205,6 +218,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testDuplicateColumnName_DiscriminatorColumn_ThrowsMappingException()
|
|
|
|
public function testDuplicateColumnName_DiscriminatorColumn_ThrowsMappingException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->mapField(array('fieldName' => 'name', 'columnName' => 'name'));
|
|
|
|
$cm->mapField(array('fieldName' => 'name', 'columnName' => 'name'));
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
@ -214,6 +229,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testDuplicateColumnName_DiscriminatorColumn2_ThrowsMappingException()
|
|
|
|
public function testDuplicateColumnName_DiscriminatorColumn2_ThrowsMappingException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->setDiscriminatorColumn(array('name' => 'name'));
|
|
|
|
$cm->setDiscriminatorColumn(array('name' => 'name'));
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
@ -223,6 +240,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testDuplicateFieldAndAssocationMapping1_ThrowsException()
|
|
|
|
public function testDuplicateFieldAndAssocationMapping1_ThrowsException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->mapField(array('fieldName' => 'name', 'columnName' => 'name'));
|
|
|
|
$cm->mapField(array('fieldName' => 'name', 'columnName' => 'name'));
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
@ -232,6 +251,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testDuplicateFieldAndAssocationMapping2_ThrowsException()
|
|
|
|
public function testDuplicateFieldAndAssocationMapping2_ThrowsException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser'));
|
|
|
|
$cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser'));
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
@ -244,6 +265,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testGetTemporaryTableNameSchema()
|
|
|
|
public function testGetTemporaryTableNameSchema()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->setTableName('foo.bar');
|
|
|
|
$cm->setTableName('foo.bar');
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('foo_bar_id_tmp', $cm->getTemporaryIdTableName());
|
|
|
|
$this->assertEquals('foo_bar_id_tmp', $cm->getTemporaryIdTableName());
|
|
|
@ -252,6 +275,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testDefaultTableName()
|
|
|
|
public function testDefaultTableName()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
// When table's name is not given
|
|
|
|
// When table's name is not given
|
|
|
|
$primaryTable = array();
|
|
|
|
$primaryTable = array();
|
|
|
@ -261,6 +285,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
$this->assertEquals('CmsUser', $cm->table['name']);
|
|
|
|
$this->assertEquals('CmsUser', $cm->table['name']);
|
|
|
|
|
|
|
|
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
// When joinTable's name is not given
|
|
|
|
// When joinTable's name is not given
|
|
|
|
$cm->mapManyToMany(array(
|
|
|
|
$cm->mapManyToMany(array(
|
|
|
|
'fieldName' => 'user',
|
|
|
|
'fieldName' => 'user',
|
|
|
@ -274,6 +299,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testDefaultJoinColumnName()
|
|
|
|
public function testDefaultJoinColumnName()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
// this is really dirty, but it's the simpliest way to test whether
|
|
|
|
// this is really dirty, but it's the simpliest way to test whether
|
|
|
|
// joinColumn's name will be automatically set to user_id
|
|
|
|
// joinColumn's name will be automatically set to user_id
|
|
|
|
$cm->mapOneToOne(array(
|
|
|
|
$cm->mapOneToOne(array(
|
|
|
@ -283,6 +310,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
$this->assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']);
|
|
|
|
$this->assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']);
|
|
|
|
|
|
|
|
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
$cm->mapManyToMany(array(
|
|
|
|
$cm->mapManyToMany(array(
|
|
|
|
'fieldName' => 'user',
|
|
|
|
'fieldName' => 'user',
|
|
|
|
'targetEntity' => 'CmsUser',
|
|
|
|
'targetEntity' => 'CmsUser',
|
|
|
@ -300,6 +328,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testSetMultipleIdentifierSetsComposite()
|
|
|
|
public function testSetMultipleIdentifierSetsComposite()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->mapField(array('fieldName' => 'name'));
|
|
|
|
$cm->mapField(array('fieldName' => 'name'));
|
|
|
|
$cm->mapField(array('fieldName' => 'username'));
|
|
|
|
$cm->mapField(array('fieldName' => 'username'));
|
|
|
|
|
|
|
|
|
|
|
@ -313,6 +343,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testMappingNotFound()
|
|
|
|
public function testMappingNotFound()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "No mapping found for field 'foo' on class 'Doctrine\Tests\Models\CMS\CmsUser'.");
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "No mapping found for field 'foo' on class 'Doctrine\Tests\Models\CMS\CmsUser'.");
|
|
|
|
$cm->getFieldMapping('foo');
|
|
|
|
$cm->getFieldMapping('foo');
|
|
|
@ -324,6 +355,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testJoinTableMappingDefaults()
|
|
|
|
public function testJoinTableMappingDefaults()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('DoctrineGlobal_Article');
|
|
|
|
$cm = new ClassMetadata('DoctrineGlobal_Article');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->mapManyToMany(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\Tests\Models\CMS\CmsUser'));
|
|
|
|
$cm->mapManyToMany(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\Tests\Models\CMS\CmsUser'));
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('doctrineglobal_article_cmsuser', $cm->associationMappings['author']['joinTable']['name']);
|
|
|
|
$this->assertEquals('doctrineglobal_article_cmsuser', $cm->associationMappings['author']['joinTable']['name']);
|
|
|
@ -335,6 +368,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testMapIdentifierAssociation()
|
|
|
|
public function testMapIdentifierAssociation()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->mapOneToOne(array(
|
|
|
|
$cm->mapOneToOne(array(
|
|
|
|
'fieldName' => 'article',
|
|
|
|
'fieldName' => 'article',
|
|
|
|
'id' => true,
|
|
|
|
'id' => true,
|
|
|
@ -352,6 +387,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testOrphanRemovalIdentifierAssociation()
|
|
|
|
public function testOrphanRemovalIdentifierAssociation()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'The orphan removal option is not allowed on an association that');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'The orphan removal option is not allowed on an association that');
|
|
|
|
$cm->mapOneToOne(array(
|
|
|
|
$cm->mapOneToOne(array(
|
|
|
@ -369,6 +405,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testInverseIdentifierAssocation()
|
|
|
|
public function testInverseIdentifierAssocation()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'An inverse association is not allowed to be identifier in');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'An inverse association is not allowed to be identifier in');
|
|
|
|
$cm->mapOneToOne(array(
|
|
|
|
$cm->mapOneToOne(array(
|
|
|
@ -386,6 +424,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testIdentifierAssocationManyToMany()
|
|
|
|
public function testIdentifierAssocationManyToMany()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'Many-to-many or one-to-many associations are not allowed to be identifier in');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'Many-to-many or one-to-many associations are not allowed to be identifier in');
|
|
|
|
$cm->mapManyToMany(array(
|
|
|
|
$cm->mapManyToMany(array(
|
|
|
@ -404,12 +444,16 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException',
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException',
|
|
|
|
"The field or association mapping misses the 'fieldName' attribute in entity 'Doctrine\Tests\Models\CMS\CmsUser'.");
|
|
|
|
"The field or association mapping misses the 'fieldName' attribute in entity 'Doctrine\Tests\Models\CMS\CmsUser'.");
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$cm->mapField(array('fieldName' => ''));
|
|
|
|
$cm->mapField(array('fieldName' => ''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testRetrievalOfNamedQueries()
|
|
|
|
public function testRetrievalOfNamedQueries()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(0, count($cm->getNamedQueries()));
|
|
|
|
$this->assertEquals(0, count($cm->getNamedQueries()));
|
|
|
|
|
|
|
|
|
|
|
@ -424,6 +468,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testExistanceOfNamedQuery()
|
|
|
|
public function testExistanceOfNamedQuery()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cm->addNamedQuery(array(
|
|
|
|
$cm->addNamedQuery(array(
|
|
|
|
'name' => 'all',
|
|
|
|
'name' => 'all',
|
|
|
@ -437,6 +483,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testRetrieveOfNamedQuery()
|
|
|
|
public function testRetrieveOfNamedQuery()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cm->addNamedQuery(array(
|
|
|
|
$cm->addNamedQuery(array(
|
|
|
|
'name' => 'userById',
|
|
|
|
'name' => 'userById',
|
|
|
@ -449,6 +497,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testNamingCollisionNamedQueryShouldThrowException()
|
|
|
|
public function testNamingCollisionNamedQueryShouldThrowException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
|
|
|
|
|
|
|
|
|
@ -470,6 +520,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$user = new \Doctrine\Tests\Models\CMS\CmsUser();
|
|
|
|
$user = new \Doctrine\Tests\Models\CMS\CmsUser();
|
|
|
|
$cm = new ClassMetadata('DOCTRINE\TESTS\MODELS\CMS\CMSUSER');
|
|
|
|
$cm = new ClassMetadata('DOCTRINE\TESTS\MODELS\CMS\CMSUSER');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name);
|
|
|
|
$this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -479,6 +531,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testLifecycleCallbackNotFound()
|
|
|
|
public function testLifecycleCallbackNotFound()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "Entity 'Doctrine\Tests\Models\CMS\CmsUser' has no method 'notfound' to be registered as lifecycle callback.");
|
|
|
|
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "Entity 'Doctrine\Tests\Models\CMS\CmsUser' has no method 'notfound' to be registered as lifecycle callback.");
|
|
|
|
$cm->addLifecycleCallback('notfound', 'postLoad');
|
|
|
|
$cm->addLifecycleCallback('notfound', 'postLoad');
|
|
|
@ -490,6 +544,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
public function testTargetEntityNotFound()
|
|
|
|
public function testTargetEntityNotFound()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
|
|
|
|
|
|
|
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "The target-entity Doctrine\Tests\Models\CMS\UnknownClass cannot be found in 'Doctrine\Tests\Models\CMS\CmsUser#address'.");
|
|
|
|
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "The target-entity Doctrine\Tests\Models\CMS\UnknownClass cannot be found in 'Doctrine\Tests\Models\CMS\CmsUser#address'.");
|
|
|
|
$cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass'));
|
|
|
|
$cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass'));
|
|
|
|