mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
9f05546c1e
commit
1be18b792c
@ -175,7 +175,7 @@ class ManifestBuilder {
|
|||||||
$manifestInfo["require_once"][] = "$baseDir/$filename/_config.php";
|
$manifestInfo["require_once"][] = "$baseDir/$filename/_config.php";
|
||||||
// Include this so that we're set up for connecting to the database
|
// Include this so that we're set up for connecting to the database
|
||||||
// in the rest of the manifest builder
|
// in the rest of the manifest builder
|
||||||
require("$baseDir/$filename/_config.php");
|
require_once("$baseDir/$filename/_config.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,9 @@ class DatabaseAdmin extends Controller {
|
|||||||
set_time_limit(600);
|
set_time_limit(600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get all our classes
|
||||||
|
ManifestBuilder::compileManifest();
|
||||||
|
|
||||||
$this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']));
|
$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
|
* @param boolean $populate Populate the database, as well as setting up its schema
|
||||||
*/
|
*/
|
||||||
function doBuild($quiet = false, $populate = true, $testMode = false) {
|
function doBuild($quiet = false, $populate = true, $testMode = false) {
|
||||||
$conn = DB::getConn();
|
|
||||||
|
|
||||||
if($quiet) {
|
if($quiet) {
|
||||||
DB::quiet();
|
DB::quiet();
|
||||||
} else {
|
} else {
|
||||||
@ -152,10 +153,6 @@ class DatabaseAdmin extends Controller {
|
|||||||
// ManifestBuilder::compileManifest();
|
// ManifestBuilder::compileManifest();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all our classes
|
|
||||||
// ManifestBuilder::compileManifest();
|
|
||||||
// ManifestBuilder::includeEverything();
|
|
||||||
|
|
||||||
// Build the database. Most of the hard work is handled by DataObject
|
// Build the database. Most of the hard work is handled by DataObject
|
||||||
$dataClasses = ClassInfo::subclassesFor('DataObject');
|
$dataClasses = ClassInfo::subclassesFor('DataObject');
|
||||||
array_shift($dataClasses);
|
array_shift($dataClasses);
|
||||||
@ -165,6 +162,7 @@ class DatabaseAdmin extends Controller {
|
|||||||
else echo "\n<p><b>Creating database tables</b></p>\n\n";
|
else echo "\n<p><b>Creating database tables</b></p>\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$conn = DB::getConn();
|
||||||
$conn->beginSchemaUpdate();
|
$conn->beginSchemaUpdate();
|
||||||
foreach($dataClasses as $dataClass) {
|
foreach($dataClasses as $dataClass) {
|
||||||
$SNG = singleton($dataClass);
|
$SNG = singleton($dataClass);
|
||||||
|
@ -7,6 +7,7 @@ class ManifestBuilderTest extends SapphireTest {
|
|||||||
function testManifest() {
|
function testManifest() {
|
||||||
$baseFolder = TEMP_FOLDER . '/manifest-test';
|
$baseFolder = TEMP_FOLDER . '/manifest-test';
|
||||||
$manifestInfo = ManifestBuilder::get_manifest_info($baseFolder, DB::getConn()->tableList());
|
$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/MyClass.php", $manifestInfo['globals']['_CLASS_MANIFEST']['MyClass']);
|
||||||
$this->assertEquals("$baseFolder/sapphire/subdir/SubDirClass.php", $manifestInfo['globals']['_CLASS_MANIFEST']['SubDirClass']);
|
$this->assertEquals("$baseFolder/sapphire/subdir/SubDirClass.php", $manifestInfo['globals']['_CLASS_MANIFEST']['SubDirClass']);
|
||||||
@ -33,6 +34,8 @@ class ManifestBuilderTest extends SapphireTest {
|
|||||||
|
|
||||||
function testManifestIgnoresClassesInComments() {
|
function testManifestIgnoresClassesInComments() {
|
||||||
$baseFolder = TEMP_FOLDER . '/manifest-test';
|
$baseFolder = TEMP_FOLDER . '/manifest-test';
|
||||||
|
global $project;
|
||||||
|
|
||||||
$manifestInfo = ManifestBuilder::get_manifest_info($baseFolder, DB::getConn()->tableList());
|
$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. */
|
/* Our fixture defines the class MyClass_InComment inside a comment, so it shouldn't be included in the class manifest. */
|
||||||
@ -73,6 +76,7 @@ class ManifestBuilderTest extends SapphireTest {
|
|||||||
|
|
||||||
|
|
||||||
protected $originalClassManifest, $originalProject, $originalAllClasses;
|
protected $originalClassManifest, $originalProject, $originalAllClasses;
|
||||||
|
protected static $test_fixture_project;
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
// Trick the auto-loder into loading this class before we muck with the manifest
|
// 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;
|
global $_CLASS_MANIFEST, $_ALL_CLASSES, $project;
|
||||||
|
|
||||||
$this->originalAllClasses = $_ALL_CLASSES;
|
$this->originalAllClasses = $_ALL_CLASSES;
|
||||||
$this->originalClassManifest = $_CLASS_MANIFEST;
|
$this->originalClassManifest = $_CLASS_MANIFEST;
|
||||||
$this->originalProject = $project;
|
$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() {
|
function tearDown() {
|
||||||
global $_CLASS_MANIFEST, $_ALL_CLASSES, $project;
|
global $_CLASS_MANIFEST, $_ALL_CLASSES, $project;
|
||||||
|
|
||||||
|
if(!self::$test_fixture_project) self::$test_fixture_project = $project;
|
||||||
|
|
||||||
$project = $this->originalProject;
|
$project = $this->originalProject;
|
||||||
$_CLASS_MANIFEST = $this->originalClassManifest;
|
$_CLASS_MANIFEST = $this->originalClassManifest;
|
||||||
$_ALL_CLASSES = $this->originalAllClasses;
|
$_ALL_CLASSES = $this->originalAllClasses;
|
||||||
|
Loading…
Reference in New Issue
Block a user