2012-11-09 19:16:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Framework\Test\Behaviour;
|
|
|
|
|
|
|
|
use SilverStripe\BehatExtension\Context\SilverStripeContext,
|
2012-12-08 12:20:20 +01:00
|
|
|
SilverStripe\BehatExtension\Context\BasicContext,
|
|
|
|
SilverStripe\BehatExtension\Context\LoginContext,
|
2013-06-04 17:30:13 +02:00
|
|
|
SilverStripe\BehatExtension\Context\FixtureContext,
|
2012-12-08 12:20:20 +01:00
|
|
|
SilverStripe\Framework\Test\Behaviour\CmsFormsContext,
|
|
|
|
SilverStripe\Framework\Test\Behaviour\CmsUiContext;
|
2012-11-09 19:16:16 +01:00
|
|
|
|
|
|
|
// PHPUnit
|
|
|
|
require_once 'PHPUnit/Autoload.php';
|
|
|
|
require_once 'PHPUnit/Framework/Assert/Functions.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Features context
|
|
|
|
*
|
|
|
|
* Context automatically loaded by Behat.
|
|
|
|
* Uses subcontexts to extend functionality.
|
|
|
|
*/
|
|
|
|
class FeatureContext extends SilverStripeContext
|
|
|
|
{
|
2013-06-04 17:30:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var FixtureFactory
|
|
|
|
*/
|
|
|
|
protected $fixtureFactory;
|
|
|
|
|
2012-12-08 12:20:20 +01:00
|
|
|
/**
|
|
|
|
* Initializes context.
|
|
|
|
* Every scenario gets it's own context object.
|
|
|
|
*
|
|
|
|
* @param array $parameters context parameters (set them up through behat.yml)
|
|
|
|
*/
|
|
|
|
public function __construct(array $parameters)
|
|
|
|
{
|
2013-06-04 17:30:13 +02:00
|
|
|
parent::__construct($parameters);
|
|
|
|
|
2012-12-08 12:20:20 +01:00
|
|
|
$this->useContext('BasicContext', new BasicContext($parameters));
|
|
|
|
$this->useContext('LoginContext', new LoginContext($parameters));
|
|
|
|
$this->useContext('CmsFormsContext', new CmsFormsContext($parameters));
|
|
|
|
$this->useContext('CmsUiContext', new CmsUiContext($parameters));
|
2012-11-09 19:16:16 +01:00
|
|
|
|
2013-06-04 17:30:13 +02:00
|
|
|
$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;
|
2012-12-08 12:20:20 +01:00
|
|
|
}
|
2012-11-09 19:16:16 +01:00
|
|
|
}
|