2014-11-07 14:14:54 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Functional;
|
|
|
|
|
2015-01-22 12:10:39 +01:00
|
|
|
use Doctrine\Tests\Models\MixedToOneIdentity\CompositeToOneKeyState;
|
|
|
|
use Doctrine\Tests\Models\MixedToOneIdentity\Country;
|
2014-11-07 14:14:54 +01:00
|
|
|
|
|
|
|
class MergeCompositeToOneKeyTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|
|
|
{
|
2015-01-22 12:10:39 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2014-11-07 14:14:54 +01:00
|
|
|
protected function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2015-01-22 12:10:39 +01:00
|
|
|
|
2014-11-07 14:14:54 +01:00
|
|
|
$this->_schemaTool->createSchema(array(
|
2015-01-22 12:10:39 +01:00
|
|
|
$this->_em->getClassMetadata(Country::CLASSNAME),
|
|
|
|
$this->_em->getClassMetadata(CompositeToOneKeyState::CLASSNAME),
|
2014-11-07 14:14:54 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2015-01-22 12:10:39 +01:00
|
|
|
/**
|
|
|
|
* @group DDC-3378
|
|
|
|
* @group 1176
|
|
|
|
*/
|
|
|
|
public function testMergingOfEntityWithCompositeIdentifierContainingToOneAssociation()
|
2014-11-07 14:14:54 +01:00
|
|
|
{
|
2015-01-22 12:10:39 +01:00
|
|
|
$country = new Country();
|
2014-11-07 14:14:54 +01:00
|
|
|
$country->country = 'US';
|
|
|
|
|
2015-01-22 12:10:39 +01:00
|
|
|
$state = new CompositeToOneKeyState();
|
|
|
|
$state->state = 'CA';
|
|
|
|
$state->country = $country;
|
2014-11-07 14:14:54 +01:00
|
|
|
|
2015-01-22 12:10:39 +01:00
|
|
|
/* @var $merged CompositeToOneKeyState */
|
|
|
|
$merged = $this->_em->merge($state);
|
2014-11-07 14:14:54 +01:00
|
|
|
|
2015-01-22 12:10:39 +01:00
|
|
|
$this->assertInstanceOf(CompositeToOneKeyState::CLASSNAME, $state);
|
|
|
|
$this->assertNotSame($state, $merged);
|
|
|
|
$this->assertInstanceOf(Country::CLASSNAME, $merged->country);
|
|
|
|
$this->assertNotSame($country, $merged->country);
|
|
|
|
}
|
2014-11-07 14:14:54 +01:00
|
|
|
}
|