Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-04-04 14:29:04 +0300
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-04 14:29:04 +0300
commit85a0dd36891d31a2af0e654a6c1b571c0f612c08 (patch)
tree639c65316b34160e53509f50760d8675536ac797 /tests
parentf8b1e2cca151219c563ece3c068ee72e355d6f80 (diff)
[stable9] Read available l10n files also from theme folder
* Read available l10n files also from theme folder The old behaviour was that only languages could be used for an app that are already present in the apps/$app/l10n folder. If there is a themed l10n that is not present in the apps default l10n folder the language could not be used and the texts are not translated. With this change this is possible and also the l10n files are loaded even if the default l10n doesn't contain the l10n file. * Inject server root - allows proper testing and separation of concerns
Diffstat (limited to 'tests')
-rw-r--r--tests/data/themes/abc/apps/files/l10n/zz.json0
-rw-r--r--tests/lib/l10n/factorytest.php28
-rw-r--r--tests/lib/l10n/l10nlegacytest.php2
-rw-r--r--tests/lib/l10n/l10ntest.php2
4 files changed, 28 insertions, 4 deletions
diff --git a/tests/data/themes/abc/apps/files/l10n/zz.json b/tests/data/themes/abc/apps/files/l10n/zz.json
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/tests/data/themes/abc/apps/files/l10n/zz.json
diff --git a/tests/lib/l10n/factorytest.php b/tests/lib/l10n/factorytest.php
index 9f5954d0ee1..e4c0eab2e6a 100644
--- a/tests/lib/l10n/factorytest.php
+++ b/tests/lib/l10n/factorytest.php
@@ -28,6 +28,9 @@ class FactoryTest extends TestCase {
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */
protected $userSession;
+ /** @var string */
+ protected $serverRoot;
+
public function setUp() {
parent::setUp();
@@ -42,6 +45,8 @@ class FactoryTest extends TestCase {
->getMock();
$this->userSession = $this->getMock('\OCP\IUserSession');
+
+ $this->serverRoot = \OC::$SERVERROOT;
}
/**
@@ -54,12 +59,13 @@ class FactoryTest extends TestCase {
->setConstructorArgs([
$this->config,
$this->request,
- $this->userSession
+ $this->userSession,
+ $this->serverRoot,
])
->setMethods($methods)
->getMock();
} else {
- return new Factory($this->config, $this->request, $this->userSession);
+ return new Factory($this->config, $this->request, $this->userSession, $this->serverRoot);
}
}
@@ -287,6 +293,24 @@ class FactoryTest extends TestCase {
];
}
+ public function testFindAvailableLanguagesWithThemes() {
+ $this->serverRoot .= '/tests/data';
+ $app = 'files';
+
+ $factory = $this->getFactory(['findL10nDir']);
+ $factory->expects($this->once())
+ ->method('findL10nDir')
+ ->with($app)
+ ->willReturn($this->serverRoot . '/apps/files/l10n/');
+ $this->config
+ ->expects($this->once())
+ ->method('getSystemValue')
+ ->with('theme')
+ ->willReturn('abc');
+
+ $this->assertEquals(['en', 'zz'], $factory->findAvailableLanguages($app), '', 0.0, 10, true);
+ }
+
/**
* @dataProvider dataLanguageExists
*
diff --git a/tests/lib/l10n/l10nlegacytest.php b/tests/lib/l10n/l10nlegacytest.php
index 025f761fe5c..1df22ba36bd 100644
--- a/tests/lib/l10n/l10nlegacytest.php
+++ b/tests/lib/l10n/l10nlegacytest.php
@@ -124,7 +124,7 @@ class L10nLegacyTest extends \Test\TestCase {
}
public function testFactoryGetLanguageCode() {
- $factory = new \OC\L10N\Factory($this->getMock('OCP\IConfig'), $this->getMock('OCP\IRequest'), $this->getMock('OCP\IUserSession'));
+ $factory = new \OC\L10N\Factory($this->getMock('OCP\IConfig'), $this->getMock('OCP\IRequest'), $this->getMock('OCP\IUserSession'), \OC::$SERVERROOT);
$l = $factory->get('lib', 'de');
$this->assertEquals('de', $l->getLanguageCode());
}
diff --git a/tests/lib/l10n/l10ntest.php b/tests/lib/l10n/l10ntest.php
index 0d175954bc1..227e07056a8 100644
--- a/tests/lib/l10n/l10ntest.php
+++ b/tests/lib/l10n/l10ntest.php
@@ -31,7 +31,7 @@ class L10nTest extends TestCase {
$request = $this->getMock('OCP\IRequest');
/** @var IUserSession $userSession */
$userSession = $this->getMock('OCP\IUserSession');
- return new Factory($config, $request, $userSession);
+ return new Factory($config, $request, $userSession, \OC::$SERVERROOT);
}
public function testGermanPluralTranslations() {