GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 5f00e9...94bde4 )
by Freek
01:36 queued 25s
created

it_throws_exception_when_second_parameter_is_lower_than_1()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Test;
4
5
use function spatie\array_split;
6
use PHPUnit\Framework\TestCase;
7
8
class ArraySplitTest extends TestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function it_can_handle_an_empty_array()
14
    {
15
        $this->assertSame(array_split([]), []);
16
    }
17
18
    /**
19
     * @dataProvider argumentsProvider
20
     * @test
21
     */
22
    public function it_throws_exception_when_second_parameter_is_lower_than_1($numberOfPieces, $mustThrow)
23
    {
24
        $exception = null;
25
        try {
26
            array_split([], $numberOfPieces);
27
        } catch (\InvalidArgumentException $exception) {}
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
28
29
        $this->assertSame($mustThrow, $exception instanceof \InvalidArgumentException);
30
    }
31
32
    public function argumentsProvider()
33
    {
34
        return [
35
          [2 , false],
36
          [1 , false],
37
          [0 , true],
38
          [-1 , true],
39
          [-2 , true],
40
        ];
41
    }
42
43
    /**
44
     * @test
45
     */
46
    public function it_splits_an_array_in_two_by_default()
47
    {
48
        $this->assertSame(array_split(['a', 'b']), [['a'], ['b']]);
49
    }
50
51
    /**
52
     * @test
53
     */
54
    public function it_splits_an_array_in_two_by_default_while_preserving_keys()
55
    {
56
        $this->assertSame(array_split(['a' => 1, 'b' => 2], 2, true), [['a' => 1], ['b' => 2]]);
57
    }
58
59
    /**
60
     * @dataProvider arrayProvider
61
     *
62
     * @test
63
     *
64
     * @param $array
65
     * @param $splitIntoNumber
66
     * @param $expectedArray
67
     */
68
    public function it_can_split_an_array_in_equal_pieces($array, $splitIntoNumber, $expectedArray)
69
    {
70
        $this->assertSame($expectedArray, array_split($array, $splitIntoNumber));
71
    }
72
73
    public function arrayProvider()
74
    {
75
        return [
76
            [
77
                ['a', 'b', 'c', 'd'], 2, [['a', 'b'], ['c', 'd']],
78
            ],
79
            [
80
                ['a', 'b', 'c', 'd', 'e'], 2, [['a', 'b', 'c'], ['d', 'e']],
81
            ],
82
            [
83
                ['a', 'b', 'c', 'd', 'e'], 3, [['a', 'b'], ['c', 'd'], ['e']],
84
            ],
85
        ];
86
    }
87
}
88