FUnit::test_stats PHP Method

test_stats() public static method

Retrieves stats about tests run. returns an array with the keys 'total', 'pass', 'run'
public static test_stats ( array $tests ) : array
$tests array a set of test results
return array has keys 'total', 'pass', 'run', 'error'
    public static function test_stats(array $tests)
    {
        $total = count($tests);
        $run = 0;
        $pass = 0;
        $error = 0;
        foreach ($tests as $test_name => $tdata) {
            if ($tdata['pass']) {
                $pass++;
            }
            if ($tdata['run']) {
                $run++;
            }
            $error += count($tdata['errors']);
        }
        return compact('total', 'pass', 'run', 'error');
    }

Usage Example

Example #1
0
 /**
  * @see \FUnit::test_stats()
  * @return array
  */
 public function testCounts()
 {
     return \FUnit::test_stats($this->tests, $test_name);
 }