18
18
}
19
19
20
20
/**
21
- * This class implements tests for core Annotations
21
+ * This class implements tests for core annotations
22
22
*/
23
23
class AnnotationsTest extends xTest
24
24
{
@@ -35,22 +35,20 @@ public function run(xTestRunner $testRunner)
35
35
$ testRunner ->startCoverageCollector (__CLASS__ );
36
36
$ cachePath = dirname (__DIR__ ) . DIRECTORY_SEPARATOR . 'runtime ' ;
37
37
38
- Annotations::$ config = array (
39
- 'cache ' => new AnnotationCache ($ cachePath ),
40
- );
38
+ Annotations::setConfig ('cache ' , new AnnotationCache ($ cachePath ));
41
39
42
40
if (!is_writable ($ cachePath )) {
43
41
die ('cache path is not writable: ' . $ cachePath );
44
42
}
45
43
46
44
// manually wipe out the cache:
47
- $ pattern = Annotations::getManager ()->cache ->getRoot () . DIRECTORY_SEPARATOR . '*.Annotations .php ' ;
45
+ $ pattern = Annotations::getManager ()->cache ->getRoot () . DIRECTORY_SEPARATOR . '*.annotations .php ' ;
48
46
49
47
foreach (glob ($ pattern ) as $ path ) {
50
48
unlink ($ path );
51
49
}
52
50
53
- // disable some Annotations not used during testing:
51
+ // disable some annotations not used during testing:
54
52
Annotations::getManager ()->registerAnnotation ('var ' , false );
55
53
Annotations::getManager ()->registerAnnotation ('undefined ' , 'UndefinedAnnotation ' );
56
54
$ testRunner ->stopCoverageCollector ();
@@ -61,7 +59,7 @@ public function run(xTestRunner $testRunner)
61
59
protected function testCanResolveAnnotationNames ()
62
60
{
63
61
$ manager = new AnnotationManager ;
64
- $ manager ->namespace = '' ; // look for Annotations in the global namespace
62
+ $ manager ->namespace = '' ; // look for annotations in the global namespace
65
63
$ manager ->suffix = 'Annotation ' ; // use a suffix for annotation class-names
66
64
67
65
$ this ->check (
@@ -125,7 +123,7 @@ protected function testCanParseAnnotations()
125
123
{
126
124
$ manager = new AnnotationManager ;
127
125
Package::register ($ manager );
128
- $ manager ->namespace = '' ; // look for Annotations in the global namespace
126
+ $ manager ->namespace = '' ; // look for annotations in the global namespace
129
127
$ manager ->suffix = 'Annotation ' ; // use a suffix for annotation class-names
130
128
131
129
$ parser = $ manager ->getParser ();
@@ -281,7 +279,7 @@ protected function testGetAnnotationsFromMethodOfNonExistingClass()
281
279
{
282
280
$ this ->setExpectedException (
283
281
self ::ANNOTATION_EXCEPTION ,
284
- "Unable to read Annotations from an undefined class 'NonExistingClass' "
282
+ "Unable to read annotations from an undefined class 'NonExistingClass' "
285
283
);
286
284
Annotations::ofMethod ('NonExistingClass ' );
287
285
}
@@ -290,7 +288,7 @@ protected function testGetAnnotationsFromNonExistingMethodOfAClass()
290
288
{
291
289
$ this ->setExpectedException (
292
290
self ::ANNOTATION_EXCEPTION ,
293
- 'Unable to read Annotations from an undefined method Test::nonExistingMethod() '
291
+ 'Unable to read annotations from an undefined method Test::nonExistingMethod() '
294
292
);
295
293
Annotations::ofMethod ('Test ' , 'nonExistingMethod ' );
296
294
}
@@ -314,7 +312,7 @@ protected function testGetAnnotationsFromPropertyOfNonExistingClass()
314
312
{
315
313
$ this ->setExpectedException (
316
314
self ::ANNOTATION_EXCEPTION ,
317
- "Unable to read Annotations from an undefined class 'NonExistingClass' "
315
+ "Unable to read annotations from an undefined class 'NonExistingClass' "
318
316
);
319
317
Annotations::ofProperty ('NonExistingClass ' , 'sample ' );
320
318
}
@@ -323,7 +321,7 @@ public function testGetAnnotationsFromNonExistingPropertyOfExistingClass()
323
321
{
324
322
$ this ->setExpectedException (
325
323
self ::ANNOTATION_EXCEPTION ,
326
- 'Unable to read Annotations from an undefined property Test::$nonExisting '
324
+ 'Unable to read annotations from an undefined property Test::$nonExisting '
327
325
);
328
326
Annotations::ofProperty ('Test ' , 'nonExisting ' );
329
327
}
@@ -333,7 +331,7 @@ protected function testCanGetFilteredClassAnnotations()
333
331
$ anns = Annotations::ofClass ('TestBase ' , 'NoteAnnotation ' );
334
332
335
333
if (!count ($ anns )) {
336
- $ this ->fail ('No Annotations found ' );
334
+ $ this ->fail ('No annotations found ' );
337
335
return ;
338
336
}
339
337
@@ -351,7 +349,7 @@ protected function testCanGetFilteredMethodAnnotations()
351
349
$ anns = Annotations::ofMethod ('TestBase ' , 'run ' , 'NoteAnnotation ' );
352
350
353
351
if (!count ($ anns )) {
354
- $ this ->fail ('No Annotations found ' );
352
+ $ this ->fail ('No annotations found ' );
355
353
return ;
356
354
}
357
355
@@ -369,7 +367,7 @@ protected function testCanGetFilteredPropertyAnnotations()
369
367
$ anns = Annotations::ofProperty ('Test ' , 'mixed ' , 'NoteAnnotation ' );
370
368
371
369
if (!count ($ anns )) {
372
- $ this ->fail ('No Annotations found ' );
370
+ $ this ->fail ('No annotations found ' );
373
371
return ;
374
372
}
375
373
@@ -458,7 +456,7 @@ protected function testCanOverrideSingleAnnotation()
458
456
$ anns = Annotations::ofProperty ('Test ' , 'override_me ' );
459
457
460
458
if (count ($ anns ) != 1 ) {
461
- $ this ->fail (count ($ anns ) . ' Annotations found - expected 1 ' );
459
+ $ this ->fail (count ($ anns ) . ' annotations found - expected 1 ' );
462
460
return ;
463
461
}
464
462
@@ -548,28 +546,28 @@ protected function testParseUserDefinedClasses()
548
546
{
549
547
$ annotations = Annotations::ofClass ('TestClassExtendingUserDefined ' , '@note ' );
550
548
551
- $ this ->check (count ($ annotations ) == 2 , 'TestClassExtendingUserDefined has two note Annotations . ' );
549
+ $ this ->check (count ($ annotations ) == 2 , 'TestClassExtendingUserDefined has two note annotations . ' );
552
550
}
553
551
554
552
protected function testDoNotParseCoreClasses ()
555
553
{
556
554
$ annotations = Annotations::ofClass ('TestClassExtendingCore ' , '@note ' );
557
555
558
- $ this ->check (count ($ annotations ) == 1 , 'TestClassExtendingCore has one note Annotations . ' );
556
+ $ this ->check (count ($ annotations ) == 1 , 'TestClassExtendingCore has one note annotations . ' );
559
557
}
560
558
561
559
protected function testDoNotParseExtensionClasses ()
562
560
{
563
561
$ annotations = Annotations::ofClass ('TestClassExtendingExtension ' , '@note ' );
564
562
565
- $ this ->check (count ($ annotations ) == 1 , 'TestClassExtendingExtension has one note Annotations . ' );
563
+ $ this ->check (count ($ annotations ) == 1 , 'TestClassExtendingExtension has one note annotations . ' );
566
564
}
567
565
568
566
protected function testGetAnnotationsFromNonExistingClass ()
569
567
{
570
568
$ this ->setExpectedException (
571
569
self ::ANNOTATION_EXCEPTION ,
572
- "Unable to read Annotations from an undefined class/trait 'NonExistingClass' "
570
+ "Unable to read annotations from an undefined class/trait 'NonExistingClass' "
573
571
);
574
572
Annotations::ofClass ('NonExistingClass ' , '@note ' );
575
573
}
@@ -578,7 +576,7 @@ protected function testGetAnnotationsFromAnInterface()
578
576
{
579
577
$ this ->setExpectedException (
580
578
self ::ANNOTATION_EXCEPTION ,
581
- "Reading Annotations from interface 'TestInterface' is not supported "
579
+ "Reading annotations from interface 'TestInterface' is not supported "
582
580
);
583
581
Annotations::ofClass ('TestInterface ' , '@note ' );
584
582
}
@@ -617,12 +615,12 @@ protected function testHandlesMethodInheritanceWithTraits()
617
615
}
618
616
619
617
$ annotations = Annotations::ofMethod ('InheritanceTraitTester ' , 'baseTraitAndParent ' );
620
- $ this ->check (count ($ annotations ) === 2 , 'baseTraitAndParent inherits parent Annotations ' );
618
+ $ this ->check (count ($ annotations ) === 2 , 'baseTraitAndParent inherits parent annotations ' );
621
619
$ this ->check ($ annotations [0 ]->note === 'inheritance-base-trait-tester ' , 'parent annotation first ' );
622
620
$ this ->check ($ annotations [1 ]->note === 'inheritance-base-trait ' , 'trait annotation second ' );
623
621
624
622
$ annotations = Annotations::ofMethod ('InheritanceTraitTester ' , 'traitAndParent ' );
625
- $ this ->check (count ($ annotations ) === 2 , 'traitAndParent inherits parent Annotations ' );
623
+ $ this ->check (count ($ annotations ) === 2 , 'traitAndParent inherits parent annotations ' );
626
624
$ this ->check ($ annotations [0 ]->note === 'inheritance-base-trait-tester ' , 'parent annotation first ' );
627
625
$ this ->check ($ annotations [1 ]->note === 'inheritance-trait ' , 'trait annotation second ' );
628
626
@@ -707,12 +705,12 @@ protected function testHandlesPropertyConflictWithTraits()
707
705
$ this ->check ($ annotations [0 ]->note === 'property-conflict-trait-tester ' , 'child annotation first ' );
708
706
709
707
$ annotations = Annotations::ofProperty ('PropertyConflictTraitTester ' , 'traitAndTraitAndParent ' );
710
- $ this ->check (count ($ annotations ) === 2 , 'traitAndTraitAndParent inherits parent Annotations ' );
708
+ $ this ->check (count ($ annotations ) === 2 , 'traitAndTraitAndParent inherits parent annotations ' );
711
709
$ this ->check ($ annotations [0 ]->note === 'property-conflict-base-trait-tester ' , 'parent annotation first ' );
712
710
$ this ->check ($ annotations [1 ]->note === 'property-conflict-trait-two ' , 'first listed trait annotation second ' );
713
711
714
712
$ annotations = Annotations::ofProperty ('PropertyConflictTraitTester ' , 'unannotatedTraitAndAnnotatedTrait ' );
715
- $ this ->check (count ($ annotations ) === 0 , 'unannotatedTraitAndAnnotatedTrait has no Annotations ' );
713
+ $ this ->check (count ($ annotations ) === 0 , 'unannotatedTraitAndAnnotatedTrait has no annotations ' );
716
714
717
715
$ annotations = Annotations::ofProperty ('PropertyConflictTraitTester ' , 'traitAndParentAndChild ' );
718
716
$ this ->check (count ($ annotations ) === 2 , 'traitAndParentAndChild does not inherit trait annotation ' );
0 commit comments