1 | <?php |
||
18 | class CombineKeysCollectionTest extends UnitTestCase |
||
19 | { |
||
20 | public function testCombineKeysUsesIncomingTraversableAsKeysForCollectionsValues() |
||
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() |
||
57 | |||
58 | /** |
||
59 | * @expectedException \InvalidArgumentException |
||
60 | * @expectedExceptionMessage Invalid input for combineKeys, number of items does not match. |
||
61 | */ |
||
62 | public function testCombineKeysThrowsExceptionIfPassedTraversableWithBadCount() |
||
67 | |||
68 | public function testCombineKeysAcceptsTraversable() |
||
95 | } |
||
96 |
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: