public reverseMutation ( array $mutation ) | ||
$mutation | array |
public function reverseMutation(array $mutation)
{
if (runkit_method_remove($mutation['class'], $mutation['method']) == false) {
throw new \Exception('runkit_method_remove() failed attempting to remove ' . $mutation['class'] . '::' . $mutation['method']);
}
if (runkit_method_rename($mutation['class'], $mutation['method'] . $this->_methodPreserveCode, $mutation['method']) == false) {
throw new \Exception('runkit_method_rename() failed renaming from ' . $mutation['class'] . '::' . $mutation['method'] . $this->_methodPreserveCode . ' to ' . $mutation['class'] . '::' . $mutation['method'] . ' (mutation reversal)');
}
}
public function testShouldRevertToOriginalStaticMethodBodyWhenRequested() { $mutationInstance = new OperatorAddition(2); $testeeInstance = new Testee(); $testeeInstance->setFileName($this->root . '/runkit/Math2.php')->setClassName('RunkitTest_Math2')->setMethodName('add')->setArguments('$op1,$op2')->setTokens(array(array(335, 'return', 7), array(309, '$op1', 7), '+', array(309, '$op2', 7), ';')); $mutant = new Mutant($testeeInstance, $mutationInstance); $runkit = new Runkit(); $runkit->applyMutation($mutant); $runkit->reverseMutation($mutant); $this->assertEquals(2, \RunkitTest_Math2::add(1, 1)); }