diff --git a/src/SilverStripe/BehatExtension/Compiler/CoreInitializationPass.php b/src/SilverStripe/BehatExtension/Compiler/CoreInitializationPass.php index fd754fc..f3da535 100644 --- a/src/SilverStripe/BehatExtension/Compiler/CoreInitializationPass.php +++ b/src/SilverStripe/BehatExtension/Compiler/CoreInitializationPass.php @@ -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']); diff --git a/src/SilverStripe/BehatExtension/Context/Initializer/SilverStripeAwareInitializer.php b/src/SilverStripe/BehatExtension/Context/Initializer/SilverStripeAwareInitializer.php index c26a577..2c7f56e 100644 --- a/src/SilverStripe/BehatExtension/Context/Initializer/SilverStripeAwareInitializer.php +++ b/src/SilverStripe/BehatExtension/Context/Initializer/SilverStripeAwareInitializer.php @@ -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(); - } } diff --git a/src/SilverStripe/BehatExtension/services/silverstripe.yml b/src/SilverStripe/BehatExtension/services/silverstripe.yml index a204ac7..3e699ce 100644 --- a/src/SilverStripe/BehatExtension/services/silverstripe.yml +++ b/src/SilverStripe/BehatExtension/services/silverstripe.yml @@ -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%]]