Beispiel #1
0
    public function setUp()
    {
        if (!$this->entityManager) {
            EntityManagerContainer::clearEntityManager();

            $configuration = new Configuration();
            $configuration->setMetadataDriverImpl(new StaticPHPDriver(__DIR__.'/../../Model'));
            $configuration->setProxyDir(__DIR__.'/../../Proxy');
            $configuration->setProxyNamespace('Proxy');
            $configuration->setAutoGenerateProxyClasses(true);

            $this->entityManager = EntityManager::create(array(
                'driver' => 'pdo_sqlite',
                'path'   => ':memory:',
            ), $configuration);

            // event manager
            $this->eventManager = $this->entityManager->getEventManager();

            // metadata factory
            $this->metadataFactory = $this->entityManager->getMetadataFactory();

            // create schema
            $schemaTool = new SchemaTool($this->entityManager);
            $schemaTool->createSchema($this->metadataFactory->getAllMetadata());

            // entity manager container
            EntityManagerContainer::setEntityManager($this->entityManager);
        }
    }
    public function testEntityManager()
    {
        Container::clearEntityManager();
        $this->assertNull(Container::getEntityManager());

        Container::setEntityManager($this->entityManager);
        $this->assertSame($this->entityManager, Container::getEntityManager());

        Container::clearEntityManager();
        $this->assertNull(Container::getEntityManager());
    }
Beispiel #3
0
 static public function getEntityManager()
 {
     return EntityManagerContainer::getEntityManager();
 }