Completed
Push — master ( dbb439...8abb49 )
by Jakub
01:34
created

ReaderTest::testGetAnnotation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
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"));
0 ignored issues
show
introduced by
Line exceeds 120 characters; contains 129 characters
Loading history...
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));
0 ignored issues
show
introduced by
Line exceeds 120 characters; contains 123 characters
Loading history...
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"));
0 ignored issues
show
introduced by
Line exceeds 120 characters; contains 136 characters
Loading history...
40
  }
41
42
  /**
43
   * @fail(1)
44
   */
45
  #[Fail(1)]
0 ignored issues
show
introduced by
This comment is 80% valid code; is this commented out code?
Loading history...
46
  private function method(): void {
47
  }
48
}
49
?>