DDC381Test.php 1.3 KB

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