ENHANCEMENT Added ClassManifest->getModules(), and removed limitation to toplevel modules in ClassManifest->handleFile() (necessary to detect new sapphire/admin/ "submodule")

This commit is contained in:
Ingo Schommer 2011-04-30 17:35:25 +12:00
parent afbb4cc045
commit 37774d4103
2 changed files with 21 additions and 1 deletions

View File

@ -209,6 +209,20 @@ class SS_ClassManifest {
public function getConfigs() {
return $this->configs;
}
/**
* Returns an array of module names mapped to their paths.
* "Modules" in sapphire are simply directories with a _config.php file.
*
* @return array
*/
public function getModules() {
$modules = array();
foreach($this->configs as $configPath) {
$modules[basename(dirname($configPath))] = dirname($configPath);
}
return $modules;
}
/**
* Completely regenerates the manifest file.
@ -252,7 +266,7 @@ class SS_ClassManifest {
}
public function handleFile($basename, $pathname, $depth) {
if ($depth == 1 && $basename == self::CONF_FILE) {
if ($basename == self::CONF_FILE) {
$this->configs[] = $pathname;
return;
}

View File

@ -105,6 +105,12 @@ class ClassManifestTest extends SapphireTest {
$this->assertEquals($expect, $this->manifest->getConfigs());
$this->assertEquals($expect, $this->manifestTests->getConfigs());
}
public function testGetModules() {
$expect = array("module" => "{$this->base}/module");
$this->assertEquals($expect, $this->manifest->getModules());
$this->assertEquals($expect, $this->manifestTests->getModules());
}
public function testTestManifestIncludesTestClasses() {
$this->assertNotContains('testclassa', array_keys($this->manifest->getClasses()));