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

SkipCheckerTest::getSkipChecker()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
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;
5
6
use MyTester\Annotations\Attributes\Skip;
7
use MyTester\Annotations\Attributes\TestSuite;
8
9
/**
10
 * Test suite for class SkipChecker
11
 *
12
 * @testSuite SkipChecker
13
 * @author Jakub Konečný
14
 */
15
#[TestSuite("SkipChecker")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
16
final class SkipCheckerTest extends TestCase {
17
  private function getSkipChecker(): SkipChecker {
18
    return $this->skipChecker;
19
  }
20
21
  public function testCheckPhpVersion(): void {
22
    $this->assertNull($this->getSkipChecker()->checkPhpVersion(1));
23
    $this->assertType("string", $this->getSkipChecker()->checkPhpVersion(PHP_INT_MAX));
24
  }
25
26
  public function testCheckLoadedExtension(): void {
27
    $this->assertNull($this->getSkipChecker()->checkLoadedExtension("ctype"));
28
    $this->assertType("string", $this->getSkipChecker()->checkLoadedExtension("abc"));
29
  }
30
31
  public function testCheckPhpSapi(): void {
32
    $this->assertType("string", $this->getSkipChecker()->checkPhpSapi("abc"));
33
  }
34
35
  public function testGetSkipValue(): void {
36
    $this->assertNull($this->getSkipChecker()->getSkipValue(static::class, "skipNull"));
37
    $this->assertTrue($this->getSkipChecker()->getSkipValue(static::class, "skip"));
1 ignored issue
show
Bug introduced by
It seems like $this->getSkipChecker()-...(static::class, 'skip') can also be of type null; however, parameter $actual of MyTester\TestCase::assertTrue() does only seem to accept boolean, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
    $this->assertTrue(/** @scrutinizer ignore-type */ $this->getSkipChecker()->getSkipValue(static::class, "skip"));
Loading history...
38
    $this->assertSame(false, $this->getSkipChecker()->getSkipValue(static::class, "skipFalse"));
39
    $this->assertSame(1.5, $this->getSkipChecker()->getSkipValue(static::class, "skipFloat"));
40
    $this->assertSame("abc", $this->getSkipChecker()->getSkipValue(static::class, "skipString"));
41
    $array = $this->getSkipChecker()->getSkipValue(static::class, "skipArray");
42
    $this->assertType("iterable", $array);
43
    $this->assertCount(1, $array);
44
  }
45
46
  public function testShouldSkip(): void {
47
    $this->assertFalsey($this->getSkipChecker()->shouldSkip(static::class, "skipNull"));
48
    $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skip"));
49
    $this->assertFalsey($this->getSkipChecker()->shouldSkip(static::class, "skipFalse"));
50
    $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skipInteger"));
51
    $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skipFloat"));
52
    $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skipString"));
53
    $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skipArray"));
54
  }
55
56
  private function skipNull(): void {
1 ignored issue
show
Unused Code introduced by
The method skipNull() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
57
  }
58
59
  /**
60
   * @skip
61
   */
62
  #[Skip()]
0 ignored issues
show
introduced by
This comment is 80% valid code; is this commented out code?
Loading history...
63
  private function skip(): void {
1 ignored issue
show
Unused Code introduced by
The method skip() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
64
  }
65
66
  /**
67
   * @skip(false)
68
   */
69
  #[Skip(false)]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
70
  private function skipFalse(): void {
1 ignored issue
show
Unused Code introduced by
The method skipFalse() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
71
  }
72
73
  /**
74
   * @skip(1)
75
   */
76
  #[Skip(1)]
0 ignored issues
show
introduced by
This comment is 80% valid code; is this commented out code?
Loading history...
77
  private function skipInteger(): void {
1 ignored issue
show
Unused Code introduced by
The method skipInteger() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
78
  }
79
80
  /**
81
   * @skip(1.5)
82
   */
83
  #[Skip(1.5)]
0 ignored issues
show
introduced by
This comment is 67% valid code; is this commented out code?
Loading history...
84
  private function skipFloat(): void {
1 ignored issue
show
Unused Code introduced by
The method skipFloat() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
85
  }
86
87
  /**
88
   * @skip(abc)
89
   */
90
  #[Skip("abc")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
91
  private function skipString(): void {
1 ignored issue
show
Unused Code introduced by
The method skipString() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
92
  }
93
94
  /**
95
   * @skip(php=666)
96
   */
97
  #[Skip(["php" => 666])]
0 ignored issues
show
introduced by
This comment is 73% valid code; is this commented out code?
Loading history...
98
  private function skipArray(): void {
1 ignored issue
show
Unused Code introduced by
The method skipArray() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
99
  }
100
}
101
?>