Doctrine\Tests\Common\DataFixtures\ReferenceRepositoryTest::testReferenceReconstruction PHP Method

testReferenceReconstruction() public method

    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);
    }