1
0
mirror of synced 2025-02-20 22:23:14 +03:00

Adding tests for the attribute use-column-prefix

This commit is contained in:
Andrey Knupp Vital 2015-01-08 00:11:34 -02:00
parent 4935da138d
commit bacadbf366
7 changed files with 107 additions and 0 deletions

View File

@ -0,0 +1,10 @@
<?php
namespace Doctrine\Tests\Models\DDC3293;
class DDC3293Address
{
public $street;
public $city;
public $country;
}

View File

@ -0,0 +1,16 @@
<?php
namespace Doctrine\Tests\Models\DDC3293;
class DDC3293User
{
/**
* @var string
*/
protected $id;
/**
* @var Doctrine\Tests\Models\DDC3293\DDC3293Address
*/
protected $address;
}

View File

@ -0,0 +1,16 @@
<?php
namespace Doctrine\Tests\Models\DDC3293;
class DDC3293UserPrefixed
{
/**
* @var string
*/
protected $id;
/**
* @var Doctrine\Tests\Models\DDC3293\DDC3293Address
*/
protected $address;
}

View File

@ -57,6 +57,25 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
$this->assertEquals(true, $class->isEmbeddedClass);
}
public function testEmbeddedUseColumnPrefix()
{
$em = $this->_getTestEntityManager();
$em->getConfiguration()->setMetadataDriverImpl($this->_loadDriver());
$factory = new ClassMetadataFactory();
$factory->setEntityManager($em);
$class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC3293\DDC3293User');
$this->assertFalse($class->embeddedClasses['address']['columnPrefix']);
$class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC3293\DDC3293UserPrefixed');
$this->assertEquals(
'__prefix__',
$class->embeddedClasses['address']['columnPrefix']
);
}
public function testEmbeddedMapping()
{
$class = $this->createClassMetadata('Doctrine\Tests\Models\ValueObjects\Person');

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
<embeddable name="Doctrine\Tests\Models\DDC3293\DDC3293Address">
<field name="street" type="string" />
<field name="city" type="string" />
<field name="country" type="string" />
</embeddable>
</doctrine-mapping>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
<entity name="Doctrine\Tests\Models\DDC3293\DDC3293User" table="user">
<id name="id" column="id">
<generator strategy="UUID" />
</id>
<embedded
name="address"
class="Doctrine\Tests\Models\DDC3293\DDC3293Address"
column-prefix="__prefix__"
use-column-prefix="false" />
</entity>
</doctrine-mapping>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
<entity name="Doctrine\Tests\Models\DDC3293\DDC3293UserPrefixed" table="user">
<id name="id" column="id">
<generator strategy="UUID" />
</id>
<embedded
name="address"
class="Doctrine\Tests\Models\DDC3293\DDC3293Address"
column-prefix="__prefix__"
use-column-prefix="true" />
</entity>
</doctrine-mapping>