Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d930cbd

Browse files
committedFeb 16, 2021
POC for generalizing translation tests
1 parent 4f88dda commit d930cbd

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed
 

‎tests/acceptance/features/apiTranslation/translation.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Feature: translate messages in api response to preferred language
1414
And user "Brian" has shared file "textfile0.txt" with user "Carol"
1515
When user "Alice" gets the info of the last share in language "<language>" using the sharing API
1616
Then the OCS status code should be "404"
17-
And the OCS status message should be "<error_message>"
17+
And the OCS status message should be "Wrong share ID, share doesn't exist" in language "<language>"
1818
Examples:
1919
| dav_version | language | error_message |
2020
| old | de-DE | Fehlerhafte Freigabe-ID, Freigabe existiert nicht |

‎tests/acceptance/features/bootstrap/OCSContext.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -698,12 +698,25 @@ public function theOcsStatusCodeShouldBeOr($statusCode1, $statusCode2) {
698698
* Check the text in an OCS status message
699699
*
700700
* @Then /^the OCS status message should be "([^"]*)"$/
701+
* @Then /^the OCS status message should be "([^"]*)" in language "([^"]*)"$/
701702
*
702703
* @param string $statusMessage
704+
* @param string $language
703705
*
704706
* @return void
705707
*/
706-
public function theOCSStatusMessageShouldBe($statusMessage) {
708+
public function theOCSStatusMessageShouldBe($statusMessage, $language=null) {
709+
if($language !== null) {
710+
$multiLingualMessage = json_decode(
711+
\file_get_contents("./tests/acceptance/multiLanguageErrors.json"),
712+
true
713+
);
714+
715+
if (isset($multiLingualMessage[$statusMessage][$language])) {
716+
$statusMessage = $multiLingualMessage[$statusMessage][$language];
717+
}
718+
}
719+
707720
Assert::assertEquals(
708721
$statusMessage,
709722
$this->getOCSResponseStatusMessage(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Wrong share ID, share doesn't exist": {
3+
"de-DE": "Fehlerhafte Freigabe-ID, Freigabe existiert nicht",
4+
"zh-CN": "错误的共享 ID,共享不存在",
5+
"fr-FR": "Mauvais ID de partage, le partage n'existe pas",
6+
"es-ES": "El ID del recurso compartido no es correcto, el recurso compartido no existe"
7+
}
8+
}

0 commit comments

Comments
 (0)
Please sign in to comment.