1
0
mirror of synced 2024-12-05 03:06:05 +03:00

#1229 - code style fixes (alignment/spacing)

This commit is contained in:
Marco Pivetta 2015-02-16 02:06:22 +00:00
parent baeab5d4f4
commit 1f67218dc5
3 changed files with 128 additions and 113 deletions

View File

@ -186,11 +186,12 @@ class AssociationBuilder
/**
* Sets field as primary key.
*
* @return AssociationBuilder
* @return self
*/
public function isPrimaryKey()
{
$this->mapping['id'] = true;
return $this;
}

View File

@ -1461,7 +1461,7 @@ class ClassMetadataInfo implements ClassMetadata
}
if ( ! in_array($mapping['fieldName'], $this->identifier)) {
if (!isset($mapping['joinColumns'])) {
if (! isset($mapping['joinColumns'])) {
throw MappingException::illegalInverseIdentifierAssociation($this->name, $mapping['fieldName']);
}

View File

@ -335,62 +335,68 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testCreateManyToOneWithIdentity()
{
$this->assertIsFluent(
$this->builder->createManyToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
->addJoinColumn('group_id', 'id', true, false, 'CASCADE')
->cascadeAll()
->fetchExtraLazy()
->isPrimaryKey()
->build()
$this
->builder
->createManyToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
->addJoinColumn('group_id', 'id', true, false, 'CASCADE')
->cascadeAll()
->fetchExtraLazy()
->isPrimaryKey()
->build()
);
$this->assertEquals(array('groups' => array (
'fieldName' => 'groups',
'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup',
'cascade' => array (
0 => 'remove',
1 => 'persist',
2 => 'refresh',
3 => 'merge',
4 => 'detach',
$this->assertEquals(
array(
'groups' => array(
'fieldName' => 'groups',
'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup',
'cascade' => array(
0 => 'remove',
1 => 'persist',
2 => 'refresh',
3 => 'merge',
4 => 'detach',
),
'fetch' => 4,
'joinColumns' => array(
0 =>
array(
'name' => 'group_id',
'referencedColumnName' => 'id',
'nullable' => true,
'unique' => false,
'onDelete' => 'CASCADE',
'columnDefinition' => NULL,
),
),
'type' => 2,
'mappedBy' => NULL,
'inversedBy' => NULL,
'isOwningSide' => true,
'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser',
'isCascadeRemove' => true,
'isCascadePersist' => true,
'isCascadeRefresh' => true,
'isCascadeMerge' => true,
'isCascadeDetach' => true,
'sourceToTargetKeyColumns' =>
array(
'group_id' => 'id',
),
'joinColumnFieldNames' =>
array(
'group_id' => 'group_id',
),
'targetToSourceKeyColumns' =>
array(
'id' => 'group_id',
),
'orphanRemoval' => false,
'id' => true
),
'fetch' => 4,
'joinColumns' => array (
0 =>
array (
'name' => 'group_id',
'referencedColumnName' => 'id',
'nullable' => true,
'unique' => false,
'onDelete' => 'CASCADE',
'columnDefinition' => NULL,
),
),
'type' => 2,
'mappedBy' => NULL,
'inversedBy' => NULL,
'isOwningSide' => true,
'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser',
'isCascadeRemove' => true,
'isCascadePersist' => true,
'isCascadeRefresh' => true,
'isCascadeMerge' => true,
'isCascadeDetach' => true,
'sourceToTargetKeyColumns' =>
array (
'group_id' => 'id',
),
'joinColumnFieldNames' =>
array (
'group_id' => 'group_id',
),
'targetToSourceKeyColumns' =>
array (
'id' => 'group_id',
),
'orphanRemoval' => false,
'id' => true
),
), $this->cm->associationMappings);
),
$this->cm->associationMappings
);
}
public function testCreateOneToOne()
@ -455,73 +461,81 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testCreateOneToOneWithIdentity()
{
$this->assertIsFluent(
$this->builder->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
->addJoinColumn('group_id', 'id', true, false, 'CASCADE')
->cascadeAll()
->fetchExtraLazy()
->isPrimaryKey()
->build()
$this
->builder
->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
->addJoinColumn('group_id', 'id', true, false, 'CASCADE')
->cascadeAll()
->fetchExtraLazy()
->isPrimaryKey()
->build()
);
$this->assertEquals(array('groups' => array (
'fieldName' => 'groups',
'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup',
'cascade' => array (
0 => 'remove',
1 => 'persist',
2 => 'refresh',
3 => 'merge',
4 => 'detach',
$this->assertEquals(
array(
'groups' => array(
'fieldName' => 'groups',
'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup',
'cascade' => array(
0 => 'remove',
1 => 'persist',
2 => 'refresh',
3 => 'merge',
4 => 'detach',
),
'fetch' => 4,
'id' => true,
'joinColumns' => array(
0 =>
array(
'name' => 'group_id',
'referencedColumnName' => 'id',
'nullable' => true,
'unique' => false,
'onDelete' => 'CASCADE',
'columnDefinition' => NULL,
),
),
'type' => 1,
'mappedBy' => NULL,
'inversedBy' => NULL,
'isOwningSide' => true,
'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser',
'isCascadeRemove' => true,
'isCascadePersist' => true,
'isCascadeRefresh' => true,
'isCascadeMerge' => true,
'isCascadeDetach' => true,
'sourceToTargetKeyColumns' =>
array(
'group_id' => 'id',
),
'joinColumnFieldNames' =>
array(
'group_id' => 'group_id',
),
'targetToSourceKeyColumns' =>
array(
'id' => 'group_id',
),
'orphanRemoval' => false
),
'fetch' => 4,
'id' => true,
'joinColumns' => array (
0 =>
array (
'name' => 'group_id',
'referencedColumnName' => 'id',
'nullable' => true,
'unique' => false,
'onDelete' => 'CASCADE',
'columnDefinition' => NULL,
),
),
'type' => 1,
'mappedBy' => NULL,
'inversedBy' => NULL,
'isOwningSide' => true,
'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser',
'isCascadeRemove' => true,
'isCascadePersist' => true,
'isCascadeRefresh' => true,
'isCascadeMerge' => true,
'isCascadeDetach' => true,
'sourceToTargetKeyColumns' =>
array (
'group_id' => 'id',
),
'joinColumnFieldNames' =>
array (
'group_id' => 'group_id',
),
'targetToSourceKeyColumns' =>
array (
'id' => 'group_id',
),
'orphanRemoval' => false
),
), $this->cm->associationMappings);
),
$this->cm->associationMappings
);
}
public function testThrowsExceptionOnCreateOneToOneWithIdentityOnInverseSide()
{
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
$this->builder->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
->mappedBy('test')
->fetchExtraLazy()
->isPrimaryKey()
->build();
$this
->builder
->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
->mappedBy('test')
->fetchExtraLazy()
->isPrimaryKey()
->build();
}
public function testCreateManyToMany()