[DDC-1872] add tests to evaluate annotations overrides with traits
This commit is contained in:
parent
04e6cc78cd
commit
8742377c3b
@ -215,6 +215,19 @@ class AnnotationDriverTest extends AbstractMappingDriverTest
|
||||
"Entity 'Doctrine\Tests\ORM\Mapping\InvalidFetchOption' has a mapping with invalid fetch mode 'eager");
|
||||
$cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\InvalidFetchOption');
|
||||
}
|
||||
|
||||
public function testAttributeOverridesMappingWithTrait()
|
||||
{
|
||||
$factory = $this->createClassMetadataFactory();
|
||||
|
||||
$metadataWithoutOverride = $factory->getMetadataFor(get_class(new ExampleEntityWithoutOverride()));
|
||||
$metadataWithOverride = $factory->getMetadataFor(get_class(new ExampleEntityWithOverride()));
|
||||
|
||||
$this->assertEquals('trait_foo', $metadataWithoutOverride->fieldMappings['foo']['columnName']);
|
||||
$this->assertEquals('foo_overridden', $metadataWithOverride->fieldMappings['foo']['columnName']);
|
||||
$this->assertArrayHasKey('example_trait_bar_id', $metadataWithoutOverride->associationMappings['bar']['joinColumnFieldNames']);
|
||||
$this->assertArrayHasKey('example_entity_overridden_bar_id', $metadataWithOverride->associationMappings['bar']['joinColumnFieldNames']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -338,3 +351,68 @@ class InvalidFetchOption
|
||||
*/
|
||||
private $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*
|
||||
* @AttributeOverrides({
|
||||
* @AttributeOverride(name="foo",
|
||||
* column=@Column(
|
||||
* name = "foo_overridden",
|
||||
* type = "integer",
|
||||
* length = 140,
|
||||
* nullable = false,
|
||||
* unique = false
|
||||
* )
|
||||
* )
|
||||
* })
|
||||
*
|
||||
* @AssociationOverrides({
|
||||
* @AssociationOverride(name="bar",
|
||||
* joinColumns=@JoinColumn(
|
||||
* name="example_entity_overridden_bar_id", referencedColumnName="id"
|
||||
* )
|
||||
* )
|
||||
* })
|
||||
*/
|
||||
class ExampleEntityWithOverride
|
||||
{
|
||||
use ExampleTrait;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class ExampleEntityWithoutOverride
|
||||
{
|
||||
use ExampleTrait;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trait class
|
||||
*/
|
||||
trait ExampleTrait
|
||||
{
|
||||
/** @Id @Column(type="string") */
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @Column(name="trait_foo", type="integer", length=100, nullable=true, unique=true)
|
||||
*/
|
||||
protected $foo;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="Bar", cascade={"persist", "merge"})
|
||||
* @JoinColumn(name="example_trait_bar_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $bar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class Bar
|
||||
{
|
||||
/** @Id @Column(type="string") */
|
||||
private $id;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user