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
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ protected function getUsersToNotify(): array {
}
}

return array_unique($this->users);
$this->users = array_values(array_unique($this->users));
return $this->users;
}

/**
Expand Down
19 changes: 10 additions & 9 deletions apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public function testRunWithNotExpiredToken() {
->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())
Expand All @@ -75,13 +75,14 @@ public function testRunWithNotExpiredToken() {

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')
Expand All @@ -94,9 +95,9 @@ public function testRunWithExpiredTokenAndReadOnlyConfigFile() {
$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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,19 @@ public function testCheckCoreUpdate(string $channel, $versionCheck, $version, $r
$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())
Expand Down Expand Up @@ -302,15 +302,15 @@ public function testCreateNotifications(string $app, string $version, $lastNotif
'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) {
Expand Down Expand Up @@ -386,10 +386,10 @@ public function dataGetUsersToNotify(): array {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public function testCreateCredentials() {
->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');
Expand Down