Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use new Environment::getenv() #170

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@
"autoload-dev": {
"psr-4": {
"SilverStripe\\BehatExtension\\Tests\\": "tests/php/"
},
"classmap": [
"framework",
"vendor/phpunit/phpunit"
]
}
},
"extra": {
"branch-alias": {
Expand Down
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::setEnv('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