Removed method isTestingOnOc10, and refactored code

This commit is contained in:
Prarup Gurung
2023-03-09 16:02:54 +05:45
parent b445f847e8
commit 152f71ca3b
2 changed files with 26 additions and 59 deletions

View File

@@ -47,13 +47,6 @@ class OcisHelper {
return (\getenv("TEST_REVA") === "true");
}
/**
* @return bool
*/
public static function isTestingOnOc10():bool {
return false;
}
/**
* @return bool
*/

View File

@@ -2783,60 +2783,34 @@ class FeatureContext extends BehatVariablesContext {
$jsonExpectedDecoded['product'] = $product;
$jsonExpectedDecoded['productname'] = $productName;
if (OcisHelper::isTestingOnOc10()) {
// On oC10 get the expected version values by parsing the output of "occ status"
$runOccStatus = $this->runOcc(['status']);
if ($runOccStatus === 0) {
$output = \explode("- ", $this->lastStdOut);
$version = \explode(": ", $output[3]);
Assert::assertEquals(
"version",
$version[0],
"Expected 'version' but got $version[0]"
);
$versionString = \explode(": ", $output[4]);
Assert::assertEquals(
"versionstring",
$versionString[0],
"Expected 'versionstring' but got $versionString[0]"
);
$jsonExpectedDecoded['version'] = \trim($version[1]);
$jsonExpectedDecoded['versionstring'] = \trim($versionString[1]);
} else {
Assert::fail(
"Cannot get version variables from occ - status $runOccStatus"
);
}
} else {
// We are on oCIS or reva or some other implementation. We cannot do "occ status".
// So get the expected version values by looking in the capabilities response.
$version = $this->appConfigurationContext->getParameterValueFromXml(
$this->appConfigurationContext->getCapabilitiesXml(__METHOD__),
'core',
'status@@@version'
// We are on oCIS or reva or some other implementation. We cannot do "occ status".
// So get the expected version values by looking in the capabilities response.
$version = $this->appConfigurationContext->getParameterValueFromXml(
$this->appConfigurationContext->getCapabilitiesXml(__METHOD__),
'core',
'status@@@version'
);
if (!\strlen($version)) {
Assert::fail(
"Cannot get version from core capabilities"
);
if (!\strlen($version)) {
Assert::fail(
"Cannot get version from core capabilities"
);
}
$versionString = $this->appConfigurationContext->getParameterValueFromXml(
$this->appConfigurationContext->getCapabilitiesXml(__METHOD__),
'core',
'status@@@versionstring'
);
if (!\strlen($versionString)) {
Assert::fail(
"Cannot get versionstring from core capabilities"
);
}
$jsonExpectedDecoded['version'] = $version;
$jsonExpectedDecoded['versionstring'] = $versionString;
}
$versionString = $this->appConfigurationContext->getParameterValueFromXml(
$this->appConfigurationContext->getCapabilitiesXml(__METHOD__),
'core',
'status@@@versionstring'
);
if (!\strlen($versionString)) {
Assert::fail(
"Cannot get versionstring from core capabilities"
);
}
$jsonExpectedDecoded['version'] = $version;
$jsonExpectedDecoded['versionstring'] = $versionString;
$errorMessage = "";
$errorFound = false;
foreach ($jsonExpectedDecoded as $key => $expectedValue) {