Completed
Push — master ( 4eb33b...9d87b5 )
by Marco
11s queued 10s
created

ArrayHelpersTest::invalidStringArrays()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\Support;
6
7
use PHPUnit\Framework\TestCase;
8
use Roave\BackwardCompatibility\Support\ArrayHelpers;
9
10
/**
11
 * @covers \Roave\BackwardCompatibility\Support\ArrayHelpers
12
 */
13
final class ArrayHelpersTest extends TestCase
14
{
15
    /**
16
     * @param string[] $array
17
     *
18
     * @dataProvider stringArrayContainsStringValidValues
19
     */
20
    public function testInclusion(string $value, array $array, bool $expected) : void
21
    {
22
        self::assertSame($expected, ArrayHelpers::stringArrayContainsString($value, $array));
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\Assert::assertSame() is not static, but was called statically. ( Ignorable by Annotation )

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

22
        self::/** @scrutinizer ignore-call */ 
23
              assertSame($expected, ArrayHelpers::stringArrayContainsString($value, $array));
Loading history...
Bug introduced by
$expected of type boolean is incompatible with the type PHPUnit\Framework\T expected by parameter $expected of PHPUnit\Framework\Assert::assertSame(). ( Ignorable by Annotation )

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

22
        self::assertSame(/** @scrutinizer ignore-type */ $expected, ArrayHelpers::stringArrayContainsString($value, $array));
Loading history...
23
    }
24
25
    /**
26
     * @return array<int, array<int, string|array<int, string>|bool>>
27
     *
28
     * @psalm-return array<int, array{0: string, 1: array<int, string>, 2: bool}>
29
     */
30
    public function stringArrayContainsStringValidValues() : array
31
    {
32
        return [
33
            [
34
                '',
35
                [],
36
                false,
37
            ],
38
            [
39
                '',
40
                [''],
41
                true,
42
            ],
43
            [
44
                '0',
45
                [''],
46
                false,
47
            ],
48
            [
49
                '',
50
                ['0'],
51
                false,
52
            ],
53
            [
54
                'foo',
55
                ['foo', 'bar', 'baz'],
56
                true,
57
            ],
58
            [
59
                'foo',
60
                ['bar', 'baz'],
61
                false,
62
            ],
63
            [
64
                'foo',
65
                ['foo', 'foo', 'foo'],
66
                true,
67
            ],
68
        ];
69
    }
70
}
71