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.
Test Failed
Push — develop ( 62839f...05114b )
by Sébastien
03:22
created

testCombineKeysThrowsExceptionIfPassedTraversableWithBadCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
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 CombineKeysCollectionTest.
17
 */
18
class CombineKeysCollectionTest extends UnitTestCase
19
{
20 View Code Duplication
    public function testCombineKeysUsesIncomingTraversableAsKeysForCollectionsValues()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
    {
22
        $coll    = Factory::create($this->fixtures['names']);
23
        $orig    = $coll->toArray();
24
        $newkeys = $coll->combineKeys($this->fixtures['emails']);
25
        $this->assertEquals(
26
            [
27
                '[email protected]' => 'Chelsea',
28
                '[email protected]'       => 'Adella',
29
                '[email protected]'   => 'Monte',
30
                '[email protected]'        => 'Maye',
31
                '[email protected]'        => 'Lottie',
32
                '[email protected]'      => 'Don',
33
                '[email protected]'       => 'Dayton',
34
                '[email protected]'       => 'Kirk',
35
                '[email protected]'      => 'Troy',
36
                '[email protected]'       => 'Nakia',
37
            ],
38
            $newkeys->toArray()
39
        );
40
        $this->assertNotSame($newkeys->toArray(), $orig);
41
        $this->assertSame(
42
            $coll->toArray(),
43
            $orig,
44
            'The original collection should not be affected by Collection::combineKeys().'
45
        );
46
    }
47
48
    /**
49
     * @expectedException \InvalidArgumentException
50
     * @expectedExceptionMessage Invalid input type for combineKeys.
51
     */
52
    public function testCombineKeysThrowsExceptionIfPassedNonTraversableNonArray()
53
    {
54
        $coll = Factory::create($this->fixtures['emails']);
55
        $coll->combineKeys('this is not traversable');
0 ignored issues
show
Documentation introduced by
'this is not traversable' 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...
56
    }
57
58
    /**
59
     * @expectedException \InvalidArgumentException
60
     * @expectedExceptionMessage Invalid input for combineKeys, number of items does not match.
61
     */
62
    public function testCombineKeysThrowsExceptionIfPassedTraversableWithBadCount()
63
    {
64
        $coll = Factory::create($this->fixtures['emails']);
65
        $coll->combineKeys([1, 2, 3]);
66
    }
67
68 View Code Duplication
    public function testCombineKeysAcceptsTraversable()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
    {
70
        $coll        = Factory::create($this->fixtures['names']);
71
        $orig        = $coll->toArray();
72
        $iter        = $this->getIteratorForArray($this->fixtures['emails']);
73
        $keycombined = $coll->combineKeys($iter);
74
        $this->assertSame(
75
            [
76
                '[email protected]' => 'Chelsea',
77
                '[email protected]'       => 'Adella',
78
                '[email protected]'   => 'Monte',
79
                '[email protected]'        => 'Maye',
80
                '[email protected]'        => 'Lottie',
81
                '[email protected]'      => 'Don',
82
                '[email protected]'       => 'Dayton',
83
                '[email protected]'       => 'Kirk',
84
                '[email protected]'      => 'Troy',
85
                '[email protected]'       => 'Nakia',
86
            ],
87
            $keycombined->toArray()
88
        );
89
        $this->assertSame(
90
            $orig,
91
            $coll->toArray(),
92
            'Ensure that Collection::combineKeys does not change the original collection.'
93
        );
94
    }
95
}
96