From 1bf327d4de19345bc0d7fb58c13ee1b01a18fdb1 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Wed, 28 Aug 2024 14:08:42 +1200 Subject: [PATCH] API Update API to reflect changes to CLI interaction --- src/TestSessionEnvironment.php | 19 ++++++++++++++----- src/TestSessionHTTPMiddleware.php | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/TestSessionEnvironment.php b/src/TestSessionEnvironment.php index 306315d..499423b 100644 --- a/src/TestSessionEnvironment.php +++ b/src/TestSessionEnvironment.php @@ -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; @@ -370,9 +371,13 @@ 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); } /** @@ -380,9 +385,13 @@ public function importDatabase($path, $requireDefaultRecords = false) */ 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); } /** diff --git a/src/TestSessionHTTPMiddleware.php b/src/TestSessionHTTPMiddleware.php index 47789c3..e47d68c 100644 --- a/src/TestSessionHTTPMiddleware.php +++ b/src/TestSessionHTTPMiddleware.php @@ -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;