Commit 160b803a9e6556bb8a652aa329823da68ba5d9c3

Authored by Neil Blakey-Milner
1 parent 91b31301

Include file for all tests - turns KT into test mode (changes database,

for example) on include.

Add KTUnitTestCase, where we can add additional asserts and different
behaviour if necessary.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5398 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 34 additions and 0 deletions
tests/test.php 0 → 100644
  1 +<?php
  2 +
  3 +$GLOBALS['kt_test'] = true;
  4 +require_once(dirname(__FILE__) . '/../config/dmsDefaults.php');
  5 +require_once('simpletest/unit_tester.php');
  6 +require_once('simpletest/mock_objects.php');
  7 +require_once('simpletest/reporter.php');
  8 +
  9 +class KTUnitTestCase extends UnitTestCase {
  10 + function assertExpectedResults($aExpected, $aReceived) {
  11 + if ($aReceived == $aExpected) {
  12 + $this->pass('Expected results received');
  13 + return;
  14 + }
  15 +
  16 + $iLen = count($aExpected);
  17 + for ($c = 0; $c < $iLen; $c++) {
  18 + if ($aReceived[$c] != $aExpected[$c]) {
  19 + $this->fail(sprintf("Failure. Expected %s, but got %s\n", $aExpected[$c], $aReceived[$c]));
  20 + }
  21 + }
  22 + }
  23 +
  24 + function assertEntity($oEntity, $sClass) {
  25 + if (is_a($oEntity, $sClass)) {
  26 + return $this->pass(sprintf('Object is a %s', $sClass));
  27 + }
  28 + return $this->fail(sprintf('Object is not a %s', $sClass));
  29 + }
  30 +
  31 + function assertGroup($oGroup) {
  32 + return $this->assertEntity($oGroup, 'Group');
  33 + }
  34 +}
... ...