static public function instance($db_type='', $db_params=array(), $force_new_instance=false)
  {
    if(!$db_type)
      $db_type = getIniOption('common.ini', 'type', 'DB');
    elseif(!$db_type)
      $db_type = 'null';

    $db_class_name = self :: _mapTypeToClass($db_type);

    $obj = null;
    if (isset($GLOBALS['global_db_handler']))
      $obj =& $GLOBALS['global_db_handler'];

    if (get_class($obj) != $db_class_name ||  $force_new_instance)
    {
      if(!$db_params &&  $db_type !== 'null')
      {
        $conf = getIni('common.ini');
        $db_params['host'] = $conf->getOption('host', 'DB');
        $db_params['login'] = $conf->getOption('login', 'DB');
        $db_params['password'] = $conf->getOption('password', 'DB');
        $db_params['name'] = $conf->getOption('name', 'DB');
      }

      include_once(LIMB_DIR . '/class/lib/db/' . $db_class_name . '.class.php');

      $obj = new $db_class_name($db_params);

      $GLOBALS['global_db_handler'] = $obj;
    }
    return $obj;
  }
  function setUp()
  {
    if (!mysql_connect(getIniOption('common.ini', 'host', 'DB'), getIniOption('common.ini', 'login', 'DB'), getIniOption('common.ini', 'password', 'DB')))
      die ('Could not connect: ' . mysql_errno() . ' - ' . mysql_errno());
    if (!mysql_select_db(getIniOption('common.ini', 'name', 'DB')))
      die ('Could not connect: ' . mysql_errno() . ' - ' . mysql_errno());

    if (!mysql_query("DROP TABLE IF EXISTS founding_fathers;"))
      die ('Error dropping table: ' . mysql_errno() . ' - ' . mysql_errno());

    $sql = "CREATE TABLE founding_fathers (
      id int(11) NOT NULL auto_increment,
      first varchar(50) NOT NULL default '',
      last varchar(50) NOT NULL default '',
      dog_name varchar(50) default NULL,
      int_test int(11) default 0,
      PRIMARY KEY (id)
    ) type=InnoDB;";

    if (!mysql_query($sql))
      die ('Error creating table: ' . mysql_errno() . ' - ' . mysql_errno());

    $inserts = array(
      "INSERT INTO founding_fathers VALUES (1, 'George', 'Washington', '', 0);",
      "INSERT INTO founding_fathers VALUES (2, 'Alexander', 'Hamilton', '', 0);",
      "INSERT INTO founding_fathers VALUES (3, 'Benjamin', 'Franklin', '', 0);",
      "INSERT INTO founding_fathers VALUES (10, 'Benjamin', 'Zade', '', 0);"
    );

    foreach ($inserts as $insert)
    {
      if (!mysql_query($insert))
        die ('Error inserting ' . mysql_errno() . ' - ' . mysql_errno());
    }
  }
  function getTestCasesHandles()
  {
    $handles = array();
    $handles = TestFinder::getTestCasesHandlesFromDirectory(LIMB_DIR . '/tests/cases/db');

    $db_type = getIniOption('common.ini', 'type', 'DB');

    $handles = array_merge(
      $handles,
      TestFinder::getTestCasesHandlesFromDirectory(LIMB_DIR . '/tests/cases/db/' . $db_type)
    );

    return $handles;
  }
<?php

/**********************************************************************************
* Copyright 2004 BIT, Ltd. http://limb-project.com, mailto: support@limb-project.com
*
* Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html)
***********************************************************************************
*
* $Id$
*
***********************************************************************************/
require_once LIMB_DIR . '/core/util/ini_support.inc.php';
if (!($HTMLSax_dir = getIniOption('external.ini', 'library_path', 'XML_HTMLSAX'))) {
    $HTMLSax_dir = '../external/pear/XML/';
}
define('XML_HTMLSAX3', $HTMLSax_dir);
require_once XML_HTMLSAX3 . '/HTMLSax3.php';
<?php
/**********************************************************************************
* Copyright 2004 BIT, Ltd. http://limb-project.com, mailto: support@limb-project.com
*
* Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html)
***********************************************************************************
*
* $Id$
*
***********************************************************************************/
require_once(LIMB_DIR . '/class/lib/util/ini_support.inc.php');

if(!$SimpleTest_dir = getIniOption('external.ini', 'library_path', 'SimpleTest'))
  $SimpleTest_dir = '../external/SimpleTest/';

define('SIMPLE_TEST', $SimpleTest_dir);

if ( !file_exists(SIMPLE_TEST . 'unit_tester.php') )
  die ('Make sure the SIMPLE_TEST constant is set correctly in this file');

require_once(SIMPLE_TEST . 'unit_tester.php');
require_once(SIMPLE_TEST . 'mock_objects.php');
require_once(SIMPLE_TEST . 'reporter.php');

?>