public function getAllAnnotations($restriction = false)
 {
     $restriction = Addendum::resolveClassName($restriction);
     $result = array();
     foreach ($this->annotations as $class => $instances) {
         if (!$restriction || $restriction == $class) {
             $result = array_merge($result, $instances);
         }
     }
     return $result;
 }
 public function testIgnoredAnnotationsAreNotUsed()
 {
     Addendum::ignore('FirstAnnotation', 'SecondAnnotation');
     $reflection = new ReflectionAnnotatedClass('Example');
     $this->assertFalse($reflection->hasAnnotation('FirstAnnotation'));
     $this->assertFalse($reflection->hasAnnotation('SecondAnnotation'));
 }
Exemplo n.º 3
0
 public static function resetIgnoredAnnotations()
 {
     self::$ignore = array();
 }
 public function testClassResolverShouldTriggerErrorOnCommonSuffix()
 {
     $this->expectError("Cannot resolve class name for 'CommonSuffix'. Possible matches: Namespace1_CommonSuffix, Namespace2_CommonSuffix");
     Addendum::resolveClassName('CommonSuffix');
 }
Exemplo n.º 5
0
<?php

require_once 'simpletest/unit_tester.php';
require_once 'simpletest/reporter.php';
require_once dirname(__FILE__) . '/addendum_test.php';
require_once dirname(__FILE__) . '/acceptance_test.php';
require_once dirname(__FILE__) . '/annotation_test.php';
require_once dirname(__FILE__) . '/constrained_annotation_test.php';
require_once dirname(__FILE__) . '/annotation_parser_test.php';
require_once dirname(__FILE__) . '/doc_comment_test.php';
$suite = new TestSuite('All tests');
$suite->add(new TestOfAddendum());
$suite->add(new TestOfAnnotations());
$suite->add(new TestOfPerformanceFeatures());
$suite->add(new TestOfSupportingFeatures());
$suite->add(new TestOfAnnotation());
$suite->add(new TestOfAnnotationCollection());
$suite->add(new TestOfConstrainedAnnotation());
$suite->add(new TestOfMatchers());
$suite->add(new TestOfAnnotationMatchers());
$suite->add(new TestOfDocComment());
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
    require_once dirname(__FILE__) . '/namespaces_test.php';
    $suite->add(new TestOfNamespaces());
}
$reporter = TextReporter::inCli() ? new TextReporter() : new HtmlReporter();
Addendum::setRawMode(false);
$suite->run($reporter);
Addendum::setRawMode(true);
$suite->run($reporter);
Exemplo n.º 6
0
 private static function getDeclaredAnnotations()
 {
     if (!self::$annotations) {
         self::$annotations = array();
         foreach (get_declared_classes() as $class) {
             if (is_subclass_of($class, 'Annotation') || $class == 'Annotation') {
                 self::$annotations[] = $class;
             }
         }
     }
     return self::$annotations;
 }
Exemplo n.º 7
0
 protected function getDocComment($reflection)
 {
     return Addendum::getDocComment($reflection);
 }