/** * Tests an exception thrown on an invalid docblock template. * * This exception is never thrown when using TR the "standard way". * * @expectedException \TokenReflection\Exception\RuntimeException */ public function testAnnotationInvalidTemplate() { $broker = $this->getBroker(); $broker->processString('<?php class AnnotationInvalidTemplate {}', 'annotationInvalidTemplate.php'); $this->assertTrue($broker->hasClass('AnnotationInvalidTemplate')); $class = $broker->getClass('AnnotationInvalidTemplate'); $a = new ReflectionAnnotation($class); $a->setTemplates(array(new \Exception())); }
/** * This test checks if the annotations passed from a PHP reflection class will * be initialized correctly. * * @return void */ public function testFromReflectionClass() { // load the annotations of this class $annotations = ReflectionAnnotation::fromReflectionClass(new ReflectionClass($this)); // check if we can find the default annotations $this->assertTrue(isset($annotations['author'])); $this->assertTrue(isset($annotations['copyright'])); $this->assertTrue(isset($annotations['link'])); $this->assertTrue(isset($annotations['license'])); // try to load the @Test annotation with the specified name $this->assertSame($annotations['Test']->getValue('name'), 'ReflectionAnnotationTest'); }