Skip to content

Commit

Permalink
Update to use new Environment::getenv()
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Oct 17, 2017
1 parent 15c770b commit e758be9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Compiler/CoreInitializationPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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::putEnv('SS_ENVIRONMENT_TYPE=dev');
}

// Include bootstrap file
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/MinkExtensionBaseUrlPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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'
Expand Down
8 changes: 5 additions & 3 deletions src/Context/SilverStripeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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
);
Expand Down

0 comments on commit e758be9

Please sign in to comment.