Skip to content

Commit

Permalink
Add test exposing UnitOfWork merge bug
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienbrault committed Nov 7, 2014
1 parent 76e1a46 commit 5d5fc67
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php
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__ . '\Country'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\State'),
));
}

public function testIssue()
{
$country = new Country();
$country->country = 'US';
$state = new State();
$state->state = 'CA';
$state->country = $country;

$this->_em->merge($country);
$this->_em->merge($state);
}
}

/**
* @Entity
*/
class Country
{
/**
* @Id
* @Column(type="string", name="country")
* @GeneratedValue(strategy="NONE")
*/
public $country;
}

/**
* @Entity
*/
class State
{
/**
* @Id
* @Column(type="string")
* @GeneratedValue(strategy="NONE")
*/
public $state;

/**
* @Id
* @ManyToOne(targetEntity="Country")
* @JoinColumn(name="country", referencedColumnName="country")
*/
public $country;
}

0 comments on commit 5d5fc67

Please sign in to comment.