public function testReferenceReconstruction()
 {
     $em = $this->getMockSqliteEntityManager();
     $referenceRepository = new ProxyReferenceRepository($em);
     $listener = new ORMReferenceListener($referenceRepository);
     $em->getEventManager()->addEventSubscriber($listener);
     $schemaTool = new SchemaTool($em);
     $schemaTool->dropSchema(array());
     $schemaTool->createSchema(array($em->getClassMetadata(self::TEST_ENTITY_ROLE)));
     $roleFixture = new TestFixtures\RoleFixture();
     $roleFixture->setReferenceRepository($referenceRepository);
     $roleFixture->load($em);
     // first test against managed state
     $ref = $referenceRepository->getReference('admin-role');
     $this->assertNotInstanceOf('Doctrine\\ORM\\Proxy\\Proxy', $ref);
     // test reference reconstruction from serialized data (was managed)
     $serializedData = $referenceRepository->serialize();
     $proxyReferenceRepository = new ProxyReferenceRepository($em);
     $proxyReferenceRepository->unserialize($serializedData);
     $ref = $proxyReferenceRepository->getReference('admin-role');
     $this->assertInstanceOf('Doctrine\\ORM\\Proxy\\Proxy', $ref);
     // now test reference reconstruction from identity
     $em->clear();
     $ref = $referenceRepository->getReference('admin-role');
     $this->assertInstanceOf('Doctrine\\ORM\\Proxy\\Proxy', $ref);
     // test reference reconstruction from serialized data (was identity)
     $serializedData = $referenceRepository->serialize();
     $proxyReferenceRepository = new ProxyReferenceRepository($em);
     $proxyReferenceRepository->unserialize($serializedData);
     $ref = $proxyReferenceRepository->getReference('admin-role');
     $this->assertInstanceOf('Doctrine\\ORM\\Proxy\\Proxy', $ref);
 }
 public function testReferenceReconstruction()
 {
     $em = $this->getMockSqliteEntityManager();
     $referenceRepository = new ReferenceRepository($em);
     $em->getEventManager()->addEventSubscriber(new ORMReferenceListener($referenceRepository));
     $schemaTool = new SchemaTool($em);
     $schemaTool->dropSchema(array());
     $schemaTool->createSchema(array($em->getClassMetadata(Role::class)));
     $roleFixture = new TestFixtures\RoleFixture();
     $roleFixture->setReferenceRepository($referenceRepository);
     $roleFixture->load($em);
     // first test against managed state
     $ref = $referenceRepository->getReference('admin-role');
     $this->assertNotInstanceOf(Proxy::class, $ref);
     // now test reference reconstruction from identity
     $em->clear();
     $ref = $referenceRepository->getReference('admin-role');
     $this->assertInstanceOf(Proxy::class, $ref);
 }