Esempio n. 1
0
 /**
  * 
  * @return EntityManager
  */
 private function getManager()
 {
     $config = new Configuration();
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), __DIR__ . '/../Mocks/Entity/'));
     $em = new EntityManager($this->getMock('Pasinter\\OHM\\Storage\\StorageInterface'), $config);
     $cmFactory = new ClassMetadataFactory();
     $cmFactory->setEntityManager($em);
     return $em;
 }
 public function test_getMetadataFor()
 {
     $cmFactory = new ClassMetadataFactory();
     $emConfig = new Configuration();
     $emConfig->setEntityNamespaces(['PasinterMocks' => 'Pasinter\\Mocks\\Entity']);
     $emConfig->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), __DIR__ . '/../../Mocks/Entity/'));
     $emConfig->setMetadataCacheImpl(new ArrayCache());
     $cmFactory->setEntityManager(new EntityManager($this->getMock('Pasinter\\OHM\\Storage\\StorageInterface'), $emConfig));
     $cmFactory->getAllMetadata();
     $this->assertInstanceOf('Pasinter\\OHM\\Mapping\\ClassMetadata', $cmFactory->getMetadataFor('PasinterMocks:Blog\\Post'));
 }
 protected function setUp()
 {
     if (!$this->storage) {
         $this->storage = $storage = new RedisStorage([]);
         $this->storage->getRedis()->flushall();
         $this->storage->getRedis()->config('SET', 'stop-writes-on-bgsave-error', 'no');
     }
     if (!$this->em) {
         $configuration = new Configuration();
         $configuration->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), __DIR__ . '/../../Mocks/Entity/'));
         $this->em = new EntityManager($this->storage, $configuration);
     }
 }
Esempio n. 4
0
 public function test_metadataDriveImpl()
 {
     $config = new Configuration();
     $config->setMetadataDriverImpl($this->getMock('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver'));
     $this->assertInstanceOf('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver', $config->getMetadataDriverImpl());
 }
Esempio n. 5
0
 /**
  * 
  * @return UnitOfWork
  */
 private function getUow(Changeset $cs = null)
 {
     $storage = $this->getMockBuilder('Pasinter\\OHM\\Storage\\AbstractStorage')->setConstructorArgs([[]])->setMethods(['storeScalar', 'storeSet', 'removeValuesFromSet', 'storeHash', 'delete', 'find', 'exists', 'getName', 'getVersion', 'allocateIds', 'beginTransaction', 'commit', 'rollback'])->getMock();
     $storage->expects($this->any())->method('allocateIds')->willReturnCallback(function ($class, $number = 1) {
         static $ids = [];
         if (!isset($ids[$class])) {
             $ids[$class] = 1;
         }
         $ids[$class] = $ids[$class] + $number;
         return range($ids[$class] - $number, $number);
     });
     $config = new Configuration();
     $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), __DIR__ . '/../../Mocks/Entity/'));
     $em = $this->getMockBuilder('Pasinter\\OHM\\EntityManager')->setConstructorArgs([$storage, $config])->setMethods(['getClassMetadata'])->getMock();
     $em->expects($this->any())->method('getClassMetadata')->will($this->returnValue(new PostClassMetadataMock()));
     $cmf = new ClassMetadataFactory();
     $cmf->setEntityManager($em);
     $uow = new UnitOfWork($em);
     $uow->cs = $cs ?: new Changeset();
     return $uow;
 }