initializeReflection() публичный Метод

Initializes a new ClassMetadata instance that will hold the object-relational mapping metadata of the class with the given name.
public initializeReflection ( Doctrine\Common\Persistence\Mapping\ReflectionService $reflService )
$reflService Doctrine\Common\Persistence\Mapping\ReflectionService
Пример #1
0
 public function testClassName()
 {
     $cm = new ClassMetadata("Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Person");
     $cm->initializeReflection(new RuntimeReflectionService());
     $this->assertEquals("Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Person", $cm->name);
     $this->assertInstanceOf('ReflectionClass', $cm->reflClass);
     return $cm;
 }
Пример #2
0
 /**
  * @covers Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver::loadMetadataForClass
  * @covers Doctrine\ODM\PHPCR\Mapping\Driver\YamlDriver::loadMetadataForClass
  * @covers Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver::loadMetadataForClass
  */
 public function testLoadMapping()
 {
     $className = 'Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\PropertyMappingObj';
     $mappingDriver = $this->loadDriver();
     $class = new ClassMetadata($className);
     $class->initializeReflection(new RuntimeReflectionService());
     $mappingDriver->loadMetadataForClass($className, $class);
     return $class;
 }
 public function testLoadMetadataForNonDocumentThrowsException()
 {
     $cm = new ClassMetadata('stdClass');
     $cm->initializeReflection(new RuntimeReflectionService());
     $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
     $annotationDriver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver($reader);
     $this->setExpectedException('Doctrine\\ODM\\PHPCR\\Mapping\\MappingException');
     $annotationDriver->loadMetadataForClass('stdClass', $cm);
 }
 /**
  * @covers Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver::loadMetadataForClass
  * @covers Doctrine\ODM\PHPCR\Mapping\Driver\YamlDriver::loadMetadataForClass
  * @covers Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver::loadMetadataForClass
  */
 public function testLoadMapping()
 {
     $className = 'Doctrine\\Tests\\Models\\CMS\\CmsUser';
     $mappingDriver = $this->loadDriver();
     $class = new ClassMetadata($className);
     $class->initializeReflection(new RuntimeReflectionService());
     $mappingDriver->loadMetadataForClass($className, $class);
     return $class;
 }
Пример #5
0
 public function setUp()
 {
     if (!class_exists('Jackalope\\Factory', true)) {
         $this->markTestSkipped('The Node needs to be properly mocked/stubbed. Remove dependency to Jackalope');
     }
     $this->factory = new Factory();
     $this->session = $this->getMock('Jackalope\\Session', array(), array($this->factory), '', false);
     $this->objectManager = $this->getMock('Jackalope\\ObjectManager', array(), array($this->factory), '', false);
     $this->type = 'Doctrine\\Tests\\ODM\\PHPCR\\UoWUser';
     $this->dm = DocumentManager::create($this->session);
     $this->uow = new UnitOfWork($this->dm);
     $cmf = $this->dm->getMetadataFactory();
     $metadata = new ClassMetadata($this->type);
     $metadata->initializeReflection($cmf->getReflectionService());
     $metadata->mapId(array('fieldName' => 'id', 'id' => true));
     $metadata->idGenerator = ClassMetadata::GENERATOR_TYPE_ASSIGNED;
     $metadata->mapField(array('fieldName' => 'username', 'type' => 'string'));
     $cmf->setMetadataFor($this->type, $metadata);
 }
 public function testLoadMappedSuperclassChildTypeMapping()
 {
     $parentClass = $this->loadMetadataForClassname('Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Model\\ClassInheritanceParentMappingObject');
     $mappingDriver = $this->loadDriver();
     $subClass = new ClassMetadata($className = 'Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Model\\ClassInheritanceChildMappingObject');
     $subClass->initializeReflection(new RuntimeReflectionService());
     $subClass->mapId($parentClass->mappings[$parentClass->identifier], $parentClass);
     $mappingDriver->loadMetadataForClass($className, $subClass);
     return $subClass;
 }
Пример #7
0
 public function testClassMetadataInstanceSerialization()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     // Test initial state
     $this->assertTrue(count($cm->getReflectionProperties()) == 0);
     $this->assertInstanceOf('ReflectionClass', $cm->reflClass);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
     $this->assertEquals(array(), $cm->parentClasses);
     $this->assertEquals(0, count($cm->referenceMappings));
     // Customize state
     $cm->setParentClasses(array("UserParent"));
     $cm->setCustomRepositoryClassName("CmsUserRepository");
     $cm->setNodeType('foo:bar');
     $cm->mapManyToOne(array('fieldName' => 'address', 'targetDocument' => 'CmsAddress', 'mappedBy' => 'foo'));
     $this->assertEquals(1, count($cm->referenceMappings));
     $serialized = serialize($cm);
     /** @var ClassMetadata $cm */
     $cm = unserialize($serialized);
     $cm->wakeupReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     // Check state
     $this->assertTrue(count($cm->getReflectionProperties()) > 0);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS', $cm->namespace);
     $this->assertInstanceOf('ReflectionClass', $cm->reflClass);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
     $this->assertEquals(array('UserParent'), $cm->parentClasses);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUserRepository', $cm->customRepositoryClassName);
     $this->assertEquals('foo:bar', $cm->getNodeType());
     $this->assertEquals(ClassMetadata::MANY_TO_ONE, $cm->getTypeOfField('address'));
     $this->assertEquals(1, count($cm->referenceMappings));
     $this->assertTrue($cm->hasAssociation('address'));
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsAddress', $cm->getAssociationTargetClass('address'));
 }
Пример #8
0
 /**
  * It should throw an exception if the given class is not allowed.
  *
  * @expectedException \Doctrine\ODM\PHPCR\Exception\OutOfBoundsException
  * @expectedExceptionMessage does not allow children of type "stdClass"
  */
 public function testAssertValidChildClassesNotAllowed()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Person');
     $cm->initializeReflection(new RuntimeReflectionService());
     $childCm = new ClassMetadata('stdClass');
     $childCm->initializeReflection(new RuntimeReflectionService());
     $cm->setChildClasses(array('Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Person'));
     $cm->assertValidChildClass($childCm);
 }