Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 47 lines (43 sloc) 1.385 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
<?php

class AsciiFailureReporter implements Reporter
{
    public function report(TestClassResult $results)
    {
        if ($results->hasFailingTests()) {
            $this->printClassInfo($results->getClass());
            $this->printFailures($results);
        }
    }

    protected function printFailures(TestClassResult $results)
    {
        $failedTests = 0;
        foreach($results as $test) {
            if ($test->isFailure()) {
                $this->printFailedTestInfo($test->getTestName(),
                                                $test->getTestMessage());
                $failedTests++;
            }
        }
        $this->printFailureSummary($failedCount = $failedTests,
                                $totalTestCount = count($results->getIterator()));
        
    }

    public function printHeader() {}
    public function printFooter() {}
    public function printClassInfo($className)
    {
        echo "\n$className failed tests:\n";
    }
    public function printFailedTestInfo($testName, $message = null)
    {
        echo "$testName";
        if ($message) {
            echo " (message: $message)";
        }
        echo ". ";
    }
    public function printSuccessSummary() {}
    public function printFailureSummary($failedTestCount, $totalTestCount)
    {
        echo "\n$failedTestCount failed out of $totalTestCount.\n";
    }
}
Something went wrong with that request. Please try again.