[DDC-3461] Renamed AssocationBuilder::isPrimaryKey() to makePrimaryKey(). Same for FieldBuilder and depreceating isPrimaryKey(). Adjust tests. Revert change in ClassMetadataInfo and fix bug.
This commit is contained in:
parent
df8be6f31e
commit
b3a6fb7fde
@ -188,7 +188,7 @@ class AssociationBuilder
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function isPrimaryKey()
|
||||
public function makePrimaryKey()
|
||||
{
|
||||
$this->mapping['id'] = true;
|
||||
|
||||
|
@ -145,9 +145,20 @@ class FieldBuilder
|
||||
/**
|
||||
* Sets field as primary key.
|
||||
*
|
||||
* @deprecated Use makePrimaryKey() instead
|
||||
* @return FieldBuilder
|
||||
*/
|
||||
public function isPrimaryKey()
|
||||
{
|
||||
return $this->makePrimaryKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets field as primary key.
|
||||
*
|
||||
* @return FieldBuilder
|
||||
*/
|
||||
public function makePrimaryKey()
|
||||
{
|
||||
$this->mapping['id'] = true;
|
||||
return $this;
|
||||
|
@ -1462,11 +1462,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
}
|
||||
|
||||
if ( ! in_array($mapping['fieldName'], $this->identifier)) {
|
||||
if (! isset($mapping['joinColumns'])) {
|
||||
throw MappingException::illegalInverseIdentifierAssociation($this->name, $mapping['fieldName']);
|
||||
}
|
||||
|
||||
if (count($mapping['joinColumns']) >= 2) {
|
||||
if (isset($mapping['joinColumns']) && count($mapping['joinColumns']) >= 2) {
|
||||
throw MappingException::cannotMapCompositePrimaryKeyEntitiesAsForeignId(
|
||||
$mapping['targetEntity'], $this->name, $mapping['fieldName']
|
||||
);
|
||||
|
@ -253,7 +253,7 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
public function testCreatePrimaryField()
|
||||
{
|
||||
$this->builder->createField('id', 'integer')->isPrimaryKey()->generatedValue()->build();
|
||||
$this->builder->createField('id', 'integer')->makePrimaryKey()->generatedValue()->build();
|
||||
|
||||
$this->assertEquals(array('id'), $this->cm->identifier);
|
||||
$this->assertEquals(array('columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'), $this->cm->fieldMappings['id']);
|
||||
@ -341,7 +341,7 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
|
||||
->addJoinColumn('group_id', 'id', true, false, 'CASCADE')
|
||||
->cascadeAll()
|
||||
->fetchExtraLazy()
|
||||
->isPrimaryKey()
|
||||
->makePrimaryKey()
|
||||
->build()
|
||||
);
|
||||
|
||||
@ -467,7 +467,7 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
|
||||
->addJoinColumn('group_id', 'id', true, false, 'CASCADE')
|
||||
->cascadeAll()
|
||||
->fetchExtraLazy()
|
||||
->isPrimaryKey()
|
||||
->makePrimaryKey()
|
||||
->build()
|
||||
);
|
||||
|
||||
@ -534,7 +534,7 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
|
||||
->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
|
||||
->mappedBy('test')
|
||||
->fetchExtraLazy()
|
||||
->isPrimaryKey()
|
||||
->makePrimaryKey()
|
||||
->build();
|
||||
}
|
||||
|
||||
@ -626,7 +626,7 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
||||
|
||||
$this->builder->createManyToMany('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
|
||||
->isPrimaryKey()
|
||||
->makePrimaryKey()
|
||||
->setJoinTable('groups_users')
|
||||
->addJoinColumn('group_id', 'id', true, false, 'CASCADE')
|
||||
->addInverseJoinColumn('user_id', 'id')
|
||||
@ -679,7 +679,7 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
||||
|
||||
$this->builder->createOneToMany('groups', 'Doctrine\Tests\Models\CMS\CmsGroup')
|
||||
->isPrimaryKey()
|
||||
->makePrimaryKey()
|
||||
->mappedBy('test')
|
||||
->setOrderBy(array('test'))
|
||||
->setIndexBy('test')
|
||||
|
@ -24,3 +24,4 @@ if ( ! file_exists(__DIR__ . '/Proxies') && ! mkdir(__DIR__ . '/Proxies')) {
|
||||
if ( ! file_exists(__DIR__ . '/ORM/Proxy/generated') && ! mkdir(__DIR__ . '/ORM/Proxy/generated')) {
|
||||
throw new \Exception('Could not create ' . __DIR__ . '/ORM/Proxy/generated Folder.');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user