Location: PHPKode > scripts > PHP DataCache > php-datacachea1/tests/TestDataCache.php
<?php
/**
 * test harness for DataCache classes
 *
 * Modification History: <pre>
 *	$Log: TestDataCache.php,v $
 *	Revision 1.1.1.1  2003/12/11 05:22:11  jsweat
 *	Initial check-in of PHP DataCache library.
 *	
 * </pre>
 * @author		Jason E. Sweat
 * @since		2003-10-28
 * @package		DataCache
 * @subpackage	tests
 * @version		$Id: TestDataCache.php,v 1.1.1.1 2003/12/11 05:22:11 jsweat Exp $
 */
error_reporting(E_ALL);

/**
 *	relative path to SimpleTest
 *	@ignore
 */
@define('SIMPLE_TEST', '../.lib/simpletest/');
/**
 *	SimpleTest base class
 */
require_once SIMPLE_TEST.'unit_tester.php';
/**
 *	SimpleTest reporter class
 */
require_once SIMPLE_TEST.'reporter.php';
/**
 *	DataCache class to be tested
 */
require_once '../DataCache.php';
/**
 *	Application Identifier to use for the tests
 */
@define('TEST_APPLICATION', 'SimpleTests');

/**
 *
 * @package		DataCache
 * @subpackage	tests
 */
class TestDataCache extends UnitTestCase 
{
	/**
	 * constructor
	 *
	 * @return	void
	 */
	function TestDataCache()
	{
		$this->UnitTestCase();
	}

	/**
	 * initialization of test function
	 *
	 * @return	void
	 */
	function Setup() {
		$this->_moCache =& new DataCache(TEST_APPLICATION);
	}
	
	
	/**
	 * test improper instanciation
	 *
	 * @return	void
	 */
	function TestBadCreate()
	{
		$o =& new DataCache;
		$this->AssertError('Missing argument 1 for datacache()');
		$this->AssertError("Invalid Application identifier '' for DataCache");
		$too_big = TEST_APPLICATION.TEST_APPLICATION.TEST_APPLICATION;
		$o =& new DataCache($too_big);
		$this->assertError("Invalid Application identifier '$too_big' for DataCache");
		$has_spaces = TEST_APPLICATION.' foo';
		$o =& new DataCache($has_spaces);
		$this->assertError("Invalid Application identifier '$has_spaces' for DataCache");
	}

	/**
	 * test when there is no data cached
	 *
	 * @return	void
	 */
	function TestNoData()
	{
		$id = TEST_APPLICATION;
		$this->AssertFalse($this->_moCache->GetCache($id));
		$this->AssertError("identifier '$id' does not have a valid cache");
	}
	
}

//run if stand alone
if (!isset($this)) {
	$test = &new TestDataCache('DataCache Class Test');
	$test->run(new HtmlReporter());
}

/* vim: set tabstop=4: */
#?>
Return current item: PHP DataCache