Skip to content

Commit ece7a4d

Browse files
committed
Update tests suite to use Annotations::setConfig()
1 parent 3b98c1a commit ece7a4d

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

test/annotations/ValidationAnnotationBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use ElementaryFramework\Annotations\Annotation;
1818

1919
/**
20-
* Abstract base class for validation Annotations.
20+
* Abstract base class for validation annotations.
2121
*/
2222
abstract class ValidationAnnotationBase extends Annotation
2323
{

test/suite/Annotations.case.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* TEST CASE: Sample Annotations
4+
* TEST CASE: Sample annotations
55
*/
66

77
use ElementaryFramework\Annotations\Annotation;

test/suite/Annotations.test.php

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919

2020
/**
21-
* This class implements tests for core Annotations
21+
* This class implements tests for core annotations
2222
*/
2323
class AnnotationsTest extends xTest
2424
{
@@ -35,22 +35,20 @@ public function run(xTestRunner $testRunner)
3535
$testRunner->startCoverageCollector(__CLASS__);
3636
$cachePath = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'runtime';
3737

38-
Annotations::$config = array(
39-
'cache' => new AnnotationCache($cachePath),
40-
);
38+
Annotations::setConfig('cache', new AnnotationCache($cachePath));
4139

4240
if (!is_writable($cachePath)) {
4341
die('cache path is not writable: ' . $cachePath);
4442
}
4543

4644
// 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';
4846

4947
foreach (glob($pattern) as $path) {
5048
unlink($path);
5149
}
5250

53-
// disable some Annotations not used during testing:
51+
// disable some annotations not used during testing:
5452
Annotations::getManager()->registerAnnotation('var', false);
5553
Annotations::getManager()->registerAnnotation('undefined', 'UndefinedAnnotation');
5654
$testRunner->stopCoverageCollector();
@@ -61,7 +59,7 @@ public function run(xTestRunner $testRunner)
6159
protected function testCanResolveAnnotationNames()
6260
{
6361
$manager = new AnnotationManager;
64-
$manager->namespace = ''; // look for Annotations in the global namespace
62+
$manager->namespace = ''; // look for annotations in the global namespace
6563
$manager->suffix = 'Annotation'; // use a suffix for annotation class-names
6664

6765
$this->check(
@@ -125,7 +123,7 @@ protected function testCanParseAnnotations()
125123
{
126124
$manager = new AnnotationManager;
127125
Package::register($manager);
128-
$manager->namespace = ''; // look for Annotations in the global namespace
126+
$manager->namespace = ''; // look for annotations in the global namespace
129127
$manager->suffix = 'Annotation'; // use a suffix for annotation class-names
130128

131129
$parser = $manager->getParser();
@@ -281,7 +279,7 @@ protected function testGetAnnotationsFromMethodOfNonExistingClass()
281279
{
282280
$this->setExpectedException(
283281
self::ANNOTATION_EXCEPTION,
284-
"Unable to read Annotations from an undefined class 'NonExistingClass'"
282+
"Unable to read annotations from an undefined class 'NonExistingClass'"
285283
);
286284
Annotations::ofMethod('NonExistingClass');
287285
}
@@ -290,7 +288,7 @@ protected function testGetAnnotationsFromNonExistingMethodOfAClass()
290288
{
291289
$this->setExpectedException(
292290
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()'
294292
);
295293
Annotations::ofMethod('Test', 'nonExistingMethod');
296294
}
@@ -314,7 +312,7 @@ protected function testGetAnnotationsFromPropertyOfNonExistingClass()
314312
{
315313
$this->setExpectedException(
316314
self::ANNOTATION_EXCEPTION,
317-
"Unable to read Annotations from an undefined class 'NonExistingClass'"
315+
"Unable to read annotations from an undefined class 'NonExistingClass'"
318316
);
319317
Annotations::ofProperty('NonExistingClass', 'sample');
320318
}
@@ -323,7 +321,7 @@ public function testGetAnnotationsFromNonExistingPropertyOfExistingClass()
323321
{
324322
$this->setExpectedException(
325323
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'
327325
);
328326
Annotations::ofProperty('Test', 'nonExisting');
329327
}
@@ -333,7 +331,7 @@ protected function testCanGetFilteredClassAnnotations()
333331
$anns = Annotations::ofClass('TestBase', 'NoteAnnotation');
334332

335333
if (!count($anns)) {
336-
$this->fail('No Annotations found');
334+
$this->fail('No annotations found');
337335
return;
338336
}
339337

@@ -351,7 +349,7 @@ protected function testCanGetFilteredMethodAnnotations()
351349
$anns = Annotations::ofMethod('TestBase', 'run', 'NoteAnnotation');
352350

353351
if (!count($anns)) {
354-
$this->fail('No Annotations found');
352+
$this->fail('No annotations found');
355353
return;
356354
}
357355

@@ -369,7 +367,7 @@ protected function testCanGetFilteredPropertyAnnotations()
369367
$anns = Annotations::ofProperty('Test', 'mixed', 'NoteAnnotation');
370368

371369
if (!count($anns)) {
372-
$this->fail('No Annotations found');
370+
$this->fail('No annotations found');
373371
return;
374372
}
375373

@@ -458,7 +456,7 @@ protected function testCanOverrideSingleAnnotation()
458456
$anns = Annotations::ofProperty('Test', 'override_me');
459457

460458
if (count($anns) != 1) {
461-
$this->fail(count($anns) . ' Annotations found - expected 1');
459+
$this->fail(count($anns) . ' annotations found - expected 1');
462460
return;
463461
}
464462

@@ -548,28 +546,28 @@ protected function testParseUserDefinedClasses()
548546
{
549547
$annotations = Annotations::ofClass('TestClassExtendingUserDefined', '@note');
550548

551-
$this->check(count($annotations) == 2, 'TestClassExtendingUserDefined has two note Annotations.');
549+
$this->check(count($annotations) == 2, 'TestClassExtendingUserDefined has two note annotations.');
552550
}
553551

554552
protected function testDoNotParseCoreClasses()
555553
{
556554
$annotations = Annotations::ofClass('TestClassExtendingCore', '@note');
557555

558-
$this->check(count($annotations) == 1, 'TestClassExtendingCore has one note Annotations.');
556+
$this->check(count($annotations) == 1, 'TestClassExtendingCore has one note annotations.');
559557
}
560558

561559
protected function testDoNotParseExtensionClasses()
562560
{
563561
$annotations = Annotations::ofClass('TestClassExtendingExtension', '@note');
564562

565-
$this->check(count($annotations) == 1, 'TestClassExtendingExtension has one note Annotations.');
563+
$this->check(count($annotations) == 1, 'TestClassExtendingExtension has one note annotations.');
566564
}
567565

568566
protected function testGetAnnotationsFromNonExistingClass()
569567
{
570568
$this->setExpectedException(
571569
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'"
573571
);
574572
Annotations::ofClass('NonExistingClass', '@note');
575573
}
@@ -578,7 +576,7 @@ protected function testGetAnnotationsFromAnInterface()
578576
{
579577
$this->setExpectedException(
580578
self::ANNOTATION_EXCEPTION,
581-
"Reading Annotations from interface 'TestInterface' is not supported"
579+
"Reading annotations from interface 'TestInterface' is not supported"
582580
);
583581
Annotations::ofClass('TestInterface', '@note');
584582
}
@@ -617,12 +615,12 @@ protected function testHandlesMethodInheritanceWithTraits()
617615
}
618616

619617
$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');
621619
$this->check($annotations[0]->note === 'inheritance-base-trait-tester', 'parent annotation first');
622620
$this->check($annotations[1]->note === 'inheritance-base-trait', 'trait annotation second');
623621

624622
$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');
626624
$this->check($annotations[0]->note === 'inheritance-base-trait-tester', 'parent annotation first');
627625
$this->check($annotations[1]->note === 'inheritance-trait', 'trait annotation second');
628626

@@ -707,12 +705,12 @@ protected function testHandlesPropertyConflictWithTraits()
707705
$this->check($annotations[0]->note === 'property-conflict-trait-tester', 'child annotation first');
708706

709707
$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');
711709
$this->check($annotations[0]->note === 'property-conflict-base-trait-tester', 'parent annotation first');
712710
$this->check($annotations[1]->note === 'property-conflict-trait-two', 'first listed trait annotation second');
713711

714712
$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');
716714

717715
$annotations = Annotations::ofProperty('PropertyConflictTraitTester', 'traitAndParentAndChild');
718716
$this->check(count($annotations) === 2, 'traitAndParentAndChild does not inherit trait annotation');

0 commit comments

Comments
 (0)