Refined and added tests, fixed found issues
- Renamed id properties so they don't coexist between entities in a test - Added tests for extra lazy one-to-many associations - Fixed production code to make tests green
This commit is contained in:
parent
f7b14085f2
commit
ba3df8577b
@ -1883,20 +1883,21 @@ class BasicEntityPersister implements EntityPersister
|
||||
. $this->getLockTablesSql(null)
|
||||
. ' WHERE ' . $this->getSelectConditionSQL($criteria);
|
||||
|
||||
list($params) = $this->expandParameters($criteria);
|
||||
list($params, $types) = $this->expandParameters($criteria);
|
||||
|
||||
if (null !== $extraConditions) {
|
||||
$sql .= ' AND ' . $this->getSelectConditionCriteriaSQL($extraConditions);
|
||||
list($criteriaParams, $values) = $this->expandCriteriaParameters($extraConditions);
|
||||
$sql .= ' AND ' . $this->getSelectConditionCriteriaSQL($extraConditions);
|
||||
list($extraParams, $extraTypes) = $this->expandCriteriaParameters($extraConditions);
|
||||
|
||||
$params = array_merge($params, $criteriaParams);
|
||||
$params = array_merge($params, $extraParams);
|
||||
$types = array_merge($types, $extraTypes);
|
||||
}
|
||||
|
||||
if ($filterSql = $this->generateFilterConditionSQL($this->class, $alias)) {
|
||||
$sql .= ' AND ' . $filterSql;
|
||||
}
|
||||
|
||||
return (bool) $this->conn->fetchColumn($sql, $params);
|
||||
return (bool) $this->conn->fetchColumn($sql, $params, 0, $types);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,5 +12,5 @@ class AuxiliaryEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id4;
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ class InversedManyToManyCompositeIdForeignKeyEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="AuxiliaryEntity")
|
||||
* @JoinColumn(name="foreign_id", referencedColumnName="id")
|
||||
* @JoinColumn(name="foreign_id", referencedColumnName="id4")
|
||||
* @Id
|
||||
*/
|
||||
public $foreignEntity;
|
||||
|
@ -14,7 +14,7 @@ class InversedManyToManyEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="OwningManyToManyEntity", mappedBy="associatedEntities")
|
||||
|
@ -14,11 +14,11 @@ class InversedOneToManyCompositeIdForeignKeyEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="AuxiliaryEntity")
|
||||
* @JoinColumn(name="foreign_id", referencedColumnName="id")
|
||||
* @JoinColumn(name="foreign_id", referencedColumnName="id4")
|
||||
* @Id
|
||||
*/
|
||||
public $foreignEntity;
|
||||
|
@ -14,7 +14,7 @@ class InversedOneToManyEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="OwningManyToOneEntity", mappedBy="associatedEntity")
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_inversed_onetomany_extralazy")
|
||||
*/
|
||||
class InversedOneToManyExtraLazyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @OneToMany(
|
||||
* targetEntity="OwningManyToOneExtraLazyEntity",
|
||||
* mappedBy="associatedEntity",
|
||||
* fetch="EXTRA_LAZY",
|
||||
* indexBy="id2"
|
||||
* )
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->associatedEntities = new ArrayCollection();
|
||||
}
|
||||
}
|
@ -12,11 +12,11 @@ class InversedOneToOneCompositeIdForeignKeyEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="AuxiliaryEntity")
|
||||
* @JoinColumn(name="foreign_id", referencedColumnName="id")
|
||||
* @JoinColumn(name="foreign_id", referencedColumnName="id4")
|
||||
* @Id
|
||||
*/
|
||||
public $foreignEntity;
|
||||
|
@ -12,7 +12,7 @@ class InversedOneToOneEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @Column(type="string", name="some_property")
|
||||
|
@ -14,13 +14,13 @@ class OwningManyToManyCompositeIdEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id3;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="InversedManyToManyCompositeIdEntity", inversedBy="associatedEntities")
|
||||
* @JoinTable(
|
||||
* name="vct_xref_manytomany_compositeid",
|
||||
* joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id")},
|
||||
* joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id3")},
|
||||
* inverseJoinColumns={
|
||||
* @JoinColumn(name="inversed_id1", referencedColumnName="id1"),
|
||||
* @JoinColumn(name="inversed_id2", referencedColumnName="id2")
|
||||
|
@ -14,15 +14,15 @@ class OwningManyToManyCompositeIdForeignKeyEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="InversedManyToManyCompositeIdForeignKeyEntity", inversedBy="associatedEntities")
|
||||
* @JoinTable(
|
||||
* name="vct_xref_manytomany_compositeid_foreignkey",
|
||||
* joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id")},
|
||||
* joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id2")},
|
||||
* inverseJoinColumns={
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id"),
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id1"),
|
||||
* @JoinColumn(name="associated_foreign_id", referencedColumnName="foreign_id")
|
||||
* }
|
||||
* )
|
||||
|
@ -14,14 +14,14 @@ class OwningManyToManyEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="InversedManyToManyEntity", inversedBy="associatedEntities")
|
||||
* @JoinTable(
|
||||
* name="vct_xref_manytomany",
|
||||
* joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@JoinColumn(name="inversed_id", referencedColumnName="id")}
|
||||
* joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id2")},
|
||||
* inverseJoinColumns={@JoinColumn(name="inversed_id", referencedColumnName="id1")}
|
||||
* )
|
||||
*/
|
||||
public $associatedEntities;
|
||||
|
@ -12,7 +12,7 @@ class OwningManyToOneCompositeIdEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id3;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="InversedOneToManyCompositeIdEntity", inversedBy="associatedEntities")
|
||||
|
@ -12,12 +12,12 @@ class OwningManyToOneCompositeIdForeignKeyEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="InversedOneToManyCompositeIdForeignKeyEntity", inversedBy="associatedEntities")
|
||||
* @JoinColumns({
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id"),
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id1"),
|
||||
* @JoinColumn(name="associated_foreign_id", referencedColumnName="foreign_id")
|
||||
* })
|
||||
*/
|
||||
|
@ -12,11 +12,11 @@ class OwningManyToOneEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="InversedOneToManyEntity", inversedBy="associatedEntities")
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id")
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id1")
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ValueConversionType;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="vct_owning_manytoone_extralazy")
|
||||
*/
|
||||
class OwningManyToOneExtraLazyEntity
|
||||
{
|
||||
/**
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="InversedOneToManyExtraLazyEntity", inversedBy="associatedEntities")
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id1")
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
@ -12,7 +12,7 @@ class OwningOneToOneCompositeIdEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id3;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="InversedOneToOneCompositeIdEntity", inversedBy="associatedEntity")
|
||||
|
@ -17,12 +17,12 @@ class OwningOneToOneCompositeIdForeignKeyEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="InversedOneToOneCompositeIdForeignKeyEntity", inversedBy="associatedEntity")
|
||||
* @JoinColumns({
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id"),
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id1"),
|
||||
* @JoinColumn(name="associated_foreign_id", referencedColumnName="foreign_id")
|
||||
* })
|
||||
*/
|
||||
|
@ -12,11 +12,11 @@ class OwningOneToOneEntity
|
||||
* @Column(type="rot13")
|
||||
* @Id
|
||||
*/
|
||||
public $id;
|
||||
public $id2;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="InversedOneToOneEntity", inversedBy="associatedEntity")
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id")
|
||||
* @JoinColumn(name="associated_id", referencedColumnName="id1")
|
||||
*/
|
||||
public $associatedEntity;
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
parent::setUp();
|
||||
|
||||
$auxiliary = new Entity\AuxiliaryEntity();
|
||||
$auxiliary->id = 'abc';
|
||||
$auxiliary->id4 = 'abc';
|
||||
|
||||
$inversed = new Entity\InversedManyToManyCompositeIdForeignKeyEntity();
|
||||
$inversed->id = 'def';
|
||||
$inversed->id1 = 'def';
|
||||
$inversed->foreignEntity = $auxiliary;
|
||||
|
||||
$owning = new Entity\OwningManyToManyCompositeIdForeignKeyEntity();
|
||||
$owning->id = 'ghi';
|
||||
$owning->id2 = 'ghi';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntities->add($inversed);
|
||||
@ -63,10 +63,12 @@ class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
$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 id4 FROM vct_auxiliary LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id1 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('tuv', $conn->fetchColumn('SELECT id2 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'));
|
||||
@ -78,9 +80,14 @@ class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$auxiliary = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
@ -88,6 +95,7 @@ class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity', $auxiliary);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity', $owning);
|
||||
}
|
||||
@ -97,9 +105,14 @@ class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$auxiliary = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
@ -107,9 +120,28 @@ class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertEquals('def', $inversed->id);
|
||||
$this->assertEquals('abc', $inversed->foreignEntity->id);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
$this->assertEquals('abc', $auxiliary->id4);
|
||||
$this->assertEquals('def', $inversed->id1);
|
||||
$this->assertEquals('abc', $inversed->foreignEntity->id4);
|
||||
$this->assertEquals('ghi', $owning->id2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId()
|
||||
{
|
||||
$auxiliary = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
array('id1' => 'def', 'foreignEntity' => $auxiliary)
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity', $inversed);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,7 +164,7 @@ class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$this->assertCount(1, $inversed->associatedEntities);
|
||||
@ -150,7 +182,7 @@ class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
foreach ($inversed->associatedEntities as $owning) {
|
||||
|
@ -32,7 +32,7 @@ class ManyToManyCompositeIdTest extends OrmFunctionalTestCase
|
||||
$inversed->id2 = 'def';
|
||||
|
||||
$owning = new Entity\OwningManyToManyCompositeIdEntity();
|
||||
$owning->id = 'ghi';
|
||||
$owning->id3 = 'ghi';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntities->add($inversed);
|
||||
@ -60,7 +60,7 @@ class ManyToManyCompositeIdTest extends OrmFunctionalTestCase
|
||||
$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('tuv', $conn->fetchColumn('SELECT id3 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'));
|
||||
@ -103,7 +103,7 @@ class ManyToManyCompositeIdTest extends OrmFunctionalTestCase
|
||||
|
||||
$this->assertEquals('abc', $inversed->id1);
|
||||
$this->assertEquals('def', $inversed->id2);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
$this->assertEquals('ghi', $owning->id3);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,10 +28,10 @@ class ManyToManyTest extends OrmFunctionalTestCase
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedManyToManyEntity();
|
||||
$inversed->id = 'abc';
|
||||
$inversed->id1 = 'abc';
|
||||
|
||||
$owning = new Entity\OwningManyToManyEntity();
|
||||
$owning->id = 'def';
|
||||
$owning->id2 = 'def';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntities->add($inversed);
|
||||
@ -56,9 +56,9 @@ class ManyToManyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id FROM vct_inversed_manytomany LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id FROM vct_owning_manytomany LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 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'));
|
||||
@ -98,8 +98,8 @@ class ManyToManyTest extends OrmFunctionalTestCase
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertEquals('abc', $inversed->id);
|
||||
$this->assertEquals('def', $owning->id);
|
||||
$this->assertEquals('abc', $inversed->id1);
|
||||
$this->assertEquals('def', $owning->id2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,15 +29,15 @@ class OneToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
parent::setUp();
|
||||
|
||||
$auxiliary = new Entity\AuxiliaryEntity();
|
||||
$auxiliary->id = 'abc';
|
||||
$auxiliary->id4 = 'abc';
|
||||
|
||||
$inversed = new Entity\InversedOneToManyCompositeIdForeignKeyEntity();
|
||||
$inversed->id = 'def';
|
||||
$inversed->id1 = 'def';
|
||||
$inversed->foreignEntity = $auxiliary;
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningManyToOneCompositeIdForeignKeyEntity();
|
||||
$owning->id = 'ghi';
|
||||
$owning->id2 = 'ghi';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntity = $inversed;
|
||||
@ -63,10 +63,12 @@ class OneToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
$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 id4 FROM vct_auxiliary LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id1 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('tuv', $conn->fetchColumn('SELECT id2 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'));
|
||||
}
|
||||
@ -76,9 +78,14 @@ class OneToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$auxiliary = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
@ -86,6 +93,7 @@ class OneToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity', $auxiliary);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity', $owning);
|
||||
}
|
||||
@ -95,9 +103,14 @@ class OneToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$auxiliary = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
@ -105,9 +118,28 @@ class OneToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertEquals('def', $inversed->id);
|
||||
$this->assertEquals('abc', $inversed->foreignEntity->id);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
$this->assertEquals('abc', $auxiliary->id4);
|
||||
$this->assertEquals('def', $inversed->id1);
|
||||
$this->assertEquals('abc', $inversed->foreignEntity->id4);
|
||||
$this->assertEquals('ghi', $owning->id2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId()
|
||||
{
|
||||
$auxiliary = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity',
|
||||
array('id1' => 'def', 'foreignEntity' => $auxiliary)
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity', $inversed);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,7 +164,7 @@ class OneToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$this->assertCount(1, $inversed->associatedEntities);
|
||||
|
@ -33,7 +33,7 @@ class OneToManyCompositeIdTest extends OrmFunctionalTestCase
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningManyToOneCompositeIdEntity();
|
||||
$owning->id = 'ghi';
|
||||
$owning->id3 = 'ghi';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntity = $inversed;
|
||||
@ -60,7 +60,7 @@ class OneToManyCompositeIdTest extends OrmFunctionalTestCase
|
||||
$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('tuv', $conn->fetchColumn('SELECT id3 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'));
|
||||
}
|
||||
@ -101,7 +101,7 @@ class OneToManyCompositeIdTest extends OrmFunctionalTestCase
|
||||
|
||||
$this->assertEquals('abc', $inversed->id1);
|
||||
$this->assertEquals('def', $inversed->id2);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
$this->assertEquals('ghi', $owning->id3);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,111 @@
|
||||
<?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, focusing on EXTRA_LAZY
|
||||
* functionality.
|
||||
*
|
||||
* @group DDC-3380
|
||||
*/
|
||||
class OneToManyExtraLazyTest 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_extralazy');
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedOneToManyExtraLazyEntity();
|
||||
$inversed->id1 = 'abc';
|
||||
|
||||
$owning1 = new Entity\OwningManyToOneExtraLazyEntity();
|
||||
$owning1->id2 = 'def';
|
||||
|
||||
$owning2 = new Entity\OwningManyToOneExtraLazyEntity();
|
||||
$owning2->id2 = 'ghi';
|
||||
|
||||
$owning3 = new Entity\OwningManyToOneExtraLazyEntity();
|
||||
$owning3->id2 = 'jkl';
|
||||
|
||||
$inversed->associatedEntities->add($owning1);
|
||||
$owning1->associatedEntity = $inversed;
|
||||
$inversed->associatedEntities->add($owning2);
|
||||
$owning2->associatedEntity = $inversed;
|
||||
$inversed->associatedEntities->add($owning3);
|
||||
$owning3->associatedEntity = $inversed;
|
||||
|
||||
$this->_em->persist($inversed);
|
||||
$this->_em->persist($owning1);
|
||||
$this->_em->persist($owning2);
|
||||
$this->_em->persist($owning3);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$conn = static::$_sharedConn;
|
||||
|
||||
$conn->executeUpdate('DROP TABLE vct_owning_manytoone_extralazy');
|
||||
$conn->executeUpdate('DROP TABLE vct_inversed_onetomany_extralazy');
|
||||
}
|
||||
|
||||
public function testThatExtraLazyCollectionIsCounted()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$this->assertEquals(3, $inversed->associatedEntities->count());
|
||||
}
|
||||
|
||||
public function testThatExtraLazyCollectionContainsAnEntity()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneExtraLazyEntity',
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertTrue($inversed->associatedEntities->contains($owning));
|
||||
}
|
||||
|
||||
public function testThatExtraLazyCollectionContainsAnIndexbyKey()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$this->assertTrue($inversed->associatedEntities->containsKey('def'));
|
||||
}
|
||||
|
||||
public function testThatASliceOfTheExtraLazyCollectionIsLoaded()
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$this->assertCount(2, $inversed->associatedEntities->slice(0, 2));
|
||||
}
|
||||
}
|
@ -28,11 +28,11 @@ class OneToManyTest extends OrmFunctionalTestCase
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedOneToManyEntity();
|
||||
$inversed->id = 'abc';
|
||||
$inversed->id1 = 'abc';
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningManyToOneEntity();
|
||||
$owning->id = 'def';
|
||||
$owning->id2 = 'def';
|
||||
|
||||
$inversed->associatedEntities->add($owning);
|
||||
$owning->associatedEntity = $inversed;
|
||||
@ -56,9 +56,9 @@ class OneToManyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id FROM vct_inversed_onetomany LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id FROM vct_owning_manytoone LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytoone LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone LIMIT 1'));
|
||||
}
|
||||
|
||||
@ -96,8 +96,8 @@ class OneToManyTest extends OrmFunctionalTestCase
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertEquals('abc', $inversed->id);
|
||||
$this->assertEquals('def', $owning->id);
|
||||
$this->assertEquals('abc', $inversed->id1);
|
||||
$this->assertEquals('def', $owning->id2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,15 +29,15 @@ class OneToOneCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
parent::setUp();
|
||||
|
||||
$auxiliary = new Entity\AuxiliaryEntity();
|
||||
$auxiliary->id = 'abc';
|
||||
$auxiliary->id4 = 'abc';
|
||||
|
||||
$inversed = new Entity\InversedOneToOneCompositeIdForeignKeyEntity();
|
||||
$inversed->id = 'def';
|
||||
$inversed->id1 = 'def';
|
||||
$inversed->foreignEntity = $auxiliary;
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningOneToOneCompositeIdForeignKeyEntity();
|
||||
$owning->id = 'ghi';
|
||||
$owning->id2 = 'ghi';
|
||||
|
||||
$inversed->associatedEntity = $owning;
|
||||
$owning->associatedEntity = $inversed;
|
||||
@ -63,10 +63,12 @@ class OneToOneCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
$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 id4 FROM vct_auxiliary LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id1 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('tuv', $conn->fetchColumn('SELECT id2 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'));
|
||||
}
|
||||
@ -76,9 +78,14 @@ class OneToOneCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
*/
|
||||
public function testThatEntitiesAreFetchedFromTheDatabase()
|
||||
{
|
||||
$auxiliary = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
@ -86,6 +93,7 @@ class OneToOneCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity', $auxiliary);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity', $inversed);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity', $owning);
|
||||
}
|
||||
@ -95,9 +103,14 @@ class OneToOneCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
*/
|
||||
public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase()
|
||||
{
|
||||
$auxiliary = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$owning = $this->_em->find(
|
||||
@ -105,9 +118,28 @@ class OneToOneCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
'ghi'
|
||||
);
|
||||
|
||||
$this->assertEquals('def', $inversed->id);
|
||||
$this->assertEquals('abc', $inversed->foreignEntity->id);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
$this->assertEquals('abc', $auxiliary->id4);
|
||||
$this->assertEquals('def', $inversed->id1);
|
||||
$this->assertEquals('abc', $inversed->foreignEntity->id4);
|
||||
$this->assertEquals('ghi', $owning->id2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase
|
||||
*/
|
||||
public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId()
|
||||
{
|
||||
$auxiliary = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity',
|
||||
array('id1' => 'def', 'foreignEntity' => $auxiliary)
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity', $inversed);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,7 +164,7 @@ class OneToOneCompositeIdForeignKeyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
$inversed = $this->_em->find(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity',
|
||||
array('id' => 'def', 'foreignEntity' => 'abc')
|
||||
array('id1' => 'def', 'foreignEntity' => 'abc')
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity', $inversed->associatedEntity);
|
||||
|
@ -33,7 +33,7 @@ class OneToOneCompositeIdTest extends OrmFunctionalTestCase
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningOneToOneCompositeIdEntity();
|
||||
$owning->id = 'ghi';
|
||||
$owning->id3 = 'ghi';
|
||||
|
||||
$inversed->associatedEntity = $owning;
|
||||
$owning->associatedEntity = $inversed;
|
||||
@ -60,7 +60,7 @@ class OneToOneCompositeIdTest extends OrmFunctionalTestCase
|
||||
$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('tuv', $conn->fetchColumn('SELECT id3 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'));
|
||||
}
|
||||
@ -101,7 +101,7 @@ class OneToOneCompositeIdTest extends OrmFunctionalTestCase
|
||||
|
||||
$this->assertEquals('abc', $inversed->id1);
|
||||
$this->assertEquals('def', $inversed->id2);
|
||||
$this->assertEquals('ghi', $owning->id);
|
||||
$this->assertEquals('ghi', $owning->id3);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,11 +28,11 @@ class OneToOneTest extends OrmFunctionalTestCase
|
||||
parent::setUp();
|
||||
|
||||
$inversed = new Entity\InversedOneToOneEntity();
|
||||
$inversed->id = 'abc';
|
||||
$inversed->id1 = 'abc';
|
||||
$inversed->someProperty = 'some value to be loaded';
|
||||
|
||||
$owning = new Entity\OwningOneToOneEntity();
|
||||
$owning->id = 'def';
|
||||
$owning->id2 = 'def';
|
||||
|
||||
$inversed->associatedEntity = $owning;
|
||||
$owning->associatedEntity = $inversed;
|
||||
@ -56,9 +56,9 @@ class OneToOneTest extends OrmFunctionalTestCase
|
||||
{
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id FROM vct_inversed_onetoone LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone LIMIT 1'));
|
||||
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id FROM vct_owning_onetoone LIMIT 1'));
|
||||
$this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_onetoone LIMIT 1'));
|
||||
$this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone LIMIT 1'));
|
||||
}
|
||||
|
||||
@ -96,8 +96,8 @@ class OneToOneTest extends OrmFunctionalTestCase
|
||||
'def'
|
||||
);
|
||||
|
||||
$this->assertEquals('abc', $inversed->id);
|
||||
$this->assertEquals('def', $owning->id);
|
||||
$this->assertEquals('abc', $inversed->id1);
|
||||
$this->assertEquals('def', $owning->id2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,6 +225,10 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity'
|
||||
),
|
||||
'vct_onetomany_extralazy' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneExtraLazyEntity'
|
||||
),
|
||||
'vct_manytomany' => array(
|
||||
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity',
|
||||
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity'
|
||||
@ -429,6 +433,11 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
|
||||
$conn->executeUpdate('DELETE FROM vct_auxiliary');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_onetomany_extralazy'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_manytoone_extralazy');
|
||||
$conn->executeUpdate('DELETE FROM vct_inversed_onetomany_extralazy');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['vct_manytomany'])) {
|
||||
$conn->executeUpdate('DELETE FROM vct_xref_manytomany');
|
||||
$conn->executeUpdate('DELETE FROM vct_owning_manytomany');
|
||||
|
Loading…
x
Reference in New Issue
Block a user