mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Behat fixture refactoring (shared factory instance)
This commit is contained in:
parent
a9ed6b34cb
commit
bb92e494d7
@ -5,6 +5,7 @@ namespace SilverStripe\Framework\Test\Behaviour;
|
|||||||
use SilverStripe\BehatExtension\Context\SilverStripeContext,
|
use SilverStripe\BehatExtension\Context\SilverStripeContext,
|
||||||
SilverStripe\BehatExtension\Context\BasicContext,
|
SilverStripe\BehatExtension\Context\BasicContext,
|
||||||
SilverStripe\BehatExtension\Context\LoginContext,
|
SilverStripe\BehatExtension\Context\LoginContext,
|
||||||
|
SilverStripe\BehatExtension\Context\FixtureContext,
|
||||||
SilverStripe\Framework\Test\Behaviour\CmsFormsContext,
|
SilverStripe\Framework\Test\Behaviour\CmsFormsContext,
|
||||||
SilverStripe\Framework\Test\Behaviour\CmsUiContext;
|
SilverStripe\Framework\Test\Behaviour\CmsUiContext;
|
||||||
|
|
||||||
@ -20,6 +21,12 @@ require_once 'PHPUnit/Framework/Assert/Functions.php';
|
|||||||
*/
|
*/
|
||||||
class FeatureContext extends SilverStripeContext
|
class FeatureContext extends SilverStripeContext
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var FixtureFactory
|
||||||
|
*/
|
||||||
|
protected $fixtureFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes context.
|
* Initializes context.
|
||||||
* Every scenario gets it's own context object.
|
* Every scenario gets it's own context object.
|
||||||
@ -28,11 +35,38 @@ class FeatureContext extends SilverStripeContext
|
|||||||
*/
|
*/
|
||||||
public function __construct(array $parameters)
|
public function __construct(array $parameters)
|
||||||
{
|
{
|
||||||
|
parent::__construct($parameters);
|
||||||
|
|
||||||
$this->useContext('BasicContext', new BasicContext($parameters));
|
$this->useContext('BasicContext', new BasicContext($parameters));
|
||||||
$this->useContext('LoginContext', new LoginContext($parameters));
|
$this->useContext('LoginContext', new LoginContext($parameters));
|
||||||
$this->useContext('CmsFormsContext', new CmsFormsContext($parameters));
|
$this->useContext('CmsFormsContext', new CmsFormsContext($parameters));
|
||||||
$this->useContext('CmsUiContext', new CmsUiContext($parameters));
|
$this->useContext('CmsUiContext', new CmsUiContext($parameters));
|
||||||
|
|
||||||
parent::__construct($parameters);
|
$fixtureContext = new FixtureContext($parameters);
|
||||||
|
$fixtureContext->setFixtureFactory($this->getFixtureFactory());
|
||||||
|
$this->useContext('FixtureContext', $fixtureContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMinkParameters(array $parameters)
|
||||||
|
{
|
||||||
|
parent::setMinkParameters($parameters);
|
||||||
|
|
||||||
|
if(isset($parameters['files_path'])) {
|
||||||
|
$this->getSubcontext('FixtureContext')->setFilesPath($parameters['files_path']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return FixtureFactory
|
||||||
|
*/
|
||||||
|
public function getFixtureFactory() {
|
||||||
|
if(!$this->fixtureFactory) {
|
||||||
|
$this->fixtureFactory = \Injector::inst()->get('FixtureFactory', 'FixtureContextFactory');
|
||||||
|
}
|
||||||
|
return $this->fixtureFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFixtureFactory(FixtureFactory $factory) {
|
||||||
|
$this->fixtureFactory = $factory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user