From 3eb61e353f2fa7ddff519d254b991223df250844 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:17:06 +1200 Subject: [PATCH] API Update API to reflect changes to CLI interaction (#93) --- src/TestSessionEnvironment.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/TestSessionEnvironment.php b/src/TestSessionEnvironment.php index 306315d..4dc08f1 100644 --- a/src/TestSessionEnvironment.php +++ b/src/TestSessionEnvironment.php @@ -15,9 +15,10 @@ use SilverStripe\Core\Extensible; use SilverStripe\Core\Injector\Injectable; use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\FixtureFactory; +use SilverStripe\PolyExecution\Command\DbBuild; +use SilverStripe\PolyExecution\PolyOutput; 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 @@ class TestSessionEnvironment } // 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 PolyOutput( + Director::is_cli() ? PolyOutput::FORMAT_ANSI : PolyOutput::FORMAT_HTML, + PolyOutput::VERBOSITY_QUIET + ); + $dbBuild->doBuild($output, $requireDefaultRecords); } /** @@ -380,9 +385,13 @@ class TestSessionEnvironment */ public function requireDefaultRecords() { - $dbAdmin = new DatabaseAdmin(); + $dbBuild = new DbBuild(); Versioned::set_reading_mode(''); - $dbAdmin->doBuild(true, true); + $output = new PolyOutput( + Director::is_cli() ? PolyOutput::FORMAT_ANSI : PolyOutput::FORMAT_HTML, + PolyOutput::VERBOSITY_QUIET + ); + $dbBuild->doBuild($output, true); } /**