diff --git a/src/Compiler/CoreInitializationPass.php b/src/Compiler/CoreInitializationPass.php index 390bab36..da785a47 100644 --- a/src/Compiler/CoreInitializationPass.php +++ b/src/Compiler/CoreInitializationPass.php @@ -7,6 +7,7 @@ use SilverStripe\Control\HTTPApplication; use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\CoreKernel; +use SilverStripe\Core\Environment; use SilverStripe\Core\Manifest\ModuleLoader; use SilverStripe\ORM\DataObject; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -28,8 +29,8 @@ public function process(ContainerBuilder $container) file_put_contents('php://stdout', 'Bootstrapping' . PHP_EOL); // Connect to database and build manifest - if (!getenv('SS_ENVIRONMENT_TYPE')) { - putenv('SS_ENVIRONMENT_TYPE=dev'); + if (!Environment::getEnv('SS_ENVIRONMENT_TYPE')) { + Environment::setEnv('SS_ENVIRONMENT_TYPE', 'dev'); } // Include bootstrap file diff --git a/src/Compiler/MinkExtensionBaseUrlPass.php b/src/Compiler/MinkExtensionBaseUrlPass.php index d26779d9..1eceac2e 100644 --- a/src/Compiler/MinkExtensionBaseUrlPass.php +++ b/src/Compiler/MinkExtensionBaseUrlPass.php @@ -3,6 +3,7 @@ namespace SilverStripe\BehatExtension\Compiler; use InvalidArgumentException; +use SilverStripe\Core\Environment; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -23,7 +24,7 @@ class MinkExtensionBaseUrlPass implements CompilerPassInterface public function process(ContainerBuilder $container) { // Set url from environment - $baseURL = getenv('SS_BASE_URL'); + $baseURL = Environment::getEnv('SS_BASE_URL'); if (!$baseURL) { throw new InvalidArgumentException( '"base_url" not configured. Please specify it in your .env config with SS_BASE_URL' diff --git a/src/Context/SilverStripeContext.php b/src/Context/SilverStripeContext.php index 50b3033a..64349069 100644 --- a/src/Context/SilverStripeContext.php +++ b/src/Context/SilverStripeContext.php @@ -10,8 +10,10 @@ use Behat\Mink\Exception\UnsupportedDriverActionException; use Behat\Mink\Exception\ElementNotFoundException; use InvalidArgumentException; +use SilverStripe\BehatExtension\Utility\TestMailer; use SilverStripe\CMS\Model\SiteTree; use SilverStripe\Core\ClassInfo; +use SilverStripe\Core\Environment; use SilverStripe\Core\Resettable; use SilverStripe\ORM\DataObject; use SilverStripe\TestSession\TestSessionEnvironment; @@ -255,7 +257,7 @@ public function before(BeforeScenarioScope $event) $this->testSessionEnvironment->loadFixtureIntoDb($fixtureFile); } - if ($screenSize = getenv('BEHAT_SCREEN_SIZE')) { + if ($screenSize = Environment::getEnv('BEHAT_SCREEN_SIZE')) { list($screenWidth, $screenHeight) = explode('x', $screenSize); $this->getSession()->resizeWindow((int)$screenWidth, (int)$screenHeight); } else { @@ -282,11 +284,11 @@ public function before(BeforeScenarioScope $event) public function getTestSessionState() { $extraParams = array(); - parse_str(getenv('TESTSESSION_PARAMS'), $extraParams); + parse_str(Environment::getEnv('TESTSESSION_PARAMS'), $extraParams); return array_merge( array( 'database' => $this->databaseName, - 'mailer' => 'SilverStripe\BehatExtension\Utility\TestMailer', + 'mailer' => TestMailer::class, ), $extraParams );