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 @@ -64,9 +64,14 @@ protected function run($argument) {
}

/**
* Check for ownCloud update
* Check for Nextcloud server update
*/
protected function checkCoreUpdate() {
if (!$this->config->getSystemValueBool('updatechecker', true)) {
// update checker is disabled so no core update check!
return;
}

if (\in_array($this->serverVersion->getChannel(), ['daily', 'git'], true)) {
// "These aren't the update channels you're looking for." - Ben Obi-Wan Kenobi
return;
Expand Down
7 changes: 6 additions & 1 deletion apps/updatenotification/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ protected function getSelectedGroups(array $groupIds): array {
return $result;
}

public function getSection(): string {
public function getSection(): ?string {
if (!$this->config->getSystemValueBool('updatechecker', true)) {
// update checker is disabled so we do not show the section at all
return null;
}

return 'overview';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Test\TestCase;

class UpdateAvailableNotificationsTest extends TestCase {
private ServerVersion $serverVersion;
private ServerVersion&MockObject $serverVersion;
private IConfig|MockObject $config;
private IManager|MockObject $notificationManager;
private IGroupManager|MockObject $groupManager;
Expand Down Expand Up @@ -96,13 +96,12 @@ public function testRun(): void {
$job->expects($this->once())
->method('checkAppUpdates');

$this->config->expects($this->exactly(2))
$this->config->expects(self::exactly(2))
->method('getSystemValueBool')
->willReturnMap([
['has_internet_connection', true, true],
['debug', false, true],
['has_internet_connection', true, true],
]);

self::invokePrivate($job, 'run', [null]);
}

Expand All @@ -117,7 +116,9 @@ public function testRunNoInternet(): void {
$job->expects($this->never())
->method('checkAppUpdates');

$this->config->method('getSystemValueBool')
$this->config
->expects(self::once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(false);

Expand Down Expand Up @@ -212,6 +213,13 @@ public function testCheckCoreUpdate(string $channel, $versionCheck, $version, $r
->with('core', $version, $readableVersion);
}

$this->config->expects(self::any())
->method('getSystemValueBool')
->willReturnMap([
['updatechecker', true, true],
['has_internet_connection', true, true],
]);

self::invokePrivate($job, 'checkCoreUpdate');
}

Expand Down
31 changes: 31 additions & 0 deletions apps/updatenotification/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public function testGetFormWithUpdate(): void {
['updater.server.url', 'https://updates.nextcloud.com/updater_server/', 'https://updates.nextcloud.com/updater_server/'],
['upgrade.disable-web', false, false],
]);
$this->config
->expects(self::any())
->method('getSystemValueBool')
->with('updatechecker', true)
->willReturn(true);
$this->dateTimeFormatter
->expects($this->once())
->method('formatDateTime')
Expand Down Expand Up @@ -192,6 +197,11 @@ public function testGetFormWithUpdateAndChangedUpdateServer(): void {
->method('getValueInt')
->with('core', 'lastupdatedat', 0)
->willReturn(12345);
$this->config
->expects(self::any())
->method('getSystemValueBool')
->with('updatechecker', true)
->willReturn(true);
$this->config
->expects($this->once())
->method('getAppValue')
Expand Down Expand Up @@ -287,6 +297,11 @@ public function testGetFormWithUpdateAndCustomersUpdateServer(): void {
->method('getValueInt')
->with('core', 'lastupdatedat', 0)
->willReturn(12345);
$this->config
->expects(self::any())
->method('getSystemValueBool')
->with('updatechecker', true)
->willReturn(true);
$this->config
->expects($this->once())
->method('getAppValue')
Expand Down Expand Up @@ -363,9 +378,25 @@ public function testGetFormWithUpdateAndCustomersUpdateServer(): void {


public function testGetSection(): void {
$this->config
->expects(self::atLeastOnce())
->method('getSystemValueBool')
->with('updatechecker', true)
->willReturn(true);

$this->assertSame('overview', $this->admin->getSection());
}

public function testGetSectionDisabled(): void {
$this->config
->expects(self::atLeastOnce())
->method('getSystemValueBool')
->with('updatechecker', true)
->willReturn(false);

$this->assertNull($this->admin->getSection());
}

public function testGetPriority(): void {
$this->assertSame(11, $this->admin->getPriority());
}
Expand Down
Loading