Move bootstrap file up into correct point in application cycle

This commit is contained in:
Damian Mooyman 2017-02-27 15:49:31 +13:00
parent 8b0e0615f6
commit 6024d2bc5d
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
3 changed files with 13 additions and 30 deletions

View File

@ -22,7 +22,11 @@ class CoreInitializationPass implements CompilerPassInterface
$_GET['flush'] = 1;
require_once('Core/Core.php');
SapphireTest::use_test_manifest();
// Include bootstrap file
$bootstrapFile = $container->getParameter('behat.silverstripe_extension.bootstrap_file');
if ($bootstrapFile) {
require_once $bootstrapFile;
}
unset($_GET['flush']);

View File

@ -6,6 +6,7 @@ use Behat\Behat\Context\Initializer\InitializerInterface;
use Behat\Behat\Context\ContextInterface;
use SilverStripe\BehatExtension\Context\SilverStripeAwareContextInterface;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\SapphireTest;
/*
* This file is part of the Behat/SilverStripeExtension
@ -57,19 +58,19 @@ class SilverStripeAwareInitializer implements InitializerInterface
*/
protected $testSessionEnvironment;
/**
* @var string PHP file to included before loading Core.php
*/
protected $bootstrapFile;
/**
* Initializes initializer.
*
* @param string $frameworkPath
*/
public function __construct($frameworkPath, $bootstrapFile = null)
public function __construct($frameworkPath)
{
$this->bootstrap($frameworkPath, $bootstrapFile);
file_put_contents('php://stdout', 'Bootstrapping' . PHP_EOL);
SapphireTest::start();
// Remove the error handler so that PHPUnit can add its own
restore_error_handler();
file_put_contents('php://stdout', "Creating test session environment" . PHP_EOL);
@ -188,25 +189,4 @@ class SilverStripeAwareInitializer implements InitializerInterface
{
$this->regionMap = $regionMap;
}
/**
* @param string $frameworkPath Absolute path to 'framework' module
*/
protected function bootstrap($frameworkPath, $bootstrapFile = null)
{
file_put_contents('php://stdout', 'Bootstrapping' . PHP_EOL);
// Require a bootstrap file, if provided
if ($bootstrapFile) {
require_once($bootstrapFile);
}
// Connect to database and build manifest
$_GET['flush'] = 1;
require_once('Core/Core.php');
unset($_GET['flush']);
// Remove the error handler so that PHPUnit can add its own
restore_error_handler();
}
}

View File

@ -18,7 +18,6 @@ services:
class: %behat.silverstripe_extension.context.initializer.class%
arguments:
- %behat.silverstripe_extension.framework_path%
- %behat.silverstripe_extension.bootstrap_file%
calls:
- [setAjaxSteps, [%behat.silverstripe_extension.ajax_steps%]]
- [setAjaxTimeout, [%behat.silverstripe_extension.ajax_timeout%]]