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
81cf52e6
Commit
81cf52e6
authored
Jul 15, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved 'path_with_slash' function to Base class and added root namespace to Autoloader constructor.
parent
fd39d522
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
19 deletions
+17
-19
autoloader.php
autoloader.php
+0
-10
base.php
base.php
+10
-0
tests/test_autoloader.php
tests/test_autoloader.php
+0
-8
tests/test_base.php
tests/test_base.php
+7
-1
No files found.
autoloader.php
View file @
81cf52e6
...
...
@@ -149,16 +149,6 @@ class Autoloader extends Base {
return
$this
->
root_namespace
;
}
/**
* Append a slash ('/') to the given directory name, if it is not already there.
*
* @param string $directory The directory to append a slash to.
* @return string
*/
static
function
path_with_slash
(
$directory
)
{
return
$directory
[
strlen
(
$directory
)
-
1
]
==
'/'
?
$directory
:
$directory
.
'/'
;
}
/**
* Convert a class name to a file name.
*
...
...
base.php
View file @
81cf52e6
...
...
@@ -55,6 +55,16 @@ abstract class Base {
return
$rc
->
newInstanceArgs
(
$args
);
}
/**
* Append a slash ('/') to the given directory name, if it is not already there.
*
* @param string $directory The directory to append a slash to.
* @return string
*/
static
function
path_with_slash
(
$directory
)
{
return
$directory
[
strlen
(
$directory
)
-
1
]
==
'/'
?
$directory
:
$directory
.
'/'
;
}
}
/**
...
...
tests/test_autoloader.php
View file @
81cf52e6
...
...
@@ -45,14 +45,6 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
$strip
->
invoke
(
$this
->
autoloader
,
'Foo\Bar'
),
'Bar'
);
}
function
test_path_with_slash
()
{
$this
->
assertEquals
(
Autoloader
::
path_with_slash
(
'dirname'
),
'dirname/'
);
$this
->
assertEquals
(
Autoloader
::
path_with_slash
(
'dirname/'
),
'dirname/'
);
}
/**
* @depends test_path_with_slash
*/
function
test_set_root_directory
()
{
$this
->
autoloader
->
set_root_directory
(
'tests'
);
$this
->
assertEquals
(
$this
->
autoloader
->
get_root_directory
(),
'tests/'
);
...
...
tests/test_base.php
View file @
81cf52e6
<?php
require_once
'base.php'
;
use
WebBasics\Base
;
class
BaseExtension
extends
WebBasics\
Base
{
class
BaseExtension
extends
Base
{
function
__construct
(
$foo
,
$bar
)
{
$this
->
foo
=
$foo
;
$this
->
bar
=
$bar
;
...
...
@@ -21,6 +22,11 @@ class BaseTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
WebBasics\asprintf
(
'%(bar) baz %(foo)'
,
array
(
'foo'
=>
'bar'
,
'bar'
=>
'foobar'
)),
'foobar baz bar'
);
}
function
test_path_with_slash
()
{
$this
->
assertEquals
(
Base
::
path_with_slash
(
'dirname'
),
'dirname/'
);
$this
->
assertEquals
(
Base
::
path_with_slash
(
'dirname/'
),
'dirname/'
);
}
}
?>
\ No newline at end of file
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