mirror of
https://github.com/silverstripe/silverstripe-testsession
synced 2024-10-22 14:06:00 +02:00
FIX: Properly extend onBeforeStartTestSession so extensions can modify the $state array
This commit is contained in:
parent
e198f738b4
commit
962e8214f2
@ -71,7 +71,15 @@ class TestSessionEnvironment extends Object {
|
||||
* @param array $state An array of test state options to write.
|
||||
*/
|
||||
public function startTestSession($state) {
|
||||
$this->extend('onBeforeStartTestSession', $state);
|
||||
$extendedState = $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()
|
||||
$json = json_encode($state, JSON_FORCE_OBJECT);
|
||||
|
Loading…
Reference in New Issue
Block a user