Skip to content

Commit

Permalink
API Update API to reflect changes to CLI interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Sep 3, 2024
1 parent c1cf2b4 commit 8009ccd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/TestSessionEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\FixtureFactory;
use SilverStripe\HybridExecution\Command\DbBuild;
use SilverStripe\HybridExecution\HybridOutput;
use SilverStripe\Dev\YamlFixture;
use SilverStripe\ORM\Connect\TempDatabase;
use SilverStripe\ORM\DatabaseAdmin;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Versioned\Versioned;
Expand Down Expand Up @@ -370,19 +371,27 @@ public function importDatabase($path, $requireDefaultRecords = false)
}

// In case the dump involved CREATE TABLE commands, we need to ensure the schema is still up to date
$dbAdmin = new DatabaseAdmin();
$dbBuild = new DbBuild();
Versioned::set_reading_mode('');
$dbAdmin->doBuild(true, $requireDefaultRecords);
$output = new HybridOutput(
Director::is_cli() ? HybridOutput::FORMAT_ANSI : HybridOutput::FORMAT_HTML,
HybridOutput::VERBOSITY_QUIET
);
$dbBuild->doBuild($output, $requireDefaultRecords);
}

/**
* Build the database with default records, see {@link DataObject->requireDefaultRecords()}.
*/
public function requireDefaultRecords()
{
$dbAdmin = new DatabaseAdmin();
$dbBuild = new DbBuild();
Versioned::set_reading_mode('');
$dbAdmin->doBuild(true, true);
$output = new HybridOutput(
Director::is_cli() ? HybridOutput::FORMAT_ANSI : HybridOutput::FORMAT_HTML,
HybridOutput::VERBOSITY_QUIET
);
$dbBuild->doBuild($output, true);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/TestSessionHTTPMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBDatetime;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mailer\Transport\NullTransport;

Expand Down

0 comments on commit 8009ccd

Please sign in to comment.