|
|
|
|
@ -76,22 +76,20 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
|
|
|
|
|
public function testGetWithAlreadyExistingFileAndUpToDateTimestampAndVersion() { |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getSystemValueBool') |
|
|
|
|
->with('appstoreenabled', true) |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('has_internet_connection', true) |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(2)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with( |
|
|
|
|
$this->equalTo('version'), |
|
|
|
|
$this->anything() |
|
|
|
|
)->willReturn('11.0.0.2'); |
|
|
|
|
->withConsecutive( |
|
|
|
|
['has_internet_connection', true], |
|
|
|
|
[$this->equalTo('version'), $this->anything()], |
|
|
|
|
)->willReturnOnConsecutiveCalls( |
|
|
|
|
true, |
|
|
|
|
'11.0.0.2', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$folder = $this->createMock(ISimpleFolder::class); |
|
|
|
|
$file = $this->createMock(ISimpleFile::class); |
|
|
|
|
@ -148,12 +146,12 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
->with('/') |
|
|
|
|
->willReturn($folder); |
|
|
|
|
$folder |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getFile') |
|
|
|
|
->with($this->fileName) |
|
|
|
|
->willThrowException(new NotFoundException()); |
|
|
|
|
$folder |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('newFile') |
|
|
|
|
->with($this->fileName) |
|
|
|
|
->willReturn($file); |
|
|
|
|
@ -177,15 +175,15 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
->willReturn('"myETag"'); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1502,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn($fileData); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturn(1502); |
|
|
|
|
|
|
|
|
|
@ -227,14 +225,25 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
->method('getFile') |
|
|
|
|
->with($this->fileName) |
|
|
|
|
->willReturn($file); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1502,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn('{"timestamp":1200,"data":{"MyApp":{"id":"MyApp"}},"ncversion":"11.0.0.2"}'); |
|
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
|
'{"timestamp":1200,"data":{"MyApp":{"id":"MyApp"}},"ncversion":"11.0.0.2"}', |
|
|
|
|
$fileData |
|
|
|
|
); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturn(4801); |
|
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
|
4801, |
|
|
|
|
1502 |
|
|
|
|
); |
|
|
|
|
$client = $this->createMock(IClient::class); |
|
|
|
|
$this->clientService |
|
|
|
|
->expects($this->once()) |
|
|
|
|
@ -253,19 +262,6 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
$response->method('getHeader') |
|
|
|
|
->with($this->equalTo('ETag')) |
|
|
|
|
->willReturn('"myETag"'); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1502,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn($fileData); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturn(1502); |
|
|
|
|
|
|
|
|
|
$expected = [ |
|
|
|
|
[ |
|
|
|
|
@ -309,12 +305,20 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
->method('getFile') |
|
|
|
|
->with($this->fileName) |
|
|
|
|
->willReturn($file); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1201,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn('{"timestamp":1200,"data":{"MyApp":{"id":"MyApp"}}'); |
|
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
|
'{"timestamp":1200,"data":{"MyApp":{"id":"MyApp"}}', |
|
|
|
|
$fileData |
|
|
|
|
); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturn(1201); |
|
|
|
|
$client = $this->createMock(IClient::class); |
|
|
|
|
@ -335,15 +339,6 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
$response->method('getHeader') |
|
|
|
|
->with($this->equalTo('ETag')) |
|
|
|
|
->willReturn('"myETag"'); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1201,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn($fileData); |
|
|
|
|
|
|
|
|
|
$expected = [ |
|
|
|
|
[ |
|
|
|
|
@ -387,10 +382,18 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
->method('getFile') |
|
|
|
|
->with($this->fileName) |
|
|
|
|
->willReturn($file); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1201,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn('{"timestamp":1200,"data":{"MyApp":{"id":"MyApp"}},"ncversion":"11.0.0.1"'); |
|
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
|
'{"timestamp":1200,"data":{"MyApp":{"id":"MyApp"}},"ncversion":"11.0.0.1"', |
|
|
|
|
$fileData |
|
|
|
|
); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturn(1201); |
|
|
|
|
@ -412,15 +415,6 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
$response->method('getHeader') |
|
|
|
|
->with($this->equalTo('ETag')) |
|
|
|
|
->willReturn('"myETag"'); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1201,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn($fileData); |
|
|
|
|
|
|
|
|
|
$expected = [ |
|
|
|
|
[ |
|
|
|
|
@ -457,7 +451,7 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
->with($this->fileName) |
|
|
|
|
->willReturn($file); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn('{"timestamp":1200,"data":{"MyApp":{"id":"MyApp"}}}'); |
|
|
|
|
$client = $this->createMock(IClient::class); |
|
|
|
|
@ -501,18 +495,26 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
->with($this->fileName) |
|
|
|
|
->willReturn($file); |
|
|
|
|
$origData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1200,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
|
|
|
|
|
$newData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":4802,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($newData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn($origData); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturn(4801); |
|
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
|
$origData, |
|
|
|
|
$newData, |
|
|
|
|
); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturn(4802); |
|
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
|
4801, |
|
|
|
|
4802 |
|
|
|
|
); |
|
|
|
|
$client = $this->createMock(IClient::class); |
|
|
|
|
$this->clientService |
|
|
|
|
->expects($this->once()) |
|
|
|
|
@ -534,16 +536,6 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
$response->method('getStatusCode') |
|
|
|
|
->willReturn(304); |
|
|
|
|
|
|
|
|
|
$newData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":4802,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($newData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn($newData); |
|
|
|
|
|
|
|
|
|
$expected = [ |
|
|
|
|
[ |
|
|
|
|
'id' => 'MyNewApp', |
|
|
|
|
@ -579,14 +571,29 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
->with('/') |
|
|
|
|
->willReturn($folder); |
|
|
|
|
$folder |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getFile') |
|
|
|
|
->with($this->fileName) |
|
|
|
|
->willReturn($file); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":4802,"ncversion":"11.0.0.2","ETag":"\"newETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn('{"data":[{"id":"MyOldApp","abc":"def"}],"timestamp":1200,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'); |
|
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
|
'{"data":[{"id":"MyOldApp","abc":"def"}],"timestamp":1200,"ncversion":"11.0.0.2","ETag":"\"myETag\""}', |
|
|
|
|
$fileData, |
|
|
|
|
); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
|
4801, |
|
|
|
|
4802, |
|
|
|
|
); |
|
|
|
|
$client = $this->createMock(IClient::class); |
|
|
|
|
$this->clientService |
|
|
|
|
->expects($this->once()) |
|
|
|
|
@ -615,23 +622,6 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
$response->method('getHeader') |
|
|
|
|
->with($this->equalTo('ETag')) |
|
|
|
|
->willReturn('"newETag"'); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":4802,"ncversion":"11.0.0.2","ETag":"\"newETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn($fileData); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturn(4801); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->method('getTime') |
|
|
|
|
->willReturn(4802); |
|
|
|
|
|
|
|
|
|
$expected = [ |
|
|
|
|
[ |
|
|
|
|
@ -668,14 +658,22 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
->with('/') |
|
|
|
|
->willReturn($folder); |
|
|
|
|
$folder |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getFile') |
|
|
|
|
->with($this->fileName) |
|
|
|
|
->willReturn($file); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1501,"ncversion":"11.0.0.3","ETag":"\"newETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn('{"data":[{"id":"MyOldApp","abc":"def"}],"timestamp":1200,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'); |
|
|
|
|
->willReturnOnConsecutiveCalls( |
|
|
|
|
'{"data":[{"id":"MyOldApp","abc":"def"}],"timestamp":1200,"ncversion":"11.0.0.2","ETag":"\"myETag\""}', |
|
|
|
|
$fileData |
|
|
|
|
); |
|
|
|
|
$client = $this->createMock(IClient::class); |
|
|
|
|
$this->clientService |
|
|
|
|
->expects($this->once()) |
|
|
|
|
@ -701,15 +699,6 @@ abstract class FetcherBase extends TestCase { |
|
|
|
|
$response->method('getHeader') |
|
|
|
|
->with($this->equalTo('ETag')) |
|
|
|
|
->willReturn('"newETag"'); |
|
|
|
|
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1501,"ncversion":"11.0.0.3","ETag":"\"newETag\""}'; |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->method('putContent') |
|
|
|
|
->with($fileData); |
|
|
|
|
$file |
|
|
|
|
->expects($this->at(2)) |
|
|
|
|
->method('getContent') |
|
|
|
|
->willReturn($fileData); |
|
|
|
|
$this->timeFactory |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getTime') |
|
|
|
|
|