mirror of
https://github.com/silverstripe/silverstripe-testsession
synced 2024-10-22 14:06:00 +02:00
Modify state by reference to allow removals through 'onBeforeStartTestSession'
This commit is contained in:
parent
0a1a318623
commit
4b15214588
@ -114,15 +114,8 @@ class TestSessionEnvironment extends Object {
|
|||||||
$this->removeStateFile();
|
$this->removeStateFile();
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
$extendedState = $this->extend('onBeforeStartTestSession', $state);
|
// Assumes state will be modified by reference
|
||||||
|
$this->extend('onBeforeStartTestSession', $state);
|
||||||
// $extendedState is now a multi-dimensional array (if extensions exist)
|
|
||||||
if($extendedState && is_array($extendedState)) {
|
|
||||||
foreach($extendedState as $stateVal) {
|
|
||||||
// $stateVal is one extension's additions to $state
|
|
||||||
$state = array_merge($state, $stateVal); // Merge this into the original $state
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert to JSON and back so we can share the applyState() code between this and ->loadFromFile()
|
// Convert to JSON and back so we can share the applyState() code between this and ->loadFromFile()
|
||||||
$json = json_encode($state, JSON_FORCE_OBJECT);
|
$json = json_encode($state, JSON_FORCE_OBJECT);
|
||||||
|
Loading…
Reference in New Issue
Block a user