Skip to content

Commit

Permalink
Merge pull request #38432 from owncloud/translation-test-genaralized-2
Browse files Browse the repository at this point in the history
[Tests-Only]used environment variable for language setup
  • Loading branch information
phil-davis authored Mar 5, 2021
2 parents 143faf2 + 331151f commit 6fc175a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ def acceptance(ctx):
'replaceUsernames': False,
'extraSetup': [],
'extraServices': [],
'extraEnvironment': {},
'extraEnvironment': {'OC_LANGUAGE':'en-EN'},
'extraCommandsBeforeTestRun': [],
'extraApps': {},
'useBundledApp': False,
Expand Down
45 changes: 45 additions & 0 deletions tests/TestHelpers/TranslationHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* ownCloud
*
* @author Talank Baral <[email protected]>
* @copyright Copyright (c) 2021 Talank Baral [email protected]
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License,
* as published by the Free Software Foundation;
* either version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace TestHelpers;

/**
* Class TranslationHelper
*
* Helper functions that are needed to run tests on different languages
*
* @package TestHelpers
*/
class TranslationHelper {
/**
* @param $language
*
* @return string
*/
public static function getLanguage($language) {
if (!isset($language)) {
if (\getenv('OC_LANGUAGE') !== false) {
$language = \getenv('OC_LANGUAGE');
}
}
return $language;
}
}
2 changes: 2 additions & 0 deletions tests/acceptance/features/bootstrap/OCSContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Psr\Http\Message\ResponseInterface;
use PHPUnit\Framework\Assert;
use TestHelpers\OcsApiHelper;
use TestHelpers\TranslationHelper;

require_once 'bootstrap.php';

Expand Down Expand Up @@ -676,6 +677,7 @@ public function theOcsStatusCodeShouldBeOr($statusCode1, $statusCode2) {
* @return void
*/
public function theOCSStatusMessageShouldBe($statusMessage, $language=null) {
$language = TranslationHelper::getLanguage($language);
$statusMessage = $this->getActualStatusMessage($statusMessage, $language);

Assert::assertEquals(
Expand Down
2 changes: 2 additions & 0 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use TestHelpers\OcisHelper;
use TestHelpers\SharingHelper;
use TestHelpers\HttpRequestHelper;
use TestHelpers\TranslationHelper;

/**
* Sharing trait
Expand Down Expand Up @@ -1631,6 +1632,7 @@ public function theUserGetsInfoOfLastShareUsingTheSharingApi() {
*/
public function userGetsInfoOfLastShareUsingTheSharingApi($user, $language=null) {
$share_id = $this->getLastShareIdOf($user);
$language = TranslationHelper::getLanguage($language);
$this->getShareData($user, $share_id, $language);
}

Expand Down

0 comments on commit 6fc175a

Please sign in to comment.