Autoloader should not throw exceptions.

pull/57/head v1.1
Mike Cao 12 years ago
parent 988d4f5631
commit 7e1a098f6c

@ -175,13 +175,6 @@ class Loader {
return;
}
}
// Allow other autoloaders to run before raising an error
$loaders = spl_autoload_functions();
$loader = array_pop($loaders);
if (is_array($loader) && $loader[0] == __CLASS__ && $loader[1] == __FUNCTION__) {
throw new \Exception('Unable to load file: '.$class_file);
}
}
/**

@ -18,12 +18,11 @@ class AutoloadTest extends PHPUnit_Framework_TestCase
function setUp() {
$this->app = new \flight\Engine();
$this->app->path(__DIR__.'/classes');
}
// Autoload a class
function testAutoload(){
$this->app->path(__DIR__.'/classes');
$this->app->register('test', 'TestClass');
$loaders = spl_autoload_functions();
@ -34,4 +33,16 @@ class AutoloadTest extends PHPUnit_Framework_TestCase
$this->assertTrue(is_object($test));
$this->assertEquals('TestClass', get_class($test));
}
// Check autoload failure
function testMissingClass(){
$test = null;
$this->app->register('test', 'NonExistentClass');
if (class_exists('NonExistentClass')) {
$test = $this->app->test();
}
$this->assertEquals(null, $test);
}
}

Loading…
Cancel
Save