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
Branch develop (05114b)
by Sébastien
05:38 queued 03:11
created

testCombineReturnsCollectionWithExistingKeysAndIncomingValues()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 43
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 32
nc 1
nop 0
dl 0
loc 43
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * Novactive Collection.
4
 *
5
 * @author    Luke Visinoni <[email protected], [email protected]>
6
 * @author    Sébastien Morel <[email protected], [email protected]>
7
 * @copyright 2017 Novactive
8
 * @license   MIT
9
 */
10
11
namespace Novactive\Tests;
12
13
use Novactive\Collection\Factory;
14
15
/**
16
 * Class CombineCollectionTest.
17
 */
18
class CombineCollectionTest extends UnitTestCase
19
{
20
    public function testCombineReturnsCollectionWithExistingKeysAndIncomingValues()
21
    {
22
        $coll = Factory::create($this->fixtures['names']);
23
24
        $this->assertSame(
25
            [
26
                'Chelsea',
27
                'Adella',
28
                'Monte',
29
                'Maye',
30
                'Lottie',
31
                'Don',
32
                'Dayton',
33
                'Kirk',
34
                'Troy',
35
                'Nakia',
36
            ],
37
            $orig = $coll->toArray()
38
        );
39
40
        $newcoll = $coll->combine($this->fixtures['emails']);
41
        $this->assertNotSame($coll, $newcoll);
42
        $this->assertSame(
43
            [
44
                'Chelsea' => '[email protected]',
45
                'Adella'  => '[email protected]',
46
                'Monte'   => '[email protected]',
47
                'Maye'    => '[email protected]',
48
                'Lottie'  => '[email protected]',
49
                'Don'     => '[email protected]',
50
                'Dayton'  => '[email protected]',
51
                'Kirk'    => '[email protected]',
52
                'Troy'    => '[email protected]',
53
                'Nakia'   => '[email protected]',
54
            ],
55
            $newcoll->toArray()
56
        );
57
        $this->assertSame(
58
            $orig,
59
            $coll->toArray(),
60
            'Ensure that Collection::combine() has not changed the original collection.'
61
        );
62
    }
63
64
    public function testCombineAcceptsTraversable()
65
    {
66
        $stub = $this->getIteratorForArray($this->fixtures['emails']);
67
        $coll = Factory::create($this->fixtures['names']);
68
        $this->assertSame(
69
            [
70
                'Chelsea',
71
                'Adella',
72
                'Monte',
73
                'Maye',
74
                'Lottie',
75
                'Don',
76
                'Dayton',
77
                'Kirk',
78
                'Troy',
79
                'Nakia',
80
            ],
81
            $coll->toArray()
82
        );
83
        $this->assertSame(
84
            [
85
                '[email protected]',
86
                '[email protected]',
87
                '[email protected]',
88
                '[email protected]',
89
                '[email protected]',
90
                '[email protected]',
91
                '[email protected]',
92
                '[email protected]',
93
                '[email protected]',
94
                '[email protected]',
95
            ],
96
            Factory::getArrayForItems($stub)
97
        );
98
        $orig   = $coll->toArray();
99
        $return = $coll->combine($stub);
100
        $this->assertEquals(
101
            [
102
                'Chelsea' => '[email protected]',
103
                'Adella'  => '[email protected]',
104
                'Monte'   => '[email protected]',
105
                'Maye'    => '[email protected]',
106
                'Lottie'  => '[email protected]',
107
                'Don'     => '[email protected]',
108
                'Dayton'  => '[email protected]',
109
                'Kirk'    => '[email protected]',
110
                'Troy'    => '[email protected]',
111
                'Nakia'   => '[email protected]',
112
            ],
113
            $return->toArray()
114
        );
115
        $this->assertSame(
116
            $orig,
117
            $coll->toArray(),
118
            'Ensure that Collection::combine() has not changed the original collection.'
119
        );
120
    }
121
122
    /**
123
     * @expectedException \InvalidArgumentException
124
     * @expectedExceptionMessage Invalid input type for combine.
125
     */
126
    public function testCombineThrowsExceptionIfInvalidInput()
127
    {
128
        $coll = Factory::create($this->fixtures['names']);
129
        $coll->combine('not an array');
0 ignored issues
show
Documentation introduced by
'not an array' is of type string, but the function expects a object<Traversable>|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
130
    }
131
132
    /**
133
     * @expectedException \InvalidArgumentException
134
     * @expectedExceptionMessage Invalid input for combine, number of items does not match.
135
     */
136
    public function testCombineThrowsExceptionIfIncomingTraversableCountIsNotSameAsCollection()
137
    {
138
        $coll = Factory::create($this->fixtures['names']);
139
        $coll->combine([1, 2, 3]);
140
    }
141
}
142