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.
|
The path should be relative to the webroot.
|
||||||
* `createDatabase`: Create a temporary database.
|
* `createDatabase`: Create a temporary database.
|
||||||
* `createDatabaseTemplate`: Path to a database dump to load into a newly created 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
|
* `database`: Set an alternative database name in the current
|
||||||
browser session as a cookie. Does not actually create the database,
|
browser session as a cookie. Does not actually create the database,
|
||||||
that's usually handled by `SapphireTest::create_temp_db()`.
|
that's usually handled by `SapphireTest::create_temp_db()`.
|
||||||
|
@ -100,6 +100,7 @@ class TestSessionController extends Controller {
|
|||||||
$dropdown->setSource($databaseTemplates)
|
$dropdown->setSource($databaseTemplates)
|
||||||
->setEmptyString('Empty database');
|
->setEmptyString('Empty database');
|
||||||
}
|
}
|
||||||
|
$fields->push(new CheckboxField('requireDefaultRecords', 'Create default data?'));
|
||||||
$fields->merge($this->getBaseFields());
|
$fields->merge($this->getBaseFields());
|
||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
|
@ -197,7 +197,9 @@ class TestSessionEnvironment extends Object {
|
|||||||
// In case the dump involved CREATE TABLE commands, we need to ensure
|
// In case the dump involved CREATE TABLE commands, we need to ensure
|
||||||
// the schema is still up to date
|
// the schema is still up to date
|
||||||
$dbAdmin = new DatabaseAdmin();
|
$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);
|
if(isset($state->createDatabase)) unset($state->createDatabase);
|
||||||
|
Loading…
Reference in New Issue
Block a user