Arbit - project tracking

Static Reflection

Browse source code

File: / test/ ReflectionClassProxyTest.php

Type
text/plain text/plain
Last Author
mapi
Version
269
Line Rev. Author Source
1 189 mapi <?php
2 mapi /**
3 mapi * This file is part of the static reflection component.
4 mapi *
5 mapi * PHP Version 5
6 mapi *
7 247 mapi * Copyright (c) 2009-2010, Manuel Pichler <mapi@pdepend.org>.
8 189 mapi * All rights reserved.
9 mapi *
10 mapi * Redistribution and use in source and binary forms, with or without
11 mapi * modification, are permitted provided that the following conditions
12 mapi * are met:
13 mapi *
14 mapi * * Redistributions of source code must retain the above copyright
15 mapi * notice, this list of conditions and the following disclaimer.
16 mapi *
17 mapi * * Redistributions in binary form must reproduce the above copyright
18 mapi * notice, this list of conditions and the following disclaimer in
19 mapi * the documentation and/or other materials provided with the
20 mapi * distribution.
21 mapi *
22 mapi * * Neither the name of Manuel Pichler nor the names of his
23 mapi * contributors may be used to endorse or promote products derived
24 mapi * from this software without specific prior written permission.
25 mapi *
26 mapi * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 mapi * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 mapi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29 mapi * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30 mapi * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31 mapi * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32 mapi * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 mapi * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 mapi * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 mapi * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36 mapi * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 mapi * POSSIBILITY OF SUCH DAMAGE.
38 mapi *
39 mapi * @category PHP
40 248 mapi * @package pdepend\reflection
41 189 mapi * @author Manuel Pichler <mapi@pdepend.org>
42 247 mapi * @copyright 2009-2010 Manuel Pichler. All rights reserved.
43 189 mapi * @license http://www.opensource.org/licenses/bsd-license.php BSD License
44 mapi * @version SVN: $Id$
45 mapi * @link http://pdepend.org/
46 mapi */
47 mapi
48 248 mapi namespace pdepend\reflection;
49 189 mapi
50 mapi require_once 'BaseTest.php';
51 mapi
52 mapi /**
53 mapi * Test case for the reflection class proxy.
54 mapi *
55 mapi * @category PHP
56 248 mapi * @package pdepend\reflection
57 189 mapi * @author Manuel Pichler <mapi@pdepend.org>
58 247 mapi * @copyright 2009-2010 Manuel Pichler. All rights reserved.
59 189 mapi * @license http://www.opensource.org/licenses/bsd-license.php BSD License
60 mapi * @version Release: @package_version@
61 mapi * @link http://pdepend.org/
62 mapi */
63 mapi class ReflectionClassProxyTest extends BaseTest
64 mapi {
65 mapi /**
66 mapi * @return void
67 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
68 189 mapi * @group reflection
69 mapi * @group unittest
70 mapi */
71 mapi public function testProxyGetFileNameDelegatesToRealSubject()
72 mapi {
73 mapi $proxy = $this->_createClassProxy( 'getFileName' );
74 mapi $proxy->getFileName();
75 mapi }
76 mapi
77 mapi /**
78 mapi * @return void
79 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
80 189 mapi * @group reflection
81 mapi * @group unittest
82 mapi */
83 mapi public function testProxyGetNameDelegatesToRealSubject()
84 mapi {
85 mapi $proxy = $this->_createClassProxy( 'getName' );
86 mapi $proxy->getName();
87 mapi }
88 mapi
89 mapi /**
90 mapi * @return void
91 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
92 189 mapi * @group reflection
93 mapi * @group unittest
94 mapi */
95 mapi public function testProxyGetShortNameDelegatesToRealSubject()
96 mapi {
97 mapi $proxy = $this->_createClassProxy( 'getShortName' );
98 mapi $proxy->getShortName();
99 mapi }
100 mapi
101 mapi /**
102 mapi * @return void
103 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
104 189 mapi * @group reflection
105 mapi * @group unittest
106 mapi */
107 mapi public function testProxyGetNamespaceNameDelegatesToRealSubject()
108 mapi {
109 mapi $proxy = $this->_createClassProxy( 'getNamespaceName' );
110 mapi $proxy->getNamespaceName();
111 mapi }
112 mapi
113 mapi /**
114 mapi * @return void
115 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
116 189 mapi * @group reflection
117 mapi * @group unittest
118 mapi */
119 mapi public function testProxyInNamespaceDelegatesToRealSubject()
120 mapi {
121 mapi $proxy = $this->_createClassProxy( 'inNamespace' );
122 mapi $proxy->inNamespace();
123 mapi }
124 mapi
125 mapi /**
126 mapi * @return void
127 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
128 189 mapi * @group reflection
129 mapi * @group unittest
130 mapi */
131 mapi public function testProxyGetDocCommentDelegatesToRealSubject()
132 mapi {
133 mapi $proxy = $this->_createClassProxy( 'getDocComment' );
134 mapi $proxy->getDocComment();
135 mapi }
136 mapi
137 mapi /**
138 mapi * @return void
139 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
140 189 mapi * @group reflection
141 mapi * @group unittest
142 mapi */
143 mapi public function testProxyGetModifiersDelegatesToRealSubject()
144 mapi {
145 mapi $proxy = $this->_createClassProxy( 'getModifiers' );
146 mapi $proxy->getModifiers();
147 mapi }
148 mapi
149 mapi /**
150 mapi * @return void
151 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
152 189 mapi * @group reflection
153 mapi * @group unittest
154 mapi */
155 mapi public function testProxyIsAbstractDelegatesToRealSubject()
156 mapi {
157 mapi $proxy = $this->_createClassProxy( 'isAbstract' );
158 mapi $proxy->isAbstract();
159 mapi }
160 mapi
161 mapi /**
162 mapi * @return void
163 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
164 189 mapi * @group reflection
165 mapi * @group unittest
166 mapi */
167 mapi public function testProxyIsFinalDelegatesToRealSubject()
168 mapi {
169 mapi $proxy = $this->_createClassProxy( 'isFinal' );
170 mapi $proxy->isFinal();
171 mapi }
172 mapi
173 mapi /**
174 mapi * @return void
175 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
176 189 mapi * @group reflection
177 mapi * @group unittest
178 mapi */
179 mapi public function testProxyIsInterfaceDelegatesToRealSubject()
180 mapi {
181 mapi $proxy = $this->_createClassProxy( 'isInterface' );
182 mapi $proxy->isInterface();
183 mapi }
184 mapi
185 mapi /**
186 mapi * @return void
187 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
188 189 mapi * @group reflection
189 mapi * @group unittest
190 mapi */
191 mapi public function testProxyIsInternalDelegatesToRealSubject()
192 mapi {
193 mapi $proxy = $this->_createClassProxy( 'isInternal' );
194 mapi $proxy->isInternal();
195 mapi }
196 mapi
197 mapi /**
198 mapi * @return void
199 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
200 189 mapi * @group reflection
201 mapi * @group unittest
202 mapi */
203 mapi public function testProxyIsUserDefinedDelegatesToRealSubject()
204 mapi {
205 mapi $proxy = $this->_createClassProxy( 'isUserDefined' );
206 mapi $proxy->isUserDefined();
207 mapi }
208 mapi
209 mapi /**
210 mapi * @return void
211 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
212 189 mapi * @group reflection
213 mapi * @group unittest
214 mapi */
215 mapi public function testProxyIsInstanceDelegatesToRealSubject()
216 mapi {
217 mapi $proxy = $this->_createClassProxy( 'isInstance' );
218 mapi $proxy->isInstance( $this );
219 mapi }
220 mapi
221 mapi /**
222 mapi * @return void
223 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
224 189 mapi * @group reflection
225 mapi * @group unittest
226 mapi */
227 mapi public function testProxyIsInstantiableDelegatesToRealSubject()
228 mapi {
229 mapi $proxy = $this->_createClassProxy( 'isInstantiable' );
230 mapi $proxy->isInstantiable();
231 mapi }
232 mapi
233 mapi /**
234 mapi * @return void
235 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
236 189 mapi * @group reflection
237 mapi * @group unittest
238 mapi */
239 mapi public function testProxyIsIterateableDelegatesToRealSubject()
240 mapi {
241 mapi $proxy = $this->_createClassProxy( 'isIterateable' );
242 mapi $proxy->isIterateable();
243 mapi }
244 mapi
245 mapi /**
246 mapi * @return void
247 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
248 189 mapi * @group reflection
249 mapi * @group unittest
250 mapi */
251 mapi public function testProxyIsSubclassOfDelegatesToRealSubject()
252 mapi {
253 mapi $proxy = $this->_createClassProxy( 'isSubclassOf' );
254 mapi $proxy->isSubclassOf( '\stdClass' );
255 mapi }
256 mapi
257 mapi /**
258 mapi * @return void
259 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
260 189 mapi * @group reflection
261 mapi * @group unittest
262 mapi */
263 mapi public function testProxyHasConstantDelegatesToRealSubject()
264 mapi {
265 mapi $proxy = $this->_createClassProxy( 'hasConstant' );
266 mapi $proxy->hasConstant( 'FOO' );
267 mapi }
268 mapi
269 mapi /**
270 mapi * @return void
271 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
272 189 mapi * @group reflection
273 mapi * @group unittest
274 mapi */
275 mapi public function testProxyGetConstantDelegatesToRealSubject()
276 mapi {
277 mapi $proxy = $this->_createClassProxy( 'getConstant' );
278 mapi $proxy->getConstant( 'FOO' );
279 mapi }
280 mapi
281 mapi /**
282 mapi * @return void
283 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
284 189 mapi * @group reflection
285 mapi * @group unittest
286 mapi */
287 mapi public function testProxyGetConstantsDelegatesToRealSubject()
288 mapi {
289 mapi $proxy = $this->_createClassProxy( 'getConstants' );
290 mapi $proxy->getConstants();
291 mapi }
292 mapi
293 mapi /**
294 mapi * @return void
295 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
296 189 mapi * @group reflection
297 mapi * @group unittest
298 mapi */
299 mapi public function testProxyImplementsInterfaceDelegatesToRealSubject()
300 mapi {
301 mapi $proxy = $this->_createClassProxy( 'implementsInterface' );
302 mapi $proxy->implementsInterface( '\Iterator' );
303 mapi }
304 mapi
305 mapi /**
306 mapi * @return void
307 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
308 189 mapi * @group reflection
309 mapi * @group unittest
310 mapi */
311 mapi public function testProxyGetInterfaceNameDelegatesToRealSubject()
312 mapi {
313 mapi $proxy = $this->_createClassProxy( 'getInterfaceNames' );
314 mapi $proxy->getInterfaceNames();
315 mapi }
316 mapi
317 mapi /**
318 mapi * @return void
319 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
320 189 mapi * @group reflection
321 mapi * @group unittest
322 mapi */
323 mapi public function testProxyGetInterfacesDelegatesToRealSubject()
324 mapi {
325 mapi $proxy = $this->_createClassProxy( 'getInterfaces' );
326 mapi $proxy->getInterfaces();
327 mapi }
328 mapi
329 mapi /**
330 mapi * @return void
331 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
332 189 mapi * @group reflection
333 mapi * @group unittest
334 mapi */
335 mapi public function testProxyGetParentClassDelegatesToRealSubject()
336 mapi {
337 mapi $proxy = $this->_createClassProxy( 'getParentClass' );
338 mapi $proxy->getParentClass();
339 mapi }
340 mapi
341 mapi /**
342 mapi * @return void
343 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
344 189 mapi * @group reflection
345 mapi * @group unittest
346 mapi */
347 mapi public function testProxyGetConstructorDelegatesToRealSubject()
348 mapi {
349 mapi $proxy = $this->_createClassProxy( 'getConstructor' );
350 mapi $proxy->getConstructor();
351 mapi }
352 mapi
353 mapi /**
354 mapi * @return void
355 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
356 189 mapi * @group reflection
357 mapi * @group unittest
358 mapi */
359 mapi public function testProxyHasMethodDelegatesToRealSubject()
360 mapi {
361 mapi $proxy = $this->_createClassProxy( 'hasMethod' );
362 mapi $proxy->hasMethod( 'foo' );
363 mapi }
364 mapi
365 mapi /**
366 mapi * @return void
367 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
368 189 mapi * @group reflection
369 mapi * @group unittest
370 mapi */
371 mapi public function testProxyGetMethodDelegatesToRealSubject()
372 mapi {
373 mapi $proxy = $this->_createClassProxy( 'getMethod' );
374 mapi $proxy->getMethod( 'foo' );
375 mapi }
376 mapi
377 mapi /**
378 mapi * @return void
379 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
380 189 mapi * @group reflection
381 mapi * @group unittest
382 mapi */
383 mapi public function testProxyGetMethodsDelegatesToRealSubject()
384 mapi {
385 mapi $proxy = $this->_createClassProxy( 'getMethods' );
386 mapi $proxy->getMethods( 42 );
387 mapi }
388 mapi
389 mapi /**
390 mapi * @return void
391 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
392 189 mapi * @group reflection
393 mapi * @group unittest
394 mapi */
395 mapi public function testProxyHasPropertyDelegatesToRealSubject()
396 mapi {
397 mapi $proxy = $this->_createClassProxy( 'hasProperty' );
398 mapi $proxy->hasProperty( '_foo' );
399 mapi }
400 mapi
401 mapi /**
402 mapi * @return void
403 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
404 189 mapi * @group reflection
405 mapi * @group unittest
406 mapi */
407 mapi public function testProxyGetPropertyDelegatesToRealSubject()
408 mapi {
409 mapi $proxy = $this->_createClassProxy( 'getProperty' );
410 mapi $proxy->getProperty( '_foo' );
411 mapi }
412 mapi
413 mapi /**
414 mapi * @return void
415 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
416 189 mapi * @group reflection
417 mapi * @group unittest
418 mapi */
419 mapi public function testProxyGetPropertiesDelegatesToRealSubject()
420 mapi {
421 mapi $proxy = $this->_createClassProxy( 'getProperties' );
422 mapi $proxy->getProperties( 23 );
423 mapi }
424 mapi
425 mapi /**
426 mapi * @return void
427 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
428 189 mapi * @group reflection
429 mapi * @group unittest
430 mapi */
431 mapi public function testProxyGetDefaultPropertiesDelegatesToRealSubject()
432 mapi {
433 mapi $proxy = $this->_createClassProxy( 'getDefaultProperties' );
434 mapi $proxy->getDefaultProperties();
435 mapi }
436 mapi
437 mapi /**
438 mapi * @return void
439 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
440 189 mapi * @group reflection
441 mapi * @group unittest
442 mapi */
443 mapi public function testProxyGetStaticPropertyValueDelegatesToRealSubject()
444 mapi {
445 mapi $proxy = $this->_createClassProxy( 'getStaticPropertyValue' );
446 mapi $proxy->getStaticPropertyValue( 'foo' );
447 mapi }
448 mapi
449 mapi /**
450 mapi * @return void
451 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
452 189 mapi * @group reflection
453 mapi * @group unittest
454 mapi */
455 mapi public function testProxySetStaticPropertyValueDelegatesToRealSubject()
456 mapi {
457 mapi $proxy = $this->_createClassProxy( 'setStaticPropertyValue' );
458 mapi $proxy->setStaticPropertyValue( '_foo', 42 );
459 mapi }
460 mapi
461 mapi /**
462 mapi * @return void
463 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
464 189 mapi * @group reflection
465 mapi * @group unittest
466 mapi */
467 mapi public function testProxyGetStaticPropertiesDelegatesToRealSubject()
468 mapi {
469 mapi $proxy = $this->_createClassProxy( 'getStaticProperties' );
470 mapi $proxy->getStaticProperties();
471 mapi }
472 mapi
473 mapi /**
474 mapi * @return void
475 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
476 189 mapi * @group reflection
477 mapi * @group unittest
478 mapi */
479 mapi public function testProxyGetStartLineDelegatesToRealSubject()
480 mapi {
481 mapi $proxy = $this->_createClassProxy( 'getStartLine' );
482 mapi $proxy->getStartLine();
483 mapi }
484 mapi
485 mapi /**
486 mapi * @return void
487 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
488 189 mapi * @group reflection
489 mapi * @group unittest
490 mapi */
491 mapi public function testProxyGetEndLineDelegatesToRealSubject()
492 mapi {
493 mapi $proxy = $this->_createClassProxy( 'getEndLine' );
494 mapi $proxy->getEndLine();
495 mapi }
496 mapi
497 mapi /**
498 mapi * @return void
499 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
500 189 mapi * @group reflection
501 mapi * @group unittest
502 mapi */
503 mapi public function testProxyGetExtensionDelegatesToRealSubject()
504 mapi {
505 mapi $proxy = $this->_createClassProxy( 'getExtension' );
506 mapi $proxy->getExtension();
507 mapi }
508 mapi
509 mapi /**
510 mapi * @return void
511 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
512 189 mapi * @group reflection
513 mapi * @group unittest
514 mapi */
515 mapi public function testProxyGetExtensionNameDelegatesToRealSubject()
516 mapi {
517 mapi $proxy = $this->_createClassProxy( 'getExtensionName' );
518 mapi $proxy->getExtensionName();
519 mapi }
520 mapi
521 mapi /**
522 mapi * @return void
523 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
524 189 mapi * @group reflection
525 mapi * @group unittest
526 mapi */
527 mapi public function testProxyNewInstanceDelegatesToRealSubject()
528 mapi {
529 mapi $proxy = $this->_createClassProxy( 'newInstance' );
530 mapi $proxy->newInstance( null );
531 mapi }
532 mapi
533 mapi /**
534 mapi * @return void
535 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
536 189 mapi * @group reflection
537 mapi * @group unittest
538 mapi */
539 mapi public function testProxyNewInstanceArgsDelegatesToRealSubject()
540 mapi {
541 mapi $proxy = $this->_createClassProxy( 'newInstanceArgs' );
542 mapi $proxy->newInstanceArgs();
543 mapi }
544 mapi
545 mapi /**
546 mapi * @return void
547 248 mapi * @covers \pdepend\reflection\ReflectionClassProxy
548 189 mapi * @group reflection
549 mapi * @group unittest
550 mapi */
551 mapi public function testProxyToStringDelegatesToRealSubject()
552 mapi {
553 mapi $proxy = $this->_createClassProxy( '__toString' );
554 mapi $proxy->__toString();
555 mapi }
556 mapi
557 mapi /**
558 mapi * Create a prepared proxy instance.
559 mapi *
560 mapi * @param string $methodName Name of the tested method.
561 mapi *
562 248 mapi * @return \pdepend\reflection\ReflectionClassProxy
563 189 mapi */
564 mapi private function _createClassProxy( $methodName )
565 mapi {
566 mapi $subject = $this->getMock( '\ReflectionClass', array( $methodName ), array( __CLASS__ ) );
567 mapi $subject->expects( $this->once() )
568 mapi ->method( $methodName );
569 mapi
570 269 mapi $context = $this->createContext();
571 mapi $context->expects( $this->once() )
572 189 mapi ->method( 'getClass' )
573 mapi ->with( $this->equalTo( __CLASS__ ) )
574 mapi ->will( $this->returnValue( $subject ) );
575 mapi
576 269 mapi return new ReflectionClassProxy( $context, __CLASS__ );
577 189 mapi }
578 mapi }