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

NetteReflectionEngineTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAnnotationsReader() 0 7 2
A method() 0 1 1
A testHasAnnotation() 0 5 1
A testGetAnnotation() 0 5 1
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"));
0 ignored issues
show
introduced by
Line exceeds 120 characters; contains 129 characters
Loading history...
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));
0 ignored issues
show
introduced by
Line exceeds 120 characters; contains 141 characters
Loading history...
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"));
0 ignored issues
show
introduced by
Line exceeds 120 characters; contains 132 characters
Loading history...
37
  }
38
39
  /**
40
   * @fail(1)
41
   */
42
  private function method(): void {
43
  }
44
}
45
?>