From 1f67218dc56335dca43cce43ed85c5ba315318e1 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 16 Feb 2015 02:06:22 +0000 Subject: [PATCH] #1229 - code style fixes (alignment/spacing) --- .../Mapping/Builder/AssociationBuilder.php | 3 +- .../ORM/Mapping/ClassMetadataInfo.php | 2 +- .../ORM/Mapping/ClassMetadataBuilderTest.php | 236 ++++++++++-------- 3 files changed, 128 insertions(+), 113 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php index 2536f5be6..9a9c4dabe 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php @@ -186,11 +186,12 @@ class AssociationBuilder /** * Sets field as primary key. * - * @return AssociationBuilder + * @return self */ public function isPrimaryKey() { $this->mapping['id'] = true; + return $this; } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index a93f46a74..51791af0d 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -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']); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index e05382202..f82079481 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -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()