EHANCEMENT #2853 - You can now use db/build instead of db/build?flush=1

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63020 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-09-25 00:03:09 +00:00
parent 9f05546c1e
commit 1be18b792c
3 changed files with 21 additions and 9 deletions

View File

@ -175,7 +175,7 @@ class ManifestBuilder {
$manifestInfo["require_once"][] = "$baseDir/$filename/_config.php";
// Include this so that we're set up for connecting to the database
// in the rest of the manifest builder
require("$baseDir/$filename/_config.php");
require_once("$baseDir/$filename/_config.php");
}
}

View File

@ -87,6 +87,9 @@ class DatabaseAdmin extends Controller {
set_time_limit(600);
}
// Get all our classes
ManifestBuilder::compileManifest();
$this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']));
}
@ -129,8 +132,6 @@ class DatabaseAdmin extends Controller {
* @param boolean $populate Populate the database, as well as setting up its schema
*/
function doBuild($quiet = false, $populate = true, $testMode = false) {
$conn = DB::getConn();
if($quiet) {
DB::quiet();
} else {
@ -152,10 +153,6 @@ class DatabaseAdmin extends Controller {
// ManifestBuilder::compileManifest();
}
// Get all our classes
// ManifestBuilder::compileManifest();
// ManifestBuilder::includeEverything();
// Build the database. Most of the hard work is handled by DataObject
$dataClasses = ClassInfo::subclassesFor('DataObject');
array_shift($dataClasses);
@ -165,6 +162,7 @@ class DatabaseAdmin extends Controller {
else echo "\n<p><b>Creating database tables</b></p>\n\n";
}
$conn = DB::getConn();
$conn->beginSchemaUpdate();
foreach($dataClasses as $dataClass) {
$SNG = singleton($dataClass);

View File

@ -7,6 +7,7 @@ class ManifestBuilderTest extends SapphireTest {
function testManifest() {
$baseFolder = TEMP_FOLDER . '/manifest-test';
$manifestInfo = ManifestBuilder::get_manifest_info($baseFolder, DB::getConn()->tableList());
global $project;
$this->assertEquals("$baseFolder/sapphire/MyClass.php", $manifestInfo['globals']['_CLASS_MANIFEST']['MyClass']);
$this->assertEquals("$baseFolder/sapphire/subdir/SubDirClass.php", $manifestInfo['globals']['_CLASS_MANIFEST']['SubDirClass']);
@ -33,8 +34,10 @@ class ManifestBuilderTest extends SapphireTest {
function testManifestIgnoresClassesInComments() {
$baseFolder = TEMP_FOLDER . '/manifest-test';
global $project;
$manifestInfo = ManifestBuilder::get_manifest_info($baseFolder, DB::getConn()->tableList());
/* Our fixture defines the class MyClass_InComment inside a comment, so it shouldn't be included in the class manifest. */
$this->assertNotContains('MyClass_InComment', array_keys($manifestInfo['globals']['_CLASS_MANIFEST']));
$this->assertNotContains('MyClass_InComment', array_keys($manifestInfo['globals']['_ALL_CLASSES']['exists']));
@ -51,7 +54,7 @@ class ManifestBuilderTest extends SapphireTest {
function testManifestIgnoresClassesInStrings() {
$baseFolder = TEMP_FOLDER . '/manifest-test';
$manifestInfo = ManifestBuilder::get_manifest_info($baseFolder, DB::getConn()->tableList());
/* If a class defintion is listed in a single quote string, then it shouldn't be inlcuded. Here we have put a class definition for MyClass_InSingleQuoteString inside a single-quoted string */
$this->assertNotContains('MyClass_InSingleQuoteString', array_keys($manifestInfo['globals']['_CLASS_MANIFEST']));
$this->assertNotContains('MyClass_InSingleQuoteString', array_keys($manifestInfo['globals']['_ALL_CLASSES']['exists']));
@ -73,6 +76,7 @@ class ManifestBuilderTest extends SapphireTest {
protected $originalClassManifest, $originalProject, $originalAllClasses;
protected static $test_fixture_project;
function setUp() {
// Trick the auto-loder into loading this class before we muck with the manifest
@ -108,13 +112,23 @@ class ManifestBuilderTest extends SapphireTest {
}
global $_CLASS_MANIFEST, $_ALL_CLASSES, $project;
$this->originalAllClasses = $_ALL_CLASSES;
$this->originalClassManifest = $_CLASS_MANIFEST;
$this->originalProject = $project;
// Because it's difficult to run multiple tests on a piece of code that uses require_once, we keep a copy of the
// $project value.
if(self::$test_fixture_project) $project = self::$test_fixture_project;
global $project;
}
function tearDown() {
global $_CLASS_MANIFEST, $_ALL_CLASSES, $project;
if(!self::$test_fixture_project) self::$test_fixture_project = $project;
$project = $this->originalProject;
$_CLASS_MANIFEST = $this->originalClassManifest;
$_ALL_CLASSES = $this->originalAllClasses;