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