mirror of
https://github.com/silverstripe/silverstripe-testsession
synced 2024-10-22 14:06:00 +02:00
Allow requireDefaultRecords population
This commit is contained in:
parent
65b80d881d
commit
cd6a485b84
@ -49,6 +49,7 @@ on "dev/testsession/start":
|
||||
The path should be relative to the webroot.
|
||||
* `createDatabase`: Create a temporary database.
|
||||
* `createDatabaseTemplate`: Path to a database dump to load into a newly created temporary database.
|
||||
* `requireDefaultRecords`: Include default records as defined on the model classes (in PHP)
|
||||
* `database`: Set an alternative database name in the current
|
||||
browser session as a cookie. Does not actually create the database,
|
||||
that's usually handled by `SapphireTest::create_temp_db()`.
|
||||
|
@ -100,6 +100,7 @@ class TestSessionController extends Controller {
|
||||
$dropdown->setSource($databaseTemplates)
|
||||
->setEmptyString('Empty database');
|
||||
}
|
||||
$fields->push(new CheckboxField('requireDefaultRecords', 'Create default data?'));
|
||||
$fields->merge($this->getBaseFields());
|
||||
$form = new Form(
|
||||
$this,
|
||||
|
@ -197,7 +197,9 @@ class TestSessionEnvironment extends Object {
|
||||
// In case the dump involved CREATE TABLE commands, we need to ensure
|
||||
// the schema is still up to date
|
||||
$dbAdmin = new DatabaseAdmin();
|
||||
$dbAdmin->doBuild(true /*quiet*/, false /*populate*/);
|
||||
$populate = (isset($state->requireDefaultRecords) && $state->requireDefaultRecords);
|
||||
Versioned::set_reading_mode('');
|
||||
$dbAdmin->doBuild(true /*quiet*/, $populate);
|
||||
}
|
||||
|
||||
if(isset($state->createDatabase)) unset($state->createDatabase);
|
||||
|
Loading…
Reference in New Issue
Block a user