Location: PHPKode > projects > OpenNitro > trunk/Nitro/Modules/BackOffice/TestSuite/Module.inc.php
<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: Modules :: BackendSubModule :: TestSuiteModule                     |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2006 June Systems B.V.                                      |
// +---------------------------------------------------------------------------+
// | This source file is copyrighted by June Systems BV, the Netherlands       |
// | If you would like to use this file in your projects, please contact       |
// | hide@address.com                                                     |
// +---------------------------------------------------------------------------+
// | Authors: Jesper Avôt <hide@address.com>                        |
// |          Siggi Oskarsson <hide@address.com>                          |
// +---------------------------------------------------------------------------+
//
// $Id: Module.inc.php 229 2008-04-17 09:20:31Z oli $
//

/**
 * TestSuiteModule
 *
 * @author			Jesper Avôt <hide@address.com>
 * @author			Siggi Oskarsson <hide@address.com>
 * @copyright		2006 June Systems B.V.
 * @package			Modules
 * @subpackage  NitroBO
 */
 
/**
 * Include required files
 */
include_once 'Nitro/Libraries/PHPUnit/Nitro_TestSuite.inc.php';
include_once 'Nitro/XML/XMLResponse.inc.php';
require_once "Nitro/Template.inc.php";

/**
 * Nitro Test Suite class
 */
class NitroBO_TestSuite extends NitroBOSubModule {
	
	/**
	 * Define some Module things
	 */
	var $ModuleName = "NitroBO_TestSuite";
	var $ModuleVersion = "1.0";
	var $ModuleAuthor = Array( "Jesper Avôt", "Siggi Oskarsson" );

	var $Action;
	var $TestSuite;

	/**
	 * Constructor
	 */
	function NitroBO_TestSuite() {
		/**
		 * Get Action
		 */
		$this->Action = isset($_REQUEST['A']) ? $_REQUEST['A'] : FALSE;

		/**
		 * Start the TestSuite class.
		 */
		$this->TestSuite = new Nitro_TestSuite();
		$this->TestSuite->ProcessTests();
		$this->TestSuite->Settings['Action'] = $Action;
	}
	
	function GetObjectsDefinition()
	{
		DebugGroup( __CLASS__, __FUNCTION__, "NitroBO->Submodule->" . $this->ModuleName . "->" . __FUNCTION__, __FILE__, __LINE__, DEBUG_MOD_OK );
		
		$this->_ModuleObjects = Array(
			'Draw' => Array('Type'					=> 'HTML',
								 			'Name'					=> 'Text',
								 			'FunctionName'	=> 'Draw',
								 			'Default'				=> TRUE)
		);

		DebugCloseGroup( DEBUG_MOD_OK );
		
		return $this->_ModuleObjects;
	}
	
	/**
	 * GetSettingsDefinition function
	 *
	 * Which Settings are allowed in this Module for XML Requests?
	 */
	function GetXMLDefinition()
	{
		DebugGroup(__CLASS__, __FUNCTION__, "NitroBO->SubModule->" . $this->ModuleName . "->" . __FUNCTION__, __FILE__, __LINE__, DEBUG_MOD_OK);
		
		if (!isset($this->_XMLDefinition)) {
			$this->_XMLDefinition = Array(
				'Test' => Array(
					'Type'					=> "HTML", 
					'Name' 					=> 'Test', 
					'DivID' 				=> "TestSuiteDiv", 
					'FunctionName'	=> "XML_Test"),
				'List' => Array(
					'Type'					=> "HTML", 
					'Name' 					=> 'List Tests', 
					'DivID' 				=> "TestSuiteDiv", 
					'FunctionName'	=> "XML_List"),
				'Req' => Array(
					'Type'					=> "HTML", 
					'Name' 					=> 'Req', 
					'DivID' 				=> "TestSuiteDiv", 
					'FunctionName'	=> "XML_Req")
			);
		}
			
		DebugCloseGroup(DEBUG_MOD_OK);
		
		return $this->_XMLDefinition;
	}
	
	/**
	 * Draw function
	**/
	function Draw()
	{
		DebugGroup( __CLASS__, __FUNCTION__, 'Draw the TestSuite Module', __FILE__, __LINE__, DEBUG_MOD_OK );

		$Template = new NitroTemplate(NULL);
		$Template->Assign('TestSuiteList', $this->TestSuite->GetTestFilesOverview());
		$RV = $Template->Fetch("file:".NITRO_PATH."Defaults/Templates/TestSuite.tpl");
		
		DebugCloseGroup( DEBUG_MOD_OK );
		
		return $RV;
	}
	
	function XML_List()
	{
		return array('TestSuiteDiv' => $this->TestSuite->GetTestFilesOverview());
	}

	function XML_Test()
	{
		return $this->TestSuite->Test();
	}
	
	function XML_Req()
	{
		return $this->TestSuite->PrintSettings();
	}
}
?>
Return current item: OpenNitro