本文整理汇总了PHP中Doctrine\Common\Annotations\AnnotationReader::getAutoloadAnnotations方法的典型用法代码示例。如果您正苦于以下问题:PHP AnnotationReader::getAutoloadAnnotations方法的具体用法?PHP AnnotationReader::getAutoloadAnnotations怎么用?PHP AnnotationReader::getAutoloadAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Annotations\AnnotationReader
的用法示例。
在下文中一共展示了AnnotationReader::getAutoloadAnnotations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAnnotations
public function testAnnotations()
{
$reader = new AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
$reader->setDefaultAnnotationNamespace('Doctrine\\Tests\\Common\\Annotations\\');
$this->assertFalse($reader->getAutoloadAnnotations());
$reader->setAutoloadAnnotations(true);
$this->assertTrue($reader->getAutoloadAnnotations());
$reader->setAutoloadAnnotations(false);
$this->assertFalse($reader->getAutoloadAnnotations());
$class = new ReflectionClass('Doctrine\\Tests\\Common\\Annotations\\DummyClass');
$classAnnots = $reader->getClassAnnotations($class);
$annotName = 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation';
$this->assertEquals(1, count($classAnnots));
$this->assertTrue($classAnnots[$annotName] instanceof DummyAnnotation);
$this->assertEquals("hello", $classAnnots[$annotName]->dummyValue);
$field1Prop = $class->getProperty('field1');
$propAnnots = $reader->getPropertyAnnotations($field1Prop);
$this->assertEquals(1, count($propAnnots));
$this->assertTrue($propAnnots[$annotName] instanceof DummyAnnotation);
$this->assertEquals("fieldHello", $propAnnots[$annotName]->dummyValue);
$getField1Method = $class->getMethod('getField1');
$methodAnnots = $reader->getMethodAnnotations($getField1Method);
$this->assertEquals(1, count($methodAnnots));
$this->assertTrue($methodAnnots[$annotName] instanceof DummyAnnotation);
$this->assertEquals(array(1, 2, "three"), $methodAnnots[$annotName]->value);
$field2Prop = $class->getProperty('field2');
$propAnnots = $reader->getPropertyAnnotations($field2Prop);
$this->assertEquals(1, count($propAnnots));
$this->assertTrue(isset($propAnnots['Doctrine\\Tests\\Common\\Annotations\\DummyJoinTable']));
$joinTableAnnot = $propAnnots['Doctrine\\Tests\\Common\\Annotations\\DummyJoinTable'];
$this->assertEquals(1, count($joinTableAnnot->joinColumns));
$this->assertEquals(1, count($joinTableAnnot->inverseJoinColumns));
$this->assertTrue($joinTableAnnot->joinColumns[0] instanceof DummyJoinColumn);
$this->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof DummyJoinColumn);
$this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name);
$this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName);
$this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name);
$this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName);
$dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation');
$this->assertEquals('', $dummyAnnot->dummyValue);
$this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value);
$dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation');
$this->assertEquals('fieldHello', $dummyAnnot->dummyValue);
$classAnnot = $reader->getClassAnnotation($class, 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation');
$this->assertEquals('hello', $classAnnot->dummyValue);
}