Fixed associations using a value-conversion type for identifiers
This commit is contained in:
parent
f6445d5a3e
commit
f60f2a567a
@ -374,22 +374,20 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$mapping = $collection->getMapping();
|
||||
$identifier = $this->uow->getEntityIdentifier($collection->getOwner());
|
||||
|
||||
// Optimization for single column identifier
|
||||
if (count($mapping['relationToSourceKeyColumns']) === 1) {
|
||||
return array(reset($identifier));
|
||||
}
|
||||
|
||||
// Composite identifier
|
||||
$sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']);
|
||||
$params = array();
|
||||
$types = array();
|
||||
|
||||
foreach ($mapping['relationToSourceKeyColumns'] as $columnName => $refColumnName) {
|
||||
$params[] = isset($sourceClass->fieldNames[$refColumnName])
|
||||
? $identifier[$sourceClass->fieldNames[$refColumnName]]
|
||||
: $identifier[$sourceClass->getFieldForColumn($columnName)];
|
||||
$field = isset($sourceClass->fieldNames[$refColumnName])
|
||||
? $sourceClass->fieldNames[$refColumnName]
|
||||
: $sourceClass->getFieldForColumn($columnName);
|
||||
|
||||
$params[] = $identifier[$field];
|
||||
$types[] = $this->getType($field, $sourceClass);
|
||||
}
|
||||
|
||||
return $params;
|
||||
return array($params, $types);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -710,6 +710,7 @@ class BasicEntityPersister implements EntityPersister
|
||||
{
|
||||
$sql = $this->getSelectSQL($criteria, $assoc, $lockMode, $limit, null, $orderBy);
|
||||
list($params, $types) = $this->expandParameters($criteria);
|
||||
|
||||
$stmt = $this->conn->executeQuery($sql, $params, $types);
|
||||
|
||||
if ($entity !== null) {
|
||||
@ -965,11 +966,12 @@ class BasicEntityPersister implements EntityPersister
|
||||
*/
|
||||
private function getManyToManyStatement(array $assoc, $sourceEntity, $offset = null, $limit = null)
|
||||
{
|
||||
$sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']);
|
||||
$class = $sourceClass;
|
||||
$association = $assoc;
|
||||
$criteria = array();
|
||||
$criteria = array();
|
||||
$parameters = array();
|
||||
|
||||
$sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']);
|
||||
$class = $sourceClass;
|
||||
$association = $assoc;
|
||||
|
||||
if ( ! $assoc['isOwningSide']) {
|
||||
$class = $this->em->getClassMetadata($assoc['targetEntity']);
|
||||
@ -984,8 +986,8 @@ class BasicEntityPersister implements EntityPersister
|
||||
|
||||
foreach ($joinColumns as $joinColumn) {
|
||||
|
||||
$sourceKeyColumn = $joinColumn['referencedColumnName'];
|
||||
$quotedKeyColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
|
||||
$sourceKeyColumn = $joinColumn['referencedColumnName'];
|
||||
$quotedKeyColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
|
||||
|
||||
switch (true) {
|
||||
case $sourceClass->containsForeignIdentifier:
|
||||
@ -1012,10 +1014,11 @@ class BasicEntityPersister implements EntityPersister
|
||||
}
|
||||
|
||||
$criteria[$quotedJoinTable . '.' . $quotedKeyColumn] = $value;
|
||||
$parameters[] = array('value' => $value, 'field' => $field, 'class' => $sourceClass);
|
||||
}
|
||||
|
||||
$sql = $this->getSelectSQL($criteria, $assoc, null, $limit, $offset);
|
||||
list($params, $types) = $this->expandParameters($criteria);
|
||||
list($params, $types) = $this->expandToManyParameters($parameters);
|
||||
|
||||
return $this->conn->executeQuery($sql, $params, $types);
|
||||
}
|
||||
@ -1303,17 +1306,13 @@ class BasicEntityPersister implements EntityPersister
|
||||
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
|
||||
|
||||
foreach ($assoc['joinColumns'] as $joinColumn) {
|
||||
$type = null;
|
||||
$type = $this->getColumnType($joinColumn['referencedColumnName'], null, $targetClass);
|
||||
$isIdentifier = isset($assoc['id']) && $assoc['id'] === true;
|
||||
$quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform);
|
||||
$resultColumnName = $this->getSQLColumnAlias($joinColumn['name']);
|
||||
$columnList[] = $this->getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias) )
|
||||
. '.' . $quotedColumn . ' AS ' . $resultColumnName;
|
||||
|
||||
if (isset($targetClass->fieldNames[$joinColumn['referencedColumnName']])) {
|
||||
$type = $targetClass->fieldMappings[$targetClass->fieldNames[$joinColumn['referencedColumnName']]]['type'];
|
||||
}
|
||||
|
||||
$this->rsm->addMetaResult($alias, $resultColumnName, $quotedColumn, $isIdentifier, $type);
|
||||
}
|
||||
|
||||
@ -1713,7 +1712,9 @@ class BasicEntityPersister implements EntityPersister
|
||||
*/
|
||||
private function getOneToManyStatement(array $assoc, $sourceEntity, $offset = null, $limit = null)
|
||||
{
|
||||
$criteria = array();
|
||||
$criteria = array();
|
||||
$parameters = array();
|
||||
|
||||
$owningAssoc = $this->class->associationMappings[$assoc['mappedBy']];
|
||||
$sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']);
|
||||
|
||||
@ -1730,15 +1731,20 @@ class BasicEntityPersister implements EntityPersister
|
||||
}
|
||||
|
||||
$criteria[$tableAlias . "." . $targetKeyColumn] = $value;
|
||||
$parameters[] = array('value' => $value, 'field' => $field, 'class' => $sourceClass);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$criteria[$tableAlias . "." . $targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity);
|
||||
$field = $sourceClass->fieldNames[$sourceKeyColumn];
|
||||
$value = $sourceClass->reflFields[$field]->getValue($sourceEntity);
|
||||
|
||||
$criteria[$tableAlias . "." . $targetKeyColumn] = $value;
|
||||
$parameters[] = array('value' => $value, 'field' => $field, 'class' => $sourceClass);
|
||||
}
|
||||
|
||||
$sql = $this->getSelectSQL($criteria, $assoc, null, $limit, $offset);
|
||||
list($params, $types) = $this->expandParameters($criteria);
|
||||
list($params, $types) = $this->expandToManyParameters($parameters);
|
||||
|
||||
return $this->conn->executeQuery($sql, $params, $types);
|
||||
}
|
||||
@ -1764,17 +1770,51 @@ class BasicEntityPersister implements EntityPersister
|
||||
}
|
||||
|
||||
/**
|
||||
* Infers field type to be used by parameter type casting.
|
||||
* Expands the parameters from the given criteria and use the correct binding types if found,
|
||||
* specialized for OneToMany or ManyToMany associations.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* DDC-3380: {@see getManyToManyStatement()} and {@see getOneToManyStatement()}.
|
||||
*
|
||||
* @return integer
|
||||
* @param array $criteria
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function expandToManyParameters($criteria)
|
||||
{
|
||||
$params = array();
|
||||
$types = array();
|
||||
|
||||
foreach ($criteria as $criterion) {
|
||||
if ($criterion['value'] === null) {
|
||||
continue; // skip null values.
|
||||
}
|
||||
|
||||
$types[] = $this->getType($criterion['field'], $criterion['value'], $criterion['class']);
|
||||
$params[] = $this->getValue($criterion['value']);
|
||||
}
|
||||
|
||||
return array($params, $types);
|
||||
}
|
||||
|
||||
/**
|
||||
* Infers the binding type of a field by parameter type casting.
|
||||
*
|
||||
* DDC-3380: Added optional $class argument.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param ClassMetadata|null $class
|
||||
*
|
||||
* @return int|string|null
|
||||
*
|
||||
* @throws \Doctrine\ORM\Query\QueryException
|
||||
*/
|
||||
private function getType($field, $value)
|
||||
private function getType($field, $value, ClassMetadata $class = null)
|
||||
{
|
||||
if ($class === null) {
|
||||
$class = $this->class;
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case (isset($this->class->fieldMappings[$field])):
|
||||
$type = $this->class->fieldMappings[$field]['type'];
|
||||
@ -1802,8 +1842,8 @@ class BasicEntityPersister implements EntityPersister
|
||||
|
||||
break;
|
||||
|
||||
case (isset($this->class->associationMappings[$field])):
|
||||
$assoc = $this->class->associationMappings[$field];
|
||||
case (isset($class->associationMappings[$field])):
|
||||
$assoc = $class->associationMappings[$field];
|
||||
|
||||
if (count($assoc['sourceToTargetKeyColumns']) > 1) {
|
||||
throw Query\QueryException::associationPathCompositeKeyNotSupported();
|
||||
@ -1831,6 +1871,67 @@ class BasicEntityPersister implements EntityPersister
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Infers the binding type of a column by parameter type casting.
|
||||
*
|
||||
* @param string $columnName
|
||||
* @param mixed $value
|
||||
* @param ClassMetadata $class
|
||||
* @return int|string|null
|
||||
*/
|
||||
private function getColumnType($columnName, $value, ClassMetadata $class)
|
||||
{
|
||||
$type = null;
|
||||
|
||||
switch (true) {
|
||||
case (isset($class->fieldNames[$columnName])):
|
||||
$fieldName = $class->fieldNames[$columnName];
|
||||
|
||||
if (isset($class->fieldMappings[$fieldName])) {
|
||||
$type = $class->fieldMappings[$fieldName]['type'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$type = $this->getAssociationColumnType($columnName, $class);
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$type = Type::getType($type)->getBindingType();
|
||||
$type += Connection::ARRAY_PARAM_OFFSET;
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Infers the binding type of a column by traversing association mappings.
|
||||
*
|
||||
* @param string $columnName
|
||||
* @param ClassMetadata $class
|
||||
* @return string|null
|
||||
*/
|
||||
private function getAssociationColumnType($columnName, ClassMetadata $class)
|
||||
{
|
||||
foreach ($class->associationMappings as $assoc) {
|
||||
foreach ($assoc['joinColumns'] as $joinColumn) {
|
||||
if ($joinColumn['name'] == $columnName) {
|
||||
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
|
||||
$targetColumn = $joinColumn['referencedColumnName'];
|
||||
|
||||
if (isset($targetClass->fieldNames[$targetColumn])) {
|
||||
return $targetClass->fieldMappings[$targetClass->fieldNames[$targetColumn]]['type'];
|
||||
}
|
||||
|
||||
return $this->getAssociationColumnType($targetColumn, $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves parameter value.
|
||||
*
|
||||
|
81
tests/Doctrine/Tests/DbalTypes/Rot13Type.php
Normal file
81
tests/Doctrine/Tests/DbalTypes/Rot13Type.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\DbalTypes;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
|
||||
/**
|
||||
* Shifts every letter by 13 places in the alphabet (ROT13 encoding).
|
||||
*/
|
||||
class Rot13Type extends Type
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param string|null $value
|
||||
* @param AbstractPlatform $platform
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function convertToDatabaseValue($value, AbstractPlatform $platform)
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return str_rot13($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param string|null $value
|
||||
* @param AbstractPlatform $platform
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function convertToPHPValue($value, AbstractPlatform $platform)
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return str_rot13($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param array $fieldDeclaration
|
||||
* @param AbstractPlatform $platform
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
|
||||
{
|
||||
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param AbstractPlatform $platform
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getDefaultLength(AbstractPlatform $platform)
|
||||
{
|
||||
return $platform->getVarcharDefaultLength();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'rot13';
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_auxiliary")
|
||||
*/
|
||||
class AuxiliaryEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_manytomany_compositeid")
|
||||
*/
|
||||
class InversedManyToManyCompositeIdEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="OwningManyToManyCompositeIdEntity", mappedBy="associatedEntities")
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_manytomany_compositeid_foreignkey")
|
||||
*/
|
||||
class InversedManyToManyCompositeIdForeignKeyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="AuxiliaryEntity")
|
||||
* @JoinColumn(name="foreign_id", referencedColumnName="id")
|
||||
* @Id
|
||||
*/
|
||||
public $foreignEntity;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="OwningManyToManyCompositeIdForeignKeyEntity", mappedBy="associatedEntities")
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_manytomany")
|
||||
*/
|
||||
class InversedManyToManyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="OwningManyToManyEntity", mappedBy="associatedEntities")
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_onetomany_compositeid")
|
||||
*/
|
||||
class InversedOneToManyCompositeIdEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @Column(type="string", name="some_property")
|
||||
*/
|
||||
public $someProperty;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="OwningManyToOneCompositeIdEntity", mappedBy="associatedEntity")
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_onetomany_compositeid_foreignkey")
|
||||
*/
|
||||
class InversedOneToManyCompositeIdForeignKeyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="AuxiliaryEntity")
|
||||
* @JoinColumn(name="foreign_id", referencedColumnName="id")
|
||||
* @Id
|
||||
*/
|
||||
public $foreignEntity;
|
||||
|
||||
/**
|
||||
* @Column(type="string", name="some_property")
|
||||
*/
|
||||
public $someProperty;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="OwningManyToOneCompositeIdForeignKeyEntity", mappedBy="associatedEntity")
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_onetomany")
|
||||
*/
|
||||
class InversedOneToManyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="OwningManyToOneEntity", mappedBy="associatedEntity")
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
/**
|
||||
* @Column(type="string", name="some_property")
|
||||
*/
|
||||
public $someProperty;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_onetoone_compositeid")
|
||||
*/
|
||||
class InversedOneToOneCompositeIdEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @Column(type="string", name="some_property")
|
||||
*/
|
||||
public $someProperty;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="OwningOneToOneCompositeIdEntity", mappedBy="associatedEntity")
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_onetoone_compositeid_foreignkey")
|
||||
*/
|
||||
class InversedOneToOneCompositeIdForeignKeyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="AuxiliaryEntity")
|
||||
* @JoinColumn(name="foreign_id", referencedColumnName="id")
|
||||
* @Id
|
||||
*/
|
||||
public $foreignEntity;
|
||||
|
||||
/**
|
||||
* @Column(type="string", name="some_property")
|
||||
*/
|
||||
public $someProperty;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="OwningOneToOneCompositeIdForeignKeyEntity", mappedBy="associatedEntity")
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_onetoone")
|
||||
*/
|
||||
class InversedOneToOneEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(type="string", name="some_property")
|
||||
*/
|
||||
public $someProperty;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="OwningOneToOneEntity", mappedBy="associatedEntity")
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_owning_manytomany_compositeid")
|
||||
*/
|
||||
class OwningManyToManyCompositeIdEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="InversedManyToManyCompositeIdEntity", inversedBy="associatedEntities")
|
||||
* @JoinTable(
|
||||
* name="vct_xref_manytomany_compositeid",
|
||||
* joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={
|
||||
* @JoinColumn(name="inversed_id1", referencedColumnName="id1"),
|
||||
* @JoinColumn(name="inversed_id2", referencedColumnName="id2")
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_owning_manytomany_compositeid_foreignkey")
|
||||
*/
|
||||
class OwningManyToManyCompositeIdForeignKeyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="InversedManyToManyCompositeIdForeignKeyEntity", inversedBy="associatedEntities")
|
||||
* @JoinTable(
|
||||
* name="vct_xref_manytomany_compositeid_foreignkey",
|
||||
* joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id"),
|
||||
* @JoinColumn(name="associated_foreign_id", referencedColumnName="foreign_id")
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_owning_manytomany")
|
||||
*/
|
||||
class OwningManyToManyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="InversedManyToManyEntity", inversedBy="associatedEntities")
|
||||
* @JoinTable(
|
||||
* name="vct_xref_manytomany",
|
||||
* joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@JoinColumn(name="inversed_id", referencedColumnName="id")}
|
||||
* )
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_owning_manytoone_compositeid")
|
||||
*/
|
||||
class OwningManyToOneCompositeIdEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="InversedOneToManyCompositeIdEntity", inversedBy="associatedEntities")
|
||||
* @JoinColumns({
|
||||
* @JoinColumn(name="associated_id1", referencedColumnName="id1"),
|
||||
* @JoinColumn(name="associated_id2", referencedColumnName="id2")
|
||||
* })
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_owning_manytoone_compositeid_foreignkey")
|
||||
*/
|
||||
class OwningManyToOneCompositeIdForeignKeyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="InversedOneToManyCompositeIdForeignKeyEntity", inversedBy="associatedEntities")
|
||||
* @JoinColumns({
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id"),
|
||||
* @JoinColumn(name="associated_foreign_id", referencedColumnName="foreign_id")
|
||||
* })
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_owning_manytoone")
|
||||
*/
|
||||
class OwningManyToOneEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="InversedOneToManyEntity", inversedBy="associatedEntities")
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id")
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_owning_onetoone_compositeid")
|
||||
*/
|
||||
class OwningOneToOneCompositeIdEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="InversedOneToOneCompositeIdEntity", inversedBy="associatedEntity")
|
||||
* @JoinColumns({
|
||||
* @JoinColumn(name="associated_id1", referencedColumnName="id1"),
|
||||
* @JoinColumn(name="associated_id2", referencedColumnName="id2")
|
||||
* })
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(
|
||||
* name="vct_owning_onetoone_compositeid_foreignkey",
|
||||
* uniqueConstraints={
|
||||
* @UniqueConstraint(name="associated_entity_uniq", columns={"associated_id", "associated_foreign_id"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class OwningOneToOneCompositeIdForeignKeyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="InversedOneToOneCompositeIdForeignKeyEntity", inversedBy="associatedEntity")
|
||||
* @JoinColumns({
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id"),
|
||||
* @JoinColumn(name="associated_foreign_id", referencedColumnName="foreign_id")
|
||||
* })
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_owning_onetoone")
|
||||
*/
|
||||
class OwningOneToOneEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="InversedOneToOneEntity", inversedBy="associatedEntity")
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id")
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\ORM\Tools\SchemaValidator;
|
||||
|
||||
/**
|
||||
@ -18,6 +19,16 @@ class SchemaValidatorTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
if ($modelSet == "customtype") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// DDC-3380: Register DBAL type for these modelsets
|
||||
if (substr($modelSet, 0, 4) == 'vct_') {
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
}
|
||||
|
||||
$modelSets[] = array($modelSet);
|
||||
}
|
||||
return $modelSets;
|
||||
|
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\ValueConversionType;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\Tests\Models\ValueConversionType as Entity;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* The entities all use a custom type that converst the value as identifier(s).
|
||||
* {@see \Doctrine\Tests\DbalTypes\Rot13Type}
|
||||
*
|
||||
* Test that ManyToMany associations with composite id of which one is a
|
||||
* association itself work correctly.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
|
||||
$this->useModelSet('vct_manytomany_compositeid_foreignkey');
|
||||
parent::setUp();
|
||||
|
||||
$auxiliary = new Entity\AuxiliaryEntity();
|
||||
$auxiliary->id = 'abc';
|
||||
|
||||
$inversed = new Entity\InversedManyToManyCompositeIdForeignKeyEntity();
|
||||
$inversed->id = 'def';
|
||||
$inversed->foreignEntity = $auxiliary;
|
||||
|
||||
$owning = new Entity\OwningManyToManyCompositeIdForeignKeyEntity();
|
||||
$owning->id = 'ghi';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntities->add($inversed);
|
||||
|
||||
$this->_em->persist($auxiliary);
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_xref_manytomany_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_manytomany_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_manytomany_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DROP TABLE vct_auxiliary');
|
||||
}
|
||||
|
||||
public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1'));
|
||||
|
||||
$this->assertEquals('tuv', $conn->fetchColumn('SELECT id FROM vct_owning_manytomany_compositeid_foreignkey LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1'));
|
||||
$this->assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity', $owning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertEquals('def', $inversed->id);
|
||||
$this->assertEquals('abc', $inversed->foreignEntity->id);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheCollectionFromOwningToInversedIsLoaded()
|
||||
{
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertCount(1, $owning->associatedEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheCollectionFromInversedToOwningIsLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$this->assertCount(1, $inversed->associatedEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheCollectionFromOwningToInversedIsLoaded
|
||||
* @depends testThatTheCollectionFromInversedToOwningIsLoaded
|
||||
*/
|
||||
public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
// remove association
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
foreach ($inversed->associatedEntities as $owning) {
|
||||
$inversed->associatedEntities->removeElement($owning);
|
||||
$owning->associatedEntities->removeElement($inversed);
|
||||
}
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
// test association is removed
|
||||
|
||||
$this->assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid_foreignkey'));
|
||||
}
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\ValueConversionType;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\Tests\Models\ValueConversionType as Entity;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* The entities all use a custom type that converst the value as identifier(s).
|
||||
* {@see \Doctrine\Tests\DbalTypes\Rot13Type}
|
||||
*
|
||||
* Test that ManyToMany associations with composite id work correctly.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class ManyToManyCompositeIdTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
|
||||
$this->useModelSet('vct_manytomany_compositeid');
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedManyToManyCompositeIdEntity();
|
||||
$inversed->id1 = 'abc';
|
||||
$inversed->id2 = 'def';
|
||||
|
||||
$owning = new Entity\OwningManyToManyCompositeIdEntity();
|
||||
$owning->id = 'ghi';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntities->add($inversed);
|
||||
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_xref_manytomany_compositeid');
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_manytomany_compositeid');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_manytomany_compositeid');
|
||||
}
|
||||
|
||||
public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany_compositeid LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_manytomany_compositeid LIMIT 1'));
|
||||
|
||||
$this->assertEquals('tuv', $conn->fetchColumn('SELECT id FROM vct_owning_manytomany_compositeid LIMIT 1'));
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT inversed_id1 FROM vct_xref_manytomany_compositeid LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT inversed_id2 FROM vct_xref_manytomany_compositeid LIMIT 1'));
|
||||
$this->assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid LIMIT 1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity', $owning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertEquals('abc', $inversed->id1);
|
||||
$this->assertEquals('def', $inversed->id2);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheCollectionFromOwningToInversedIsLoaded()
|
||||
{
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertCount(1, $owning->associatedEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheCollectionFromInversedToOwningIsLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
$this->assertCount(1, $inversed->associatedEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheCollectionFromOwningToInversedIsLoaded
|
||||
* @depends testThatTheCollectionFromInversedToOwningIsLoaded
|
||||
*/
|
||||
public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
// remove association
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
foreach ($inversed->associatedEntities as $owning) {
|
||||
$inversed->associatedEntities->removeElement($owning);
|
||||
$owning->associatedEntities->removeElement($inversed);
|
||||
}
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
// test association is removed
|
||||
|
||||
$this->assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid'));
|
||||
}
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\ValueConversionType;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\Tests\Models\ValueConversionType as Entity;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* The entities all use a custom type that converst the value as identifier(s).
|
||||
* {@see \Doctrine\Tests\DbalTypes\Rot13Type}
|
||||
*
|
||||
* Test that ManyToMany associations work correctly.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class ManyToManyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
|
||||
$this->useModelSet('vct_manytomany');
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedManyToManyEntity();
|
||||
$inversed->id = 'abc';
|
||||
|
||||
$owning = new Entity\OwningManyToManyEntity();
|
||||
$owning->id = 'def';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntities->add($inversed);
|
||||
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_xref_manytomany');
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_manytomany');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_manytomany');
|
||||
}
|
||||
|
||||
public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id FROM vct_inversed_manytomany LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id FROM vct_owning_manytomany LIMIT 1'));
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT inversed_id FROM vct_xref_manytomany LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany LIMIT 1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity', $owning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertEquals('abc', $inversed->id);
|
||||
$this->assertEquals('def', $owning->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheCollectionFromOwningToInversedIsLoaded()
|
||||
{
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertCount(1, $owning->associatedEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheCollectionFromInversedToOwningIsLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$this->assertCount(1, $inversed->associatedEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheCollectionFromOwningToInversedIsLoaded
|
||||
* @depends testThatTheCollectionFromInversedToOwningIsLoaded
|
||||
*/
|
||||
public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
// remove association
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
foreach ($inversed->associatedEntities as $owning) {
|
||||
$inversed->associatedEntities->removeElement($owning);
|
||||
$owning->associatedEntities->removeElement($inversed);
|
||||
}
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
// test association is removed
|
||||
|
||||
$this->assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany'));
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\ValueConversionType;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\Tests\Models\ValueConversionType as Entity;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* The entities all use a custom type that converst the value as identifier(s).
|
||||
* {@see \Doctrine\Tests\DbalTypes\Rot13Type}
|
||||
*
|
||||
* Test that OneToMany associations with composite id of which one is a
|
||||
* association itself work correctly.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class OneToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
|
||||
$this->useModelSet('vct_onetomany_compositeid_foreignkey');
|
||||
parent::setUp();
|
||||
|
||||
$auxiliary = new Entity\AuxiliaryEntity();
|
||||
$auxiliary->id = 'abc';
|
||||
|
||||
$inversed = new Entity\InversedOneToManyCompositeIdForeignKeyEntity();
|
||||
$inversed->id = 'def';
|
||||
$inversed->foreignEntity = $auxiliary;
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningManyToOneCompositeIdForeignKeyEntity();
|
||||
$owning->id = 'ghi';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntity = $inversed;
|
||||
|
||||
$this->_em->persist($auxiliary);
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_manytoone_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_onetomany_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DROP TABLE vct_auxiliary');
|
||||
}
|
||||
|
||||
public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1'));
|
||||
|
||||
$this->assertEquals('tuv', $conn->fetchColumn('SELECT id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity', $owning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertEquals('def', $inversed->id);
|
||||
$this->assertEquals('abc', $inversed->foreignEntity->id);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheProxyFromOwningToInversedIsLoaded()
|
||||
{
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$inversedProxy = $owning->associatedEntity;
|
||||
|
||||
$this->assertEquals('some value to be loaded', $inversedProxy->someProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheCollectionFromInversedToOwningIsLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$this->assertCount(1, $inversed->associatedEntities);
|
||||
}
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\ValueConversionType;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\Tests\Models\ValueConversionType as Entity;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* The entities all use a custom type that converst the value as identifier(s).
|
||||
* {@see \Doctrine\Tests\DbalTypes\Rot13Type}
|
||||
*
|
||||
* Test that OneToMany associations with composite id work correctly.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class OneToManyCompositeIdTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
|
||||
$this->useModelSet('vct_onetomany_compositeid');
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedOneToManyCompositeIdEntity();
|
||||
$inversed->id1 = 'abc';
|
||||
$inversed->id2 = 'def';
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningManyToOneCompositeIdEntity();
|
||||
$owning->id = 'ghi';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntity = $inversed;
|
||||
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_manytoone_compositeid');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_onetomany_compositeid');
|
||||
}
|
||||
|
||||
public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany_compositeid LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetomany_compositeid LIMIT 1'));
|
||||
|
||||
$this->assertEquals('tuv', $conn->fetchColumn('SELECT id FROM vct_owning_manytoone_compositeid LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_manytoone_compositeid LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_manytoone_compositeid LIMIT 1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity', $owning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertEquals('abc', $inversed->id1);
|
||||
$this->assertEquals('def', $inversed->id2);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheProxyFromOwningToInversedIsLoaded()
|
||||
{
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$inversedProxy = $owning->associatedEntity;
|
||||
|
||||
$this->assertEquals('some value to be loaded', $inversedProxy->someProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheCollectionFromInversedToOwningIsLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
$this->assertCount(1, $inversed->associatedEntities);
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\ValueConversionType;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\Tests\Models\ValueConversionType as Entity;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* The entities all use a custom type that converst the value as identifier(s).
|
||||
* {@see \Doctrine\Tests\DbalTypes\Rot13Type}
|
||||
*
|
||||
* Test that OneToMany associations work correctly.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class OneToManyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
|
||||
$this->useModelSet('vct_onetomany');
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedOneToManyEntity();
|
||||
$inversed->id = 'abc';
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningManyToOneEntity();
|
||||
$owning->id = 'def';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntity = $inversed;
|
||||
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_manytoone');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_onetomany');
|
||||
}
|
||||
|
||||
public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id FROM vct_inversed_onetomany LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id FROM vct_owning_manytoone LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone LIMIT 1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity', $owning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertEquals('abc', $inversed->id);
|
||||
$this->assertEquals('def', $owning->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheProxyFromOwningToInversedIsLoaded()
|
||||
{
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$inversedProxy = $owning->associatedEntity;
|
||||
|
||||
$this->assertEquals('some value to be loaded', $inversedProxy->someProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheCollectionFromInversedToOwningIsLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$this->assertCount(1, $inversed->associatedEntities);
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\ValueConversionType;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\Tests\Models\ValueConversionType as Entity;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* The entities all use a custom type that converst the value as identifier(s).
|
||||
* {@see \Doctrine\Tests\DbalTypes\Rot13Type}
|
||||
*
|
||||
* Test that OneToOne associations with composite id of which one is a
|
||||
* association itself work correctly.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class OneToOneCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
|
||||
$this->useModelSet('vct_onetoone_compositeid_foreignkey');
|
||||
parent::setUp();
|
||||
|
||||
$auxiliary = new Entity\AuxiliaryEntity();
|
||||
$auxiliary->id = 'abc';
|
||||
|
||||
$inversed = new Entity\InversedOneToOneCompositeIdForeignKeyEntity();
|
||||
$inversed->id = 'def';
|
||||
$inversed->foreignEntity = $auxiliary;
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningOneToOneCompositeIdForeignKeyEntity();
|
||||
$owning->id = 'ghi';
|
||||
|
||||
$inversed->associatedEntity = $owning;
|
||||
$owning->associatedEntity = $inversed;
|
||||
|
||||
$this->_em->persist($auxiliary);
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_onetoone_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_onetoone_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DROP TABLE vct_auxiliary');
|
||||
}
|
||||
|
||||
public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1'));
|
||||
|
||||
$this->assertEquals('tuv', $conn->fetchColumn('SELECT id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity', $owning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertEquals('def', $inversed->id);
|
||||
$this->assertEquals('abc', $inversed->foreignEntity->id);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheProxyFromOwningToInversedIsLoaded()
|
||||
{
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$inversedProxy = $owning->associatedEntity;
|
||||
|
||||
$this->assertEquals('some value to be loaded', $inversedProxy->someProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheEntityFromInversedToOwningIsEagerLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity', $inversed->associatedEntity);
|
||||
}
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\ValueConversionType;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\Tests\Models\ValueConversionType as Entity;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* The entities all use a custom type that converst the value as identifier(s).
|
||||
* {@see \Doctrine\Tests\DbalTypes\Rot13Type}
|
||||
*
|
||||
* Test that OneToOne associations with composite id work correctly.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class OneToOneCompositeIdTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
|
||||
$this->useModelSet('vct_onetoone_compositeid');
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedOneToOneCompositeIdEntity();
|
||||
$inversed->id1 = 'abc';
|
||||
$inversed->id2 = 'def';
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningOneToOneCompositeIdEntity();
|
||||
$owning->id = 'ghi';
|
||||
|
||||
$inversed->associatedEntity = $owning;
|
||||
$owning->associatedEntity = $inversed;
|
||||
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_onetoone_compositeid');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_onetoone_compositeid');
|
||||
}
|
||||
|
||||
public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone_compositeid LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetoone_compositeid LIMIT 1'));
|
||||
|
||||
$this->assertEquals('tuv', $conn->fetchColumn('SELECT id FROM vct_owning_onetoone_compositeid LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_onetoone_compositeid LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_onetoone_compositeid LIMIT 1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity', $owning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertEquals('abc', $inversed->id1);
|
||||
$this->assertEquals('def', $inversed->id2);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheProxyFromOwningToInversedIsLoaded()
|
||||
{
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity',
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$inversedProxy = $owning->associatedEntity;
|
||||
|
||||
$this->assertEquals('some value to be loaded', $inversedProxy->someProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheEntityFromInversedToOwningIsEagerLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity',
|
||||
array('id1' => 'abc', 'id2' => 'def')
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity', $inversed->associatedEntity);
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\ValueConversionType;
|
||||
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\Tests\Models\ValueConversionType as Entity;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* The entities all use a custom type that converst the value as identifier(s).
|
||||
* {@see \Doctrine\Tests\DbalTypes\Rot13Type}
|
||||
*
|
||||
* Test that OneToOne associations work correctly.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class OneToOneTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (DBALType::hasType('rot13')) {
|
||||
DBALType::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
} else {
|
||||
DBALType::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type');
|
||||
}
|
||||
|
||||
$this->useModelSet('vct_onetoone');
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedOneToOneEntity();
|
||||
$inversed->id = 'abc';
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningOneToOneEntity();
|
||||
$owning->id = 'def';
|
||||
|
||||
$inversed->associatedEntity = $owning;
|
||||
$owning->associatedEntity = $inversed;
|
||||
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_onetoone');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_onetoone');
|
||||
}
|
||||
|
||||
public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase()
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id FROM vct_inversed_onetoone LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id FROM vct_owning_onetoone LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone LIMIT 1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity', $owning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertEquals('abc', $inversed->id);
|
||||
$this->assertEquals('def', $owning->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheProxyFromOwningToInversedIsLoaded()
|
||||
{
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$inversedProxy = $owning->associatedEntity;
|
||||
|
||||
$this->assertEquals('some value to be loaded', $inversedProxy->someProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatEntitiesAreFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatTheEntityFromInversedToOwningIsEagerLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity', $inversed->associatedEntity);
|
||||
}
|
||||
}
|
@ -199,6 +199,45 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
|
||||
'Doctrine\Tests\Models\Quote\Phone',
|
||||
'Doctrine\Tests\Models\Quote\User'
|
||||
),
|
||||
'vct_onetoone' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity'
|
||||
),
|
||||
'vct_onetoone_compositeid' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity'
|
||||
),
|
||||
'vct_onetoone_compositeid_foreignkey' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity'
|
||||
),
|
||||
'vct_onetomany' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity'
|
||||
),
|
||||
'vct_onetomany_compositeid' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity'
|
||||
),
|
||||
'vct_onetomany_compositeid_foreignkey' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity'
|
||||
),
|
||||
'vct_manytomany' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity'
|
||||
),
|
||||
'vct_manytomany_compositeid' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity'
|
||||
),
|
||||
'vct_manytomany_compositeid_foreignkey' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity'
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
@ -358,6 +397,57 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
|
||||
$conn->executeUpdate('DELETE FROM ' . $platform->quoteIdentifier("quote-user"));
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_onetoone'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_onetoone');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_onetoone');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_onetoone_compositeid'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_onetoone_compositeid');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_onetoone_compositeid');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_onetoone_compositeid_foreignkey'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_onetoone_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_onetoone_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DELETE FROM vct_auxiliary');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_onetomany'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_manytoone');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_onetomany');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_onetomany_compositeid'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_manytoone_compositeid');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_onetomany_compositeid');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_onetomany_compositeid_foreignkey'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_manytoone_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_onetomany_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DELETE FROM vct_auxiliary');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_manytomany'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_xref_manytomany');
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_manytomany');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_manytomany');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_manytomany_compositeid'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_xref_manytomany_compositeid');
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_manytomany_compositeid');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_manytomany_compositeid');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_manytomany_compositeid_foreignkey'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_xref_manytomany_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_manytomany_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_manytomany_compositeid_foreignkey');
|
||||
$conn->executeUpdate('DELETE FROM vct_auxiliary');
|
||||
}
|
||||
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user