aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-11-19 11:01:00 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-20 19:30:59 +0100
commitda25ed997e25fb31fcb0b1fe992d38992ff071d7 (patch)
treea1c6620eac8b0b6e6dd48bcb6545b9674f25a268 /tests
parent2b2626566c19280ff207cbfa2c0c235ecae2a79b (diff)
downloadnextcloud-server-da25ed997e25fb31fcb0b1fe992d38992ff071d7.tar.gz
nextcloud-server-da25ed997e25fb31fcb0b1fe992d38992ff071d7.zip
Do not check for updates if we have no internet
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Updater/VersionCheckTest.php88
1 files changed, 64 insertions, 24 deletions
diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php
index 6da4fd2c3b2..eef16eeb520 100644
--- a/tests/lib/Updater/VersionCheckTest.php
+++ b/tests/lib/Updater/VersionCheckTest.php
@@ -67,11 +67,16 @@ class VersionCheckTest extends \Test\TestCase {
$this->config
->expects($this->at(0))
+ ->method('getSystemValueBool')
+ ->with('has_internet_connection', true)
+ ->willReturn(true);
+ $this->config
+ ->expects($this->at(1))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue(time()));
$this->config
- ->expects($this->at(1))
+ ->expects($this->at(2))
->method('getAppValue')
->with('core', 'lastupdateResult')
->will($this->returnValue(json_encode($expectedResult)));
@@ -92,30 +97,35 @@ class VersionCheckTest extends \Test\TestCase {
$this->config
->expects($this->at(0))
+ ->method('getSystemValueBool')
+ ->with('has_internet_connection', true)
+ ->willReturn(true);
+ $this->config
+ ->expects($this->at(1))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue(0));
$this->config
- ->expects($this->at(1))
+ ->expects($this->at(2))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(2))
+ ->expects($this->at(3))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
- ->expects($this->at(4))
+ ->expects($this->at(5))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
- ->expects($this->at(5))
+ ->expects($this->at(6))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
$this->config
- ->expects($this->at(6))
+ ->expects($this->at(7))
->method('setAppValue')
->with('core', 'lastupdateResult', json_encode($expectedResult));
@@ -140,30 +150,35 @@ class VersionCheckTest extends \Test\TestCase {
public function testCheckWithInvalidXml() {
$this->config
->expects($this->at(0))
+ ->method('getSystemValueBool')
+ ->with('has_internet_connection', true)
+ ->willReturn(true);
+ $this->config
+ ->expects($this->at(1))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue(0));
$this->config
- ->expects($this->at(1))
+ ->expects($this->at(2))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(2))
+ ->expects($this->at(3))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
- ->expects($this->at(4))
+ ->expects($this->at(5))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
- ->expects($this->at(5))
+ ->expects($this->at(6))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
$this->config
- ->expects($this->at(6))
+ ->expects($this->at(7))
->method('setAppValue')
->with('core', 'lastupdateResult', '[]');
@@ -190,25 +205,30 @@ class VersionCheckTest extends \Test\TestCase {
$this->config
->expects($this->at(0))
+ ->method('getSystemValueBool')
+ ->with('has_internet_connection', true)
+ ->willReturn(true);
+ $this->config
+ ->expects($this->at(1))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue(0));
$this->config
- ->expects($this->at(1))
+ ->expects($this->at(2))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(2))
+ ->expects($this->at(3))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
- ->expects($this->at(4))
+ ->expects($this->at(5))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
- ->expects($this->at(5))
+ ->expects($this->at(6))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
@@ -235,30 +255,35 @@ class VersionCheckTest extends \Test\TestCase {
$this->config
->expects($this->at(0))
+ ->method('getSystemValueBool')
+ ->with('has_internet_connection', true)
+ ->willReturn(true);
+ $this->config
+ ->expects($this->at(1))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue(0));
$this->config
- ->expects($this->at(1))
+ ->expects($this->at(2))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(2))
+ ->expects($this->at(3))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
- ->expects($this->at(4))
+ ->expects($this->at(5))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
- ->expects($this->at(5))
+ ->expects($this->at(6))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
$this->config
- ->expects($this->at(6))
+ ->expects($this->at(7))
->method('setAppValue')
->with('core', 'lastupdateResult', json_encode($expectedResult));
@@ -285,25 +310,30 @@ class VersionCheckTest extends \Test\TestCase {
$this->config
->expects($this->at(0))
+ ->method('getSystemValueBool')
+ ->with('has_internet_connection', true)
+ ->willReturn(true);
+ $this->config
+ ->expects($this->at(1))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue(0));
$this->config
- ->expects($this->at(1))
+ ->expects($this->at(2))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(2))
+ ->expects($this->at(3))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
- ->expects($this->at(4))
+ ->expects($this->at(5))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
- ->expects($this->at(5))
+ ->expects($this->at(6))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
@@ -324,4 +354,14 @@ class VersionCheckTest extends \Test\TestCase {
$this->assertSame($expectedResult, $this->updater->check());
}
+
+ public function testNoInternet() {
+ $this->config
+ ->expects($this->at(0))
+ ->method('getSystemValueBool')
+ ->with('has_internet_connection', true)
+ ->willReturn(false);
+
+ $this->assertFalse($this->updater->check());
+ }
}