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