Пример #1
0
 /**
  * Test @Route annotation initialization.
  *
  * @return null
  */
 public function testGetRouteAnnotation()
 {
     // initialize the annotations to ignore and the aliases
     $ignore = array();
     $aliases = array('Route' => 'AppserverIo\\Psr\\Servlet\\Annotations\\Route');
     // we need to load the annotation instance from the mock servlet implementation
     $reflectionClass = new ReflectionClass('AppserverIo\\Psr\\Servlet\\Annotations\\HelloWorldServlet', $ignore, $aliases);
     $reflectionAnnotation = $reflectionClass->getAnnotation(Route::ANNOTATION);
     $routeAnnotation = $reflectionAnnotation->newInstance($reflectionAnnotation->getAnnotationName(), $reflectionAnnotation->getValues());
     // define the URL patterns and the initialization parameters
     $urlPattern = array('/helloWorld.do', '/helloWorld.do*');
     $initParams = array(array('name1', 'value1'), array('name2', 'value2'));
     // check te values
     $this->assertSame('helloWorld', $routeAnnotation->getName());
     $this->assertSame('Hello World', $routeAnnotation->getDisplayName());
     $this->assertSame('The Hello World! as servlet implementation.', $routeAnnotation->getDescription());
     $this->assertSame($urlPattern, $routeAnnotation->getUrlPattern());
     $this->assertSame($initParams, $routeAnnotation->getInitParams());
 }
Пример #2
0
 /**
  * Test if an execption is thrown if a requested annotation is not available.
  *
  * @return void
  * @expectedException AppserverIo\Lang\Reflection\ReflectionException
  */
 public function testGetAnnotationWithException()
 {
     $this->reflectionClass->getAnnotation('UnknownAnnotation');
 }