Merge pull request #128 from sminnee/add-bootstrap-file

NEW: Add bootstrap_file extension parameter.
This commit is contained in:
Ingo Schommer 2016-09-14 12:54:51 +12:00 committed by GitHub
commit df828356e7
6 changed files with 21 additions and 8 deletions

View File

@ -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": {

View File

@ -10,7 +10,6 @@ use Symfony\Component\Console\Input\InputOption;
use Behat\Behat\Console\Processor\InitProcessor as BaseProcessor;
use SilverStripe\Core\Manifest\ClassLoader;
/**
* Initializes a project for Behat usage, creating context files.
*/

View File

@ -10,7 +10,6 @@ use Behat\Mink\Driver\Selenium2Driver;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Filesystem;
// PHPUnit
require_once BASE_PATH . '/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php';

View File

@ -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';

View File

@ -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',

View File

@ -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 }