Location: PHPKode > projects > OpenNitro > trunk/Nitro/Libraries/PHPUnit/UnitTest.inc.php
<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: UnitTest                                                         |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2003-2006 June Systems BV                                   |
// +---------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify it   |
// | under the terms of the GNU Lesser General Public License as published by  |
// | the Free Software Foundation; either version 2.1 of the License, or (at   |
// | your option) any later version.                                           |
// |                                                                           |
// | This library is distributed in the hope that it will be useful, but       |
// | WITHOUT ANY WARRANTY; without even the implied warranty of                |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser   |
// | General Public License for more details.                                  |
// |                                                                           |
// | You should have received a copy of the GNU Lesser General Public License  |
// | along with this library; if not, write to the Free Software Foundation,   |
// | Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA            |
// +---------------------------------------------------------------------------+
// | Authors: Jesper Avot <hide@address.com>                             |
// +---------------------------------------------------------------------------+
//
// $Id: UnitTest.inc.php 229 2008-04-17 09:20:31Z oli $
//

/**
 * This file contains the UnitTest class
 * 
 * @author			Jesper Avot <hide@address.com>
 * @copyright		2006 June Systems BV
 * @package			Classes
 * @subpackage	UnitTest
 */

/**
 * Set error_reporting
 */
error_reporting(E_ALL & ~E_NOTICE);

/**
 * Include required files
 */
include_once 'Nitro/Libraries/PHPUnit/phpunit.php';
include_once 'Nitro/Libraries/PHPUnit/Nitro_TestCase.inc.php';

/**
 * Library for regression testing
 */
class UnitTest {	
	/**
	 * Get Test Files From Dir
	 *
	 * Retrieve all test files from given directory.
	 */
	function GetTestFilesFromDir($Dir, $Recursive = FALSE)
	{
		global $TestRunner;
		$Files = array();
		
		if (file_exists($Dir)) {
			foreach (glob($Dir.'/*.php') AS $file) {
				if (is_file($file)) $Files[sha1($file)] = $file;
			}
		}
		
		if ($Recursive) {
			foreach (glob($Dir.'/*', GLOB_ONLYDIR) AS $dir) {
				$Files = array_merge($Files, UnitTest::GetTestFilesFromDir($dir, $Recursive));
			}
		}
		
		return $Files;
	}
	
	/**
	 * Create Suite
	 *
	 * Create TestSuite of given File.
	 */
	function &CreateSuite($File) 
	{
		$Case = FALSE;
		$name = strrchr($File, '/');
		
		if (strlen($name)) {
			$parts = explode('.', substr($name, 1));
			include_once $File;
			$Case = new TestSuite($parts[0].'_Test'); //Naming convention for TestCase!
		}
		
		return $Case;
	}
}
?>
Return current item: OpenNitro