summaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-08-11 12:34:58 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-08-11 12:34:58 +0200
commit0abc637782aec1745f9445f193ccc3b9a95ba77d (patch)
tree07ca480789f5718c1ded91a03a6922e62bdb06b1 /apps/files/tests
parentacd54fbeda9dae0fa43291a9c190226ccd306503 (diff)
parent81c3bbad5724bf4db5e980d052f38277bf197952 (diff)
downloadnextcloud-server-0abc637782aec1745f9445f193ccc3b9a95ba77d.tar.gz
nextcloud-server-0abc637782aec1745f9445f193ccc3b9a95ba77d.zip
Merge pull request #18171 from owncloud/fix-language-of-files-activities-in-emails
Correctly make use of the languageCode argument in the files activity extension
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/activitytest.php45
1 files changed, 44 insertions, 1 deletions
diff --git a/apps/files/tests/activitytest.php b/apps/files/tests/activitytest.php
index 4ab8ad11eae..cdb1d21bcd8 100644
--- a/apps/files/tests/activitytest.php
+++ b/apps/files/tests/activitytest.php
@@ -42,6 +42,9 @@ class ActivityTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $activityHelper;
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
+ protected $l10nFactory;
+
/** @var \OCA\Files\Activity */
protected $activityExtension;
@@ -67,8 +70,28 @@ class ActivityTest extends TestCase {
$this->config
);
+ $this->l10nFactory = $this->getMockBuilder('OC\L10N\Factory')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $deL10n = $this->getMockBuilder('OC_L10N')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $deL10n->expects($this->any())
+ ->method('t')
+ ->willReturnCallback(function ($argument) {
+ return 'translate(' . $argument . ')';
+ });
+
+ $this->l10nFactory->expects($this->any())
+ ->method('get')
+ ->willReturnMap([
+ ['files', null, new \OC_L10N('files', 'en')],
+ ['files', 'en', new \OC_L10N('files', 'en')],
+ ['files', 'de', $deL10n],
+ ]);
+
$this->activityExtension = $activityExtension = new Activity(
- new \OC\L10N\Factory(),
+ $this->l10nFactory,
$this->getMockBuilder('OCP\IURLGenerator')->disableOriginalConstructor()->getMock(),
$this->activityManager,
$this->activityHelper,
@@ -111,6 +134,26 @@ class ActivityTest extends TestCase {
$this->activityExtension->translate('files_sharing', '', [], false, false, 'en'),
'Asserting that no translations are set for files_sharing'
);
+
+ // Test english
+ $this->assertNotFalse(
+ $this->activityExtension->translate('files', 'deleted_self', ['file'], false, false, 'en'),
+ 'Asserting that translations are set for files.deleted_self'
+ );
+ $this->assertStringStartsWith(
+ 'You deleted ',
+ $this->activityExtension->translate('files', 'deleted_self', ['file'], false, false, 'en')
+ );
+
+ // Test translation
+ $this->assertNotFalse(
+ $this->activityExtension->translate('files', 'deleted_self', ['file'], false, false, 'de'),
+ 'Asserting that translations are set for files.deleted_self'
+ );
+ $this->assertStringStartsWith(
+ 'translate(You deleted ',
+ $this->activityExtension->translate('files', 'deleted_self', ['file'], false, false, 'de')
+ );
}
public function testGetSpecialParameterList() {