2009-12-08 00:20:04 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
|
|
|
|
2009-12-17 16:37:47 +03:00
|
|
|
use Doctrine\Tests\Models\Company\CompanyEmployee;
|
|
|
|
|
2009-12-08 00:20:04 +03:00
|
|
|
require_once __DIR__ . '/../../../TestInit.php';
|
|
|
|
|
|
|
|
class DDC168Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
|
|
|
{
|
2010-12-22 00:33:23 +03:00
|
|
|
protected $oldMetadata;
|
|
|
|
|
2009-12-08 00:20:04 +03:00
|
|
|
protected function setUp() {
|
|
|
|
$this->useModelSet('company');
|
|
|
|
parent::setUp();
|
2010-12-22 00:33:23 +03:00
|
|
|
|
|
|
|
$this->oldMetadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyEmployee');
|
|
|
|
|
|
|
|
$metadata = clone $this->oldMetadata;
|
|
|
|
ksort($metadata->reflFields);
|
|
|
|
$this->_em->getMetadataFactory()->setMetadataFor('Doctrine\Tests\Models\Company\CompanyEmployee', $metadata);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
$this->_em->getMetadataFactory()->setMetadataFor('Doctrine\Tests\Models\Company\CompanyEmployee', $this->oldMetadata);
|
|
|
|
parent::tearDown();
|
2009-12-08 00:20:04 +03:00
|
|
|
}
|
2009-12-09 15:37:57 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group DDC-168
|
|
|
|
*/
|
2009-12-08 00:20:04 +03:00
|
|
|
public function testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFieldsArray()
|
|
|
|
{
|
2010-04-01 00:47:35 +04:00
|
|
|
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
|
2009-12-08 00:20:04 +03:00
|
|
|
|
2009-12-17 16:37:47 +03:00
|
|
|
$spouse = new CompanyEmployee;
|
2009-12-08 00:20:04 +03:00
|
|
|
$spouse->setName("Blub");
|
2009-12-17 16:37:47 +03:00
|
|
|
$spouse->setDepartment("Accounting");
|
|
|
|
$spouse->setSalary(500);
|
2009-12-08 00:20:04 +03:00
|
|
|
|
2009-12-17 16:37:47 +03:00
|
|
|
$employee = new CompanyEmployee;
|
2009-12-08 00:20:04 +03:00
|
|
|
$employee->setName("Foo");
|
|
|
|
$employee->setDepartment("bar");
|
|
|
|
$employee->setSalary(1000);
|
|
|
|
$employee->setSpouse($spouse);
|
|
|
|
|
|
|
|
$this->_em->persist($spouse);
|
|
|
|
$this->_em->persist($employee);
|
|
|
|
|
|
|
|
$this->_em->flush();
|
|
|
|
$this->_em->clear();
|
|
|
|
|
|
|
|
$q = $this->_em->createQuery("SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e WHERE e.name = ?1");
|
|
|
|
$q->setParameter(1, "Foo");
|
|
|
|
$theEmployee = $q->getSingleResult();
|
|
|
|
|
|
|
|
$this->assertEquals("bar", $theEmployee->getDepartment());
|
2009-12-17 16:37:47 +03:00
|
|
|
$this->assertEquals("Foo", $theEmployee->getName());
|
|
|
|
$this->assertEquals(1000, $theEmployee->getSalary());
|
2011-07-26 17:22:57 +04:00
|
|
|
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $theEmployee);
|
|
|
|
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $theEmployee->getSpouse());
|
2009-12-08 00:20:04 +03:00
|
|
|
}
|
|
|
|
}
|