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

DataProviderTest::dataSource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 4
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\DataProvider as DataProviderAttribute;
7
use MyTester\Annotations\Attributes\TestSuite;
8
9
/**
10
 * Test suite for class DataProvider
11
 *
12
 * @testSuite DataProvider
13
 * @author Jakub Konečný
14
 */
15
#[TestSuite("DataProvider")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
16
final class DataProviderTest extends TestCase {
17
  private function getDataProvider(): DataProvider {
18
    return $this->dataProvider;
19
  }
20
21
  public function testGetData(): void {
22
    $data = $this->getDataProvider()->getData($this, "noData");
23
    $this->assertType("array", $data);
24
    $this->assertCount(0, $data);
25
26
    $data = $this->getDataProvider()->getData($this, "noParameters");
27
    $this->assertType("array", $data);
28
    $this->assertCount(0, $data);
29
30
    $data = $this->getDataProvider()->getData($this, "dataProvider");
31
    $this->assertType("array", $data);
32
    $this->assertCount(2, $data);
33
  }
34
35
  private function noData(): void {
1 ignored issue
show
Unused Code introduced by
The method noData() 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...
36
  }
37
38
  /**
39
   * @dataProvider(dataSource)
40
   */
41
  #[DataProviderAttribute("dataSource")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
42
  private function noParameters(): void {
1 ignored issue
show
Unused Code introduced by
The method noParameters() 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...
43
  }
44
45
  /**
46
   * @data(abc, def)
47
   */
48
  #[Data(["abc", "def"])]
0 ignored issues
show
introduced by
This comment is 82% valid code; is this commented out code?
Loading history...
49
  private function data(string $input): void {
2 ignored issues
show
Unused Code introduced by
The method data() 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...
Unused Code introduced by
The parameter $input is not used and could be removed. ( Ignorable by Annotation )

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

49
  private function data(/** @scrutinizer ignore-unused */ string $input): void {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50
  }
51
52
  /**
53
   * @dataProvider(dataSource)
54
   */
55
  #[DataProviderAttribute("dataSource")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
56
  private function dataProvider(string $input): void {
2 ignored issues
show
Unused Code introduced by
The method dataProvider() 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...
Unused Code introduced by
The parameter $input is not used and could be removed. ( Ignorable by Annotation )

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

56
  private function dataProvider(/** @scrutinizer ignore-unused */ string $input): void {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
  }
58
59
  public function dataSource(): array {
60
    return [
61
      ["abc", ],
62
      ["def", ],
63
    ];
64
  }
65
}
66
?>