Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2022-06-21 12:45:00 +0300
committerGitHub <noreply@github.com>2022-06-21 12:45:00 +0300
commitfd8f2aff09c93b81c120a05e0441a1677d8dde7c (patch)
tree9168addbe74aa1bac9a5b73164f04c607f68c5bb
parent20fc8d8f30012edcd9f1d4e92dd4704bc5b77492 (diff)
parent6a1510f8ee48494a19dc1239fd2584dc2188e18d (diff)
Merge pull request #32901 from nextcloud/fix/remove-at-matcher-in-lib-tests
Remove at matcher uses in tests/lib
-rw-r--r--tests/lib/App/AppStore/Fetcher/AppFetcherTest.php16
-rw-r--r--tests/lib/App/AppStore/Fetcher/FetcherBase.php203
-rw-r--r--tests/lib/AppFramework/Http/RequestTest.php177
-rw-r--r--tests/lib/AppFramework/Routing/RoutingTest.php86
-rw-r--r--tests/lib/Collaboration/Collaborators/LookupPluginTest.php59
-rw-r--r--tests/lib/Collaboration/Collaborators/UserPluginTest.php39
-rw-r--r--tests/lib/Collaboration/Resources/ProviderManagerTest.php15
-rw-r--r--tests/lib/Command/Integrity/SignAppTest.php263
-rw-r--r--tests/lib/Command/Integrity/SignCoreTest.php225
-rw-r--r--tests/lib/DB/MigrationsTest.php12
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php35
-rw-r--r--tests/lib/Encryption/Keys/StorageTest.php30
-rw-r--r--tests/lib/Files/Mount/ObjectHomeMountProviderTest.php20
-rw-r--r--tests/lib/Files/ViewTest.php55
-rw-r--r--tests/lib/Http/Client/ClientTest.php168
-rw-r--r--tests/lib/InstallerTest.php26
-rw-r--r--tests/lib/IntegrityCheck/CheckerTest.php377
-rw-r--r--tests/lib/L10N/FactoryTest.php32
18 files changed, 872 insertions, 966 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')
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php
index e15f3fe656c..3289a373a12 100644
--- a/tests/lib/AppFramework/Http/RequestTest.php
+++ b/tests/lib/AppFramework/Http/RequestTest.php
@@ -381,15 +381,15 @@ class RequestTest extends \Test\TestCase {
public function testGetRemoteAddressWithNoTrustedHeader() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['10.0.0.2']);
- $this->config
- ->expects($this->at(1))
- ->method('getSystemValue')
- ->with('forwarded_for_headers')
- ->willReturn([]);
+ ->withConsecutive(
+ ['trusted_proxies'],
+ ['forwarded_for_headers'],
+ )->willReturnOnConsecutiveCalls(
+ ['10.0.0.2'],
+ []
+ );
$request = new Request(
[
@@ -410,15 +410,15 @@ class RequestTest extends \Test\TestCase {
public function testGetRemoteAddressWithSingleTrustedRemote() {
$this->config
- ->expects($this->at(0))
- ->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['10.0.0.2']);
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('forwarded_for_headers')
- ->willReturn(['HTTP_X_FORWARDED']);
+ ->withConsecutive(
+ ['trusted_proxies'],
+ ['forwarded_for_headers'],
+ )-> willReturnOnConsecutiveCalls(
+ ['10.0.0.2'],
+ ['HTTP_X_FORWARDED'],
+ );
$request = new Request(
[
@@ -439,15 +439,15 @@ class RequestTest extends \Test\TestCase {
public function testGetRemoteAddressIPv6WithSingleTrustedRemote() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['2001:db8:85a3:8d3:1319:8a2e:370:7348']);
- $this->config
- ->expects($this->at(1))
- ->method('getSystemValue')
- ->with('forwarded_for_headers')
- ->willReturn(['HTTP_X_FORWARDED']);
+ ->withConsecutive(
+ ['trusted_proxies'],
+ ['forwarded_for_headers'],
+ )-> willReturnOnConsecutiveCalls(
+ ['2001:db8:85a3:8d3:1319:8a2e:370:7348'],
+ ['HTTP_X_FORWARDED'],
+ );
$request = new Request(
[
@@ -468,19 +468,19 @@ class RequestTest extends \Test\TestCase {
public function testGetRemoteAddressVerifyPriorityHeader() {
$this->config
- ->expects($this->at(0))
- ->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['10.0.0.2']);
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('forwarded_for_headers')
- ->willReturn([
- 'HTTP_CLIENT_IP',
- 'HTTP_X_FORWARDED_FOR',
- 'HTTP_X_FORWARDED'
- ]);
+ ->withConsecutive(
+ ['trusted_proxies'],
+ ['forwarded_for_headers'],
+ )-> willReturnOnConsecutiveCalls(
+ ['10.0.0.2'],
+ [
+ 'HTTP_CLIENT_IP',
+ 'HTTP_X_FORWARDED_FOR',
+ 'HTTP_X_FORWARDED',
+ ],
+ );
$request = new Request(
[
@@ -501,19 +501,19 @@ class RequestTest extends \Test\TestCase {
public function testGetRemoteAddressIPv6VerifyPriorityHeader() {
$this->config
- ->expects($this->at(0))
- ->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['2001:db8:85a3:8d3:1319:8a2e:370:7348']);
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('forwarded_for_headers')
- ->willReturn([
- 'HTTP_CLIENT_IP',
- 'HTTP_X_FORWARDED_FOR',
- 'HTTP_X_FORWARDED'
- ]);
+ ->withConsecutive(
+ ['trusted_proxies'],
+ ['forwarded_for_headers'],
+ )-> willReturnOnConsecutiveCalls(
+ ['2001:db8:85a3:8d3:1319:8a2e:370:7348'],
+ [
+ 'HTTP_CLIENT_IP',
+ 'HTTP_X_FORWARDED_FOR',
+ 'HTTP_X_FORWARDED'
+ ],
+ );
$request = new Request(
[
@@ -534,15 +534,15 @@ class RequestTest extends \Test\TestCase {
public function testGetRemoteAddressWithMatchingCidrTrustedRemote() {
$this->config
- ->expects($this->at(0))
- ->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['192.168.2.0/24']);
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('forwarded_for_headers')
- ->willReturn(['HTTP_X_FORWARDED_FOR']);
+ ->withConsecutive(
+ ['trusted_proxies'],
+ ['forwarded_for_headers'],
+ )-> willReturnOnConsecutiveCalls(
+ ['192.168.2.0/24'],
+ ['HTTP_X_FORWARDED_FOR'],
+ );
$request = new Request(
[
@@ -587,15 +587,15 @@ class RequestTest extends \Test\TestCase {
public function testGetRemoteAddressWithXForwardedForIPv6() {
$this->config
- ->expects($this->at(0))
- ->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['192.168.2.0/24']);
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('forwarded_for_headers')
- ->willReturn(['HTTP_X_FORWARDED_FOR']);
+ ->withConsecutive(
+ ['trusted_proxies'],
+ ['forwarded_for_headers'],
+ )-> willReturnOnConsecutiveCalls(
+ ['192.168.2.0/24'],
+ ['HTTP_X_FORWARDED_FOR'],
+ );
$request = new Request(
[
@@ -666,20 +666,12 @@ class RequestTest extends \Test\TestCase {
public function testGetServerProtocolWithOverride() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getSystemValue')
- ->with('overwriteprotocol')
- ->willReturn('customProtocol');
- $this->config
- ->expects($this->at(1))
- ->method('getSystemValue')
- ->with('overwritecondaddr')
- ->willReturn('');
- $this->config
- ->expects($this->at(2))
- ->method('getSystemValue')
- ->with('overwriteprotocol')
- ->willReturn('customProtocol');
+ ->willReturnMap([
+ ['overwriteprotocol', '', 'customProtocol'],
+ ['overwritecondaddr', '', ''],
+ ]);
$request = new Request(
[],
@@ -1266,20 +1258,12 @@ class RequestTest extends \Test\TestCase {
public function testGetOverwriteHostWithOverwrite() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getSystemValue')
- ->with('overwritehost')
- ->willReturn('www.owncloud.org');
- $this->config
- ->expects($this->at(1))
- ->method('getSystemValue')
- ->with('overwritecondaddr')
- ->willReturn('');
- $this->config
- ->expects($this->at(2))
- ->method('getSystemValue')
- ->with('overwritehost')
- ->willReturn('www.owncloud.org');
+ ->willReturnMap([
+ ['overwritehost', '', 'www.owncloud.org'],
+ ['overwritecondaddr', '', ''],
+ ]);
$request = new Request(
[],
@@ -1493,15 +1477,12 @@ class RequestTest extends \Test\TestCase {
*/
public function testGetRequestUriWithOverwrite($expectedUri, $overwriteWebRoot, $overwriteCondAddr) {
$this->config
- ->expects($this->at(0))
- ->method('getSystemValue')
- ->with('overwritewebroot')
- ->willReturn($overwriteWebRoot);
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('overwritecondaddr')
- ->willReturn($overwriteCondAddr);
+ ->willReturnMap([
+ ['overwritewebroot', '', $overwriteWebRoot],
+ ['overwritecondaddr', '', $overwriteCondAddr],
+ ]);
$request = $this->getMockBuilder('\OC\AppFramework\Http\Request')
->setMethods(['getScriptName'])
diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php
index b4965d61d4f..22037c31d0d 100644
--- a/tests/lib/AppFramework/Routing/RoutingTest.php
+++ b/tests/lib/AppFramework/Routing/RoutingTest.php
@@ -304,36 +304,23 @@ class RoutingTest extends \Test\TestCase {
$urlWithParam = $url . '/{' . $paramName . '}';
- // we expect create to be called once:
- $router
- ->expects($this->at(0))
- ->method('create')
- ->with($this->equalTo('ocs.app1.' . $resourceName . '.index'), $this->equalTo($url))
- ->willReturn($indexRoute);
-
- $router
- ->expects($this->at(1))
- ->method('create')
- ->with($this->equalTo('ocs.app1.' . $resourceName . '.show'), $this->equalTo($urlWithParam))
- ->willReturn($showRoute);
-
- $router
- ->expects($this->at(2))
- ->method('create')
- ->with($this->equalTo('ocs.app1.' . $resourceName . '.create'), $this->equalTo($url))
- ->willReturn($createRoute);
-
- $router
- ->expects($this->at(3))
- ->method('create')
- ->with($this->equalTo('ocs.app1.' . $resourceName . '.update'), $this->equalTo($urlWithParam))
- ->willReturn($updateRoute);
-
+ // we expect create to be called five times:
$router
- ->expects($this->at(4))
+ ->expects($this->exactly(5))
->method('create')
- ->with($this->equalTo('ocs.app1.' . $resourceName . '.destroy'), $this->equalTo($urlWithParam))
- ->willReturn($destroyRoute);
+ ->withConsecutive(
+ [$this->equalTo('ocs.app1.' . $resourceName . '.index'), $this->equalTo($url)],
+ [$this->equalTo('ocs.app1.' . $resourceName . '.show'), $this->equalTo($urlWithParam)],
+ [$this->equalTo('ocs.app1.' . $resourceName . '.create'), $this->equalTo($url)],
+ [$this->equalTo('ocs.app1.' . $resourceName . '.update'), $this->equalTo($urlWithParam)],
+ [$this->equalTo('ocs.app1.' . $resourceName . '.destroy'), $this->equalTo($urlWithParam)],
+ )->willReturnOnConsecutiveCalls(
+ $indexRoute,
+ $showRoute,
+ $createRoute,
+ $updateRoute,
+ $destroyRoute,
+ );
// load route configuration
$config = new RouteConfig($container, $router, $yaml);
@@ -364,36 +351,23 @@ class RoutingTest extends \Test\TestCase {
$urlWithParam = $url . '/{' . $paramName . '}';
- // we expect create to be called once:
- $router
- ->expects($this->at(0))
- ->method('create')
- ->with($this->equalTo('app1.' . $resourceName . '.index'), $this->equalTo($url))
- ->willReturn($indexRoute);
-
- $router
- ->expects($this->at(1))
- ->method('create')
- ->with($this->equalTo('app1.' . $resourceName . '.show'), $this->equalTo($urlWithParam))
- ->willReturn($showRoute);
-
- $router
- ->expects($this->at(2))
- ->method('create')
- ->with($this->equalTo('app1.' . $resourceName . '.create'), $this->equalTo($url))
- ->willReturn($createRoute);
-
- $router
- ->expects($this->at(3))
- ->method('create')
- ->with($this->equalTo('app1.' . $resourceName . '.update'), $this->equalTo($urlWithParam))
- ->willReturn($updateRoute);
-
+ // we expect create to be called five times:
$router
- ->expects($this->at(4))
+ ->expects($this->exactly(5))
->method('create')
- ->with($this->equalTo('app1.' . $resourceName . '.destroy'), $this->equalTo($urlWithParam))
- ->willReturn($destroyRoute);
+ ->withConsecutive(
+ [$this->equalTo('app1.' . $resourceName . '.index'), $this->equalTo($url)],
+ [$this->equalTo('app1.' . $resourceName . '.show'), $this->equalTo($urlWithParam)],
+ [$this->equalTo('app1.' . $resourceName . '.create'), $this->equalTo($url)],
+ [$this->equalTo('app1.' . $resourceName . '.update'), $this->equalTo($urlWithParam)],
+ [$this->equalTo('app1.' . $resourceName . '.destroy'), $this->equalTo($urlWithParam)],
+ )->willReturnOnConsecutiveCalls(
+ $indexRoute,
+ $showRoute,
+ $createRoute,
+ $updateRoute,
+ $destroyRoute,
+ );
// load route configuration
$config = new RouteConfig($container, $router, $yaml);
diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
index 1d856252745..b52e1d2745e 100644
--- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
@@ -92,19 +92,20 @@ class LookupPluginTest extends TestCase {
->method('getAppValue')
->with('files_sharing', 'lookupServerEnabled', 'yes')
->willReturn('yes');
- $this->config->expects($this->at(0))
+ $this->config->expects($this->exactly(2))
->method('getSystemValue')
- ->with('gs.enabled', false)
- ->willReturn(false);
+ ->withConsecutive(
+ ['gs.enabled', false],
+ ['lookup_server', 'https://lookup.nextcloud.com'],
+ )->willReturnOnConsecutiveCalls(
+ false,
+ '',
+ );
- $this->config->expects($this->at(2))
+ $this->config->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
- $this->config->expects($this->at(3))
- ->method('getSystemValue')
- ->with('lookup_server', 'https://lookup.nextcloud.com')
- ->willReturn('');
$this->clientService->expects($this->never())
->method('newClient');
@@ -120,12 +121,12 @@ class LookupPluginTest extends TestCase {
->method('getAppValue')
->with('files_sharing', 'lookupServerEnabled', 'yes')
->willReturn('yes');
- $this->config->expects($this->at(0))
+ $this->config->expects($this->once())
->method('getSystemValue')
->with('gs.enabled', false)
->willReturn(false);
- $this->config->expects($this->at(2))
+ $this->config->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(false);
@@ -156,19 +157,20 @@ class LookupPluginTest extends TestCase {
->method('getAppValue')
->with('files_sharing', 'lookupServerEnabled', 'yes')
->willReturn('yes');
- $this->config->expects($this->at(0))
+ $this->config->expects($this->exactly(2))
->method('getSystemValue')
- ->with('gs.enabled', false)
- ->willReturn(false);
+ ->withConsecutive(
+ ['gs.enabled', false],
+ ['lookup_server', 'https://lookup.nextcloud.com'],
+ )->willReturnOnConsecutiveCalls(
+ false,
+ $searchParams['server'],
+ );
- $this->config->expects($this->at(2))
+ $this->config->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
- $this->config->expects($this->at(3))
- ->method('getSystemValue')
- ->with('lookup_server', 'https://lookup.nextcloud.com')
- ->willReturn($searchParams['server']);
$response = $this->createMock(IResponse::class);
$response->expects($this->once())
@@ -215,23 +217,24 @@ class LookupPluginTest extends TestCase {
->method('getAppValue')
->with('files_sharing', 'lookupServerEnabled', 'yes')
->willReturn($LookupEnabled ? 'yes' : 'no');
- $this->config->expects($this->at(0))
- ->method('getSystemValue')
- ->with('gs.enabled', false)
- ->willReturn($GSEnabled);
if ($GSEnabled || $LookupEnabled) {
$searchResult->expects($this->once())
->method('addResultSet')
->with($type, $searchParams['expectedResult'], []);
- $this->config->expects($this->at(2))
+ $this->config->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
- $this->config->expects($this->at(3))
+ $this->config->expects($this->exactly(2))
->method('getSystemValue')
- ->with('lookup_server', 'https://lookup.nextcloud.com')
- ->willReturn($searchParams['server']);
+ ->withConsecutive(
+ ['gs.enabled', false],
+ ['lookup_server', 'https://lookup.nextcloud.com'],
+ )->willReturnOnConsecutiveCalls(
+ $GSEnabled,
+ $searchParams['server'],
+ );
$response = $this->createMock(IResponse::class);
$response->expects($this->once())
@@ -252,6 +255,10 @@ class LookupPluginTest extends TestCase {
->willReturn($client);
} else {
$searchResult->expects($this->never())->method('addResultSet');
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with('gs.enabled', false)
+ ->willReturn($GSEnabled);
}
$moreResults = $this->plugin->search(
$searchParams['search'],
diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
index 20e1ed898ad..2c8297014d2 100644
--- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
@@ -23,9 +23,6 @@
namespace Test\Collaboration\Collaborators;
-use OC\Collaboration\Collaborators\SearchResult;
-use OC\Collaboration\Collaborators\UserPlugin;
-use OC\KnownUser\KnownUserService;
use OCP\Collaboration\Collaborators\ISearchResult;
use OCP\IConfig;
use OCP\IGroup;
@@ -35,25 +32,29 @@ use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\IShare;
use OCP\UserStatus\IManager as IUserStatusManager;
+use OC\Collaboration\Collaborators\SearchResult;
+use OC\Collaboration\Collaborators\UserPlugin;
+use OC\KnownUser\KnownUserService;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class UserPluginTest extends TestCase {
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|MockObject */
protected $config;
- /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUserManager|MockObject */
protected $userManager;
- /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IGroupManager|MockObject */
protected $groupManager;
- /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUserSession|MockObject */
protected $session;
- /** @var KnownUserService|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var KnownUserService|MockObject */
protected $knownUserService;
- /** @var IUserStatusManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUserStatusManager|MockObject */
protected $userStatusManager;
/** @var UserPlugin */
@@ -62,13 +63,11 @@ class UserPluginTest extends TestCase {
/** @var ISearchResult */
protected $searchResult;
- /** @var int */
- protected $limit = 2;
+ protected int $limit = 2;
- /** @var int */
- protected $offset = 0;
+ protected int $offset = 0;
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUser|MockObject */
protected $user;
protected function setUp(): void {
@@ -798,13 +797,15 @@ class UserPluginTest extends TestCase {
$this->session->expects($this->any())
->method('getUser')
->willReturn($this->getUserMock('test', 'foo'));
- // current user
- $this->groupManager->expects($this->at(0))
- ->method('getUserGroupIds')
- ->willReturn($userGroups);
$this->groupManager->expects($this->any())
->method('getUserGroupIds')
- ->willReturnCallback(function ($user) use ($matchingUsers) {
+ ->willReturnCallback(function ($user) use ($matchingUsers, $userGroups) {
+ static $firstCall = true;
+ if ($firstCall) {
+ $firstCall = false;
+ // current user
+ return $userGroups;
+ }
$neededObject = array_filter(
$matchingUsers,
function ($e) use ($user) {
diff --git a/tests/lib/Collaboration/Resources/ProviderManagerTest.php b/tests/lib/Collaboration/Resources/ProviderManagerTest.php
index 01e45de9fdf..8f408418409 100644
--- a/tests/lib/Collaboration/Resources/ProviderManagerTest.php
+++ b/tests/lib/Collaboration/Resources/ProviderManagerTest.php
@@ -91,14 +91,15 @@ class ProviderManagerTest extends TestCase {
}
public function testGetResourceProvidersValidAndInvalidProvider(): void {
- $this->serverContainer->expects($this->at(0))
+ $this->serverContainer->expects($this->exactly(2))
->method('query')
- ->with($this->equalTo('InvalidResourceProvider'))
- ->willThrowException(new QueryException('A meaningful error message'));
- $this->serverContainer->expects($this->at(1))
- ->method('query')
- ->with($this->equalTo(ResourceProvider::class))
- ->willReturn($this->createMock(ResourceProvider::class));
+ ->withConsecutive(
+ [$this->equalTo('InvalidResourceProvider')],
+ [$this->equalTo(ResourceProvider::class)],
+ )->willReturnOnConsecutiveCalls(
+ $this->throwException(new QueryException('A meaningful error message')),
+ $this->createMock(ResourceProvider::class),
+ );
$this->logger->expects($this->once())
->method('error');
diff --git a/tests/lib/Command/Integrity/SignAppTest.php b/tests/lib/Command/Integrity/SignAppTest.php
index fefed296a0c..66005ca06f5 100644
--- a/tests/lib/Command/Integrity/SignAppTest.php
+++ b/tests/lib/Command/Integrity/SignAppTest.php
@@ -56,25 +56,24 @@ class SignAppTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('path')
- ->willReturn(null);
- $inputInterface
- ->expects($this->at(1))
- ->method('getOption')
- ->with('privateKey')
- ->willReturn('PrivateKey');
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('certificate')
- ->willReturn('Certificate');
+ ->withConsecutive(
+ ['path'],
+ ['privateKey'],
+ ['certificate'],
+ )->willReturnOnConsecutiveCalls(
+ null,
+ 'PrivateKey',
+ 'Certificate',
+ );
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('This command requires the --path, --privateKey and --certificate.');
+ ->withConsecutive(
+ ['This command requires the --path, --privateKey and --certificate.']
+ );
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -84,25 +83,24 @@ class SignAppTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('path')
- ->willReturn('AppId');
- $inputInterface
- ->expects($this->at(1))
- ->method('getOption')
- ->with('privateKey')
- ->willReturn(null);
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('certificate')
- ->willReturn('Certificate');
+ ->withConsecutive(
+ ['path'],
+ ['privateKey'],
+ ['certificate'],
+ )->willReturnOnConsecutiveCalls(
+ 'AppId',
+ null,
+ 'Certificate',
+ );
$outputInterface
- ->expects($this->at(0))
- ->method('writeln')
- ->with('This command requires the --path, --privateKey and --certificate.');
+ ->expects($this->any())
+ ->method('writeln')
+ ->withConsecutive(
+ ['This command requires the --path, --privateKey and --certificate.']
+ );
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -112,25 +110,24 @@ class SignAppTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('path')
- ->willReturn('AppId');
- $inputInterface
- ->expects($this->at(1))
- ->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('certificate')
- ->willReturn(null);
+ ->withConsecutive(
+ ['path'],
+ ['privateKey'],
+ ['certificate'],
+ )->willReturnOnConsecutiveCalls(
+ 'AppId',
+ 'privateKey',
+ null,
+ );
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('This command requires the --path, --privateKey and --certificate.');
+ ->withConsecutive(
+ ['This command requires the --path, --privateKey and --certificate.']
+ );
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -140,31 +137,31 @@ class SignAppTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('path')
- ->willReturn('AppId');
- $inputInterface
- ->expects($this->at(1))
- ->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('certificate')
- ->willReturn('certificate');
+ ->withConsecutive(
+ ['path'],
+ ['privateKey'],
+ ['certificate'],
+ )->willReturnOnConsecutiveCalls(
+ 'AppId',
+ 'privateKey',
+ 'certificate',
+ );
$this->fileAccessHelper
- ->expects($this->at(0))
+ ->expects($this->any())
->method('file_get_contents')
- ->with('privateKey')
- ->willReturn(false);
+ ->withConsecutive(['privateKey'])
+ ->willReturnOnConsecutiveCalls(false);
+
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('Private key "privateKey" does not exists.');
+ ->withConsecutive(
+ ['Private key "privateKey" does not exists.']
+ );
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -174,36 +171,36 @@ class SignAppTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('path')
- ->willReturn('AppId');
- $inputInterface
- ->expects($this->at(1))
- ->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('certificate')
- ->willReturn('certificate');
+ ->withConsecutive(
+ ['path'],
+ ['privateKey'],
+ ['certificate'],
+ )->willReturnOnConsecutiveCalls(
+ 'AppId',
+ 'privateKey',
+ 'certificate',
+ );
$this->fileAccessHelper
- ->expects($this->at(0))
+ ->expects($this->any())
->method('file_get_contents')
- ->with('privateKey')
- ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key');
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with('certificate')
- ->willReturn(false);
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ \OC::$SERVERROOT . '/tests/data/integritycheck/core.key',
+ false
+ );
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('Certificate "certificate" does not exists.');
+ ->withConsecutive(
+ ['Certificate "certificate" does not exists.']
+ );
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -213,31 +210,29 @@ class SignAppTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
- ->method('getOption')
- ->with('path')
- ->willReturn('AppId');
- $inputInterface
- ->expects($this->at(1))
- ->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(2))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('certificate')
- ->willReturn('certificate');
+ ->withConsecutive(
+ ['path'],
+ ['privateKey'],
+ ['certificate'],
+ )->willReturnOnConsecutiveCalls(
+ 'AppId',
+ 'privateKey',
+ 'certificate',
+ );
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with('privateKey')
- ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
- $this->fileAccessHelper
- ->expects($this->at(1))
+ ->expects($this->any())
->method('file_get_contents')
- ->with('certificate')
- ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
+ file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
+ );
$this->checker
->expects($this->once())
@@ -245,9 +240,11 @@ class SignAppTest extends TestCase {
->willThrowException(new \Exception('My error message'));
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('Error: My error message');
+ ->withConsecutive(
+ ['Error: My error message']
+ );
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -257,40 +254,40 @@ class SignAppTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
- ->method('getOption')
- ->with('path')
- ->willReturn('AppId');
- $inputInterface
- ->expects($this->at(1))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('certificate')
- ->willReturn('certificate');
+ ->withConsecutive(
+ ['path'],
+ ['privateKey'],
+ ['certificate'],
+ )->willReturnOnConsecutiveCalls(
+ 'AppId',
+ 'privateKey',
+ 'certificate',
+ );
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with('privateKey')
- ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
- $this->fileAccessHelper
- ->expects($this->at(1))
+ ->expects($this->any())
->method('file_get_contents')
- ->with('certificate')
- ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
+ file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
+ );
$this->checker
->expects($this->once())
->method('writeAppSignature');
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('Successfully signed "AppId"');
+ ->withConsecutive(
+ ['Successfully signed "AppId"']
+ );
$this->assertSame(0, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
diff --git a/tests/lib/Command/Integrity/SignCoreTest.php b/tests/lib/Command/Integrity/SignCoreTest.php
index 3b7fe7f3a8b..d67e2a9e2b4 100644
--- a/tests/lib/Command/Integrity/SignCoreTest.php
+++ b/tests/lib/Command/Integrity/SignCoreTest.php
@@ -51,20 +51,24 @@ class SignCoreTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('privateKey')
- ->willReturn(null);
- $inputInterface
- ->expects($this->at(1))
- ->method('getOption')
- ->with('certificate')
- ->willReturn('Certificate');
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ ['path'],
+ )->willReturnOnConsecutiveCalls(
+ null,
+ 'certificate',
+ 'certificate',
+ );
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('--privateKey, --certificate and --path are required.');
+ ->withConsecutive(
+ ['--privateKey, --certificate and --path are required.']
+ );
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -74,20 +78,24 @@ class SignCoreTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
- ->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(1))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('certificate')
- ->willReturn(null);
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ ['path'],
+ )->willReturnOnConsecutiveCalls(
+ 'privateKey',
+ null,
+ 'certificate',
+ );
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('--privateKey, --certificate and --path are required.');
+ ->withConsecutive(
+ ['--privateKey, --certificate and --path are required.']
+ );
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -97,31 +105,34 @@ class SignCoreTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
- ->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(1))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('certificate')
- ->willReturn('certificate');
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('path')
- ->willReturn('certificate');
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ ['path'],
+ )->willReturnOnConsecutiveCalls(
+ 'privateKey',
+ 'certificate',
+ 'certificate',
+ );
$this->fileAccessHelper
- ->expects($this->at(0))
+ ->expects($this->any())
->method('file_get_contents')
- ->with('privateKey')
- ->willReturn(false);
+ ->withConsecutive(
+ ['privateKey'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ false,
+ );
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('Private key "privateKey" does not exists.');
+ ->withConsecutive(
+ ['Private key "privateKey" does not exists.']
+ );
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -131,36 +142,36 @@ class SignCoreTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
- ->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(1))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('certificate')
- ->willReturn('certificate');
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('path')
- ->willReturn('certificate');
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ ['path'],
+ )->willReturnOnConsecutiveCalls(
+ 'privateKey',
+ 'certificate',
+ 'certificate',
+ );
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with('privateKey')
- ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
- $this->fileAccessHelper
- ->expects($this->at(1))
+ ->expects($this->any())
->method('file_get_contents')
- ->with('certificate')
- ->willReturn(false);
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
+ false,
+ );
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('Certificate "certificate" does not exists.');
+ ->withConsecutive(
+ ['Certificate "certificate" does not exists.']
+ );
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -170,31 +181,29 @@ class SignCoreTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(1))
- ->method('getOption')
- ->with('certificate')
- ->willReturn('certificate');
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('path')
- ->willReturn('certificate');
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ ['path'],
+ )->willReturnOnConsecutiveCalls(
+ 'privateKey',
+ 'certificate',
+ 'certificate',
+ );
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with('privateKey')
- ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
- $this->fileAccessHelper
- ->expects($this->at(1))
+ ->expects($this->any())
->method('file_get_contents')
- ->with('certificate')
- ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
+ file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
+ );
$this->checker
->expects($this->once())
@@ -202,9 +211,11 @@ class SignCoreTest extends TestCase {
->willThrowException(new \Exception('My exception message'));
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('Error: My exception message');
+ ->withConsecutive(
+ ['Error: My exception message']
+ );
$this->assertEquals(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -214,40 +225,40 @@ class SignCoreTest extends TestCase {
$outputInterface = $this->createMock(OutputInterface::class);
$inputInterface
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getOption')
- ->with('privateKey')
- ->willReturn('privateKey');
- $inputInterface
- ->expects($this->at(1))
- ->method('getOption')
- ->with('certificate')
- ->willReturn('certificate');
- $inputInterface
- ->expects($this->at(2))
- ->method('getOption')
- ->with('path')
- ->willReturn('certificate');
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ ['path'],
+ )->willReturnOnConsecutiveCalls(
+ 'privateKey',
+ 'certificate',
+ 'certificate',
+ );
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with('privateKey')
- ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
- $this->fileAccessHelper
- ->expects($this->at(1))
+ ->expects($this->any())
->method('file_get_contents')
- ->with('certificate')
- ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
+ ->withConsecutive(
+ ['privateKey'],
+ ['certificate'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
+ file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
+ );
$this->checker
->expects($this->once())
->method('writeCoreSignature');
$outputInterface
- ->expects($this->at(0))
+ ->expects($this->any())
->method('writeln')
- ->with('Successfully signed "core"');
+ ->withConsecutive(
+ ['Successfully signed "core"']
+ );
$this->assertEquals(0, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php
index 206fe1a3798..3d115f25adf 100644
--- a/tests/lib/DB/MigrationsTest.php
+++ b/tests/lib/DB/MigrationsTest.php
@@ -115,12 +115,12 @@ class MigrationsTest extends \Test\TestCase {
->willReturn($wrappedSchema);
$step = $this->createMock(IMigrationStep::class);
- $step->expects($this->at(0))
+ $step->expects($this->once())
->method('preSchemaChange');
- $step->expects($this->at(1))
+ $step->expects($this->once())
->method('changeSchema')
->willReturn($schemaResult);
- $step->expects($this->at(2))
+ $step->expects($this->once())
->method('postSchemaChange');
$this->migrationService = $this->getMockBuilder(MigrationService::class)
@@ -145,12 +145,12 @@ class MigrationsTest extends \Test\TestCase {
->method('migrateToSchema');
$step = $this->createMock(IMigrationStep::class);
- $step->expects($this->at(0))
+ $step->expects($this->once())
->method('preSchemaChange');
- $step->expects($this->at(1))
+ $step->expects($this->once())
->method('changeSchema')
->willReturn(null);
- $step->expects($this->at(2))
+ $step->expects($this->once())
->method('postSchemaChange');
$this->migrationService = $this->getMockBuilder(MigrationService::class)
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index 90ff045a9b9..92ed2dcd701 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -224,12 +224,12 @@ class DecryptAllTest extends TestCase {
$this->userInterface->expects($this->any())
->method('getUsers')
->willReturn(['user1', 'user2']);
- $instance->expects($this->at(0))
+ $instance->expects($this->exactly(2))
->method('decryptUsersFiles')
- ->with('user1');
- $instance->expects($this->at(1))
- ->method('decryptUsersFiles')
- ->with('user2');
+ ->withConsecutive(
+ ['user1'],
+ ['user2'],
+ );
} else {
$instance->expects($this->once())
->method('decryptUsersFiles')
@@ -269,17 +269,18 @@ class DecryptAllTest extends TestCase {
$sharedStorage->expects($this->once())->method('instanceOfStorage')
->with('OCA\Files_Sharing\SharedStorage')->willReturn(true);
- $this->view->expects($this->at(0))->method('getDirectoryContent')
- ->with('/user1/files')->willReturn(
+ $this->view->expects($this->exactly(2))
+ ->method('getDirectoryContent')
+ ->withConsecutive(
+ ['/user1/files'],
+ ['/user1/files/foo']
+ )
+ ->willReturnOnConsecutiveCalls(
[
new FileInfo('path', $storage, 'intPath', ['name' => 'foo', 'type' => 'dir'], null),
new FileInfo('path', $storage, 'intPath', ['name' => 'bar', 'type' => 'file', 'encrypted' => true], null),
new FileInfo('path', $sharedStorage, 'intPath', ['name' => 'shared', 'type' => 'file', 'encrypted' => true], null),
- ]
- );
-
- $this->view->expects($this->at(3))->method('getDirectoryContent')
- ->with('/user1/files/foo')->willReturn(
+ ],
[
new FileInfo('path', $storage, 'intPath', ['name' => 'subfile', 'type' => 'file', 'encrypted' => true], null)
]
@@ -295,12 +296,12 @@ class DecryptAllTest extends TestCase {
}
);
- $instance->expects($this->at(0))
- ->method('decryptFile')
- ->with('/user1/files/bar');
- $instance->expects($this->at(1))
+ $instance->expects($this->exactly(2))
->method('decryptFile')
- ->with('/user1/files/foo/subfile');
+ ->withConsecutive(
+ ['/user1/files/bar'],
+ ['/user1/files/foo/subfile'],
+ );
/* We need format method to return a string */
diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php
index 30680646f73..bb7bbbcd7c1 100644
--- a/tests/lib/Encryption/Keys/StorageTest.php
+++ b/tests/lib/Encryption/Keys/StorageTest.php
@@ -162,21 +162,21 @@ class StorageTest extends TestCase {
->method('isSystemWideMountPoint')
->willReturn(false);
- $this->view->expects($this->at(0))
- ->method('file_exists')
- ->with($this->equalTo('/user1/files_encryption/keys' . $strippedPartialName . '/encModule/fileKey'))
- ->willReturn($originalKeyExists);
-
$this->crypto->method('decrypt')
->willReturnCallback(function ($data, $pass) {
return $data;
});
if (!$originalKeyExists) {
- $this->view->expects($this->at(1))
+ $this->view->expects($this->exactly(2))
->method('file_exists')
- ->with($this->equalTo('/user1/files_encryption/keys' . $path . '/encModule/fileKey'))
- ->willReturn(true);
+ ->withConsecutive(
+ [$this->equalTo('/user1/files_encryption/keys' . $strippedPartialName . '/encModule/fileKey')],
+ [$this->equalTo('/user1/files_encryption/keys' . $path . '/encModule/fileKey')],
+ )->willReturnOnConsecutiveCalls(
+ $originalKeyExists,
+ true,
+ );
$this->view->expects($this->once())
->method('file_get_contents')
@@ -184,6 +184,11 @@ class StorageTest extends TestCase {
->willReturn(json_encode(['key' => base64_encode('key2')]));
} else {
$this->view->expects($this->once())
+ ->method('file_exists')
+ ->with($this->equalTo('/user1/files_encryption/keys' . $strippedPartialName . '/encModule/fileKey'))
+ ->willReturn($originalKeyExists);
+
+ $this->view->expects($this->once())
->method('file_get_contents')
->with($this->equalTo('/user1/files_encryption/keys' . $strippedPartialName . '/encModule/fileKey'))
->willReturn(json_encode(['key' => base64_encode('key')]));
@@ -627,10 +632,11 @@ class StorageTest extends TestCase {
->with('user1/files_encryption/backup')->willReturn(!$createBackupDir);
if ($createBackupDir) {
- $this->view->expects($this->at(1))->method('mkdir')
- ->with('user1/files_encryption/backup');
- $this->view->expects($this->at(2))->method('mkdir')
- ->with('user1/files_encryption/backup/test.encryptionModule.1234567');
+ $this->view->expects($this->exactly(2))->method('mkdir')
+ ->withConsecutive(
+ ['user1/files_encryption/backup'],
+ ['user1/files_encryption/backup/test.encryptionModule.1234567'],
+ );
} else {
$this->view->expects($this->once())->method('mkdir')
->with('user1/files_encryption/backup/test.encryptionModule.1234567');
diff --git a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
index 5dc93660d9c..7ce87140122 100644
--- a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
+++ b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
@@ -201,17 +201,17 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
}
public function testMultiBucketConfigFirstFallBackSingle() {
- $this->config->expects($this->at(0))
- ->method('getSystemValue')
- ->with($this->equalTo('objectstore_multibucket'))
- ->willReturn('');
-
- $this->config->expects($this->at(1))
+ $this->config->expects($this->exactly(2))
->method('getSystemValue')
- ->with($this->equalTo('objectstore'))
- ->willReturn([
- 'class' => 'Test\Files\Mount\FakeObjectStore',
- ]);
+ ->withConsecutive(
+ [$this->equalTo('objectstore_multibucket')],
+ [$this->equalTo('objectstore')],
+ )->willReturnOnConsecutiveCalls(
+ '',
+ [
+ 'class' => 'Test\Files\Mount\FakeObjectStore',
+ ],
+ );
$this->user->method('getUID')
->willReturn('uid');
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 7b735720ff1..37cd8414a05 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -2643,44 +2643,31 @@ class ViewTest extends \Test\TestCase {
])
->getMock();
- $view
- ->expects($this->at(0))
- ->method('is_file')
- ->with('/new')
- ->willReturn(false);
- $view
- ->expects($this->at(1))
- ->method('file_exists')
- ->with('/new')
- ->willReturn(true);
- $view
- ->expects($this->at(2))
- ->method('is_file')
- ->with('/new/folder')
- ->willReturn(false);
- $view
- ->expects($this->at(3))
- ->method('file_exists')
- ->with('/new/folder')
- ->willReturn(false);
- $view
- ->expects($this->at(4))
- ->method('mkdir')
- ->with('/new/folder');
- $view
- ->expects($this->at(5))
+ $view->expects($this->exactly(3))
->method('is_file')
- ->with('/new/folder/structure')
+ ->withConsecutive(
+ ['/new'],
+ ['/new/folder'],
+ ['/new/folder/structure'],
+ )
->willReturn(false);
- $view
- ->expects($this->at(6))
+ $view->expects($this->exactly(3))
->method('file_exists')
- ->with('/new/folder/structure')
- ->willReturn(false);
- $view
- ->expects($this->at(7))
+ ->withConsecutive(
+ ['/new'],
+ ['/new/folder'],
+ ['/new/folder/structure'],
+ )->willReturnOnConsecutiveCalls(
+ true,
+ false,
+ false,
+ );
+ $view->expects($this->exactly(2))
->method('mkdir')
- ->with('/new/folder/structure');
+ ->withConsecutive(
+ ['/new/folder'],
+ ['/new/folder/structure'],
+ );
$this->assertTrue(self::invokePrivate($view, 'createParentDirectories', ['/new/folder/structure']));
}
diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php
index 63835a4d4cd..141c6190cd9 100644
--- a/tests/lib/Http/Client/ClientTest.php
+++ b/tests/lib/Http/Client/ClientTest.php
@@ -75,35 +75,33 @@ class ClientTest extends \Test\TestCase {
public function testGetProxyUriProxyHostWithPassword(): void {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(3))
->method('getSystemValue')
- ->with(
- $this->equalTo('proxy'),
- $this->callback(function ($input) {
- return $input === '';
- })
+ ->withConsecutive(
+ [
+ $this->equalTo('proxy'),
+ $this->callback(function ($input) {
+ return $input === '';
+ })
+ ],
+ [
+ $this->equalTo('proxyuserpwd'),
+ $this->callback(function ($input) {
+ return $input === '';
+ })
+ ],
+ [
+ $this->equalTo('proxyexclude'),
+ $this->callback(function ($input) {
+ return $input === [];
+ })
+ ],
)
- ->willReturn('foo');
- $this->config
- ->expects($this->at(1))
- ->method('getSystemValue')
- ->with(
- $this->equalTo('proxyuserpwd'),
- $this->callback(function ($input) {
- return $input === '';
- })
- )
- ->willReturn('username:password');
- $this->config
- ->expects($this->at(2))
- ->method('getSystemValue')
- ->with(
- $this->equalTo('proxyexclude'),
- $this->callback(function ($input) {
- return $input === [];
- })
- )
- ->willReturn([]);
+ ->willReturnOnConsecutiveCalls(
+ 'foo',
+ 'username:password',
+ [],
+ );
$this->assertEquals([
'http' => 'username:password@foo',
'https' => 'username:password@foo'
@@ -112,35 +110,33 @@ class ClientTest extends \Test\TestCase {
public function testGetProxyUriProxyHostWithPasswordAndExclude(): void {
$this->config
- ->expects($this->at(0))
- ->method('getSystemValue')
- ->with(
- $this->equalTo('proxy'),
- $this->callback(function ($input) {
- return $input === '';
- })
- )
- ->willReturn('foo');
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(3))
->method('getSystemValue')
- ->with(
- $this->equalTo('proxyuserpwd'),
- $this->callback(function ($input) {
- return $input === '';
- })
+ ->withConsecutive(
+ [
+ $this->equalTo('proxy'),
+ $this->callback(function ($input) {
+ return $input === '';
+ })
+ ],
+ [
+ $this->equalTo('proxyuserpwd'),
+ $this->callback(function ($input) {
+ return $input === '';
+ })
+ ],
+ [
+ $this->equalTo('proxyexclude'),
+ $this->callback(function ($input) {
+ return $input === [];
+ })
+ ],
)
- ->willReturn('username:password');
- $this->config
- ->expects($this->at(2))
- ->method('getSystemValue')
- ->with(
- $this->equalTo('proxyexclude'),
- $this->callback(function ($input) {
- return $input === [];
- })
- )
- ->willReturn(['bar']);
+ ->willReturnOnConsecutiveCalls(
+ 'foo',
+ 'username:password',
+ ['bar'],
+ );
$this->assertEquals([
'http' => 'username:password@foo',
'https' => 'username:password@foo',
@@ -469,10 +465,16 @@ class ClientTest extends \Test\TestCase {
public function testSetDefaultOptionsWithNotInstalled(): void {
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('installed', false)
- ->willReturn(false);
+ ->withConsecutive(
+ ['proxy', ''],
+ ['installed', false],
+ )
+ ->willReturnOnConsecutiveCalls(
+ '',
+ false,
+ );
$this->certificateManager
->expects($this->never())
->method('listCertificates');
@@ -500,20 +502,20 @@ class ClientTest extends \Test\TestCase {
public function testSetDefaultOptionsWithProxy(): void {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(4))
->method('getSystemValue')
- ->with('proxy', null)
- ->willReturn('foo');
- $this->config
- ->expects($this->at(1))
- ->method('getSystemValue')
- ->with('proxyuserpwd', null)
- ->willReturn(null);
- $this->config
- ->expects($this->at(2))
- ->method('getSystemValue')
- ->with('proxyexclude', [])
- ->willReturn([]);
+ ->withConsecutive(
+ ['proxy', ''],
+ ['proxyuserpwd', ''],
+ ['proxyexclude', []],
+ ['installed', false],
+ )
+ ->willReturnOnConsecutiveCalls(
+ 'foo',
+ '',
+ [],
+ true,
+ );
$this->certificateManager
->expects($this->once())
->method('getAbsoluteBundlePath')
@@ -547,20 +549,20 @@ class ClientTest extends \Test\TestCase {
public function testSetDefaultOptionsWithProxyAndExclude(): void {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(4))
->method('getSystemValue')
- ->with('proxy', null)
- ->willReturn('foo');
- $this->config
- ->expects($this->at(1))
- ->method('getSystemValue')
- ->with('proxyuserpwd', null)
- ->willReturn(null);
- $this->config
- ->expects($this->at(2))
- ->method('getSystemValue')
- ->with('proxyexclude', [])
- ->willReturn(['bar']);
+ ->withConsecutive(
+ ['proxy', ''],
+ ['proxyuserpwd', ''],
+ ['proxyexclude', []],
+ ['installed', false],
+ )
+ ->willReturnOnConsecutiveCalls(
+ 'foo',
+ '',
+ ['bar'],
+ true,
+ );
$this->certificateManager
->expects($this->once())
->method('getAbsoluteBundlePath')
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php
index c49f8bf76a5..352580337ad 100644
--- a/tests/lib/InstallerTest.php
+++ b/tests/lib/InstallerTest.php
@@ -340,7 +340,7 @@ u/spPSSVhaun5BA1FlphB2TkgnzlCmxJa63nFY045e/Jq+IKMcqqZl/092gbI2EQ
$realTmpFile = \OC::$server->getTempManager()->getTemporaryFile('.tar.gz');
copy(__DIR__ . '/../data/testapp.tar.gz', $realTmpFile);
$this->tempManager
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getTemporaryFile')
->with('.tar.gz')
->willReturn($realTmpFile);
@@ -418,14 +418,14 @@ YwDVP+QmNRzx72jtqAN/Kc3CvQ9nkgYhU65B95aX0xA=',
$realTmpFile = \OC::$server->getTempManager()->getTemporaryFile('.tar.gz');
copy(__DIR__ . '/../data/testapp1.tar.gz', $realTmpFile);
$this->tempManager
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getTemporaryFile')
->with('.tar.gz')
->willReturn($realTmpFile);
$realTmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
mkdir($realTmpFolder . '/testfolder');
$this->tempManager
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getTemporaryFolder')
->willReturn($realTmpFolder);
$client = $this->createMock(IClient::class);
@@ -502,13 +502,13 @@ YwDVP+QmNRzx72jtqAN/Kc3CvQ9nkgYhU65B95aX0xA=',
$realTmpFile = \OC::$server->getTempManager()->getTemporaryFile('.tar.gz');
copy(__DIR__ . '/../data/testapp1.tar.gz', $realTmpFile);
$this->tempManager
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getTemporaryFile')
->with('.tar.gz')
->willReturn($realTmpFile);
$realTmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->tempManager
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getTemporaryFolder')
->willReturn($realTmpFolder);
$client = $this->createMock(IClient::class);
@@ -575,30 +575,30 @@ MPLX6f5V9tCJtlH6ztmEcDROfvuVc0U3rEhqx2hphoyo+MZrPFpdcJL8KkIdMKbY
],
];
$this->appFetcher
- ->expects($this->at(0))
+ ->expects($this->atLeastOnce())
->method('get')
- ->willReturn($appArray);
+ ->willReturnOnConsecutiveCalls($appArray);
$realTmpFile = \OC::$server->getTempManager()->getTemporaryFile('.tar.gz');
copy(__DIR__ . '/../data/testapp.tar.gz', $realTmpFile);
$this->tempManager
- ->expects($this->at(0))
+ ->expects($this->atLeastOnce())
->method('getTemporaryFile')
->with('.tar.gz')
- ->willReturn($realTmpFile);
+ ->willReturnOnConsecutiveCalls($realTmpFile);
$realTmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->tempManager
- ->expects($this->at(1))
+ ->expects($this->atLeastOnce())
->method('getTemporaryFolder')
- ->willReturn($realTmpFolder);
+ ->willReturnOnConsecutiveCalls($realTmpFolder);
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
$this->clientService
- ->expects($this->at(0))
+ ->expects($this->atLeastOnce())
->method('newClient')
- ->willReturn($client);
+ ->willReturnOnConsecutiveCalls($client);
$installer = $this->getInstaller();
$installer->downloadApp('testapp');
diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php
index be9ecdd9041..37f6885c0ac 100644
--- a/tests/lib/IntegrityCheck/CheckerTest.php
+++ b/tests/lib/IntegrityCheck/CheckerTest.php
@@ -88,12 +88,12 @@ class CheckerTest extends TestCase {
$this->expectExceptionMessage('Exception message');
$this->fileAccessHelper
- ->expects($this->at(0))
+ ->expects($this->once())
->method('assertDirectoryExists')
->with('NotExistingApp/appinfo')
->willThrowException(new \Exception('Exception message'));
$this->fileAccessHelper
- ->expects($this->at(1))
+ ->expects($this->once())
->method('is_writable')
->with('NotExistingApp/appinfo')
->willReturn(true);
@@ -202,19 +202,16 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\r\nKoZIhvcNAQEBBQADggIPADCCAgoCggIBALb6EgHpkAqZbO5vRO8XSh7G7XGWHw5s\r\niOf4RwPXR6SE9bWZEm\/b72SfWk\/\/J6AbrD8WiOzBuT\/ODy6k5T1arEdHO+Pux0W1\r\nMxYJJI4kH74KKgMpC0SB0Rt+8WrMqV1r3hhJ46df6Xr\/xolP3oD+eLbShPcblhdS\r\nVtkZEkoev8Sh6L2wDCeHDyPxzvj1w2dTdGVO9Kztn0xIlyfEBakqvBWtcxyi3Ln0\r\nklnxlMx3tPDUE4kqvpia9qNiB1AN2PV93eNr5\/2riAzIssMFSCarWCx0AKYb54+d\r\nxLpcYFyqPJ0ydBCkF78DD45RCZet6PNYkdzgbqlUWEGGomkuDoJbBg4wzgzO0D77\r\nH87KFhYW8tKFFvF1V3AHl\/sFQ9tDHaxM9Y0pZ2jPp\/ccdiqnmdkBxBDqsiRvHvVB\r\nCn6qpb4vWGFC7vHOBfYspmEL1zLlKXZv3ezMZEZw7O9ZvUP3VO\/wAtd2vUW8UFiq\r\ns2v1QnNLN6jNh51obcwmrBvWhJy9vQIdtIjQbDxqWTHh1zUSrw9wrlklCBZ\/zrM0\r\ni8nfCFwTxWRxp3H9KoECzO\/zS5R5KIS7s3\/wq\/w9T2Ie4rcecgXwDizwnn0C\/aKc\r\nbDIjujpL1s9HO05pcD\/V3wKcPZ1izymBkmMyIbL52iRVN5FTVHeZdXPpFuq+CTQJ\r\nQ238lC+A\/KOVAgMBAAEwDQYJKoZIhvcNAQEFBQADggIBAGoKTnh8RfJV4sQItVC2\r\nAvfJagkrIqZ3iiQTUBQGTKBsTnAqE1H7QgUSV9vSd+8rgvHkyZsRjmtyR1e3A6Ji\r\noNCXUbExC\/0iCPUqdHZIVb+Lc\/vWuv4ByFMybGPydgtLoEUX2ZrKFWmcgZFDUSRd\r\n9Uj26vtUhCC4bU4jgu6hIrR9IuxOBLQUxGTRZyAcXvj7obqRAEZwFAKQgFpfpqTb\r\nH+kjcbZSaAlLVSF7vBc1syyI8RGYbqpwvtREqJtl5IEIwe6huEqJ3zPnlP2th\/55\r\ncf3Fovj6JJgbb9XFxrdnsOsDOu\/tpnaRWlvv5ib4+SzG5wWFT5UUEo4Wg2STQiiX\r\nuVSRQxK1LE1yg84bs3NZk9FSQh4B8vZVuRr5FaJsZZkwlFlhRO\/\/+TJtXRbyNgsf\r\noMRZGi8DLGU2SGEAHcRH\/QZHq\/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- '/resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json'],
+ ['/resources/codesigning/root.crt'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$this->assertSame([], $this->checker->verifyAppSignature('SomeApp'));
}
@@ -244,19 +241,16 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEwTCCAqmgAwIBAgIUWv0iujufs5lUr0svCf\/qTQvoyKAwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIyNDk1M1oXDTE2MTEwMzIyNDk1M1owEjEQMA4GA1UEAwwHU29tZUFwcDCCAiIw\r\nDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK8q0x62agGSRBqeWsaeEwFfepMk\r\nF8cAobMMi50qHCv9IrOn\/ZH9l52xBrbIkErVmRjmly0d4JhD8Ymhidsh9ONKYl\/j\r\n+ishsZDM8eNNdp3Ew+fEYVvY1W7mR1qU24NWj0bzVsClI7hvPVIuw7AjfBDq1C5+\r\nA+ZSLSXYvOK2cEWjdxQfuNZwEZSjmA63DUllBIrm35IaTvfuyhU6BW9yHZxmb8+M\r\nw0xDv30D5UkE\/2N7Pa\/HQJLxCR+3zKibRK3nUyRDLSXxMkU9PnFNaPNX59VPgyj4\r\nGB1CFSToldJVPF4pzh7p36uGXZVxs8m3LFD4Ol8mhi7jkxDZjqFN46gzR0r23Py6\r\ndol9vfawGIoUwp9LvL0S7MvdRY0oazLXwClLP4OQ17zpSMAiCj7fgNT661JamPGj\r\nt5O7Z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ERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- '/resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json'],
+ ['/resources/codesigning/root.crt'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$expected = [
'EXCEPTION' => [
@@ -292,19 +286,16 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\r\nKoZIhvcNAQEBBQADggIPADCCAgoCggIBALb6EgHpkAqZbO5vRO8XSh7G7XGWHw5s\r\niOf4RwPXR6SE9bWZEm\/b72SfWk\/\/J6AbrD8WiOzBuT\/ODy6k5T1arEdHO+Pux0W1\r\nMxYJJI4kH74KKgMpC0SB0Rt+8WrMqV1r3hhJ46df6Xr\/xolP3oD+eLbShPcblhdS\r\nVtkZEkoev8Sh6L2wDCeHDyPxzvj1w2dTdGVO9Kztn0xIlyfEBakqvBWtcxyi3Ln0\r\nklnxlMx3tPDUE4kqvpia9qNiB1AN2PV93eNr5\/2riAzIssMFSCarWCx0AKYb54+d\r\nxLpcYFyqPJ0ydBCkF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kGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//appinfo/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- '/resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//appinfo/signature.json'],
+ ['/resources/codesigning/root.crt'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$expected = [
@@ -355,19 +346,16 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\r\nKoZIhvcNAQEBBQADggIPADCCAgoCggIBALb6EgHpkAqZbO5vRO8XSh7G7XGWHw5s\r\niOf4RwPXR6SE9bWZEm\/b72SfWk\/\/J6AbrD8WiOzBuT\/ODy6k5T1arEdHO+Pux0W1\r\nMxYJJI4kH74KKgMpC0SB0Rt+8WrMqV1r3hhJ46df6Xr\/xolP3oD+eLbShPcblhdS\r\nVtkZEkoev8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q\/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//appinfo/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- '/resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//appinfo/signature.json'],
+ ['/resources/codesigning/root.crt'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$expected = [
@@ -419,17 +407,15 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIExjCCAq6gAwIBAgIUHSJjhJqMwr+3TkoiQFg4SVVYQ1gwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIzMjc1NVoXDTE2MTEwMzIzMjc1NVowFzEVMBMGA1UEAwwMQW5vdGhlclNjb3Bl\r\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA33npb5RmUkXrDT+TbwMf\r\n0zQ33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H9cQ2KykLOb4UoCPlGUqOqKyP9m\r\nDJSFRiMJfpgMQUaJk1TLhKF+IR6FnmwURLEtkONJumtDQju9KaWPlhueONdyGi0p\r\nqxLVUo1Vb52XnPhk2GEEduxpDc9V5ePJ+pdcEdMifY\/uPNBRuBj2c87yq1DLH+U4\r\n3XzP1MlwjnBWZYuoFo0j6Jq0r\/MG6HjGdmkGIsRoheRi8Z8Scz5AW5QRkNz8pKop\r\nTELFqQy9g6TyQzzC8t6HZcpNe842ZUk4raEAbCZe\/XqxWMw5svPgNceBqM3fh7sZ\r\nBSykOHLaL8kiRO\/IS3y1yZEAuiWBvtxcTNLzBb+hdRpm2y8\/qH\/pKo+CMj1VzjNT\r\nD8YRQg0cjmDytJzHDrtV\/aTc9W1aPHun0vw=\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//appinfo/signature.json')
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- '/resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//appinfo/signature.json'],
+ ['/resources/codesigning/root.crt'],
+ )->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$expected = [
'EXCEPTION' => [
@@ -465,17 +451,15 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\n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IrR9IuxOBLQUxGTRZyAcXvj7obqRAEZwFAKQgFpfpqTb\r\nH+kjcbZSaAlLVSF7vBc1syyI8RGYbqpwvtREqJtl5IEIwe6huEqJ3zPnlP2th\/55\r\ncf3Fovj6JJgbb9XFxrdnsOsDOu\/tpnaRWlvv5ib4+SzG5wWFT5UUEo4Wg2STQiiX\r\nuVSRQxK1LE1yg84bs3NZk9FSQh4B8vZVuRr5FaJsZZkwlFlhRO\/\/+TJtXRbyNgsf\r\noMRZGi8DLGU2SGEAHcRH\/QZHq\/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(\OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json')
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- '/resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json'],
+ ['/resources/codesigning/root.crt'],
+ )->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$this->assertSame([], $this->checker->verifyAppSignature('SomeApp'));
}
@@ -486,11 +470,11 @@ class CheckerTest extends TestCase {
$this->expectExceptionMessage('Exception message');
$this->fileAccessHelper
- ->expects($this->at(0))
+ ->expects($this->once())
->method('assertDirectoryExists')
->will($this->throwException(new \Exception('Exception message')));
$this->fileAccessHelper
- ->expects($this->at(1))
+ ->expects($this->once())
->method('is_writable')
->with(__DIR__ . '/core')
->willReturn(true);
@@ -510,11 +494,11 @@ class CheckerTest extends TestCase {
$this->expectExceptionMessageMatches('/[a-zA-Z\\/_-]+ is not writable/');
$this->fileAccessHelper
- ->expects($this->at(0))
+ ->expects($this->once())
->method('assertDirectoryExists')
->will($this->throwException(new \Exception('Exception message')));
$this->fileAccessHelper
- ->expects($this->at(1))
+ ->expects($this->once())
->method('is_writable')
->with(__DIR__ . '/core')
->willReturn(false);
@@ -707,19 +691,15 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\r\nKoZIhvcNAQEBBQADggIPADCCAgoCggIBALb6EgHpkAqZbO5vRO8XSh7G7XGWHw5s\r\niOf4RwPXR6SE9bWZEm\/b72SfWk\/\/J6AbrD8WiOzBuT\/ODy6k5T1arEdHO+Pux0W1\r\nMxYJJI4kH74KKgMpC0SB0Rt+8WrMqV1r3hhJ46df6Xr\/xolP3oD+eLbShPcblhdS\r\nVtkZEkoev8Sh6L2wDCeHDyPxzvj1w2dTdGVO9Kztn0xIlyfEBakqvBWtcxyi3Ln0\r\nklnxlMx3tPDUE4kqvpia9qNiB1AN2PV93eNr5\/2riAzIssMFSCarWCx0AKYb54+d\r\nxLpcYFyqPJ0ydBCkF78DD45RCZet6PNYkdzgbqlUWEGGomkuDoJbBg4wzgzO0D77\r\nH87KFhYW8tKFFvF1V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eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json'],
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt'],
+ )->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$this->assertSame([], $this->checker->verifyCoreSignature());
}
@@ -748,19 +728,16 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\r\nKoZIhvcNAQEBBQADggIPADCCAgoCggIBALb6EgHpkAqZbO5vRO8XSh7G7XGWHw5s\r\niOf4RwPXR6SE9bWZEm\/b72SfWk\/\/J6AbrD8WiOzBuT\/ODy6k5T1arEdHO+Pux0W1\r\nMxYJJI4kH74KKgMpC0SB0Rt+8WrMqV1r3hhJ46df6Xr\/xolP3oD+eLbShPcblhdS\r\nVtkZEkoev8Sh6L2wDCeHDy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SBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent/core/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent/resources/codesigning/root.crt'
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent/core/signature.json'],
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent/resources/codesigning/root.crt'],
)
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$this->assertSame([], $this->checker->verifyCoreSignature());
}
@@ -841,19 +818,15 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\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vBc1syyI8RGYbqpwvtREqJtl5IEIwe6huEqJ3zPnlP2th\/55\r\ncf3Fovj6JJgbb9XFxrdnsOsDOu\/tpnaRWlvv5ib4+SzG5wWFT5UUEo4Wg2STQiiX\r\nuVSRQxK1LE1yg84bs3NZk9FSQh4B8vZVuRr5FaJsZZkwlFlhRO\/\/+TJtXRbyNgsf\r\noMRZGi8DLGU2SGEAHcRH\/QZHq\/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json'],
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt'],
+ )->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$this->assertSame([], $this->checker->verifyCoreSignature());
}
@@ -882,19 +855,15 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjC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QgUSV9vSd+8rgvHkyZsRjmtyR1e3A6Ji\r\noNCXUbExC\/0iCPUqdHZIVb+Lc\/vWuv4ByFMybGPydgtLoEUX2ZrKFWmcgZFDUSRd\r\n9Uj26vtUhCC4bU4jgu6hIrR9IuxOBLQUxGTRZyAcXvj7obqRAEZwFAKQgFpfpqTb\r\nH+kjcbZSaAlLVSF7vBc1syyI8RGYbqpwvtREqJtl5IEIwe6huEqJ3zPnlP2th\/55\r\ncf3Fovj6JJgbb9XFxrdnsOsDOu\/tpnaRWlvv5ib4+SzG5wWFT5UUEo4Wg2STQiiX\r\nuVSRQxK1LE1yg84bs3NZk9FSQh4B8vZVuRr5FaJsZZkwlFlhRO\/\/+TJtXRbyNgsf\r\noMRZGi8DLGU2SGEAHcRH\/QZHq\/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//core/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//core/signature.json'],
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//resources/codesigning/root.crt'],
+ )->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$expected = [
'EXCEPTION' => [
@@ -929,19 +898,15 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\r\nKoZIhvcNAQEBBQADggIPADCCAgoCggIBALb6EgHpkAqZbO5vRO8XSh7G7XGWHw5s\r\niOf4RwPXR6SE9bWZEm\/b72SfWk\/\/J6AbrD8WiOzBuT\/ODy6k5T1arEdHO+Pux0W1\r\nMxYJJI4kH74KKgMpC0SB0Rt+8WrMqV1r3hhJ46df6Xr\/xolP3oD+eLbShPcblhdS\r\nVtkZEkoev8Sh6L2wDCeHDyPxzvj1w2dTdGVO9Kztn0xIlyfEBakqvBWtcxyi3Ln0\r\nklnxlMx3tPDUE4kqvpia9qNiB1AN2PV93eNr5\/2riAzIssMFSCarWCx0AKYb54+d\r\nxLpcYFyqPJ0ydBCkF78DD45RCZet6PNYkdzgbqlUWEGGomkuDoJbBg4wzgzO0D77\r\nH87KFhYW8tKFFvF1V3AHl\/sFQ9tDHaxM9Y0pZ2jPp\/ccdiqnmdkBxBDqsiRvHvVB\r\nCn6qpb4vWGFC7vHOBfYspmEL1zLlKXZv3ezMZEZw7O9ZvUP3VO\/wAtd2vUW8UFiq\r\ns2v1QnNLN6jNh51obcwmrBvWhJy9vQIdtIjQbDxqWTHh1zUSrw9wrlklCBZ\/zrM0\r\ni8nfCFwTxWRxp3H9KoECzO\/zS5R5KIS7s3\/wq\/w9T2Ie4rcecgXwDizwnn0C\/aKc\r\nbDIjujpL1s9HO05pcD\/V3wKcPZ1izymBkmMyIbL52iRVN5FTVHeZdXPpFuq+CTQJ\r\nQ238lC+A\/KOVAgMBAAEwDQYJKoZIhvcNAQEFBQADggIBAGoKTnh8RfJV4sQItVC2\r\nAvfJagkrIqZ3iiQTUBQGTKBsTnAqE1H7QgUSV9vSd+8rgvHkyZsRjmtyR1e3A6Ji\r\noNCXUbExC\/0iCPUqdHZIVb+Lc\/vWuv4ByFMybGPydgtLoEUX2ZrKFWmcgZFDUSRd\r\n9Uj26vtUhCC4bU4jgu6hIrR9IuxOBLQUxGTRZyAcXvj7obqRAEZwFAKQgFpfpqTb\r\nH+kjcbZSaAlLVSF7vBc1syyI8RGYbqpwvtREqJtl5IEIwe6huEqJ3zPnlP2th\/55\r\ncf3Fovj6JJgbb9XFxrdnsOsDOu\/tpnaRWlvv5ib4+SzG5wWFT5UUEo4Wg2STQiiX\r\nuVSRQxK1LE1yg84bs3NZk9FSQh4B8vZVuRr5FaJsZZkwlFlhRO\/\/+TJtXRbyNgsf\r\noMRZGi8DLGU2SGEAHcRH\/QZHq\/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//core/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//core/signature.json'],
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//resources/codesigning/root.crt'],
+ )->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$expected = [
'INVALID_HASH' => [
@@ -991,19 +956,15 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUPYoweUxCPqbDW4ntuh7QvgyqSrgwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIyNDIwNloXDTE2MTEwMzIyNDIwNlowDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\r\nKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJui3nDbjOIjxNnthdBZplphujsN6u8K\r\nQ\/62zAuSwzXVp0+3IMgM\/2sepklVE8YfCyVJ5+SUJqnqHoUWVRVfs8jL0wW6nrHM\r\n\/lsscAguWCee4iAdNOqI9kq4+DUau8J45e62XA9mrAo\/8\/NKzFE2y2WduDoQZcm+\r\n8+dwcUUHXw2jl8dfrmvEMYSqTNDdb4rGmQpeV+dr9BLqr+x03U1Q08qCG9j7mSOz\r\ncvJENjOvC5uzAh5LCuCgxqG4o+mPzB0FtNnwoRRu6IsF3Y3KacRqPc30fB\/iXDn5\r\nBPr14uNxTTYWoZJ1F0tZrLzRbXdjJJOC+dnQurTtXWZ8WjPB1BWQYK7fW6t82mkN\r\n2Qe2xen99gs9nX5yY\/sHM3TKSJdM7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pvlF\/q\r\noj7YKHsaTVGA+FxBktZHfoxD\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json'],
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt'],
+ )->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$expected = [
'EXCEPTION' => [
@@ -1038,19 +999,15 @@ class CheckerTest extends TestCase {
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEwTCCAqmgAwIBAgIUWv0iujufs5lUr0svCf\/qTQvoyKAwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIyNDk1M1oXDTE2MTEwMzIyNDk1M1owEjEQMA4GA1UEAwwHU29tZUFwcDCCAiIw\r\nDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK8q0x62agGSRBqeWsaeEwFfepMk\r\nF8cAobMMi50qHCv9IrOn\/ZH9l52xBrbIkErVmRjmly0d4JhD8Ymhidsh9ONKYl\/j\r\n+ishsZDM8eNNdp3Ew+fEYVvY1W7mR1qU24NWj0bzVsClI7hvPVIuw7AjfBDq1C5+\r\nA+ZSLSXYvOK2cEWjdxQfuNZwEZSjmA63DUllBIrm35IaTvfuyhU6BW9yHZxmb8+M\r\nw0xD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yaafUziPQbWIPfEs7h8tCOWyvW\r\nUO8ZLervYCB3j44ivkrxPlcBklDCqqKKBzDP9dYOtS\/P4RB1NkHA9+NTvmBpTonS\r\nSFXdg9fFMD7VfjDE3Vnk+8DWkVH5wBYowTAD7w9Wuzr7DumiAULexnP\/Y7xwxLv7\r\n4B+pXTAcRK0zECDEaX3npS8xWzrB\r\n-----END CERTIFICATE-----"
}';
$this->fileAccessHelper
- ->expects($this->at(0))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json'
- )
- ->willReturn($signatureDataFile);
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_get_contents')
- ->with(
- \OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt'
- )
- ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'));
+ ->expects($this->exactly(2))
+ ->method('file_get_contents')
+ ->withConsecutive(
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json'],
+ [\OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt'],
+ )->willReturnOnConsecutiveCalls(
+ $signatureDataFile,
+ file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')
+ );
$expected = [
'EXCEPTION' => [
@@ -1079,10 +1036,10 @@ class CheckerTest extends TestCase {
->getMock();
$this->checker
- ->expects($this->at(0))
+ ->expects($this->once())
->method('verifyCoreSignature');
$this->appLocator
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getAllApps')
->willReturn([
'files',
@@ -1091,57 +1048,47 @@ class CheckerTest extends TestCase {
'dav',
]);
$this->appManager
- ->expects($this->at(0))
+ ->expects($this->exactly(4))
->method('isShipped')
- ->with('files')
- ->willReturn(true);
+ ->withConsecutive(
+ ['files'],
+ ['calendar'],
+ ['contacts'],
+ ['dav'],
+ )->willReturnOnConsecutiveCalls(
+ true,
+ false,
+ false,
+ true,
+ );
$this->checker
- ->expects($this->at(1))
+ ->expects($this->exactly(3))
->method('verifyAppSignature')
- ->with('files');
- $this->appManager
- ->expects($this->at(1))
- ->method('isShipped')
- ->with('calendar')
- ->willReturn(false);
+ ->withConsecutive(
+ ['files'],
+ ['calendar'],
+ ['dav'],
+ );
$this->appLocator
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getAppPath')
- ->with('calendar')
- ->willReturn('/apps/calendar');
+ ->withConsecutive(
+ ['calendar'],
+ ['contacts'],
+ )->willReturnOnConsecutiveCalls(
+ '/apps/calendar',
+ '/apps/contacts',
+ );
$this->fileAccessHelper
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('file_exists')
- ->with('/apps/calendar/appinfo/signature.json')
- ->willReturn(true);
- $this->checker
- ->expects($this->at(2))
- ->method('verifyAppSignature')
- ->with('calendar');
- $this->appManager
- ->expects($this->at(2))
- ->method('isShipped')
- ->with('contacts')
- ->willReturn(false);
- $this->appLocator
- ->expects($this->at(2))
- ->method('getAppPath')
- ->with('contacts')
- ->willReturn('/apps/contacts');
- $this->fileAccessHelper
- ->expects($this->at(1))
- ->method('file_exists')
- ->with('/apps/contacts/appinfo/signature.json')
- ->willReturn(false);
- $this->appManager
- ->expects($this->at(3))
- ->method('isShipped')
- ->with('dav')
- ->willReturn(true);
- $this->checker
- ->expects($this->at(3))
- ->method('verifyAppSignature')
- ->with('dav');
+ ->withConsecutive(
+ ['/apps/calendar/appinfo/signature.json'],
+ ['/apps/contacts/appinfo/signature.json'],
+ )->willReturnOnConsecutiveCalls(
+ true,
+ false,
+ );
$this->config
->expects($this->once())
->method('deleteAppValue')
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php
index a2c1e8b5261..faf9dff48cc 100644
--- a/tests/lib/L10N/FactoryTest.php
+++ b/tests/lib/L10N/FactoryTest.php
@@ -105,20 +105,26 @@ class FactoryTest extends TestCase {
public function testFindLanguageWithNotExistingRequestLanguageAndExistingStoredUserLanguage(): void {
$factory = $this->getFactory(['languageExists']);
$this->invokePrivate($factory, 'requestLanguage', ['de']);
- $factory->expects(self::at(0))
+ $factory->expects($this->exactly(2))
->method('languageExists')
- ->with('MyApp', 'de')
- ->willReturn(false);
+ ->withConsecutive(
+ ['MyApp', 'de'],
+ ['MyApp', 'jp'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ false,
+ true,
+ );
$this->config
- ->expects(self::at(0))
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('force_language', false)
- ->willReturn(false);
- $this->config
- ->expects(self::at(1))
- ->method('getSystemValue')
- ->with('installed', false)
- ->willReturn(true);
+ ->withConsecutive(
+ ['force_language', false],
+ ['installed', false],
+ )->willReturnOnConsecutiveCalls(
+ false,
+ true,
+ );
$user = $this->getMockBuilder(IUser::class)
->getMock();
$user->expects(self::once())
@@ -133,10 +139,6 @@ class FactoryTest extends TestCase {
->method('getUserValue')
->with('MyUserUid', 'core', 'lang', null)
->willReturn('jp');
- $factory->expects(self::at(1))
- ->method('languageExists')
- ->with('MyApp', 'jp')
- ->willReturn(true);
self::assertSame('jp', $factory->findLanguage('MyApp'));
}