mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
NEW: Add bootstrap_file extension parameter.
The bootstrap_file parameter specifies a PHP file that will be included between Constants.php (which is included by the composer autoloader) and Core.php (which is included by SilverStripeAwareInitializer). The goal of this setting is to provide a bit more flexibility about how behat test environments are set up. It’s the logical companion of PHPUnit’s bootstrap property.
This commit is contained in:
parent
c9783741ca
commit
2c4eb2050d
@ -31,8 +31,8 @@
|
||||
"symfony/translation": "~2.0",
|
||||
"symfony/yaml": "~2.0",
|
||||
"symfony/finder": "~2.0",
|
||||
"silverstripe/testsession": "*",
|
||||
"silverstripe/framework": "^4.0.0"
|
||||
"silverstripe/testsession": "^2.0.0-alpha2",
|
||||
"silverstripe/framework": "^4.0.0-alpha2"
|
||||
},
|
||||
|
||||
"autoload": {
|
||||
|
@ -57,14 +57,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)
|
||||
public function __construct($frameworkPath, $bootstrapFile = null)
|
||||
{
|
||||
$this->bootstrap($frameworkPath);
|
||||
$this->bootstrap($frameworkPath, $bootstrapFile);
|
||||
|
||||
file_put_contents('php://stdout', "Creating test session environment" . PHP_EOL);
|
||||
|
||||
@ -187,10 +192,15 @@ class SilverStripeAwareInitializer implements InitializerInterface
|
||||
/**
|
||||
* @param string $frameworkPath Absolute path to 'framework' module
|
||||
*/
|
||||
protected function bootstrap($frameworkPath)
|
||||
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 $frameworkPath . '/Core/Core.php';
|
||||
|
@ -62,6 +62,7 @@ class Extension implements ExtensionInterface
|
||||
if (isset($config['region_map'])) {
|
||||
$container->setParameter('behat.silverstripe_extension.region_map', $config['region_map']);
|
||||
}
|
||||
$container->setParameter('behat.silverstripe_extension.bootstrap_file', $config['bootstrap_file']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,6 +103,9 @@ class Extension implements ExtensionInterface
|
||||
scalarNode('ajax_timeout')->
|
||||
defaultValue(5000)->
|
||||
end()->
|
||||
scalarNode('bootstrap_file')->
|
||||
defaultNull()->
|
||||
end()->
|
||||
arrayNode('ajax_steps')->
|
||||
defaultValue(array(
|
||||
'go to',
|
||||
|
@ -18,6 +18,7 @@ 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%]]
|
||||
@ -33,4 +34,4 @@ services:
|
||||
- %behat.silverstripe_extension.context.namespace_suffix%
|
||||
- %behat.context.class%
|
||||
tags:
|
||||
- { name: behat.context.class_guesser, priority: 10 }
|
||||
- { name: behat.context.class_guesser, priority: 10 }
|
||||
|
Loading…
Reference in New Issue
Block a user