Changeset 702
- Timestamp:
- 06/02/07 12:09:51 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/test/php/net/stubbles/reflection/annotations/stubAnnotationFactoryTestCase.php
r501 r702 25 25 public $argh; 26 26 public $veggie; 27 27 28 28 /** 29 29 * Returns the target of the annotation as bitmap. … … 31 31 * @return int 32 32 */ 33 public function getAnnotationTarget() { return stubAnnotation::TARGET_ALL; } 33 public function getAnnotationTarget() { return stubAnnotation::TARGET_ALL; } 34 34 } 35 35 … … 50 50 { 51 51 public $value; 52 public function getAnnotationTarget() { return stubAnnotation::TARGET_ALL; } 52 public function getAnnotationTarget() { return stubAnnotation::TARGET_ALL; } 53 53 } 54 54 … … 62 62 class EmptyAnnotation extends stubAbstractAnnotation implements stubAnnotation 63 63 { 64 public function getAnnotationTarget() { return stubAnnotation::TARGET_CLASS; } 64 public function getAnnotationTarget() { return stubAnnotation::TARGET_CLASS; } 65 65 } 66 66 … … 77 77 } 78 78 79 /** 80 * Annotation with class parameter 81 * 82 * @MyAnnotation( 83 * foo=AnyTestClass.class 84 * ) 85 */ 86 class AnotherTestClass { 87 } 88 79 89 80 90 /** … … 92 102 */ 93 103 protected $comment = "/**\n * a test docblock\n * \n * \n * @param string \$foo\n * @StubAnnotation(foo = 'blub');\n */"; 94 104 95 105 protected $commentComplex = '/** 96 106 * Foobar bla … … 104 114 * @CastedAnnotation[AnotherAnnotation](false) 105 115 * @EmptyAnnotation 116 */'; 117 118 protected $commentWithClass = '/** 119 * Foobar bla 120 * 121 * @access public 122 * @MyAnnotation( 123 * foo=AnyTestClass.class 124 * ) 106 125 */'; 107 126 … … 142 161 $this->assertIsA($castedAnnotation, 'AnotherAnnotation'); 143 162 $this->assertFalse($castedAnnotation->value); 144 163 145 164 $this->expectException('ReflectionException'); 146 165 stubAnnotationFactory::create($this->commentComplex, 'NonExisting', stubAnnotation::TARGET_CLASS, 'MyClass'); 166 167 $myAnnotation = stubAnnotationFactory::create($this->commentCommentWithClass, 'MyAnnotation', stubAnnotation::TARGET_CLASS, 'MyClass'); 168 $this->assertIsA($myAnnotation, 'MyAnnotation'); 169 $this->assertIsA($myAnnotation->foo, 'stubReflectionClass'); 170 } 171 172 /** 173 * test that the cache works as expected 174 */ 175 public function testReflectionClass() 176 { 177 $class = new stubReflectionClass('AnotherTestClass'); 178 $anno = $class->getAnnotation('MyAnnotation'); 147 179 } 148 180 … … 154 186 $class = new stubReflectionClass('AnyTestClass'); 155 187 $anno = $class->getAnnotation('MyAnnotation'); 156 188 157 189 // assert the values read from the annotation 158 190 $this->assertIsA($anno, 'MyAnnotation'); … … 165 197 $this->assertEqual('tomato', $anno->veggie); 166 198 167 // re-fetch 199 // re-fetch 168 200 $anno2 = $class->getAnnotation('MyAnnotation'); 169 201 $this->assertIsA($anno2, 'MyAnnotation'); … … 175 207 $class2 = new stubReflectionClass('AnyTestClass'); 176 208 $anno3 = $class2->getAnnotation('MyAnnotation'); 177 209 178 210 $this->assertIsA($anno, 'MyAnnotation'); 179 211 $this->assertEqual('bar', $anno3->foo);
