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;
|
2016-05-11 02:41:26 +07:00
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase;
|
2014-11-07 14:14:54 +01:00
|
|
|
|
2016-05-11 02:41:26 +07:00
|
|
|
class MergeCompositeToOneKeyTest extends OrmFunctionalTestCase
|
2014-11-07 14:14:54 +01:00
|
|
|
{
|
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
|
|
|
|
2016-12-07 23:33:41 +01:00
|
|
|
$this->_schemaTool->createSchema(
|
|
|
|
[
|
2016-12-08 18:01:04 +01:00
|
|
|
$this->_em->getClassMetadata(Country::class),
|
|
|
|
$this->_em->getClassMetadata(CompositeToOneKeyState::class),
|
2016-12-07 23:33:41 +01:00
|
|
|
]
|
|
|
|
);
|
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
|
|
|
|
2016-12-08 18:01:04 +01:00
|
|
|
$this->assertInstanceOf(CompositeToOneKeyState::class, $state);
|
2015-01-22 12:10:39 +01:00
|
|
|
$this->assertNotSame($state, $merged);
|
2016-12-08 18:01:04 +01:00
|
|
|
$this->assertInstanceOf(Country::class, $merged->country);
|
2015-01-22 12:10:39 +01:00
|
|
|
$this->assertNotSame($country, $merged->country);
|
|
|
|
}
|
2014-11-07 14:14:54 +01:00
|
|
|
}
|