|
|
@@ -66,20 +66,21 @@ class VersionCheckTest extends \Test\TestCase { |
|
|
|
]; |
|
|
|
|
|
|
|
$this->config |
|
|
|
->expects($this->at(0)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValueBool') |
|
|
|
->with('has_internet_connection', true) |
|
|
|
->willReturn(true); |
|
|
|
$this->config |
|
|
|
->expects($this->at(1)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn(time()); |
|
|
|
$this->config |
|
|
|
->expects($this->at(2)) |
|
|
|
->expects($this->exactly(2)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdateResult') |
|
|
|
->willReturn(json_encode($expectedResult)); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
['core', 'lastupdateResult'] |
|
|
|
) |
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
time(), |
|
|
|
json_encode($expectedResult) |
|
|
|
); |
|
|
|
|
|
|
|
$this->assertSame($expectedResult, $this->updater->check()); |
|
|
|
} |
|
|
@@ -96,38 +97,37 @@ class VersionCheckTest extends \Test\TestCase { |
|
|
|
]; |
|
|
|
|
|
|
|
$this->config |
|
|
|
->expects($this->at(0)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValueBool') |
|
|
|
->with('has_internet_connection', true) |
|
|
|
->willReturn(true); |
|
|
|
$this->config |
|
|
|
->expects($this->at(1)) |
|
|
|
->expects($this->exactly(4)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn(0); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
) |
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
0, |
|
|
|
'installedat', |
|
|
|
'installedat', |
|
|
|
'lastupdatedat' |
|
|
|
); |
|
|
|
$this->config |
|
|
|
->expects($this->at(2)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValue') |
|
|
|
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') |
|
|
|
->willReturnArgument(1); |
|
|
|
$this->config |
|
|
|
->expects($this->at(3)) |
|
|
|
->method('setAppValue') |
|
|
|
->with('core', 'lastupdatedat', $this->isType('integer')); |
|
|
|
$this->config |
|
|
|
->expects($this->at(5)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'installedat') |
|
|
|
->willReturn('installedat'); |
|
|
|
$this->config |
|
|
|
->expects($this->at(6)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn('lastupdatedat'); |
|
|
|
$this->config |
|
|
|
->expects($this->at(7)) |
|
|
|
->expects($this->exactly(2)) |
|
|
|
->method('setAppValue') |
|
|
|
->with('core', 'lastupdateResult', json_encode($expectedResult)); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat', $this->isType('integer')], |
|
|
|
['core', 'lastupdateResult', json_encode($expectedResult)] |
|
|
|
); |
|
|
|
|
|
|
|
$updateXml = '<?xml version="1.0"?> |
|
|
|
<owncloud> |
|
|
@@ -149,38 +149,37 @@ class VersionCheckTest extends \Test\TestCase { |
|
|
|
|
|
|
|
public function testCheckWithInvalidXml() { |
|
|
|
$this->config |
|
|
|
->expects($this->at(0)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValueBool') |
|
|
|
->with('has_internet_connection', true) |
|
|
|
->willReturn(true); |
|
|
|
$this->config |
|
|
|
->expects($this->at(1)) |
|
|
|
->expects($this->exactly(4)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn(0); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
) |
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
0, |
|
|
|
'installedat', |
|
|
|
'installedat', |
|
|
|
'lastupdatedat' |
|
|
|
); |
|
|
|
$this->config |
|
|
|
->expects($this->at(2)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValue') |
|
|
|
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') |
|
|
|
->willReturnArgument(1); |
|
|
|
$this->config |
|
|
|
->expects($this->at(3)) |
|
|
|
->method('setAppValue') |
|
|
|
->with('core', 'lastupdatedat', $this->isType('integer')); |
|
|
|
$this->config |
|
|
|
->expects($this->at(5)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'installedat') |
|
|
|
->willReturn('installedat'); |
|
|
|
$this->config |
|
|
|
->expects($this->at(6)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn('lastupdatedat'); |
|
|
|
$this->config |
|
|
|
->expects($this->at(7)) |
|
|
|
->expects($this->exactly(2)) |
|
|
|
->method('setAppValue') |
|
|
|
->with('core', 'lastupdateResult', '[]'); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat', $this->isType('integer')], |
|
|
|
['core', 'lastupdateResult', '[]'] |
|
|
|
); |
|
|
|
|
|
|
|
$updateXml = 'Invalid XML Response!'; |
|
|
|
$this->updater |
|
|
@@ -204,34 +203,37 @@ class VersionCheckTest extends \Test\TestCase { |
|
|
|
]; |
|
|
|
|
|
|
|
$this->config |
|
|
|
->expects($this->at(0)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValueBool') |
|
|
|
->with('has_internet_connection', true) |
|
|
|
->willReturn(true); |
|
|
|
$this->config |
|
|
|
->expects($this->at(1)) |
|
|
|
->expects($this->exactly(4)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn(0); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
) |
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
0, |
|
|
|
'installedat', |
|
|
|
'installedat', |
|
|
|
'lastupdatedat' |
|
|
|
); |
|
|
|
$this->config |
|
|
|
->expects($this->at(2)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValue') |
|
|
|
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') |
|
|
|
->willReturnArgument(1); |
|
|
|
$this->config |
|
|
|
->expects($this->at(3)) |
|
|
|
->expects($this->exactly(2)) |
|
|
|
->method('setAppValue') |
|
|
|
->with('core', 'lastupdatedat', $this->isType('integer')); |
|
|
|
$this->config |
|
|
|
->expects($this->at(5)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'installedat') |
|
|
|
->willReturn('installedat'); |
|
|
|
$this->config |
|
|
|
->expects($this->at(6)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn('lastupdatedat'); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat', $this->isType('integer')], |
|
|
|
['core', 'lastupdateResult', $this->isType('string')] |
|
|
|
); |
|
|
|
|
|
|
|
$updateXml = '<?xml version="1.0"?> |
|
|
|
<owncloud> |
|
|
@@ -254,38 +256,37 @@ class VersionCheckTest extends \Test\TestCase { |
|
|
|
$expectedResult = []; |
|
|
|
|
|
|
|
$this->config |
|
|
|
->expects($this->at(0)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValueBool') |
|
|
|
->with('has_internet_connection', true) |
|
|
|
->willReturn(true); |
|
|
|
$this->config |
|
|
|
->expects($this->at(1)) |
|
|
|
->expects($this->exactly(4)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn(0); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
) |
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
0, |
|
|
|
'installedat', |
|
|
|
'installedat', |
|
|
|
'lastupdatedat' |
|
|
|
); |
|
|
|
$this->config |
|
|
|
->expects($this->at(2)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValue') |
|
|
|
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') |
|
|
|
->willReturnArgument(1); |
|
|
|
$this->config |
|
|
|
->expects($this->at(3)) |
|
|
|
->method('setAppValue') |
|
|
|
->with('core', 'lastupdatedat', $this->isType('integer')); |
|
|
|
$this->config |
|
|
|
->expects($this->at(5)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'installedat') |
|
|
|
->willReturn('installedat'); |
|
|
|
$this->config |
|
|
|
->expects($this->at(6)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn('lastupdatedat'); |
|
|
|
$this->config |
|
|
|
->expects($this->at(7)) |
|
|
|
->expects($this->exactly(2)) |
|
|
|
->method('setAppValue') |
|
|
|
->with('core', 'lastupdateResult', json_encode($expectedResult)); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat', $this->isType('integer')], |
|
|
|
['core', 'lastupdateResult', json_encode($expectedResult)] |
|
|
|
); |
|
|
|
|
|
|
|
$updateXml = ''; |
|
|
|
$this->updater |
|
|
@@ -309,34 +310,37 @@ class VersionCheckTest extends \Test\TestCase { |
|
|
|
]; |
|
|
|
|
|
|
|
$this->config |
|
|
|
->expects($this->at(0)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValueBool') |
|
|
|
->with('has_internet_connection', true) |
|
|
|
->willReturn(true); |
|
|
|
$this->config |
|
|
|
->expects($this->at(1)) |
|
|
|
->expects($this->exactly(4)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn(0); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'installedat'], |
|
|
|
['core', 'lastupdatedat'], |
|
|
|
) |
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
0, |
|
|
|
'installedat', |
|
|
|
'installedat', |
|
|
|
'lastupdatedat' |
|
|
|
); |
|
|
|
$this->config |
|
|
|
->expects($this->at(2)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValue') |
|
|
|
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') |
|
|
|
->willReturnArgument(1); |
|
|
|
$this->config |
|
|
|
->expects($this->at(3)) |
|
|
|
->expects($this->exactly(2)) |
|
|
|
->method('setAppValue') |
|
|
|
->with('core', 'lastupdatedat', $this->isType('integer')); |
|
|
|
$this->config |
|
|
|
->expects($this->at(5)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'installedat') |
|
|
|
->willReturn('installedat'); |
|
|
|
$this->config |
|
|
|
->expects($this->at(6)) |
|
|
|
->method('getAppValue') |
|
|
|
->with('core', 'lastupdatedat') |
|
|
|
->willReturn('lastupdatedat'); |
|
|
|
->withConsecutive( |
|
|
|
['core', 'lastupdatedat', $this->isType('integer')], |
|
|
|
['core', 'lastupdateResult', $this->isType('string')] |
|
|
|
); |
|
|
|
|
|
|
|
// missing autoupdater element should still not fail |
|
|
|
$updateXml = '<?xml version="1.0"?> |
|
|
@@ -357,7 +361,7 @@ class VersionCheckTest extends \Test\TestCase { |
|
|
|
|
|
|
|
public function testNoInternet() { |
|
|
|
$this->config |
|
|
|
->expects($this->at(0)) |
|
|
|
->expects($this->once()) |
|
|
|
->method('getSystemValueBool') |
|
|
|
->with('has_internet_connection', true) |
|
|
|
->willReturn(false); |