Skip to content

Commit

Permalink
moved status message switching logic in separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Talank committed Feb 18, 2021
1 parent aee9ad4 commit 84a2ba2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions tests/acceptance/features/bootstrap/OCSContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,16 +706,7 @@ public function theOcsStatusCodeShouldBeOr($statusCode1, $statusCode2) {
* @return void
*/
public function theOCSStatusMessageShouldBe($statusMessage, $language=null) {
if ($language !== null) {
$multiLingualMessage = \json_decode(
\file_get_contents("./tests/acceptance/multiLanguageErrors.json"),
true
);

if (isset($multiLingualMessage[$statusMessage][$language])) {
$statusMessage = $multiLingualMessage[$statusMessage][$language];
}
}
$statusMessage = $this->getActualStatusMessage($statusMessage, $language);

Assert::assertEquals(
$statusMessage,
Expand Down Expand Up @@ -817,6 +808,28 @@ public function getOCSResponseStatusMessage($response) {
return (string) $this->featureContext->getResponseXml($response, __METHOD__)->meta[0]->message;
}

/**
* convert status message in the desired language
*
* @param $statusMessage
* @param $language
*
* @return string
*/
public function getActualStatusMessage($statusMessage, $language) {
if ($language !== null) {
$multiLingualMessage = \json_decode(
\file_get_contents("./tests/acceptance/fixtures/multiLanguageErrors.json"),
true
);

if (isset($multiLingualMessage[$statusMessage][$language])) {
$statusMessage = $multiLingualMessage[$statusMessage][$language];
}
}
return $statusMessage;
}

/**
* check if the HTTP status code and the OCS status code indicate that the request was successful
* this function is aware of the currently used OCS version
Expand Down
File renamed without changes.

0 comments on commit 84a2ba2

Please sign in to comment.