1
0
Fork 0
mirror of synced 2025-03-30 11:40:15 +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. * Sets field as primary key.
* *
* @return AssociationBuilder * @return self
*/ */
public function isPrimaryKey() public function isPrimaryKey()
{ {
$this->mapping['id'] = true; $this->mapping['id'] = true;
return $this; return $this;
} }

View file

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

View file

@ -335,62 +335,68 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testCreateManyToOneWithIdentity() public function testCreateManyToOneWithIdentity()
{ {
$this->assertIsFluent( $this->assertIsFluent(
$this->builder->createManyToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') $this
->addJoinColumn('group_id', 'id', true, false, 'CASCADE') ->builder
->cascadeAll() ->createManyToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
->fetchExtraLazy() ->addJoinColumn('group_id', 'id', true, false, 'CASCADE')
->isPrimaryKey() ->cascadeAll()
->build() ->fetchExtraLazy()
->isPrimaryKey()
->build()
); );
$this->assertEquals(array('groups' => array ( $this->assertEquals(
'fieldName' => 'groups', array(
'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', 'groups' => array(
'cascade' => array ( 'fieldName' => 'groups',
0 => 'remove', 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup',
1 => 'persist', 'cascade' => array(
2 => 'refresh', 0 => 'remove',
3 => 'merge', 1 => 'persist',
4 => 'detach', 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 ( $this->cm->associationMappings
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);
} }
public function testCreateOneToOne() public function testCreateOneToOne()
@ -455,73 +461,81 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testCreateOneToOneWithIdentity() public function testCreateOneToOneWithIdentity()
{ {
$this->assertIsFluent( $this->assertIsFluent(
$this->builder->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') $this
->addJoinColumn('group_id', 'id', true, false, 'CASCADE') ->builder
->cascadeAll() ->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
->fetchExtraLazy() ->addJoinColumn('group_id', 'id', true, false, 'CASCADE')
->isPrimaryKey() ->cascadeAll()
->build() ->fetchExtraLazy()
->isPrimaryKey()
->build()
); );
$this->assertEquals(array('groups' => array ( $this->assertEquals(
'fieldName' => 'groups', array(
'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', 'groups' => array(
'cascade' => array ( 'fieldName' => 'groups',
0 => 'remove', 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup',
1 => 'persist', 'cascade' => array(
2 => 'refresh', 0 => 'remove',
3 => 'merge', 1 => 'persist',
4 => 'detach', 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, $this->cm->associationMappings
'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);
} }
public function testThrowsExceptionOnCreateOneToOneWithIdentityOnInverseSide() public function testThrowsExceptionOnCreateOneToOneWithIdentityOnInverseSide()
{ {
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
$this->builder->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') $this
->mappedBy('test') ->builder
->fetchExtraLazy() ->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
->isPrimaryKey() ->mappedBy('test')
->build(); ->fetchExtraLazy()
->isPrimaryKey()
->build();
} }
public function testCreateManyToMany() public function testCreateManyToMany()