diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php index 3ac207ebf75c9f1c35d09abb55f8266921a10163..5ce64671ffa5eb0a256d61a250a77ef77bcc0083 100644 --- a/lib/private/App/AppStore/Fetcher/Fetcher.php +++ b/lib/private/App/AppStore/Fetcher/Fetcher.php @@ -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 []; } diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php index 2efecef4dc77898dab7a81d6e6ad478db179d11e..4549b05935c854077b371da294e4fdd8da461a7f 100644 --- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php @@ -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'); diff --git a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php index a1ce718520fa94bc53144d66a59c73b2cc5ab5d3..f4b8c320c514b6f0d21fdb4eb0d4d42f1f99fb8c 100644 --- a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php @@ -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()); } } diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php index 2cfb34a096553afd45024a8f9500f3ab6aebe844..90b7523d85073143e02140c1c90e43073fbcc2de 100644 --- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php +++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php @@ -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()