Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC381Test.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4 use Doctrine\ORM\UnitOfWork;
5
6 require_once __DIR__ . '/../../../TestInit.php';
7
8 class DDC381Test extends \Doctrine\Tests\OrmFunctionalTestCase
9 {
10     protected function setUp()
11     {
12         parent::setUp();
13
14         try {
15             $this->_schemaTool->createSchema(array(
16                 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC381Entity'),
17             ));
18         } catch(\Exception $e) {
19
20         }
21     }
22
23     public function testCallUnserializedProxyMethods()
24     {
25         $entity = new DDC381Entity();
26
27         $this->_em->persist($entity);
28         $this->_em->flush();
29         $this->_em->clear();
30         $persistedId = $entity->getId();
31
32         $entity = $this->_em->getReference('Doctrine\Tests\ORM\Functional\Ticket\DDC381Entity', $persistedId);
33
34         // explicitly load proxy (getId() does not trigger reload of proxy)
35         $id = $entity->getOtherMethod();
36
37         $data = serialize($entity);
38         $entity = unserialize($data);
39
40         $this->assertEquals($persistedId, $entity->getId());
41     }
42 }
43
44 /**
45  * @Entity
46  */
47 class DDC381Entity
48 {
49     /**
50      * @Id @Column(type="integer") @GeneratedValue
51      */
52     protected $id;
53
54     public function getId()
55     {
56         return $this->id;
57     }
58
59     public function getOtherMethod()
60     {
61
62     }
63 }