Permalink
Browse files

Namespace are now case insensitive in the autoloader.

  • Loading branch information...
1 parent 3eb357d commit 246d651fb4eb88be4c5ba356be972cd013545338 @mageekguy mageekguy committed Jan 10, 2013
Showing with 15 additions and 1 deletion.
  1. +4 −1 classes/autoloader.php
  2. +11 −0 tests/units/classes/autoloader.php
View
@@ -65,8 +65,9 @@ public function unregister()
public function addDirectory($namespace, $directory)
{
- $namespace = trim($namespace, '\\') . '\\';
+ $namespace = strtolower(trim($namespace, '\\') . '\\');
$directory = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
+
if (isset($this->directories[$namespace]) === false || in_array($directory, $this->directories[$namespace]) === false)
{
$this->directories[$namespace][] = $directory;
@@ -108,6 +109,8 @@ public function getClassAliases()
public function getPath($class)
{
+ $class = strtolower($class);
+
foreach ($this->directories as $namespace => $directories)
{
if ($class !== $namespace)
@@ -126,6 +126,17 @@ public function testAddDirectory()
$otherNamespace => array($otherDirectory)
)
)
+ ->object($autoloader->addDirectory($mixedCaseNamespace = 'a\MiXED\CASE\NameSPACE', $mixedCaseDirectory = (uniqid() . DIRECTORY_SEPARATOR)))->isIdenticalTo($autoloader)
+ ->array($autoloader->getDirectories())->isEqualTo(array(
+ 'mageekguy\atoum\\' => array(atoum\directory . (\phar::running() ? '/' : DIRECTORY_SEPARATOR) . 'classes' . DIRECTORY_SEPARATOR),
+ $namespace . '\\' => array(
+ $directory . DIRECTORY_SEPARATOR,
+ $secondDirectory
+ ),
+ $otherNamespace => array($otherDirectory),
+ strtolower($mixedCaseNamespace) . '\\' => array($mixedCaseDirectory)
+ )
+ )
;
}
}

0 comments on commit 246d651

Please sign in to comment.