Removed restoreParameters methods

This commit is contained in:
Prarup Gurung
2023-03-02 12:40:51 +05:45
parent fab9bfc734
commit 65d11ef634
2 changed files with 28 additions and 141 deletions
@@ -3937,29 +3937,6 @@ class FeatureContext extends BehatVariablesContext {
return;
}
/**
* runs a function on every server (LOCAL & REMOTE).
* The callable function receives the server (LOCAL or REMOTE) as first argument
*
* @param callable $callback
*
* @return array
*/
public function runFunctionOnEveryServer(callable $callback): array {
$previousServer = $this->getCurrentServer();
$result = [];
foreach (['LOCAL', 'REMOTE'] as $server) {
$this->usingServer($server);
if (($server === 'LOCAL')
|| $this->federatedServerExists()
) {
$result[$server] = \call_user_func($callback, $server);
}
}
$this->usingServer($previousServer);
return $result;
}
/**
* Verify that the tableNode contains expected headers
*
@@ -4372,85 +4349,6 @@ class FeatureContext extends BehatVariablesContext {
];
}
/**
* restore settings of the system and delete new settings that were created in the test runs
*
* @param string $server LOCAL|REMOTE
*
* @return void
*
* @throws Exception
* @throws GuzzleException
*
*/
private function restoreParameters(string $server): void {
$commands = [];
if ($this->isTestingWithLdap()) {
$this->resetOldLdapConfig();
}
$result = SetupHelper::runOcc(
['config:list'],
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword(),
$this->getBaseUrl(),
$this->getOcPath()
);
$currentConfigList = \json_decode($result['stdOut'], true);
foreach ($currentConfigList['system'] as $configKey => $configValue) {
if (!\array_key_exists(
$configKey,
$this->savedConfigList[$server]['system']
)
) {
$commands[] = ["command" => ['config:system:delete', $configKey]];
}
}
foreach ($this->savedConfigList[$server]['system'] as $configKey => $configValue) {
if (!\array_key_exists($configKey, $currentConfigList["system"])
|| $currentConfigList["system"][$configKey] !== $this->savedConfigList[$server]['system'][$configKey]
) {
$commands[] = ["command" => ['config:system:set', "--type=json", "--value=" . \json_encode($configValue), $configKey]];
}
}
foreach ($currentConfigList['apps'] as $appName => $appSettings) {
foreach ($appSettings as $configKey => $configValue) {
//only check if the app was there in the original configuration
if (\array_key_exists($appName, $this->savedConfigList[$server]['apps'])
&& !\array_key_exists(
$configKey,
$this->savedConfigList[$server]['apps'][$appName]
)
) {
$commands[] = ["command" => ['config:app:delete', $appName, $configKey]];
} elseif (\array_key_exists($appName, $this->savedConfigList[$server]['apps'])
&& \array_key_exists($configKey, $this->savedConfigList[$server]['apps'][$appName])
&& $this->savedConfigList[$server]['apps'][$appName][$configKey] !== $configValue
) {
// Do not accidentally disable apps here (perhaps too early)
// That is done in Provisioning.php restoreAppEnabledDisabledState()
if ($configKey !== "enabled") {
$commands[] = [
"command" => [
'config:app:set',
$appName,
$configKey,
"--value=" . $this->savedConfigList[$server]['apps'][$appName][$configKey]
]
];
}
}
}
}
SetupHelper::runBulkOcc(
$commands,
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword(),
$this->getBaseUrl()
);
}
/**
* The method returns userId
*