public function testTablemanRenameColumnsEachRowCompatibility() { // We'll try to rename columns while looping through the items. $columnBag = with(new \mechanicious\Columnizer\Columnizer($this->mockData))->columnizeRowArray(); $tableman = new \mechanicious\Tableman\Tableman($columnBag); $tableman->eachRow(function (&$ref, &$row, &$rowIndex) { // If you actually want to make changes then make sure // you **reference** items! foreach ($row as $columnHeader => &$cell) { // Append an ellipsis at the very end of every cell. $cell .= "..."; } // Renaming columns while still in the loop if (isset($ref['id'])) { $ref->renameColumns(array('id' => 'identification', 'name' => 'firstname', 'age' => 'level', 'hobby' => 'likes')); } if (in_array('id', $ref->getColumnHeaders())) { $ref->replaceColumn(new \mechanicious\Columnizer\Column(array(6, 7), '#'), 'identification'); } }); $keyHeaders = $tableman->getColumnHeaders(); $columnHeaders = array_map(function ($column) { return $column->getHeader(); }, $tableman->getColumns()); $this->assertEquals($keyHeaders, array_values($columnHeaders)); }