Completed
Push — master ( 7cb780...532294 )
by
unknown
04:14 queued 02:10
created

UtilitiesTest::pregSplitArrayProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of the GitElephant package.
7
 *
8
 * (c) Matteo Giachino <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 *
13
 * Just for fun...
14
 */
15
16
namespace GitElephant;
17
18
/**
19
 * @author Matteo Giachino <[email protected]>
20
 */
21
final class UtilitiesTest extends TestCase
22
{
23
    private $arr = [
24
        'a',
25
        'b',
26
        'c',
27
        '1',
28
        'd',
29
        'b',
30
        'e',
31
    ];
32
33
    /**
34
     * @dataProvider pregSplitArrayProvider()
35
     *
36
     * @covers \GitElephant\Utilities::pregSplitArray
37
     */
38
    public function testPregSplitArray(array $expected, array $list, string $pattern)
39
    {
40
        $this->assertEquals(
41
            $expected,
42
            Utilities::pregSplitArray(
43
                $list,
44
                $pattern
45
            )
46
        );
47
    }
48
49
    /**
50
     * @dataProvider
51
     */
52
    public function testPregSplitFlatArray()
53
    {
54
        $this->assertEquals(
55
            [
56
                ['a'],
57
                ['b', 'c', '1', 'd'],
58
                ['b', 'e'],
59
            ],
60
            Utilities::pregSplitFlatArray($this->arr, '/^b$/')
61
        );
62
    }
63
64
    public function pregSplitArrayProvider(): array
65
    {
66
        return [
67
            [
68
                [
69
                    ['b', 'c', '1', 'd'],
70
                    ['b', 'e'],
71
                ],
72
                $this->arr,
73
                '/^b$/',
74
            ],
75
            [
76
                [
77
                    ['1', 'd', 'b', 'e'],
78
                ],
79
                $this->arr,
80
                '/^\d$/',
81
            ],
82
        ];
83
    }
84
}
85