Skip to content
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
5 changes: 3 additions & 2 deletions apps/updatenotification/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function getForm(): TemplateResponse {
return new TemplateResponse('updatenotification', 'admin', $params, '');
}

protected function filterChanges(array $changes) {
protected function filterChanges(array $changes): array {
$filtered = [];
if(isset($changes['changelogURL'])) {
$filtered['changelogURL'] = $changes['changelogURL'];
Expand All @@ -127,7 +127,8 @@ protected function filterChanges(array $changes) {
do {
$lang = $iterator->current();
if(isset($changes['whatsNew'][$lang])) {
return $filtered['whatsNew'][$lang];
$filtered['whatsNew'] = $changes['whatsNew'][$lang];
return $filtered;
}
$iterator->next();
} while($lang !== 'en' && $iterator->valid());
Expand Down
75 changes: 75 additions & 0 deletions apps/updatenotification/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use OCP\IGroupManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\L10N\ILanguageIterator;
use OCP\Util;
use Test\TestCase;

Expand Down Expand Up @@ -153,4 +154,78 @@ public function testGetSection() {
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);
}
}
1 change: 1 addition & 0 deletions core/css/whatsnew.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
bottom: 35px !important;
left: 15px !important;
width: 270px;
z-index: 700;
}

.whatsNewPopover p {
Expand Down