<?php

class CI_TestCase extends PHPUnit_Framework_TestCase {
	
	protected $ci_config;
	protected $ci_instance;
	protected static $ci_test_instance;
		
	private $global_map = array(
		'benchmark'	=> 'bm',
		'config'	=> 'cfg',
		'hooks'		=> 'ext',
		'utf8'		=> 'uni',
		'router'	=> 'rtr',
		'output'	=> 'out',
		'security'	=> 'sec',
		'input'		=> 'in',
		'lang'		=> 'lang',
		'loader'	=> 'load',
		'model'		=> 'model'
	);
	
	// --------------------------------------------------------------------
	
	public function __construct()
	{
		parent::__construct();
		
		$this->ci_config = array();
	}
	
	// --------------------------------------------------------------------
	
	public function setUp()
	{
		if (method_exists($this, 'set_up'))
		{
			$this->set_up();
		}
	}
	
	// --------------------------------------------------------------------
	
	public function tearDown() 
	{
		if (method_exists($this, 'tear_down'))
		{
			$this->tear_down();
		}
	}
	
	// --------------------------------------------------------------------
	
	function ci_set_config($key, $val = '')
	{
		if (is_array($key))
		{
			$this->ci_config = $key;
		}
		else
		{
			$this->ci_config[$key] = $val;
		}
	}
	
	// --------------------------------------------------------------------
	
	function ci_instance($obj = FALSE)
	{
		if ( ! is_object($obj))
		{
			return $this->ci_instance;
		}
		
		$this->ci_instance = $obj;
	}
	
	// --------------------------------------------------------------------
	
	function ci_instance_var($name, $obj = FALSE)
	{
		if ( ! is_object($obj))
		{
			return $this->ci_instance->$name;
		}
		
		$this->ci_instance->$name =& $obj;
	}
	
	// --------------------------------------------------------------------

	/**
	 * Grab a core class
	 *
	 * Loads the correct core class without extensions
	 * and returns a reference to the class name in the
	 * globals array with the correct key. This way the
	 * test can modify the variable it assigns to and
	 * still maintain the global.
	 */
	function &ci_core_class($name)
	{
		$name = strtolower($name);
		
		if (isset($this->global_map[$name]))
		{
			$class_name = ucfirst($name);
			$global_name = $this->global_map[$name];
		}
		elseif (in_array($name, $this->global_map))
		{
			$class_name = ucfirst(array_search($name, $this->global_map));
			$global_name = $name;
		}
		else
		{
			throw new Exception('Not a valid core class.');
		}
		
		if ( ! class_exists('CI_'.$class_name))
		{
			require_once BASEPATH.'core/'.$class_name.'.php';
		}
		
		$GLOBALS[strtoupper($global_name)] = 'CI_'.$class_name;
		return $GLOBALS[strtoupper($global_name)];
	}
	
	// --------------------------------------------------------------------
	
	// convenience function for global mocks
	function ci_set_core_class($name, $obj)
	{
		$orig =& $this->ci_core_class($name);
		$orig = $obj;
	}
	
	// --------------------------------------------------------------------
	// Internals
	// --------------------------------------------------------------------
	
	/**
	 * Overwrite runBare
	 *
	 * PHPUnit instantiates the test classes before
	 * running them individually. So right before a test
	 * runs we set our instance. Normally this step would
	 * happen in setUp, but someone is bound to forget to
	 * call the parent method and debugging this is no fun.
	 */
	public function runBare()
	{
		self::$ci_test_instance = $this;
		parent::runBare();
	}
	
	// --------------------------------------------------------------------
	
	public static function instance()
	{
		return self::$ci_test_instance;
	}
	
	// --------------------------------------------------------------------
	
	function ci_get_config()
	{
		return $this->ci_config;
	}

	// --------------------------------------------------------------------
	
	/**
	 * This overload is useful to create a stub, that need to have a specific method.
	 */
	function __call($method, $args)
	{
		if ($this->{$method} instanceof Closure) 
		{
			return call_user_func_array($this->{$method},$args);
		} 
		else 
		{
			return parent::__call($method, $args);
		}
	}
}

// EOF