function test_Switch() { $input = array('fooName' => 'fooValue', 'barName' => 'barValue'); $name = 'fooName'; $legacyName = 'replacedFooName'; $output = $input; Admin_DA::_switch($output, $name, $legacyName); // determine that the desired field name has been removed $this->assertTrue(!array_key_exists($name, $output)); // determine that the legacy name has been inserted $this->assertTrue(array_key_exists($legacyName, $output)); // make sure extra keys not altered $this->assertTrue(array_key_exists('barName', $output)); // make sure existing value has new key $this->assertEqual('fooValue', $output[$legacyName]); // assert key swapped successfully $this->assertEqual($input[$name], $output[$legacyName]); }
function addZone($aVariables) { Admin_DA::_switch($aVariables, 'publisher_id', 'affiliateid'); Admin_DA::_switch($aVariables, 'name', 'zonename'); Admin_DA::_switch($aVariables, 'type', 'delivery'); return Admin_DA::_addEntity('zones', $aVariables); }