Mutagenesis\Utility\TestTimeAnalyser::process PHP Method

process() public method

public process ( )
    public function process()
    {
        $testCases = array();
        $time = array();
        $dom = new \DOMDocument();
        $dom->loadXML($this->log);
        $xpath = new \DOMXPath($dom);
        $elements = $xpath->query('//testcase');
        foreach ($elements as $key => $case) {
            if (!isset($testCases[$case->getAttribute('class')])) {
                $testCases[$case->getAttribute('class')] = array('file' => $case->getAttribute('file'), 'time' => 0);
            }
            $testCases[$case->getAttribute('class')]['time'] += (double) $case->getAttribute('time');
        }
        unset($xpath);
        foreach ($testCases as $key => $value) {
            $time[$key] = $value['time'];
        }
        array_multisort($time, SORT_ASC, $testCases);
        return $testCases;
    }

Usage Example

 public function testAnalysisOfJunitLogFormatShowsLeastTimeTestCaseFirst()
 {
     $file = $this->root . '/mutagenesis.xml';
     $analyser = new TestTimeAnalyser($file);
     $analysis = $analyser->process();
     $first = array_shift($analysis);
     $this->assertEquals('/home/sb/ArrayTest2.php', $first['file']);
 }
All Usage Examples Of Mutagenesis\Utility\TestTimeAnalyser::process
TestTimeAnalyser