Skip to content

Instantly share code, notes, and snippets.

@kenjis
Created September 21, 2011 08:05
Show Gist options
  • Save kenjis/1231528 to your computer and use it in GitHub Desktop.
Save kenjis/1231528 to your computer and use it in GitHub Desktop.
PHPUnit for CodeIgniter Unit Testing class: http://d.hatena.ne.jp/Kenji_s/20110921/1316593782
<?php
define('BASEPATH', dirname(__FILE__) . '/../system/');
define('APPPATH', dirname(__FILE__) . '/../application/');
function autoload_core($class_name)
{
$file_name = $class_name;
if (substr($class_name, 0, 3) === 'CI_')
{
$file_name = substr($file_name, 3);
}
$file = BASEPATH . 'core/' . $file_name . '.php';
if (file_exists($file))
{
require_once $file;
}
}
function autoload_model($class_name)
{
$file_name = strtolower($class_name);
$file = APPPATH . 'models/' . $file_name . '.php';
if (file_exists($file))
{
require_once $file;
}
}
spl_autoload_register('autoload_core');
spl_autoload_register('autoload_model');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment