Allow requireDefaultRecords population

This commit is contained in:
Ingo Schommer 2014-02-19 22:38:32 +13:00
parent 65b80d881d
commit cd6a485b84
3 changed files with 5 additions and 1 deletions

View File

@ -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()`.

View File

@ -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,

View File

@ -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);