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/translation": "~2.0",
"symfony/yaml": "~2.0", "symfony/yaml": "~2.0",
"symfony/finder": "~2.0", "symfony/finder": "~2.0",
"silverstripe/testsession": "*", "silverstripe/testsession": "^2.0.0-alpha2",
"silverstripe/framework": "^4.0.0" "silverstripe/framework": "^4.0.0-alpha2"
}, },
"autoload": { "autoload": {

View File

@ -10,7 +10,6 @@ use Symfony\Component\Console\Input\InputOption;
use Behat\Behat\Console\Processor\InitProcessor as BaseProcessor; use Behat\Behat\Console\Processor\InitProcessor as BaseProcessor;
use SilverStripe\Core\Manifest\ClassLoader; use SilverStripe\Core\Manifest\ClassLoader;
/** /**
* Initializes a project for Behat usage, creating context files. * 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\File;
use SilverStripe\Assets\Filesystem; use SilverStripe\Assets\Filesystem;
// PHPUnit // PHPUnit
require_once BASE_PATH . '/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php'; require_once BASE_PATH . '/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php';

View File

@ -57,14 +57,19 @@ class SilverStripeAwareInitializer implements InitializerInterface
*/ */
protected $testSessionEnvironment; protected $testSessionEnvironment;
/**
* @var string PHP file to included before loading Core.php
*/
protected $bootstrapFile;
/** /**
* Initializes initializer. * Initializes initializer.
* *
* @param string $frameworkPath * @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); 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 * @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); 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 // Connect to database and build manifest
$_GET['flush'] = 1; $_GET['flush'] = 1;
require_once $frameworkPath . '/Core/Core.php'; require_once $frameworkPath . '/Core/Core.php';

View File

@ -62,6 +62,7 @@ class Extension implements ExtensionInterface
if (isset($config['region_map'])) { if (isset($config['region_map'])) {
$container->setParameter('behat.silverstripe_extension.region_map', $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')-> scalarNode('ajax_timeout')->
defaultValue(5000)-> defaultValue(5000)->
end()-> end()->
scalarNode('bootstrap_file')->
defaultNull()->
end()->
arrayNode('ajax_steps')-> arrayNode('ajax_steps')->
defaultValue(array( defaultValue(array(
'go to', 'go to',

View File

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