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

@ -210,6 +210,20 @@ class SS_ClassManifest {
return $this->configs; 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. * Completely regenerates the manifest file.
* *
@ -252,7 +266,7 @@ class SS_ClassManifest {
} }
public function handleFile($basename, $pathname, $depth) { public function handleFile($basename, $pathname, $depth) {
if ($depth == 1 && $basename == self::CONF_FILE) { if ($basename == self::CONF_FILE) {
$this->configs[] = $pathname; $this->configs[] = $pathname;
return; return;
} }

View File

@ -106,6 +106,12 @@ class ClassManifestTest extends SapphireTest {
$this->assertEquals($expect, $this->manifestTests->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() { public function testTestManifestIncludesTestClasses() {
$this->assertNotContains('testclassa', array_keys($this->manifest->getClasses())); $this->assertNotContains('testclassa', array_keys($this->manifest->getClasses()));
$this->assertContains('testclassa', array_keys($this->manifestTests->getClasses())); $this->assertContains('testclassa', array_keys($this->manifestTests->getClasses()));