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

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2019-04-15 15:31:55 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2019-04-15 15:45:28 +0300
commit3d88c067992b62c7222453b149ec9d3c4c43103c (patch)
tree99f6096a5d2779a85edab9cefc05499a4803dcd6 /tests
parent4a55889ed7cdb7362e5e79eff07f54855451848f (diff)
Translate folder names on the client-side
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/FolderTest.php1
-rw-r--r--tests/Service/FolderNameTranslatorTest.php115
-rw-r--r--tests/Service/MailManagerTest.php18
3 files changed, 8 insertions, 126 deletions
diff --git a/tests/FolderTest.php b/tests/FolderTest.php
index dcc95790a..512b9a37b 100644
--- a/tests/FolderTest.php
+++ b/tests/FolderTest.php
@@ -154,6 +154,7 @@ class FolderTest extends TestCase {
'delimiter' => '.',
'folders' => [['subdir data']],
'specialRole' => 'sent',
+ 'specialUse' => ['sent'],
'syncToken' => null,
];
$this->assertEquals($expected, $this->folder->jsonSerialize());
diff --git a/tests/Service/FolderNameTranslatorTest.php b/tests/Service/FolderNameTranslatorTest.php
deleted file mode 100644
index d992b9f16..000000000
--- a/tests/Service/FolderNameTranslatorTest.php
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-
-/**
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * Mail
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\Mail\Tests\Service;
-
-use ChristophWurst\Nextcloud\Testing\TestCase;
-use OCA\Mail\Folder;
-use OCA\Mail\Service\FolderNameTranslator;
-use OCP\IL10N;
-use PHPUnit_Framework_MockObject_MockObject;
-
-class FolderNameTranslatorTest extends TestCase {
-
- /** @var IL10n|PHPUnit_Framework_MockObject_MockObject */
- private $l10n;
-
- /** @var FolderNameTranslator */
- private $translator;
-
- protected function setUp() {
- parent::setUp();
-
- $this->l10n = $this->createMock(IL10N::class);
- $this->l10n->expects($this->any())
- ->method('t')
- ->willReturnCallback(function($string) {
- return "Translated $string";
- });
-
- $this->translator = new FolderNameTranslator($this->l10n);
- }
-
- public function testTranslate() {
- $folder = $this->createMock(Folder::class);
- $folder->expects($this->any())
- ->method('getDelimiter')
- ->willReturn('.');
- $folder->expects($this->any())
- ->method('getMailbox')
- ->willReturn('Archive');
- $folder->expects($this->once())
- ->method('getSpecialUse')
- ->willReturn([]);
- $folder->expects($this->once())
- ->method('setDisplayName')
- ->with('Archive');
-
- $this->translator->translateAll([$folder], false);
- }
-
- public function testTranslatePrefixed() {
- $folder1 = $this->createMock(Folder::class);
- $folder2 = $this->createMock(Folder::class);
- $folder1->expects($this->any())
- ->method('getDelimiter')
- ->willReturn('.');
- $folder2->expects($this->any())
- ->method('getDelimiter')
- ->willReturn('.');
- $folder1->expects($this->any())
- ->method('getMailbox')
- ->willReturn('INBOX');
- $folder2->expects($this->any())
- ->method('getMailbox')
- ->willReturn('INBOX.Sent');
- $folder1->expects($this->once())
- ->method('getSpecialUse')
- ->willReturn(['inbox']);
- $folder2->expects($this->once())
- ->method('getSpecialUse')
- ->willReturn([]);
- $folder1->expects($this->once())
- ->method('setDisplayName')
- ->with('Translated Inbox');
- $folder2->expects($this->once())
- ->method('setDisplayName')
- ->with('Sent');
-
- $this->translator->translateAll([$folder1, $folder2], true);
- }
-
- public function testTranslateSpecialUse() {
- $folder = $this->createMock(Folder::class);
- $folder->expects($this->any())
- ->method('getMailbox')
- ->willReturn('Sent');
- $folder->expects($this->once())
- ->method('getSpecialUse')
- ->willReturn(['sent']);
- $folder->expects($this->once())
- ->method('setDisplayName')
- ->with('Translated Sent');
-
- $this->translator->translateAll([$folder], false);
- }
-
-}
diff --git a/tests/Service/MailManagerTest.php b/tests/Service/MailManagerTest.php
index 19b57a053..fa21ec853 100644
--- a/tests/Service/MailManagerTest.php
+++ b/tests/Service/MailManagerTest.php
@@ -31,7 +31,6 @@ use OCA\Mail\IMAP\MessageMapper;
use OCA\Mail\IMAP\Sync\Request;
use OCA\Mail\IMAP\Sync\Response;
use OCA\Mail\IMAP\Sync\Synchronizer;
-use OCA\Mail\Service\FolderNameTranslator;
use OCA\Mail\Service\MailManager;
use OCP\Files\Folder;
use PHPUnit_Framework_MockObject_MockObject;
@@ -50,9 +49,6 @@ class MailManagerTest extends TestCase {
/** @var MessageMapper|PHPUnit_Framework_MockObject_MockObject */
private $messageMapper;
- /** @var FolderNameTranslator|PHPUnit_Framework_MockObject_MockObject */
- private $translator;
-
/** @var Synchronizer|PHPUnit_Framework_MockObject_MockObject */
private $sync;
@@ -66,12 +62,15 @@ class MailManagerTest extends TestCase {
$this->folderMapper = $this->createMock(FolderMapper::class);
$this->prefixDetector = $this->createMock(MailboxPrefixDetector::class);
$this->messageMapper = $this->createMock(MessageMapper::class);
- $this->translator = $this->createMock(FolderNameTranslator::class);
$this->sync = $this->createMock(Synchronizer::class);
- $this->manager = new MailManager($this->imapClientFactory,
- $this->folderMapper, $this->prefixDetector, $this->translator, $this->sync,
- $this->messageMapper);
+ $this->manager = new MailManager(
+ $this->imapClientFactory,
+ $this->folderMapper,
+ $this->prefixDetector,
+ $this->sync,
+ $this->messageMapper
+ );
}
public function testGetFolders() {
@@ -100,9 +99,6 @@ class MailManagerTest extends TestCase {
$this->folderMapper->expects($this->once())
->method('sortFolders')
->with($this->equalTo($folders));
- $this->translator->expects($this->once())
- ->method('translateAll')
- ->with($this->equalTo($folders), $this->equalTo(false));
$this->folderMapper->expects($this->once())
->method('buildFolderHierarchy')
->with($this->equalTo($folders))