src/Service/MelisPhpUnitToolService.php
private function simplifyResultsView($results)
    {
        $simplified = array();
        if(is_array($results)) {
            $simplified['tests'] = array();
            $totalTests = 0;
            $totalFailed = 0;
            $totalSuccess = 0;
            if(isset($results['testcase'])) {
                $testcase = $results['testcase'];
                $totalTests = (int) $results['tests'];
                $totalFailed = (int) $results['failures'];
                $totalSuccess = $totalTests - $totalFailed;

                if($totalTests > 1) {
                    // loop through test cases

                    foreach($testcase as $count => $testChild) {
                        $status = 'success';
                        $message = '';
                        $type = '';


                        if(isset($testChild['failure'])) {
                            $status = 'failed';
                            $message = $testChild['failure']['_'];
                            $type    = $testChild['failure']['type'];
                        }
                        if(isset($testChild['error'])) {
                            $status = 'failed';
                            $message = $testChild['error']['_'];
                            $type    = $testChild['error']['type'];
                        }

                        $simplified['tests'][$count] = array(
                            'test' => pathinfo($testChild['file'])['filename'],
                            'name' => $testChild['name'],
                            'time' => $testChild['time'],
                            'status' => $status,
                            'message' => $message,
                            'type' => $type
                        );
                    }
                }
                else {
                    $status = 'success';
                    $message = '';
                    $type = '';
                    if(isset($testcase['failure'])) {
                        $status = 'failed';
                        $message = $testcase['failure']['_'];
                        $type    = $testcase['failure']['type'];
                    }
                    if(isset($testcase['error'])) {
                        $status = 'failed';
                        $message = $testcase['error']['_'];
                        $type    = $testcase['error']['type'];
                    }
                    $simplified['tests'][] = array(
                        'test' => isset($testcase['file']) ? pathinfo($testcase['file'])['filename'] : $testcase['name'],
                        'name' => $testcase['name'],
                        'time' => $testcase['time'],
                        'status' => $status,
                        'message' => $message,
                        'type' => $type
                    );
                }
            }
            $simplified['summary'] = array(
                'totalTests' => $totalTests,
                'totalSuccess' => $totalSuccess,
                'totalFailed' => $totalFailed
            );
            return $simplified;
        }
        else {
            return 'No tests found!';
        }
    }
private function simplifyResultsView($results)
    {
        $simplified = array();
        if(is_array($results)) {
            $simplified['tests'] = array();
            $totalTests = 0;
            $totalFailed = 0;
            $totalSuccess = 0;
            if(isset($results['testcase'])) {
                $testcase = $results['testcase'];
                $totalTests = (int) $results['tests'];
                $totalFailed = (int) $results['failures'];
                $totalSuccess = $totalTests - $totalFailed;

                if($totalTests > 1) {
                    // loop through test cases

                    foreach($testcase as $count => $testChild) {
                        $status = 'success';
                        $message = '';
                        $type = '';


                        if(isset($testChild['failure'])) {
                            $status = 'failed';
                            $message = $testChild['failure']['_'];
                            $type    = $testChild['failure']['type'];
                        }
                        if(isset($testChild['error'])) {
                            $status = 'failed';
                            $message = $testChild['error']['_'];
                            $type    = $testChild['error']['type'];
                        }

                        $simplified['tests'][$count] = array(
                            'test' => pathinfo($testChild['file'])['filename'],
                            'name' => $testChild['name'],
                            'time' => $testChild['time'],
                            'status' => $status,
                            'message' => $message,
                            'type' => $type
                        );
                    }
                }
                else {
                    $status = 'success';
                    $message = '';
                    $type = '';
                    if(isset($testcase['failure'])) {
                        $status = 'failed';
                        $message = $testcase['failure']['_'];
                        $type    = $testcase['failure']['type'];
                    }
                    if(isset($testcase['error'])) {
                        $status = 'failed';
                        $message = $testcase['error']['_'];
                        $type    = $testcase['error']['type'];
                    }
                    $simplified['tests'][] = array(
                        'test' => isset($testcase['file']) ? pathinfo($testcase['file'])['filename'] : $testcase['name'],
                        'name' => $testcase['name'],
                        'time' => $testcase['time'],
                        'status' => $status,
                        'message' => $message,
                        'type' => $type
                    );
                }
            }
            $simplified['summary'] = array(
                'totalTests' => $totalTests,
                'totalSuccess' => $totalSuccess,
                'totalFailed' => $totalFailed
            );
            return $simplified;
        }
        else {
            return 'No tests found!';
        }
    }
private function simplifyResultsView ( $ results ) { $ simplified = array ( ) ; if ( is_array ( $ results ) ) { $ simplified [ 'tests' ] = array ( ) ; $ totalTests = 0 ; $ totalFailed = 0 ; $ totalSuccess = 0 ; if ( isset ( $ results [ 'testcase' ] ) ) { $ testcase = $ results [ 'testcase' ] ; $ totalTests = ( int ) $ results [ 'tests' ] ; $ totalFailed = ( int ) $ results [ 'failures' ] ; $ totalSuccess = $ totalTests - $ totalFailed ; if ( $ totalTests > 1 ) { // loop through test cases foreach ( $ testcase as $ count => $ testChild ) { $ status = 'success' ; $ message = '' ; $ type = '' ; if ( isset ( $ testChild [ 'failure' ] ) ) { $ status = 'failed' ; $ message = $ testChild [ 'failure' ] [ '_' ] ; $ type = $ testChild [ 'failure' ] [ 'type' ] ; } if ( isset ( $ testChild [ 'error' ] ) ) { $ status = 'failed' ; $ message = $ testChild [ 'error' ] [ '_' ] ; $ type = $ testChild [ 'error' ] [ 'type' ] ; } $ simplified [ 'tests' ] [ $ count ] = array ( 'test' => pathinfo ( $ testChild [ 'file' ] ) [ 'filename' ] , 'name' => $ testChild [ 'name' ] , 'time' => $ testChild [ 'time' ] , 'status' => $ status , 'message' => $ message , 'type' => $ type ) ; } } else { $ status = 'success' ; $ message = '' ; $ type = '' ; if ( isset ( $ testcase [ 'failure' ] ) ) { $ status = 'failed' ; $ message = $ testcase [ 'failure' ] [ '_' ] ; $ type = $ testcase [ 'failure' ] [ 'type' ] ; } if ( isset ( $ testcase [ 'error' ] ) ) { $ status = 'failed' ; $ message = $ testcase [ 'error' ] [ '_' ] ; $ type = $ testcase [ 'error' ] [ 'type' ] ; } $ simplified [ 'tests' ] [ ] = array ( 'test' => isset ( $ testcase [ 'file' ] ) ? pathinfo ( $ testcase [ 'file' ] ) [ 'filename' ] : $ testcase [ 'name' ] , 'name' => $ testcase [ 'name' ] , 'time' => $ testcase [ 'time' ] , 'status' => $ status , 'message' => $ message , 'type' => $ type ) ; } } $ simplified [ 'summary' ] = array ( 'totalTests' => $ totalTests , 'totalSuccess' => $ totalSuccess , 'totalFailed' => $ totalFailed ) ; return $ simplified ; } else { return 'No tests found!' ; } }
Simplifies the output of the PHPUnit result
@param $results
@return array|string
Simplifies the output of the PHPUnit result