diff --git a/composer.json b/composer.json index fab85bd..b2a8d5e 100644 --- a/composer.json +++ b/composer.json @@ -40,11 +40,7 @@ "autoload-dev": { "psr-4": { "SilverStripe\\BehatExtension\\Tests\\": "tests/php/" - }, - "classmap": [ - "framework", - "vendor/phpunit/phpunit" - ] + } }, "extra": { "branch-alias": { diff --git a/src/Compiler/CoreInitializationPass.php b/src/Compiler/CoreInitializationPass.php index 390bab3..da785a4 100644 --- a/src/Compiler/CoreInitializationPass.php +++ b/src/Compiler/CoreInitializationPass.php @@ -7,6 +7,7 @@ use SilverStripe\Control\Controller; 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 @@ class CoreInitializationPass implements CompilerPassInterface 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 d26779d..1eceac2 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 50b3033..6434906 100644 --- a/src/Context/SilverStripeContext.php +++ b/src/Context/SilverStripeContext.php @@ -10,8 +10,10 @@ use Behat\Mink\Driver\Selenium2Driver; 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 @@ abstract class SilverStripeContext extends MinkContext implements SilverStripeAw $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 @@ abstract class SilverStripeContext extends MinkContext implements SilverStripeAw 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 );