Adding autoloader and mocks directory
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
index 39c24b2..62c7d0d 100644
--- a/tests/Bootstrap.php
+++ b/tests/Bootstrap.php
@@ -6,16 +6,15 @@
 
 $dir = realpath(dirname(__FILE__));
 
-
 // Path constants
 define('PROJECT_BASE',	realpath($dir.'/../').'/');
 define('BASEPATH',		PROJECT_BASE.'system/');
 define('APPPATH',		PROJECT_BASE.'application/');
 define('VIEWPATH',		PROJECT_BASE.'');
 
-
 // Prep our test environment
-require_once $dir.'/lib/common.php';
-require_once $dir.'/lib/ci_testcase.php';
+include_once $dir.'/mocks/core/common.php';
+include_once $dir.'/mocks/autoloader.php';
+spl_autoload_register('autoload');
 
 unset($dir);
\ No newline at end of file
diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php
index cec1298..29b512d 100644
--- a/tests/codeigniter/core/Common_test.php
+++ b/tests/codeigniter/core/Common_test.php
@@ -1,7 +1,5 @@
 <?php
 
-require_once(BASEPATH.'helpers/email_helper.php');
-
 class Common_test extends CI_TestCase
 {
 	
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index b86fd34..4300865 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -1,38 +1,5 @@
 <?php
 
-require_once 'vfsStream/vfsStream.php';
-require_once BASEPATH.'/core/Loader.php';
-
-class Extended_Loader extends CI_Loader {
-	
-	/**
-	 * Since we use paths to load up models, views, etc, we need the ability to
-	 * mock up the file system so when core tests are run, we aren't mucking
-	 * in the application directory.  this will give finer grained control over
-	 * these tests.  So yeah, while this looks odd, I need to overwrite protected
-	 * class vars in the loader.  So here we go...
-	 *
-	 * @covers CI_Loader::__construct()
-	 */
-	public function __construct()
-	{
-		vfsStreamWrapper::register();
-		vfsStreamWrapper::setRoot(new vfsStreamDirectory('application'));
-		
-		$this->models_dir 	= vfsStream::newDirectory('models')->at(vfsStreamWrapper::getRoot());
-		$this->libs_dir 	= vfsStream::newDirectory('libraries')->at(vfsStreamWrapper::getRoot());
-		$this->helpers_dir 	= vfsStream::newDirectory('helpers')->at(vfsStreamWrapper::getRoot());
-		$this->views_dir 	= vfsStream::newDirectory('views')->at(vfsStreamWrapper::getRoot());
-		
-		$this->_ci_ob_level  		= ob_get_level();
-		$this->_ci_library_paths	= array(vfsStream::url('application').'/', BASEPATH);
-		$this->_ci_helper_paths 	= array(vfsStream::url('application').'/', BASEPATH);
-		$this->_ci_model_paths 		= array(vfsStream::url('application').'/');
-		$this->_ci_view_paths 		= array(vfsStream::url('application').'/views/' => TRUE);
-	}
-}
-
-
 class Loader_test extends CI_TestCase {
 	
 	private $ci_obj;
@@ -40,7 +7,7 @@
 	public function set_up()
 	{
 		// Instantiate a new loader
-		$this->load = new Extended_Loader();
+		$this->load = new Mock_Core_Loader();
 		
 		// mock up a ci instance
 		$this->ci_obj = new StdClass;
@@ -265,7 +232,4 @@
 
 	// --------------------------------------------------------------------
 	
-	
-	
-	
 }
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
index 40252aa..e340ddf 100644
--- a/tests/codeigniter/core/URI_test.php
+++ b/tests/codeigniter/core/URI_test.php
@@ -1,41 +1,10 @@
 <?php
 
-require BASEPATH.'core/URI.php';
-
-/**
- * Extend the URI class
- *  - override contructor
- *  - override CLI detection
- */
-class URI_extended extends CI_URI {
-	
-	public function __construct()
-	{
-		$test = CI_TestCase::instance();
-		$cls =& $test->ci_core_class('cfg');
-		
-		// set predictable config values
-		$test->ci_set_config(array(
-			'index_page'		=> 'index.php',
-			'base_url'			=> 'http://example.com/',
-			'subclass_prefix'	=> 'MY_'
-		));
-
-		$this->config = new $cls;	
-
-	}
-	
-	protected function _is_cli_request()
-	{
-		return FALSE;
-	}
-}
-
 class URI_test extends CI_TestCase {
 	
 	public function set_up()
 	{
-		$this->uri = new URI_extended();
+		$this->uri = new Mock_Core_URI();
 	}
 
 	// --------------------------------------------------------------------
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
new file mode 100644
index 0000000..442389f
--- /dev/null
+++ b/tests/mocks/autoloader.php
@@ -0,0 +1,33 @@
+<?php
+
+// This autoloader provide convinient way to working with mock object
+// make the test looks natural. This autoloader support cascade file loading as well
+// within mocks directory.
+//
+// Prototype :
+//
+// include_once('Mock_Core_Common') 						// Will load ./mocks/core/common.php
+// $mock_loader = new Mock_Core_Loader(); 					// Will load ./mocks/core/loader.php
+// $mock_database_driver = new Mock_Database_Driver();		// Will load ./mocks/database/driver.php 
+function autoload($class) 
+{
+	$class = (strpos($class, 'Mock_') === 0) ? str_replace(array('Mock_', '_'), array('', DIRECTORY_SEPARATOR), $class) : $class;
+	$dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR;
+	$file = $dir.strtolower($class).'.php';
+
+	if ( ! file_exists($file))
+	{
+		$trace = debug_backtrace();
+
+		// If the autoload call came from `class_exists`, we skipped
+		// and return FALSE
+		if ($trace[2]['function'] == 'class_exists')
+		{
+			return FALSE;
+		}
+
+	    throw new InvalidArgumentException("Unable to load $class.");
+	}
+
+	include_once($file);
+}
\ No newline at end of file
diff --git a/tests/lib/ci_testcase.php b/tests/mocks/ci_testcase.php
similarity index 96%
rename from tests/lib/ci_testcase.php
rename to tests/mocks/ci_testcase.php
index afccee0..5c83974 100644
--- a/tests/lib/ci_testcase.php
+++ b/tests/mocks/ci_testcase.php
@@ -1,9 +1,5 @@
 <?php
 
-
-// Need a way to change dependencies (core libs and laoded libs)
-// Need a way to set the CI class
-
 class CI_TestCase extends PHPUnit_Framework_TestCase {
 	
 	protected $ci_config;
@@ -20,7 +16,6 @@
 		'security'	=> 'sec',
 		'input'		=> 'in',
 		'lang'		=> 'lang',
-		// @todo the loader is an edge case
 		'loader'	=> 'load',
 		'model'		=> 'model'
 	);
diff --git a/tests/lib/common.php b/tests/mocks/core/common.php
similarity index 99%
rename from tests/lib/common.php
rename to tests/mocks/core/common.php
index 4a83258..fc94d7f 100644
--- a/tests/lib/common.php
+++ b/tests/mocks/core/common.php
@@ -129,4 +129,4 @@
 	return TRUE;
 }
 
-// EOF
+// EOF
\ No newline at end of file
diff --git a/tests/mocks/core/loader.php b/tests/mocks/core/loader.php
new file mode 100644
index 0000000..115ccc3
--- /dev/null
+++ b/tests/mocks/core/loader.php
@@ -0,0 +1,33 @@
+<?php
+
+require_once 'vfsStream/vfsStream.php';
+require_once BASEPATH.'/core/Loader.php';
+
+class Mock_Core_Loader extends CI_Loader {
+	
+	/**
+	 * Since we use paths to load up models, views, etc, we need the ability to
+	 * mock up the file system so when core tests are run, we aren't mucking
+	 * in the application directory.  this will give finer grained control over
+	 * these tests.  So yeah, while this looks odd, I need to overwrite protected
+	 * class vars in the loader.  So here we go...
+	 *
+	 * @covers CI_Loader::__construct()
+	 */
+	public function __construct()
+	{
+		vfsStreamWrapper::register();
+		vfsStreamWrapper::setRoot(new vfsStreamDirectory('application'));
+		
+		$this->models_dir 	= vfsStream::newDirectory('models')->at(vfsStreamWrapper::getRoot());
+		$this->libs_dir 	= vfsStream::newDirectory('libraries')->at(vfsStreamWrapper::getRoot());
+		$this->helpers_dir 	= vfsStream::newDirectory('helpers')->at(vfsStreamWrapper::getRoot());
+		$this->views_dir 	= vfsStream::newDirectory('views')->at(vfsStreamWrapper::getRoot());
+		
+		$this->_ci_ob_level  		= ob_get_level();
+		$this->_ci_library_paths	= array(vfsStream::url('application').'/', BASEPATH);
+		$this->_ci_helper_paths 	= array(vfsStream::url('application').'/', BASEPATH);
+		$this->_ci_model_paths 		= array(vfsStream::url('application').'/');
+		$this->_ci_view_paths 		= array(vfsStream::url('application').'/views/' => TRUE);
+	}
+}
\ No newline at end of file
diff --git a/tests/mocks/core/uri.php b/tests/mocks/core/uri.php
new file mode 100644
index 0000000..207c7dc
--- /dev/null
+++ b/tests/mocks/core/uri.php
@@ -0,0 +1,27 @@
+<?php
+
+require BASEPATH.'core/URI.php';
+
+class Mock_Core_URI extends CI_URI {
+	
+	public function __construct()
+	{
+		$test = CI_TestCase::instance();
+		$cls =& $test->ci_core_class('cfg');
+		
+		// set predictable config values
+		$test->ci_set_config(array(
+			'index_page'		=> 'index.php',
+			'base_url'			=> 'http://example.com/',
+			'subclass_prefix'	=> 'MY_'
+		));
+
+		$this->config = new $cls;	
+
+	}
+	
+	protected function _is_cli_request()
+	{
+		return FALSE;
+	}
+}
\ No newline at end of file