Location: PHPKode > projects > Scorpio Framework for PHP > scorpioframework_php_0.3.5/libraries/generator/templates/test/scorpioTestCase.tpl
{*
Template contains the following keys:

'textUtil' -> text transform utility class
'appAuthor' -> the application author
'appCopyright' -> application copyright notice
'oConfig' -> full base config

'class' -> the original class name
'testClassName' -> the name of the test class being built
'methods' -> array of ReflectionMethod objects
'package' -> package name from docblock or expressly set
'subpackage' -> the subpackage from docblock or expressly set
'instantiable' -> can the class be instantiated via new xxx

Generator uses { & } as a Smarty var
*}
{'<?php'}
/**
 * {$testClassName}
 * 
 * Stored in {$testClassName}.class.php
 * 
 * @author {$appAuthor}
 * @copyright {$appCopyright}
 * @package {$package}
 * @subpackage testSuite
 * @category {$testClassName}
 * @version $Rev: 722 $
 */

/*
 * Load dependencies (allows tests to be run in IDE)
 */
require_once dirname(dirname(dirname(dirname(__FILE__)))).'/libraries/system.inc';

/**
 * {$testClassName} Class
 * 
 * Test case file for {$class}, auto-generated by Test Case Generator.
 * 
 * @package {$package}
 * @subpackage testSuite
 * @category {$testClassName}
 */
class {$testClassName} extends testCaseScorpio {

	/**
	 * Stores instance of {$class}
	 *
	 * @var {$class}
	 * @access private
	 */
	private ${$class};
	
	
	
	/**
	 * Prepares the environment before running a test.
	 */
	function setUp() {
		parent::setUp();
		/*
		 * Add skip criteria in here
		 *
		if ( true ) {
			$this->markTestSkipped('Test skipped');
		}
		*/
		// @todo Auto-generated {$testClassName}::setUp()

{if $instantiable}
		$this->{$class} = new {$class}();
{/if}
	}
	
	/**
	 * Cleans up the environment after running a test.
	 */
	function tearDown() {
		// @todo Auto-generated {$testClassName}::tearDown()
		
		$this->{$class} = null;
		parent::tearDown();
	}

	/**
	 * Creates a new test case
	 *
	 * @return {$testClassName}
	 */
	function __construct() {
		// @todo Auto-generated contructor
		parent::__construct();
	}
	
	
	
{foreach item=oMethod from=$methods}
	/**
	 * Tests {$class}{if $oMethod->isStatic()}::{else}->{/if}{$oMethod->getName()}
	 */
	function test{$oMethod->getName()|capitalize}() {
		// @todo requires test implementation
		$this->markTestSkipped('test{$oMethod->getName()|capitalize}() requires implementation');
		
{if $oMethod->isStatic()}
		{$class}::{$oMethod->getName()}(/* parameters */);
{elseif $oMethod->getName() == 'isModified'}
		$this->{$class}->reset();
		
		$oReflection = new ReflectionObject($this->{$class});
		foreach ( $oReflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method ) {
			if ( strpos($method, 'set') === 0 ) {
				try {
					switch ( $method ) {
						default:
							$value = 'la la la';
					}
					$this->{$class}->$method($value);
					$this->assertTrue($this->{$class}->isModified(), ' call to set property modified object');
				} catch ( Exception $e ) {
					// ignore all exceptions
				}
				$this->{$class}->reset();
			}
		}
{else}
		$this->{$class}->{$oMethod->getName()}(/* parameters */);
{/if}
	}

{/foreach}
}
Return current item: Scorpio Framework for PHP