aboutsummaryrefslogtreecommitdiffstats
path: root/apps/updatenotification/tests
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2018-08-16 12:50:44 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2018-08-16 12:50:44 +0200
commit6645c014e9412c563c0baed7f3c20acaa639235d (patch)
treefde0e44912bf6961b134c1c8c051ba76defedb49 /apps/updatenotification/tests
parentbdead84ec68001377e599230e86c3ea18d277a13 (diff)
downloadnextcloud-server-6645c014e9412c563c0baed7f3c20acaa639235d.tar.gz
nextcloud-server-6645c014e9412c563c0baed7f3c20acaa639235d.zip
fix wrong return value of filtered whats new info
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/updatenotification/tests')
-rw-r--r--apps/updatenotification/tests/Settings/AdminTest.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php
index d0d53226490..d1f44367a1c 100644
--- a/apps/updatenotification/tests/Settings/AdminTest.php
+++ b/apps/updatenotification/tests/Settings/AdminTest.php
@@ -34,6 +34,7 @@ use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
+use OCP\L10N\ILanguageIterator;
use OCP\Util;
use Test\TestCase;
@@ -153,4 +154,78 @@ class AdminTest extends TestCase {
public function testGetPriority() {
$this->assertSame(11, $this->admin->getPriority());
}
+
+ public function changesProvider() {
+ return [
+ [ #0, all info, en
+ [
+ 'changelogURL' => 'https://go.to.changelog',
+ 'whatsNew' => [
+ 'en' => [
+ 'regular' => ['content'],
+ ],
+ 'de' => [
+ 'regular' => ['inhalt'],
+ ]
+ ],
+ ],
+ 'en',
+ [
+ 'changelogURL' => 'https://go.to.changelog',
+ 'whatsNew' => [
+ 'regular' => ['content'],
+ ],
+ ]
+ ],
+ [ #1, all info, de
+ [
+ 'changelogURL' => 'https://go.to.changelog',
+ 'whatsNew' => [
+ 'en' => [
+ 'regular' => ['content'],
+ ],
+ 'de' => [
+ 'regular' => ['inhalt'],
+ ]
+ ],
+ ],
+ 'de',
+ [
+ 'changelogURL' => 'https://go.to.changelog',
+ 'whatsNew' => [
+ 'regular' => ['inhalt'],
+ ]
+ ],
+ ],
+ [ #2, just changelog
+ [ 'changelogURL' => 'https://go.to.changelog' ],
+ 'en',
+ [ 'changelogURL' => 'https://go.to.changelog' ],
+ ],
+ [ #3 nothing
+ [],
+ 'ru',
+ []
+ ]
+ ];
+ }
+
+ /**
+ * @dataProvider changesProvider
+ */
+ public function testFilterChanges($changes, $userLang, $expectation) {
+ $iterator = $this->createMock(ILanguageIterator::class);
+ $iterator->expects($this->any())
+ ->method('current')
+ ->willReturnOnConsecutiveCalls('es', $userLang, 'it', 'en');
+ $iterator->expects($this->any())
+ ->method('valid')
+ ->willReturn(true);
+
+ $this->l10nFactory->expects($this->atMost(1))
+ ->method('getLanguageIterator')
+ ->willReturn($iterator);
+ $result = $this->invokePrivate($this->admin, 'filterChanges', [$changes]);
+ $this->assertSame($expectation, $result);
+ }
}