Sfoglia il codice sorgente

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

Taddeus Kroes 13 anni fa
parent
commit
81cf52e694
4 ha cambiato i file con 17 aggiunte e 19 eliminazioni
  1. 0 10
      autoloader.php
  2. 10 0
      base.php
  3. 0 8
      tests/test_autoloader.php
  4. 7 1
      tests/test_base.php

+ 0 - 10
autoloader.php

@@ -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.
 	 * 

+ 10 - 0
base.php

@@ -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.'/';
+	}
 }
 
 /**

+ 0 - 8
tests/test_autoloader.php

@@ -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/');

+ 7 - 1
tests/test_base.php

@@ -1,8 +1,9 @@
 <?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/');
+	}
 }
 
 ?>