public renameColumn ( string $oldName, string $newName ) | ||
$oldName | string | The current name of the column. |
$newName | string | The new name of the column. |
public function renameColumn($oldName, $newName)
{
if (isset($this[$oldName])) {
$this[$newName] = $this[$oldName];
}
// outside the if () since we want to delete nulled columns
if ($this->offsetExists($oldName)) {
unset($this[$oldName]);
}
}
public function test_renameColumn_shouldDoNothing_IfGivenColumnDoesNotExist() { $this->row->setColumn('nb_visits', 11); $this->row->renameColumn('nb_hits', 'nb_pageviews'); $this->assertFalse($this->row->hasColumn('nb_hits')); $this->assertFalse($this->row->hasColumn('nb_pageviews')); $this->assertEquals(11, $this->row->getColumn('nb_visits')); }