1 | <?php |
||
18 | class ReplaceCollectionTest extends UnitTestCase |
||
19 | { |
||
20 | public function testReplaceCombinesInPlace() |
||
21 | { |
||
22 | $coll = Factory::create($this->fixtures['names']); |
||
23 | $return = $coll->replace($this->fixtures['emails']); |
||
24 | $this->assertSame($coll, $return); |
||
25 | $this->assertEquals( |
||
26 | [ |
||
27 | 'Chelsea' => '[email protected]', |
||
28 | 'Adella' => '[email protected]', |
||
29 | 'Monte' => '[email protected]', |
||
30 | 'Maye' => '[email protected]', |
||
31 | 'Lottie' => '[email protected]', |
||
32 | 'Don' => '[email protected]', |
||
33 | 'Dayton' => '[email protected]', |
||
34 | 'Kirk' => '[email protected]', |
||
35 | 'Troy' => '[email protected]', |
||
36 | 'Nakia' => '[email protected]', |
||
37 | ], |
||
38 | $coll->toArray() |
||
39 | ); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @expectedException \InvalidArgumentException |
||
44 | * @expectedExceptionMessage Invalid input type for replace. |
||
45 | */ |
||
46 | public function testReplaceThrowsExceptionIfInvalidInput() |
||
47 | { |
||
48 | $coll = Factory::create($this->fixtures['names']); |
||
49 | $coll->replace('not an array'); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @expectedException \InvalidArgumentException |
||
54 | * @expectedExceptionMessage Invalid input for replace, number of items does not match. |
||
55 | */ |
||
56 | public function testReplaceThrowsExceptionIfIncomingTraversableCountIsNotSameAsCollection() |
||
57 | { |
||
58 | $coll = Factory::create($this->fixtures['names']); |
||
59 | $coll->replace([1, 2, 3]); |
||
60 | } |
||
61 | } |
||
62 |