mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
FIX Correctly clear extensions after each scenario (#241)
This commit is contained in:
parent
24bec4a15b
commit
937dd5e006
@ -69,6 +69,11 @@ class FixtureContext implements Context
|
||||
*/
|
||||
protected $activatedConfigFiles = array();
|
||||
|
||||
/**
|
||||
* @var string[][] Tracks any extensions that have been added to classes
|
||||
*/
|
||||
protected $addedExtensions = array();
|
||||
|
||||
/**
|
||||
* @var array Stores the asset tuples.
|
||||
*/
|
||||
@ -660,6 +665,10 @@ class FixtureContext implements Context
|
||||
/** @var Extensible $targetClass */
|
||||
$targetClass = $this->convertTypeToClass($class);
|
||||
$targetClass::add_extension($extension);
|
||||
if (!array_key_exists($targetClass, $this->addedExtensions)) {
|
||||
$this->addedExtensions[$targetClass] = [];
|
||||
}
|
||||
$this->addedExtensions[$targetClass][] = $extension;
|
||||
|
||||
// Write config for this extension too...
|
||||
$snakedExtension = strtolower(str_replace('\\', '-', $extension ?? '') ?? '');
|
||||
@ -793,6 +802,7 @@ YAML;
|
||||
public function afterResetConfig(AfterScenarioScope $event)
|
||||
{
|
||||
$this->clearConfigFiles();
|
||||
$this->clearExtensions();
|
||||
// Flush
|
||||
$this->getMainContext()->visit('/?flush');
|
||||
}
|
||||
@ -951,6 +961,17 @@ YAML;
|
||||
return join('/', $paths);
|
||||
}
|
||||
|
||||
protected function clearExtensions()
|
||||
{
|
||||
foreach ($this->addedExtensions as $targetClass => $extensions) {
|
||||
foreach ($extensions as $extension) {
|
||||
/** @var Extensible $targetClass */
|
||||
$targetClass::remove_extension($extension);
|
||||
}
|
||||
}
|
||||
$this->addedExtensions = [];
|
||||
}
|
||||
|
||||
protected function clearConfigFiles()
|
||||
{
|
||||
// No files to cleanup
|
||||
|
Loading…
Reference in New Issue
Block a user