diff --git a/apps/updatenotification/lib/Notification/BackgroundJob.php b/apps/updatenotification/lib/Notification/BackgroundJob.php index e7dc193df6c89..afecad7a69deb 100644 --- a/apps/updatenotification/lib/Notification/BackgroundJob.php +++ b/apps/updatenotification/lib/Notification/BackgroundJob.php @@ -78,6 +78,11 @@ public function __construct(IConfig $config, } protected function run($argument) { + // Do not check for updates if not connected to the internet + if (!$this->config->getSystemValueBool('has_internet_connection', true)) { + return; + } + if (\OC::$CLI && !$this->config->getSystemValueBool('debug', false)) { try { // Jitter the pinging of the updater server and the appstore a bit. diff --git a/apps/updatenotification/tests/Notification/BackgroundJobTest.php b/apps/updatenotification/tests/Notification/BackgroundJobTest.php index d4d7a543e5640..2a1d2702f141d 100644 --- a/apps/updatenotification/tests/Notification/BackgroundJobTest.php +++ b/apps/updatenotification/tests/Notification/BackgroundJobTest.php @@ -107,9 +107,34 @@ public function testRun() { $job->expects($this->once()) ->method('checkAppUpdates'); + $this->config->expects($this->exactly(2)) + ->method('getSystemValueBool') + ->withConsecutive( + ['has_internet_connection', true], + ['debug', false], + ) + ->willReturnOnConsecutiveCalls( + true, + true, + ); + + self::invokePrivate($job, 'run', [null]); + } + + public function testRunNoInternet() { + $job = $this->getJob([ + 'checkCoreUpdate', + 'checkAppUpdates', + ]); + + $job->expects($this->never()) + ->method('checkCoreUpdate'); + $job->expects($this->never()) + ->method('checkAppUpdates'); + $this->config->method('getSystemValueBool') - ->with('debug', false) - ->willReturn(true); + ->with('has_internet_connection', true) + ->willReturn(false); self::invokePrivate($job, 'run', [null]); }