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

PhpAttributesEngineTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 14
dl 0
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetAnnotation() 0 5 1
A testHasAnnotation() 0 5 1
A getAnnotationsReader() 0 7 2
A method() 0 1 1
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")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
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"])]
0 ignored issues
show
introduced by
This comment is 75% valid code; is this commented out code?
Loading history...
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"));
0 ignored issues
show
introduced by
Line exceeds 120 characters; contains 129 characters
Loading history...
37
  }
38
39
  /**
40
   * @skip(php=7.5)
41
   */
42
  #[Skip(["php" => "7.5"])]
0 ignored issues
show
introduced by
This comment is 75% valid code; is this commented out code?
Loading history...
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));
0 ignored issues
show
introduced by
Line exceeds 120 characters; contains 141 characters
Loading history...
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"));
0 ignored issues
show
introduced by
Line exceeds 120 characters; contains 132 characters
Loading history...
48
  }
49
50
  #[Fail(1)]
0 ignored issues
show
introduced by
This comment is 80% valid code; is this commented out code?
Loading history...
51
  private function method(): void {
52
  }
53
}
54
?>