Commit 81cf52e6 authored by Taddeus Kroes's avatar Taddeus Kroes

Moved 'path_with_slash' function to Base class and added root namespace to Autoloader constructor.

parent fd39d522
......@@ -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.
*
......
......@@ -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.'/';
}
}
/**
......
......@@ -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/');
......
<?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
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