1
0
mirror of synced 2024-12-14 23:26:04 +03:00
doctrine2/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php

101 lines
2.3 KiB
PHP
Raw Normal View History

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'),
));
} catch(\PDOException $e) {
}
}
public function testIssue()
{
$user = new DDC1238User;
$user->setName("test");
$this->_em->persist($user);
$this->_em->flush();
$this->_em->clear();
2011-07-04 22:59:42 +04:00
$userId = $user->getId();
$this->_em->clear();
$user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId);
$this->_em->clear();
$userId2 = $user->getId();
$this->assertEquals($userId, $userId2, "This proxy can still be initialized.");
}
public function testIssueProxyClear()
{
$user = new DDC1238User;
$user->setName("test");
$this->_em->persist($user);
$this->_em->flush();
$this->_em->clear();
// force proxy load, getId() doesn't work anymore
$user->getName();
$userId = $user->getId();
$this->_em->clear();
$user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId);
$this->_em->clear();
$user2 = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId);
2011-06-30 22:09:49 +04:00
// force proxy load, getId() doesn't work anymore
$user->getName();
$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
}
}
/**
* @Entity
2011-06-30 22:09:49 +04:00
*/
class DDC1238User
2011-06-30 22:09:49 +04:00
{
/** @Id @GeneratedValue @Column(type="integer") */
private $id;
2011-06-30 22:09:49 +04:00
/**
* @Column
* @var string
*/
private $name;
public function getId()
{
return $this->id;
}
2011-06-30 22:09:49 +04:00
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
}