aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-03-08 09:01:44 +0100
committerGitHub <noreply@github.com>2024-03-08 09:01:44 +0100
commit34069087df0087a7b4e93161da288ac2f07c5ea2 (patch)
tree70750793ea6613e1eebd8d36e3ff20bad3160c5e
parent27b09ce00a22dc9912d2931a892a1b6870d6b22c (diff)
parent2c87fbf20761a8e427b42055c1714ceba200548d (diff)
downloadnextcloud-server-34069087df0087a7b4e93161da288ac2f07c5ea2.tar.gz
nextcloud-server-34069087df0087a7b4e93161da288ac2f07c5ea2.zip
Merge pull request #44074 from nextcloud/fix/updatenotification-test
fix(updatenotification): Adjust tests for changed IAppConfig
-rw-r--r--apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php3
-rw-r--r--apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php19
-rw-r--r--apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php40
-rw-r--r--apps/updatenotification/tests/Controller/AdminControllerTest.php4
4 files changed, 34 insertions, 32 deletions
diff --git a/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php b/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
index 6e7cc7928ab..f561f38fdc0 100644
--- a/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
+++ b/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
@@ -218,7 +218,8 @@ class UpdateAvailableNotifications extends TimedJob {
}
}
- return array_unique($this->users);
+ $this->users = array_values(array_unique($this->users));
+ return $this->users;
}
/**
diff --git a/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php b/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php
index 7361e4daf91..4a677480cf4 100644
--- a/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php
+++ b/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php
@@ -57,9 +57,9 @@ class ResetTokenTest extends TestCase {
->expects($this->atLeastOnce())
->method('getTime')
->willReturn(123);
- $this->config
+ $this->appConfig
->expects($this->once())
- ->method('getAppValue')
+ ->method('getValueInt')
->with('core', 'updater.secret.created', 123);
$this->config
->expects($this->once())
@@ -75,13 +75,14 @@ class ResetTokenTest extends TestCase {
public function testRunWithExpiredToken() {
$this->timeFactory
- ->expects($this->exactly(2))
+ ->expects($this->once())
->method('getTime')
- ->willReturnOnConsecutiveCalls(1455131633, 1455045234);
- $this->config
+ ->willReturn(1455045234);
+ $this->appConfig
->expects($this->once())
- ->method('getAppValue')
- ->with('core', 'updater.secret.created', 1455045234);
+ ->method('getValueInt')
+ ->with('core', 'updater.secret.created', 1455045234)
+ ->willReturn(2 * 24 * 60 * 60 + 1); // over 2 days
$this->config
->expects($this->once())
->method('deleteSystemValue')
@@ -94,9 +95,9 @@ class ResetTokenTest extends TestCase {
$this->timeFactory
->expects($this->never())
->method('getTime');
- $this->config
+ $this->appConfig
->expects($this->never())
- ->method('getAppValue');
+ ->method('getValueInt');
$this->config
->expects($this->once())
->method('getSystemValueBool')
diff --git a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
index fd9affc87b3..a271d6988fe 100644
--- a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
+++ b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
@@ -211,19 +211,19 @@ class UpdateAvailableNotificationsTest extends TestCase {
$job->expects($this->never())
->method('clearErrorNotifications');
- $this->config->expects($this->once())
- ->method('getAppValue')
- ->willReturn($errorDays);
- $this->config->expects($this->once())
- ->method('setAppValue')
- ->with('updatenotification', 'update_check_errors', $errorDays + 1);
+ $this->appConfig->expects($this->once())
+ ->method('getAppValueInt')
+ ->willReturn($errorDays ?? 0);
+ $this->appConfig->expects($this->once())
+ ->method('setAppValueInt')
+ ->with('update_check_errors', $errorDays + 1);
$job->expects($errorDays !== null ? $this->once() : $this->never())
->method('sendErrorNotifications')
->with($errorDays + 1);
} else {
- $this->config->expects($this->once())
- ->method('setAppValue')
- ->with('updatenotification', 'update_check_errors', 0);
+ $this->appConfig->expects($this->once())
+ ->method('setAppValueInt')
+ ->with('update_check_errors', 0);
$job->expects($this->once())
->method('clearErrorNotifications');
$job->expects($this->once())
@@ -302,15 +302,15 @@ class UpdateAvailableNotificationsTest extends TestCase {
'getUsersToNotify',
]);
- $this->config->expects($this->once())
- ->method('getAppValue')
- ->with('updatenotification', $app, false)
- ->willReturn($lastNotification);
+ $this->appConfig->expects($this->once())
+ ->method('getAppValueString')
+ ->with($app, '')
+ ->willReturn($lastNotification ? $lastNotification : '');
if ($lastNotification !== $version) {
- $this->config->expects($this->once())
- ->method('setAppValue')
- ->with('updatenotification', $app, $version);
+ $this->appConfig->expects($this->once())
+ ->method('setAppValueString')
+ ->with($app, $version);
}
if ($callDelete === false) {
@@ -386,10 +386,10 @@ class UpdateAvailableNotificationsTest extends TestCase {
public function testGetUsersToNotify(array $groups, array $groupUsers, array $expected) {
$job = $this->getJob();
- $this->config->expects($this->once())
- ->method('getAppValue')
- ->with('updatenotification', 'notify_groups', '["admin"]')
- ->willReturn(json_encode($groups));
+ $this->appConfig->expects($this->once())
+ ->method('getAppValueArray')
+ ->with('notify_groups', ['admin'])
+ ->willReturn($groups);
$groupMap = [];
foreach ($groupUsers as $gid => $uids) {
diff --git a/apps/updatenotification/tests/Controller/AdminControllerTest.php b/apps/updatenotification/tests/Controller/AdminControllerTest.php
index b58eb30f82e..88622993cf1 100644
--- a/apps/updatenotification/tests/Controller/AdminControllerTest.php
+++ b/apps/updatenotification/tests/Controller/AdminControllerTest.php
@@ -92,9 +92,9 @@ class AdminControllerTest extends TestCase {
->expects($this->once())
->method('getTime')
->willReturn(12345);
- $this->config
+ $this->appConfig
->expects($this->once())
- ->method('setAppValue')
+ ->method('setValueInt')
->with('core', 'updater.secret.created', 12345);
$expected = new DataResponse('MyGeneratedToken');