Mutagenesis\Adapter\Phpunit::processOutput PHP Method

processOutput() public static method

In the context of mutation testing, a test failure is good (i.e. the mutation was detected by the test suite).
public static processOutput ( string $output ) : boolean
$output string
return boolean
    public static function processOutput($output)
    {
        if (substr($output, 0, 21) == 'Your tests timed out.') {
            //TODO: Multiple instances
            return self::TIMED_OUT;
        }
        $lines = explode("\n", $output);
        $useful = array_slice($lines, 2);
        foreach ($useful as $line) {
            if ($line == "\n") {
                break;
            }
            if (preg_match("/.*[EF].*/", $line)) {
                return false;
            }
        }
        return true;
    }

Usage Example

 public function testAdapterDetectsFailedRun()
 {
     $runner = m::mock('\\Mutagenesis\\Runner\\Base');
     $runner->shouldReceive('getOptions')->andReturn(array('tests' => $this->root, 'clioptions' => array(), 'cache' => sys_get_temp_dir(), 'constraint' => ''));
     $runner->shouldReceive(array('getBootstrap' => null, 'getTimeout' => 1200));
     $adapter = new \Mutagenesis\Adapter\Phpunit();
     $result = $adapter->runTests($runner, true, true, array(), array(array('class' => 'PassTest', 'file' => 'SyntaxError.php')));
     $this->assertEquals(\Mutagenesis\Adapter\Phpunit::PROCESS_FAILURE, $adapter->processOutput($result[1]['stdout']));
 }
All Usage Examples Of Mutagenesis\Adapter\Phpunit::processOutput