Merge pull request #170 from open-sausages/pulls/1.0/environmen-env

Update to use new Environment::getenv()
This commit is contained in:
Chris Joe 2017-10-24 16:29:34 +13:00 committed by GitHub
commit 493ccb05cd
4 changed files with 11 additions and 11 deletions

View File

@ -40,11 +40,7 @@
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"SilverStripe\\BehatExtension\\Tests\\": "tests/php/" "SilverStripe\\BehatExtension\\Tests\\": "tests/php/"
}, }
"classmap": [
"framework",
"vendor/phpunit/phpunit"
]
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {

View File

@ -7,6 +7,7 @@ use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPApplication; use SilverStripe\Control\HTTPApplication;
use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\CoreKernel; use SilverStripe\Core\CoreKernel;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Manifest\ModuleLoader; use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -28,8 +29,8 @@ class CoreInitializationPass implements CompilerPassInterface
file_put_contents('php://stdout', 'Bootstrapping' . PHP_EOL); file_put_contents('php://stdout', 'Bootstrapping' . PHP_EOL);
// Connect to database and build manifest // Connect to database and build manifest
if (!getenv('SS_ENVIRONMENT_TYPE')) { if (!Environment::getEnv('SS_ENVIRONMENT_TYPE')) {
putenv('SS_ENVIRONMENT_TYPE=dev'); Environment::setEnv('SS_ENVIRONMENT_TYPE', 'dev');
} }
// Include bootstrap file // Include bootstrap file

View File

@ -3,6 +3,7 @@
namespace SilverStripe\BehatExtension\Compiler; namespace SilverStripe\BehatExtension\Compiler;
use InvalidArgumentException; use InvalidArgumentException;
use SilverStripe\Core\Environment;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
@ -23,7 +24,7 @@ class MinkExtensionBaseUrlPass implements CompilerPassInterface
public function process(ContainerBuilder $container) public function process(ContainerBuilder $container)
{ {
// Set url from environment // Set url from environment
$baseURL = getenv('SS_BASE_URL'); $baseURL = Environment::getEnv('SS_BASE_URL');
if (!$baseURL) { if (!$baseURL) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
'"base_url" not configured. Please specify it in your .env config with SS_BASE_URL' '"base_url" not configured. Please specify it in your .env config with SS_BASE_URL'

View File

@ -10,8 +10,10 @@ use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Exception\UnsupportedDriverActionException; use Behat\Mink\Exception\UnsupportedDriverActionException;
use Behat\Mink\Exception\ElementNotFoundException; use Behat\Mink\Exception\ElementNotFoundException;
use InvalidArgumentException; use InvalidArgumentException;
use SilverStripe\BehatExtension\Utility\TestMailer;
use SilverStripe\CMS\Model\SiteTree; use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\ClassInfo; use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Resettable; use SilverStripe\Core\Resettable;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\TestSession\TestSessionEnvironment; use SilverStripe\TestSession\TestSessionEnvironment;
@ -255,7 +257,7 @@ abstract class SilverStripeContext extends MinkContext implements SilverStripeAw
$this->testSessionEnvironment->loadFixtureIntoDb($fixtureFile); $this->testSessionEnvironment->loadFixtureIntoDb($fixtureFile);
} }
if ($screenSize = getenv('BEHAT_SCREEN_SIZE')) { if ($screenSize = Environment::getEnv('BEHAT_SCREEN_SIZE')) {
list($screenWidth, $screenHeight) = explode('x', $screenSize); list($screenWidth, $screenHeight) = explode('x', $screenSize);
$this->getSession()->resizeWindow((int)$screenWidth, (int)$screenHeight); $this->getSession()->resizeWindow((int)$screenWidth, (int)$screenHeight);
} else { } else {
@ -282,11 +284,11 @@ abstract class SilverStripeContext extends MinkContext implements SilverStripeAw
public function getTestSessionState() public function getTestSessionState()
{ {
$extraParams = array(); $extraParams = array();
parse_str(getenv('TESTSESSION_PARAMS'), $extraParams); parse_str(Environment::getEnv('TESTSESSION_PARAMS'), $extraParams);
return array_merge( return array_merge(
array( array(
'database' => $this->databaseName, 'database' => $this->databaseName,
'mailer' => 'SilverStripe\BehatExtension\Utility\TestMailer', 'mailer' => TestMailer::class,
), ),
$extraParams $extraParams
); );