Merge pull request #7121 from nextcloud/fix_7119

If there is no internet connection don't try to contact appstore
This commit is contained in:
Roeland Jago Douma 2017-11-17 21:07:10 +01:00 committed by GitHub
commit 07af58df5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 10 deletions

View File

@ -128,8 +128,9 @@ abstract class Fetcher {
*/
public function get() {
$appstoreenabled = $this->config->getSystemValue('appstoreenabled', true);
$internetavailable = $this->config->getSystemValue('has_internet_connection', true);
if (!$appstoreenabled) {
if (!$appstoreenabled || !$internetavailable) {
return [];
}

View File

@ -1945,10 +1945,30 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg==
public function testAppstoreDisabled() {
$this->config
->expects($this->once())
->method('getSystemValue')
->with('appstoreenabled', true)
->willReturn(false);
->will($this->returnCallback(function($var, $default) {
if ($var === 'appstoreenabled') {
return false;
}
return $default;
}));
$this->appData
->expects($this->never())
->method('getFolder');
$this->assertEquals([], $this->fetcher->get());
}
public function testNoInternet() {
$this->config
->method('getSystemValue')
->will($this->returnCallback(function($var, $default) {
if ($var === 'has_internet_connection') {
return false;
}
return $default;
}));
$this->appData
->expects($this->never())
->method('getFolder');

View File

@ -40,15 +40,33 @@ class CategoryFetcherTest extends FetcherBase {
public function testAppstoreDisabled() {
$this->config
->expects($this->once())
->method('getSystemValue')
->with('appstoreenabled', true)
->willReturn(false);
->will($this->returnCallback(function($var, $default) {
if ($var === 'appstoreenabled') {
return false;
}
return $default;
}));
$this->appData
->expects($this->never())
->method('getFolder');
$this->assertEquals([], $this->fetcher->get());
}
public function testNoInternet() {
$this->config
->method('getSystemValue')
->will($this->returnCallback(function($var, $default) {
if ($var === 'has_internet_connection') {
return false;
}
return $default;
}));
$this->appData
->expects($this->never())
->method('getFolder');
$this->assertEquals([], $this->fetcher->get());
}
}

View File

@ -78,6 +78,11 @@ abstract class FetcherBase extends TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('has_internet_connection', true)
->willReturn(true);
$this->config
->expects($this->at(2))
->method('getSystemValue')
->with(
$this->equalTo('version'),
$this->anything()
@ -121,11 +126,16 @@ abstract class FetcherBase extends TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('appstoreenabled', true)
->with('has_internet_connection', true)
->willReturn(true);
$this->config
->expects($this->at(2))
->method('getSystemValue')
->with('appstoreenabled', true)
->willReturn(true);
$this->config
->expects($this->at(3))
->method('getSystemValue')
->with(
$this->equalTo('version'),
$this->anything()
@ -277,11 +287,16 @@ abstract class FetcherBase extends TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('appstoreenabled', true)
->with('has_internet_connection', true)
->willReturn(true);
$this->config
->expects($this->at(2))
->method('getSystemValue')
->with('appstoreenabled', true)
->willReturn(true);
$this->config
->expects($this->at(3))
->method('getSystemValue')
->with(
$this->equalTo('version'),
$this->anything()
@ -356,11 +371,16 @@ abstract class FetcherBase extends TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('appstoreenabled', true)
->with('has_internet_connection', true)
->willReturn(true);
$this->config
->expects($this->at(2))
->method('getSystemValue')
->with('appstoreenabled', true)
->willReturn(true);
$this->config
->expects($this->at(3))
->method('getSystemValue')
->with(
$this->equalTo('version'),
$this->anything()