Commit fd39d522 authored by Taddeus Kroes's avatar Taddeus Kroes

Added root namespace to Autoloader constructor.

parent 09845b1b
......@@ -81,11 +81,13 @@ class Autoloader extends Base {
/**
* Create a new Autoloader instance.
*
* @param string $directory Root directory of the autoloader.
* @param string $root_directory Root directory of the autoloader.
* @param string $root_namespace Root namespace of classes loaded by the autoloader.
* @param bool $throw Whether to throw an exception when a class file does not exist.
*/
function __construct($directory, $throw=false) {
$this->set_root_directory($directory);
function __construct($root_directory, $root_namespace='\\', $throw=false) {
$this->set_root_directory($root_directory);
$this->set_root_namespace($root_namespace);
$this->set_throw_errors($throw);
}
......@@ -128,7 +130,7 @@ class Autoloader extends Base {
/**
* Set the root namespace that loaded classes are expected to be in.
*
* @param string $directory The new root namespace.
* @param string $namespace The new root namespace.
*/
function set_root_namespace($namespace) {
// Assert that the namespace ends with a backslash
......
......@@ -10,7 +10,6 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
$this->autoloader = new Autoloader(PATH);
}
function test_set_root_namespace() {
$this->assertAttributeEquals('\\', 'root_namespace', $this->autoloader);
$this->autoloader->set_root_namespace('Foo');
......@@ -27,6 +26,14 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($this->autoloader->get_root_namespace(), 'Foo\\');
}
/**
* @depends test_set_root_namespace
*/
function test_construct_root_namespace() {
$autoloader = new Autoloader(PATH, 'Foo');
$this->assertAttributeEquals('Foo\\', 'root_namespace', $autoloader);
}
/**
* @depends test_set_root_namespace
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment