Ejemplo n.º 1
0
 public function testReflectionAnnotatedClass()
 {
     $reflection = new ReflectionAnnotatedClass('Example');
     $this->assertTrue($reflection->hasAnnotation('FirstAnnotation'));
     $this->assertTrue($reflection->hasAnnotation('SecondAnnotation'));
     $this->assertFalse($reflection->hasAnnotation('NonExistentAnnotation'));
     $this->assertInstanceOf('FirstAnnotation', $reflection->getAnnotation('FirstAnnotation'));
     $this->assertInstanceOf('SecondAnnotation', $reflection->getAnnotation('SecondAnnotation'));
     $annotations = $reflection->getAnnotations();
     $this->assertEquals(count($annotations), 2);
     $this->assertInstanceOf('FirstAnnotation', $annotations[0]);
     $this->assertInstanceOf('SecondAnnotation', $annotations[1]);
     $this->assertFalse($reflection->getAnnotation('NonExistentAnnotation'));
     $this->assertInstanceOf('Addendum\\ReflectionAnnotatedMethod', $reflection->getConstructor());
     $this->assertInstanceOf('Addendum\\ReflectionAnnotatedMethod', $reflection->getMethod('exampleMethod'));
     foreach ($reflection->getMethods() as $method) {
         $this->assertInstanceOf('Addendum\\ReflectionAnnotatedMethod', $method);
     }
     $this->assertInstanceOf('Addendum\\ReflectionAnnotatedProperty', $reflection->getProperty('exampleProperty'));
     foreach ($reflection->getProperties() as $property) {
         $this->assertInstanceOf('Addendum\\ReflectionAnnotatedProperty', $property);
     }
     foreach ($reflection->getInterfaces() as $interface) {
         $this->assertInstanceOf('Addendum\\ReflectionAnnotatedClass', $interface);
     }
     $this->assertInstanceOf('Addendum\\ReflectionAnnotatedClass', $reflection->getParentClass());
 }
Ejemplo n.º 2
0
 public function testMultiTargetAnnotationThrowsNoErrorWhenOnRightPlace()
 {
     $reflection = new ReflectionAnnotatedClass('SuccesfullyAnnotatedClass');
     $method = $reflection->getProperty('property2');
 }