Merge pull request #3211 from kinglozzer/pulls/3210-duplicate-classes

FIX: ClassManifest errors if files contain duplicate class names (fixes #3210)
This commit is contained in:
Damian Mooyman 2014-06-17 10:17:47 +12:00
commit 91afa4ac61
5 changed files with 24 additions and 3 deletions

View File

@ -391,14 +391,15 @@ class SS_ClassManifest {
$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);

View File

@ -126,4 +126,14 @@ class ClassManifestTest extends SapphireTest {
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);
}
}

View File

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

View File

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