Completed
Push — master ( 3d6ad2...b8642a )
by Jakub
01:41
created

DataProviderTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 14
c 1
b 0
f 0
dl 0
loc 47
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getDataProvider() 0 3 1
A noData() 0 2 1
A noParameters() 0 2 1
A testGetData() 0 13 1
A dataProvider() 0 2 1
A dataSource() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MyTester;
6
7
use MyTester\Annotations\Attributes\DataProvider as DataProviderAttribute;
8
use MyTester\Annotations\Attributes\TestSuite;
9
10
/**
11
 * Test suite for class DataProvider
12
 *
13
 * @testSuite DataProvider
14
 * @author Jakub Konečný
15
 */
16
#[TestSuite("DataProvider")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
17
final class DataProviderTest extends TestCase
18
{
19
    private function getDataProvider(): DataProvider
20
    {
21
        return $this->dataProvider;
22
    }
23
24
    public function testGetData(): void
25
    {
26
        $data = $this->getDataProvider()->getData($this, "noData");
27
        $this->assertType("array", $data);
28
        $this->assertCount(0, $data);
29
30
        $data = $this->getDataProvider()->getData($this, "noParameters");
31
        $this->assertType("array", $data);
32
        $this->assertCount(0, $data);
33
34
        $data = $this->getDataProvider()->getData($this, "dataProvider");
35
        $this->assertType("array", $data);
36
        $this->assertCount(2, $data);
37
    }
38
39
    private function noData(): void
40
    {
41
    }
42
43
    /**
44
     * @dataProvider(dataSource)
45
     */
46
    #[DataProviderAttribute("dataSource")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
47
    private function noParameters(): void
48
    {
49
    }
50
51
    /**
52
     * @dataProvider(dataSource)
53
     */
54
    #[DataProviderAttribute("dataSource")]
0 ignored issues
show
introduced by
This comment is 84% valid code; is this commented out code?
Loading history...
55
    private function dataProvider(string $input): void
1 ignored issue
show
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

55
    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...
56
    {
57
    }
58
59
    public function dataSource(): array
60
    {
61
        return [
62
            ["abc", ],
63
            ["def", ],
64
        ];
65
    }
66
}
67