Ejemplo n.º 1
0
 public function test__construct()
 {
     $metadata = new \Pok\PoolDBM\Mapping\ClassMetadata(__NAMESPACE__ . '\\ModelTest');
     $metadata->addModel('entity', __NAMESPACE__ . '\\EntityTest', array());
     $metadata->setIdentifier('entity', 'id');
     $metadataFactory = $this->getMock('Pok\\PoolDBM\\Mapping\\ClassMetadataFactory', array('getMetadataFor', 'setModelManager'));
     $metadataFactory->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata));
     $pool = new Pool();
     $pool->addManager('entity', new EntityManager());
     $manager = new ModelManager($pool, $metadataFactory);
     $this->assertInstanceOf('Pok\\PoolDBM\\Mapping\\ClassMetadataFactory', $manager->getMetadataFactory());
     $this->assertTrue($manager->getPool()->hasManager('entity'));
     $this->assertInstanceOf(get_class($metadata), $manager->getClassMetadata(__NAMESPACE__ . '\\ModelTest'));
     $this->assertTrue($manager->createQueryBuilder(__NAMESPACE__ . '\\ModelTest', 'test'));
     $this->assertInstanceOf('Pok\\PoolDBM\\ModelRepository', $manager->getRepository(__NAMESPACE__ . '\\ModelTest'));
     $this->assertTrue($manager->contains(new ModelTest()));
     // unitOfWork
     $this->assertInstanceOf('Pok\\PoolDBM\\UnitOfWork', $manager->getUnitOfWork());
     $manager->persist(new ModelTest());
     $manager->remove(new ModelTest());
     $manager->refresh(new ModelTest());
     $manager->detach(new ModelTest());
     $manager->merge(new ModelTest());
     $manager->flush(new ModelTest());
     $manager->close();
     try {
         $manager->flush(new ModelTest());
     } catch (\RuntimeException $e) {
         $this->assertEquals('Model manager is closed.', $e->getMessage());
     }
 }
Ejemplo n.º 2
0
 public function createQueryBuilder($alias)
 {
     return $this->manager->createQueryBuilder($this->getClassName(), $alias);
 }