-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test exposing UnitOfWork merge bug
- Loading branch information
1 parent
76e1a46
commit e17a180
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\ORM\Functional; | ||
|
||
use Doctrine\ORM\Mapping\JoinColumn; | ||
|
||
class MergeCompositeToOneKeyTest extends \Doctrine\Tests\OrmFunctionalTestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->_schemaTool->createSchema(array( | ||
$this->_em->getClassMetadata(__NAMESPACE__ . '\MergeCompositeToOneKeyCountry'), | ||
$this->_em->getClassMetadata(__NAMESPACE__ . '\MergeCompositeToOneKeyState'), | ||
)); | ||
} | ||
|
||
public function testIssue() | ||
{ | ||
$country = new MergeCompositeToOneKeyCountry(); | ||
$country->country = 'US'; | ||
$state = new MergeCompositeToOneKeyState(); | ||
$state->state = 'CA'; | ||
$state->country = $country; | ||
|
||
$this->_em->merge($country); | ||
$this->_em->merge($state); | ||
} | ||
} | ||
|
||
/** | ||
* @Entity | ||
*/ | ||
class MergeCompositeToOneKeyCountry | ||
{ | ||
/** | ||
* @Id | ||
* @Column(type="string", name="country") | ||
* @GeneratedValue(strategy="NONE") | ||
*/ | ||
public $country; | ||
} | ||
|
||
/** | ||
* @Entity | ||
*/ | ||
class MergeCompositeToOneKeyState | ||
{ | ||
/** | ||
* @Id | ||
* @Column(type="string") | ||
* @GeneratedValue(strategy="NONE") | ||
*/ | ||
public $state; | ||
|
||
/** | ||
* @Id | ||
* @ManyToOne(targetEntity="MergeCompositeToOneKeyCountry") | ||
* @JoinColumn(name="country", referencedColumnName="country") | ||
*/ | ||
public $country; | ||
} |