Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webbasics
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
webbasics
Commits
fd39d522
Commit
fd39d522
authored
Jul 15, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added root namespace to Autoloader constructor.
parent
09845b1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
autoloader.php
autoloader.php
+6
-4
tests/test_autoloader.php
tests/test_autoloader.php
+8
-1
No files found.
autoloader.php
View file @
fd39d522
...
@@ -81,11 +81,13 @@ class Autoloader extends Base {
...
@@ -81,11 +81,13 @@ class Autoloader extends Base {
/**
/**
* Create a new Autoloader instance.
* 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.
* @param bool $throw Whether to throw an exception when a class file does not exist.
*/
*/
function
__construct
(
$directory
,
$throw
=
false
)
{
function
__construct
(
$root_directory
,
$root_namespace
=
'\\'
,
$throw
=
false
)
{
$this
->
set_root_directory
(
$directory
);
$this
->
set_root_directory
(
$root_directory
);
$this
->
set_root_namespace
(
$root_namespace
);
$this
->
set_throw_errors
(
$throw
);
$this
->
set_throw_errors
(
$throw
);
}
}
...
@@ -128,7 +130,7 @@ class Autoloader extends Base {
...
@@ -128,7 +130,7 @@ class Autoloader extends Base {
/**
/**
* Set the root namespace that loaded classes are expected to be in.
* 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
)
{
function
set_root_namespace
(
$namespace
)
{
// Assert that the namespace ends with a backslash
// Assert that the namespace ends with a backslash
...
...
tests/test_autoloader.php
View file @
fd39d522
...
@@ -10,7 +10,6 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
...
@@ -10,7 +10,6 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
$this
->
autoloader
=
new
Autoloader
(
PATH
);
$this
->
autoloader
=
new
Autoloader
(
PATH
);
}
}
function
test_set_root_namespace
()
{
function
test_set_root_namespace
()
{
$this
->
assertAttributeEquals
(
'\\'
,
'root_namespace'
,
$this
->
autoloader
);
$this
->
assertAttributeEquals
(
'\\'
,
'root_namespace'
,
$this
->
autoloader
);
$this
->
autoloader
->
set_root_namespace
(
'Foo'
);
$this
->
autoloader
->
set_root_namespace
(
'Foo'
);
...
@@ -27,6 +26,14 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
...
@@ -27,6 +26,14 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
$this
->
autoloader
->
get_root_namespace
(),
'Foo\\'
);
$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
* @depends test_set_root_namespace
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment