public function testMap() { $resultSet = new ResultSet(array(1 => array('_id' => 1, 'field' => 'value1'), 2 => array('_id' => 2, 'field' => 'value2'), 3 => array('_id' => 3, 'field' => 'value3'))); $newSet = $resultSet->map(function ($item) { $item['newField'] = 'newValue' . $item['_id']; return $item; }); $this->assertNotEmpty(count($newSet)); foreach ($newSet as $id => $item) { $this->assertArrayHasKey('newField', $item); $this->assertEquals('newValue' . $id, $item['newField']); } }