summaryrefslogtreecommitdiffstats
path: root/tests/mocks/autoloader.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-04-27 11:15:47 +0200
committerAndrey Andreev <narf@bofh.bg>2012-04-27 11:15:47 +0200
commit5815dba069428514ce39e745328a898fc877773f (patch)
tree9ba5c1dc7bef0458c5f89e573f1b2acf05f3c688 /tests/mocks/autoloader.php
parent9c9591c9b4a1d7ac412f7a85aeb5c92f50aa3490 (diff)
parentced2c9ab41450cb632c042730604111ec2a24e1f (diff)
Merge upstream branch
Diffstat (limited to 'tests/mocks/autoloader.php')
-rw-r--r--tests/mocks/autoloader.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index dd5929206..f1bdb5d6f 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -53,13 +53,24 @@ function autoload($class)
$dir = BASEPATH.'libraries'.DIRECTORY_SEPARATOR;
$class = $subclass;
}
+ 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;
+ $file = $dir.$m[1].'_'.$m[2].'.php';
+ }
+ elseif (strpos($class, 'CI_DB') === 0)
+ {
+ $dir = BASEPATH.'database'.DIRECTORY_SEPARATOR;
+ $file = $dir.str_replace(array('CI_DB','active_record'), array('DB', 'active_rec'), $subclass).'.php';
+ }
else
{
$class = strtolower($class);
}
}
- $file = $dir.$class.'.php';
+ $file = (isset($file)) ? $file : $dir.$class.'.php';
if ( ! file_exists($file))
{
@@ -71,7 +82,7 @@ function autoload($class)
{
return FALSE;
}
-
+
throw new InvalidArgumentException("Unable to load $class.");
}