1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace MyTester\Annotations; |
5
|
|
|
|
6
|
|
|
use MyTester\Annotations\Attributes\Fail; |
7
|
|
|
use MyTester\Annotations\Attributes\TestSuite; |
8
|
|
|
use MyTester\ShouldFailChecker; |
9
|
|
|
use MyTester\TestCase; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Test suite for class Reader |
13
|
|
|
* |
14
|
|
|
* @testSuit Reader |
15
|
|
|
* @author Jakub Konečný |
16
|
|
|
*/ |
17
|
|
|
#[TestSuite("Reader")] |
|
|
|
|
18
|
|
|
final class ReaderTest extends TestCase { |
19
|
|
|
private function getAnnotationsReader(): Reader { |
20
|
|
|
static $annotationsReader = null; |
21
|
|
|
if($annotationsReader === null) { |
22
|
|
|
$annotationsReader = new Reader(); |
23
|
|
|
$annotationsReader->registerEngine(new DummyEngine()); |
24
|
|
|
} |
25
|
|
|
return $annotationsReader; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testHasAnnotation(): void { |
29
|
|
|
$this->assertFalse((new Reader())->hasAnnotation(TestCase::ANNOTATION_TEST_SUITE, static::class)); |
30
|
|
|
$this->assertTrue($this->getAnnotationsReader()->hasAnnotation(TestCase::ANNOTATION_TEST_SUITE, static::class)); |
31
|
|
|
$this->assertFalse((new Reader())->hasAnnotation(ShouldFailChecker::ANNOTATION_NAME, static::class, "method")); |
32
|
|
|
$this->assertTrue($this->getAnnotationsReader()->hasAnnotation(ShouldFailChecker::ANNOTATION_NAME, static::class, "method")); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testGetAnnotation(): void { |
36
|
|
|
$this->assertNull((new Reader())->getAnnotation(TestCase::ANNOTATION_TEST_SUITE, static::class)); |
37
|
|
|
$this->assertSame("abc", $this->getAnnotationsReader()->getAnnotation(TestCase::ANNOTATION_TEST_SUITE, static::class)); |
|
|
|
|
38
|
|
|
$this->assertNull((new Reader())->getAnnotation(ShouldFailChecker::ANNOTATION_NAME, static::class, "method")); |
39
|
|
|
$this->assertSame("abc", $this->getAnnotationsReader()->getAnnotation(ShouldFailChecker::ANNOTATION_NAME, static::class, "method")); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @fail(1) |
44
|
|
|
*/ |
45
|
|
|
#[Fail(1)] |
|
|
|
|
46
|
|
|
private function method(): void { |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
?> |