public function testShouldRevertToOriginalStaticMethodBodyWhenRequested() { $mutation = array('file' => $this->root . '/runkit/Math2.php', 'class' => 'RunkitTest_Math2', 'method' => 'add', 'args' => '$op1,$op2', 'tokens' => array(array(335, 'return', 7), array(309, '$op1', 7), '+', array(309, '$op2', 7), ';'), 'index' => 2, 'mutation' => new \Mutagenesis\Mutation\OperatorAddition($this->root . '/runkit/Math2.php')); $runkit = new \Mutagenesis\Utility\Runkit(); $runkit->applyMutation($mutation); $runkit->reverseMutation($mutation); $this->assertEquals(2, RunkitTest_Math2::add(1, 1)); }
/** * Uses an instance of PHPUnit_TextUI_Command to execute the PHPUnit * tests and simulates any Mutagenesis supported command line options suitable * for PHPUnit. At present, we merely dissect a generic 'options' string * equivelant to anything typed into a console after a normal 'phpunit' * command. The adapter captures the TextUI output for further processing. * * To prevent duplication of output from stdout, PHPUnit is hard * configured to write to stderrm(stdin is used in proc_open call) * * @param array $arguments Mutagenesis arguments to pass to PHPUnit * @return void */ public static function main($arguments, $mutation = null, $bootstrap = null) { $arguments = unserialize($arguments); /** * Grab the Runkit extension utility and apply the mutation if needed */ if (!is_null($mutation)) { $mutation = unserialize($mutation); if (!empty($mutation)) { if (!is_null($bootstrap)) { require_once $bootstrap; } if (!in_array('runkit', get_loaded_extensions())) { throw new \Exception('Runkit extension is not loaded. Unfortunately, runkit' . ' is essential for Mutagenesis. Please see the manual or' . ' README which explains how to install an updated runkit' . ' extension suitable for Mutagenesis and PHP 5.3.'); } $runkit = new \Mutagenesis\Utility\Runkit(); $runkit->applyMutation($mutation); } } /** * Switch working directory to tests and execute the test suite */ $originalWorkingDirectory = getcwd(); if (isset($arguments['tests'])) { chdir($arguments['tests']); } $command = new \PHPUnit_TextUI_Command(); $command->run($arguments['clioptions'], false); chdir($originalWorkingDirectory); }