Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests-Only]used environment variable for language setup #38432

Merged
merged 2 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'},
phil-davis marked this conversation as resolved.
Show resolved Hide resolved
'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 <talank@jankaritech.com>
* @copyright Copyright (c) 2021 Talank Baral talank@jankaritech.com
*
* 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 @@ -713,6 +714,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