/** * Tests map * * @return void */ public function testMap() { $items = ['a' => 1, 'b' => 2, 'c' => 3]; $collection = new Collection($items); $map = $collection->map(function ($v, $k, $it) use($collection) { $this->assertSame($collection->getInnerIterator(), $it); return $v * $v; }); $this->assertInstanceOf('Cake\\Collection\\Iterator\\ReplaceIterator', $map); $this->assertEquals(['a' => 1, 'b' => 4, 'c' => 9], iterator_to_array($map)); }