2011-06-30 22:09:49 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Tests\Models\CMS\CmsEmployee;
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../../../TestInit.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group DDC-1238
|
|
|
|
*/
|
|
|
|
class DDC1238Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
try {
|
|
|
|
$this->_schemaTool->createSchema(array(
|
|
|
|
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1238User'),
|
|
|
|
));
|
2011-10-30 01:58:09 +04:00
|
|
|
} catch(\Exception $e) {
|
|
|
|
|
2011-06-30 22:09:49 +04:00
|
|
|
}
|
|
|
|
}
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-06-30 22:09:49 +04:00
|
|
|
public function testIssue()
|
|
|
|
{
|
|
|
|
$user = new DDC1238User;
|
|
|
|
$user->setName("test");
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-06-30 22:09:49 +04:00
|
|
|
$this->_em->persist($user);
|
|
|
|
$this->_em->flush();
|
|
|
|
$this->_em->clear();
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-07-04 22:59:42 +04:00
|
|
|
$userId = $user->getId();
|
|
|
|
$this->_em->clear();
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-07-04 22:59:42 +04:00
|
|
|
$user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId);
|
2011-07-04 22:35:33 +04:00
|
|
|
$this->_em->clear();
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-07-05 01:19:08 +04:00
|
|
|
$userId2 = $user->getId();
|
|
|
|
$this->assertEquals($userId, $userId2, "This proxy can still be initialized.");
|
|
|
|
}
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-07-05 01:19:08 +04:00
|
|
|
public function testIssueProxyClear()
|
|
|
|
{
|
|
|
|
$user = new DDC1238User;
|
|
|
|
$user->setName("test");
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-07-05 01:19:08 +04:00
|
|
|
$this->_em->persist($user);
|
|
|
|
$this->_em->flush();
|
|
|
|
$this->_em->clear();
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-10-15 19:31:09 +04:00
|
|
|
// force proxy load, getId() doesn't work anymore
|
|
|
|
$user->getName();
|
2011-07-04 22:35:33 +04:00
|
|
|
$userId = $user->getId();
|
2011-07-05 01:19:08 +04:00
|
|
|
$this->_em->clear();
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-07-05 01:19:08 +04:00
|
|
|
$user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId);
|
|
|
|
$this->_em->clear();
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-07-05 01:19:08 +04:00
|
|
|
$user2 = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId);
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-10-15 19:31:09 +04:00
|
|
|
// force proxy load, getId() doesn't work anymore
|
|
|
|
$user->getName();
|
2011-07-05 01:19:08 +04:00
|
|
|
$this->assertNull($user->getId(), "Now this is null, we already have a user instance of that type");
|
2011-06-30 22:09:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-07-05 01:19:08 +04:00
|
|
|
* @Entity
|
2011-06-30 22:09:49 +04:00
|
|
|
*/
|
2011-07-05 01:19:08 +04:00
|
|
|
class DDC1238User
|
2011-06-30 22:09:49 +04:00
|
|
|
{
|
2011-07-05 01:19:08 +04:00
|
|
|
/** @Id @GeneratedValue @Column(type="integer") */
|
|
|
|
private $id;
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-06-30 22:09:49 +04:00
|
|
|
/**
|
|
|
|
* @Column
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $name;
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-07-05 01:19:08 +04:00
|
|
|
public function getId()
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
2011-10-30 01:58:09 +04:00
|
|
|
|
2011-06-30 22:09:49 +04:00
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setName($name)
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|