diff --git a/tests/acceptance/features/apiTranslation/translation.feature b/tests/acceptance/features/apiTranslation/translation.feature index 6b99dfea3d18..8a57d1fdf046 100644 --- a/tests/acceptance/features/apiTranslation/translation.feature +++ b/tests/acceptance/features/apiTranslation/translation.feature @@ -12,19 +12,16 @@ Feature: translate messages in api response to preferred language | Carol | And using DAV path And user "Brian" has shared file "textfile0.txt" with user "Carol" - When user "Alice" gets the info of the last share in language "de-DE" using the sharing API + When user "Alice" gets the info of the last share in language "" using the sharing API Then the OCS status code should be "404" - And the OCS status message should be "Fehlerhafte Freigabe-ID, Freigabe existiert nicht" - When user "Alice" gets the info of the last share in language "zh-CN" using the sharing API - Then the OCS status code should be "404" - And the OCS status message should be "错误的共享 ID,共享不存在" - When user "Alice" gets the info of the last share in language "fr-FR" using the sharing API - Then the OCS status code should be "404" - And the OCS status message should be "Mauvais ID de partage, le partage n'existe pas" - When user "Alice" gets the info of the last share in language "es-ES" using the sharing API - Then the OCS status code should be "404" - And the OCS status message should be "El ID del recurso compartido no es correcto, el recurso compartido no existe" + And the OCS status message should be "Wrong share ID, share doesn't exist" in language "" Examples: - | dav_version | - | old | - | new | + | dav_version | language | + | old | de-DE | + | new | de-DE | + | old | zh-CN | + | new | zh-CN | + | old | fr-FR | + | new | fr-FR | + | old | es-ES | + | new | es-ES | diff --git a/tests/acceptance/features/bootstrap/OCSContext.php b/tests/acceptance/features/bootstrap/OCSContext.php index 6d0addb7ca5e..9697cf095c5c 100644 --- a/tests/acceptance/features/bootstrap/OCSContext.php +++ b/tests/acceptance/features/bootstrap/OCSContext.php @@ -698,12 +698,16 @@ public function theOcsStatusCodeShouldBeOr($statusCode1, $statusCode2) { * Check the text in an OCS status message * * @Then /^the OCS status message should be "([^"]*)"$/ + * @Then /^the OCS status message should be "([^"]*)" in language "([^"]*)"$/ * * @param string $statusMessage + * @param string $language * * @return void */ - public function theOCSStatusMessageShouldBe($statusMessage) { + public function theOCSStatusMessageShouldBe($statusMessage, $language=null) { + $statusMessage = $this->getActualStatusMessage($statusMessage, $language); + Assert::assertEquals( $statusMessage, $this->getOCSResponseStatusMessage( @@ -804,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 diff --git a/tests/acceptance/fixtures/multiLanguageErrors.json b/tests/acceptance/fixtures/multiLanguageErrors.json new file mode 100644 index 000000000000..b1a2aad552ec --- /dev/null +++ b/tests/acceptance/fixtures/multiLanguageErrors.json @@ -0,0 +1,8 @@ +{ + "Wrong share ID, share doesn't exist": { + "de-DE": "Fehlerhafte Freigabe-ID, Freigabe existiert nicht", + "zh-CN": "错误的共享 ID,共享不存在", + "fr-FR": "Mauvais ID de partage, le partage n'existe pas", + "es-ES": "El ID del recurso compartido no es correcto, el recurso compartido no existe" + } +}