Skip to content

Commit

Permalink
FIX: ClassManifest errors if files contain duplicate class names (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kinglozzer committed Jun 16, 2014
1 parent 34304cf commit 3d71a22
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/manifest/ClassManifest.php
Expand Up @@ -391,14 +391,15 @@ public function handleFile($basename, $pathname, $depth) {
$extends = substr($extends, 1);
}

if (array_key_exists($name, $this->classes)) {
$lowercaseName = strtolower($name);
if (array_key_exists($lowercaseName, $this->classes)) {
throw new Exception(sprintf(
'There are two files containing the "%s" class: "%s" and "%s"',
$name, $this->classes[$name], $pathname
$name, $this->classes[$lowercaseName], $pathname
));
}

$this->classes[strtolower($name)] = $pathname;
$this->classes[$lowercaseName] = $pathname;

if ($extends) {
$extends = strtolower($extends);
Expand Down
10 changes: 10 additions & 0 deletions tests/core/manifest/ClassManifestTest.php
Expand Up @@ -126,4 +126,14 @@ public function testTestManifestIncludesTestClasses() {
public function testManifestExcludeFilesPrefixedWithUnderscore() {
$this->assertNotContains('ignore', array_keys($this->manifest->getClasses()));
}

/**
* Assert that ClassManifest throws an exception when it encounters two files
* which contain classes with the same name
* @expectedException Exception
*/
public function testManifestWarnsAboutDuplicateClasses() {
$dummy = new SS_ClassManifest(dirname(__FILE__) . '/fixtures/classmanifest_duplicates', false, true, false);
}

}
Empty file.
@@ -0,0 +1,5 @@
<?php
/**
* @ignore
*/
class TESTClass { }
@@ -0,0 +1,5 @@
<?php
/**
* @ignore
*/
class testCLASS { }

0 comments on commit 3d71a22

Please sign in to comment.