Changeset 1386
- Timestamp:
- 02/27/08 23:30:16 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/test/php/net/stubbles/reflection/stubReflectionClassTestCase.php
r1305 r1386 127 127 128 128 /** 129 * test that getting the methods works correct 130 * 131 * @test 132 */ 133 public function getMethodsByMatcher() 134 { 135 $mockMethodMatcher = $this->getMock('stubMethodMatcher'); 136 $mockMethodMatcher->expects($this->exactly(4)) 137 ->method('matchesMethod') 138 ->will($this->onConsecutiveCalls(true, true, false, false)); 139 $mockMethodMatcher->expects($this->exactly(2)) 140 ->method('matchesAnnotatableMethod') 141 ->will($this->onConsecutiveCalls(false, true)); 142 $stubRefMethods = $this->stubRefClass1->getMethodsByMatcher($mockMethodMatcher); 143 $this->assertEquals(1, count($stubRefMethods)); 144 $this->assertType('stubReflectionMethod', $stubRefMethods[0]); 145 } 146 147 /** 129 148 * test that getting the specified property works correct 130 149 * … … 156 175 $stubRefProperties = $this->stubRefClass2->getProperties(); 157 176 $this->assertEquals(0, count($stubRefProperties)); 177 } 178 179 /** 180 * test that getting the methods works correct 181 * 182 * @test 183 */ 184 public function getPropertiesByMatcher() 185 { 186 $mockPropertyMatcher = $this->getMock('stubPropertyMatcher'); 187 $mockPropertyMatcher->expects($this->exactly(3)) 188 ->method('matchesProperty') 189 ->will($this->onConsecutiveCalls(true, false, false)); 190 $mockPropertyMatcher->expects($this->once()) 191 ->method('matchesAnnotatableProperty') 192 ->will($this->returnValue(true)); 193 $stubRefProperties = $this->stubRefClass1->getPropertiesByMatcher($mockPropertyMatcher); 194 $this->assertEquals(1, count($stubRefProperties)); 195 $this->assertType('stubReflectionProperty', $stubRefProperties[0]); 158 196 } 159 197 … … 214 252 $this->assertEquals('org::stubbles::test::TestClassLoading', $refClass->getFullQualifiedClassName()); 215 253 } 254 255 /** 256 * ensure a stubReflectionPackage is returned 257 * 258 * @test 259 */ 260 public function getPackage() 261 { 262 $package = $this->stubRefClass1->getPackage(); 263 $this->assertType('stubReflectionPackage', $package); 264 } 265 266 /** 267 * reflected classes are always objects 268 * 269 * @test 270 */ 271 public function isObject() 272 { 273 $this->assertTrue($this->stubRefClass1->isObject()); 274 } 275 276 /** 277 * reflected classes are never primitives 278 * 279 * @test 280 */ 281 public function isPrimitive() 282 { 283 $this->assertFalse($this->stubRefClass1->isPrimitive()); 284 } 216 285 } 217 286 ?> trunk/src/test/php/net/stubbles/reflection/stubReflectionObjectTestCase.php
r1305 r1386 153 153 154 154 /** 155 * test that getting the methods works correct 156 * 157 * @test 158 */ 159 public function getMethodsByMatcher() 160 { 161 $mockMethodMatcher = $this->getMock('stubMethodMatcher'); 162 $mockMethodMatcher->expects($this->exactly(4)) 163 ->method('matchesMethod') 164 ->will($this->onConsecutiveCalls(true, true, false, false)); 165 $mockMethodMatcher->expects($this->exactly(2)) 166 ->method('matchesAnnotatableMethod') 167 ->will($this->onConsecutiveCalls(false, true)); 168 $stubRefMethods = $this->stubRefClass1->getMethodsByMatcher($mockMethodMatcher); 169 $this->assertEquals(1, count($stubRefMethods)); 170 $this->assertType('stubReflectionMethod', $stubRefMethods[0]); 171 } 172 173 /** 155 174 * test that getting the specified property works correct 156 175 * … … 182 201 $stubRefProperties = $this->stubRefClass2->getProperties(); 183 202 $this->assertEquals(0, count($stubRefProperties)); 203 } 204 205 /** 206 * test that getting the methods works correct 207 * 208 * @test 209 */ 210 public function getPropertiesByMatcher() 211 { 212 $mockPropertyMatcher = $this->getMock('stubPropertyMatcher'); 213 $mockPropertyMatcher->expects($this->exactly(3)) 214 ->method('matchesProperty') 215 ->will($this->onConsecutiveCalls(true, false, false)); 216 $mockPropertyMatcher->expects($this->once()) 217 ->method('matchesAnnotatableProperty') 218 ->will($this->returnValue(true)); 219 $stubRefProperties = $this->stubRefClass1->getPropertiesByMatcher($mockPropertyMatcher); 220 $this->assertEquals(1, count($stubRefProperties)); 221 $this->assertType('stubReflectionProperty', $stubRefProperties[0]); 184 222 } 185 223 … … 227 265 $this->assertType('stubReflectionExtension', $refClass->getExtension()); 228 266 } 267 268 /** 269 * ensure a stubReflectionPackage is returned 270 * 271 * @test 272 */ 273 public function getPackage() 274 { 275 $package = $this->stubRefClass1->getPackage(); 276 $this->assertType('stubReflectionPackage', $package); 277 } 278 279 /** 280 * reflected classes are always objects 281 * 282 * @test 283 */ 284 public function isObject() 285 { 286 $this->assertTrue($this->stubRefClass1->isObject()); 287 } 288 289 /** 290 * reflected classes are never primitives 291 * 292 * @test 293 */ 294 public function isPrimitive() 295 { 296 $this->assertFalse($this->stubRefClass1->isPrimitive()); 297 } 229 298 } 230 299 ?>
