diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-06-16 17:43:17 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-06-16 17:43:17 +0200 |
commit | c7e1c36362a7e4de5a7d074ab43f97c2559e06ea (patch) | |
tree | 44029b863ad1dd0a4ad05d029b13c0a64772369e /tests/lib/App | |
parent | 0c14ee6ff5a2d3aa3f77f8cd2bf331590ee62f44 (diff) | |
download | nextcloud-server-c7e1c36362a7e4de5a7d074ab43f97c2559e06ea.tar.gz nextcloud-server-c7e1c36362a7e4de5a7d074ab43f97c2559e06ea.zip |
Remove at matcher uses in tests/lib
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests/lib/App')
-rw-r--r-- | tests/lib/App/AppStore/Fetcher/AppFetcherTest.php | 16 | ||||
-rw-r--r-- | tests/lib/App/AppStore/Fetcher/FetcherBase.php | 203 |
2 files changed, 104 insertions, 115 deletions
diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php index 4746c296ab4..a2d56838b07 100644 --- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php @@ -1890,12 +1890,12 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== $file = $this->createMock(ISimpleFile::class); $folder = $this->createMock(ISimpleFolder::class); $folder - ->expects($this->at(0)) + ->expects($this->once()) ->method('getFile') ->with('apps.json') ->willThrowException(new NotFoundException()); $folder - ->expects($this->at(1)) + ->expects($this->once()) ->method('newFile') ->with('apps.json') ->willReturn($file); @@ -1946,7 +1946,7 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== } $file - ->expects($this->at(0)) + ->expects($this->once()) ->method('putContent'); $file ->method('getContent') @@ -2017,12 +2017,12 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== $file = $this->createMock(ISimpleFile::class); $folder = $this->createMock(ISimpleFolder::class); $folder - ->expects($this->at(0)) + ->expects($this->once()) ->method('getFile') ->with('future-apps.json') ->willThrowException(new NotFoundException()); $folder - ->expects($this->at(1)) + ->expects($this->once()) ->method('newFile') ->with('future-apps.json') ->willReturn($file); @@ -2073,7 +2073,7 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== } $file - ->expects($this->at(0)) + ->expects($this->once()) ->method('putContent'); $file ->method('getContent') @@ -2104,12 +2104,12 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== $file = $this->createMock(ISimpleFile::class); $folder = $this->createMock(ISimpleFolder::class); $folder - ->expects($this->at(0)) + ->expects($this->once()) ->method('getFile') ->with('apps.json') ->willThrowException(new NotFoundException()); $folder - ->expects($this->at(1)) + ->expects($this->once()) ->method('newFile') ->with('apps.json') ->willReturn($file); diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php index 87a09cb617d..42ad02ce6d8 100644 --- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php +++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php @@ -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') |