mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
3.1 compat
This commit is contained in:
parent
6960d8d6e8
commit
72141f4474
@ -58,6 +58,11 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
||||
*/
|
||||
protected $screenshotPath;
|
||||
|
||||
/**
|
||||
* @var FixtureFactory
|
||||
*/
|
||||
protected $fixtureFactory;
|
||||
|
||||
protected $context;
|
||||
protected $fixtures;
|
||||
protected $fixturesLazy;
|
||||
@ -264,7 +269,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
||||
// Save fixtures into database
|
||||
$this->fixtures[$dataObject] = new \YamlFixture($fixture);
|
||||
$model = \DataModel::inst();
|
||||
$this->fixtures[$dataObject]->saveIntoDatabase($model);
|
||||
$this->fixtures[$dataObject]->writeInto($this->getFixtureFactory());
|
||||
// Lazy load fixtures into database
|
||||
// Loop is required for nested lazy fixtures
|
||||
foreach ($fixturesLazy[$dataObject] as $identifier => $fields) {
|
||||
@ -276,7 +281,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
||||
$fixture = Yaml::dump($fixture);
|
||||
$fixture = preg_replace_callback('/=>(\w+)\.([\w.]+)/', array($this, 'replaceFixtureReferences'), $fixture);
|
||||
$this->fixturesLazy[$dataObject][$identifier] = new \YamlFixture($fixture);
|
||||
$this->fixturesLazy[$dataObject][$identifier]->saveIntoDatabase($model);
|
||||
$this->fixturesLazy[$dataObject][$identifier]->writeInto($this->getFixtureFactory());
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,7 +346,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
||||
|
||||
protected function idFromFixture($className, $identifier)
|
||||
{
|
||||
if (false !== ($id = $this->fixtures[$className]->idFromFixture($className, $identifier))) {
|
||||
if (false !== ($id = $this->getFixtureFactory()->getId($className, $identifier))) {
|
||||
return $id;
|
||||
}
|
||||
if (isset($this->fixturesLazy[$className], $this->fixturesLazy[$className][$identifier]) &&
|
||||
@ -414,6 +419,15 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
||||
return $this->getMinkParameter('base_url') ?: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FixtureFactory
|
||||
*/
|
||||
public function getFixtureFactory()
|
||||
{
|
||||
if(!$this->fixtureFactory) $this->fixtureFactory = \Injector::inst()->create('FixtureFactory');
|
||||
return $this->fixtureFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins URL parts into an URL using forward slash.
|
||||
* Forward slash usages are normalised to one between parts.
|
||||
|
Loading…
Reference in New Issue
Block a user