summaryrefslogtreecommitdiffstats
path: root/tests/mocks/autoloader.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mocks/autoloader.php')
-rw-r--r--tests/mocks/autoloader.php17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index f1bdb5d6f..90aabcbe6 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -6,11 +6,10 @@
//
// Prototype :
//
-// include_once('Mock_Core_Loader') // Will load ./mocks/core/loader.php
// $mock_table = new Mock_Libraries_Table(); // Will load ./mocks/libraries/table.php
-// $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php
+// $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php
// and so on...
-function autoload($class)
+function autoload($class)
{
$dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR;
@@ -23,7 +22,7 @@ function autoload($class)
);
$ci_libraries = array(
- 'Calendar', 'Cart', 'Driver',
+ 'Calendar', 'Cart', 'Driver_Library',
'Email', 'Encrypt', 'Form_validation',
'Ftp', 'Image_lib', 'Javascript',
'Log', 'Migration', 'Pagination',
@@ -51,9 +50,9 @@ function autoload($class)
elseif (in_array($subclass, $ci_libraries))
{
$dir = BASEPATH.'libraries'.DIRECTORY_SEPARATOR;
- $class = $subclass;
+ $class = ($subclass === 'Driver_Library') ? 'Driver' : $subclass;
}
- elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) == 3)
+ elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 3)
{
$driver_path = BASEPATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR;
$dir = $driver_path.$m[1].DIRECTORY_SEPARATOR;
@@ -76,13 +75,13 @@ function autoload($class)
{
$trace = debug_backtrace();
- // If the autoload call came from `class_exists` or `file_exists`,
+ // If the autoload call came from `class_exists` or `file_exists`,
// we skipped and return FALSE
- if ($trace[2]['function'] == 'class_exists' OR $trace[2]['function'] == 'file_exists')
+ if ($trace[2]['function'] === 'class_exists' OR $trace[2]['function'] === 'file_exists')
{
return FALSE;
}
-
+
throw new InvalidArgumentException("Unable to load $class.");
}