test.php
1.24 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
<?php
$GLOBALS['kt_test'] = true;
require_once(dirname(__FILE__) . '/../config/dmsDefaults.php');
require_once('simpletest/unit_tester.php');
require_once('simpletest/mock_objects.php');
require_once('simpletest/reporter.php');
class KTUnitTestCase extends UnitTestCase {
function assertExpectedResults($aExpected, $aReceived) {
if ($aReceived == $aExpected) {
$this->pass('Expected results received');
return;
}
$iLen = count($aExpected);
for ($c = 0; $c < $iLen; $c++) {
if ($aReceived[$c] != $aExpected[$c]) {
$this->fail(sprintf("Failure. Expected %s, but got %s\n", $aExpected[$c], $aReceived[$c]));
}
}
}
function assertEntity($oEntity, $sClass) {
if (is_a($oEntity, $sClass)) {
return $this->pass(sprintf('Object is a %s', $sClass));
}
return $this->fail(sprintf('Object is not a %s', $sClass));
}
function assertNotError($oObject) {
if(PEAR::isError($oObject)) {
return $this->fail(sprintf('Object is a PEAR Error'));
}
return $this->pass(sprintf('Object is not a PEAR Error'));
}
function assertGroup($oGroup) {
return $this->assertEntity($oGroup, 'Group');
}
}