<?php
# $HeadURL: https://svn.sigpipe.cz/r/trunk/testilence/tests/reporter.php $
# $Id: reporter.php 392 2007-02-11 19:24:38Z roman $
require_once dirname(__FILE__) . '/utils/case.php';
require_once dirname(__FILE__) . '/utils/reporter.php';
class tencetest_EmptyReporterTest extends Tence_TestCase # {{{
{
function setUp()
{
$this->r = new tencetest_QuietReporter;
}
function testSuccessesIsInitiallyZero()
{
return $this->assertEquals(0, $this->r->successes());
}
function testFailuresIsInitiallyZero()
{
return $this->assertEquals(0, $this->r->failures());
}
function testExceptionsIsInitiallyZero()
{
return $this->assertEquals(0, $this->r->exceptions());
}
function testDefectsIsInitiallyZero()
{
return $this->assertEquals(0, $this->r->defects());
}
} # }}}
class tencetest_util_TestResults # {{{
{
function __construct($s, $f, $e, $d) # {{{
{
$this->s = $s;
$this->f = $f;
$this->e = $e;
$this->d = $d;
} # }}}
function successes() { return $this->s; }
function failures() { return $this->f; }
function exceptions() { return $this->e; }
function defects() { return $this->d; }
private $s, $f, $e, $d;
} # }}}
abstract class tencetest_ReporterTest extends tencetest_TestCase # {{{
implements Tence_TestMethodInfo
{
function setUp() # {{{
{
$this->r = new tencetest_QuietReporter;
$this->testClass = $this->ReflectionClass(__CLASS__);
$this->testMethod = $this->ReflectionMethod(__CLASS__, __FUNCTION__);
$this->r->beginTest($this);
$this->reportResults($this->r);
$this->r->endTest();
$this->expected = $this->expected();
} # }}}
# Tence_TestMethodInfo {{{
function class_() # {{{
{
return $this->testClass;
} # }}}
function method() # {{{
{
return $this->testMethod;
} # }}}
# Tence_TestMethodInfo }}}
abstract protected /* void */ function reportResults(Tence_Reporter $r);
abstract protected /* tencetest_util_TestResults */ function expected();
protected function expecting($s, $f, $e, $d) # {{{
{
return new tencetest_util_TestResults($s, $f, $e, $d);
} # }}}
function testReportedSuccesses() # {{{
{
return $this->assertEquals(
$this->expected->successes(),
$this->r->successes()
);
} # }}}
function testReportedFailures() # {{{
{
return $this->assertEquals(
$this->expected->failures(),
$this->r->failures()
);
} # }}}
function testReportedExceptions() # {{{
{
return $this->assertEquals(
$this->expected->exceptions(),
$this->r->exceptions()
);
} # }}}
function testReportedDefects() # {{{
{
return $this->assertEquals(
$this->expected->defects(),
$this->r->defects()
);
} # }}}
} # }}}
class tencetest_ReporterFailureTest extends tencetest_ReporterTest # {{{
{
protected function reportResults(Tence_Reporter $r) # {{{
{
$r->reportFailure('whatever');
} # }}}
protected function expected() # {{{
{
return $this->expecting(0, 1, 0, 0);
} # }}}
} # }}}
class tencetest_ReporterExceptionTest extends tencetest_ReporterTest # {{{
{
protected function reportResults(Tence_Reporter $r) # {{{
{
$r->reportException('whatever');
} # }}}
protected function expected() # {{{
{
return $this->expecting(0, 0, 1, 0);
} # }}}
} # }}}
class tencetest_ReporterDefectTest extends tencetest_ReporterTest # {{{
{
protected function reportResults(Tence_Reporter $r) # {{{
{
$r->reportDefect('whatever');
} # }}}
protected function expected() # {{{
{
return $this->expecting(0, 0, 0, 1);
} # }}}
} # }}}
class tencetest_ReporterSuccessTest extends tencetest_ReporterTest # {{{
{
protected function reportResults(Tence_Reporter $r) # {{{
{
$r->reportSuccess();
} # }}}
protected function expected() # {{{
{
return $this->expecting(1, 0, 0, 0);
} # }}}
} # }}}
class tencetest_ReporterTests extends Tence_TestSuite # {{{
{
function __construct()
{
$this
->add(new tencetest_EmptyReporterTest)
->add(new tencetest_ReporterSuccessTest)
->add(new tencetest_ReporterFailureTest)
->add(new tencetest_ReporterExceptionTest)
->add(new tencetest_ReporterDefectTest)
;
}
} # }}}
# vim: et ts=4 sts=4 sw=4 fdm=marker cms=\ #\ %s