Mutagenesis\Adapter\Phpunit::runTests PHP Method

runTests() public method

First element is a boolean result value indicating if tests passed or not. Second element is an array containing the key "stdout" which stores the output from the last test run.
public runTests ( Base $runner, boolean $useStdout = true, boolean $firstRun = false, array $mutation = [], array $testCases = [] ) : array
$runner Mutagenesis\Runner\Base
$useStdout boolean
$firstRun boolean
$mutation array
$testCases array
return array
    public function runTests(\Mutagenesis\Runner\Base $runner, $useStdout = true, $firstRun = false, array $mutation = array(), array $testCases = array())
    {
        $options = $runner->getOptions();
        $job = new \Mutagenesis\Utility\Job();
        if (!$useStdout) {
            array_unshift($options['clioptions'], '--stderr');
        }
        if (!in_array('--stop-on-failure', $options['clioptions'])) {
            array_unshift($options['clioptions'], '--stop-on-failure');
        }
        array_unshift($options['clioptions'], 'phpunit');
        if ($firstRun) {
            $options['clioptions'] = array_merge($options['clioptions'], array('--log-junit', $options['cache'] . '/mutagenesis.xml'), explode(' ', $options['constraint']));
        }
        if (count($testCases) > 0) {
            // tests cases always 0 on first run
            foreach ($testCases as $case) {
                $args = $options;
                $args['clioptions'][] = $case['class'];
                $args['clioptions'][] = $case['file'];
                $output = self::execute($job->generate($mutation, $args, $runner->getTimeout(), $runner->getBootstrap()));
                if (!$this->processOutput($output['stdout'])) {
                    return array(false, $output);
                }
            }
        } else {
            $output = self::execute($job->generate($mutation, $options, 0, $runner->getBootstrap()));
            if (!$this->processOutput($output['stdout'])) {
                return array(false, $output);
            }
        }
        return array(true, $output);
    }

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::runTests