diff --git a/tests/lib/Controller/ConfigControllerTest.php b/tests/lib/Controller/ConfigControllerTest.php index 851418f1c..265460e31 100644 --- a/tests/lib/Controller/ConfigControllerTest.php +++ b/tests/lib/Controller/ConfigControllerTest.php @@ -44,6 +44,44 @@ protected function tearDown(): void { } } + /** + * @param MockObject $mock The mock object on which the method is expected to be called + * @param string $method The method name for which the expectations are set + * @param array $calls An array of expected argument arrays for each call + */ + private function expectMethodCalls( + $mock, + string $method, + array $calls + ): void { + $mock->expects($this->exactly(count($calls))) + ->method($method) + ->willReturnCallback(function (...$args) use (&$calls) { + $expected = array_shift($calls); + $this->assertSame($expected, $args); + }); + } + + + /** + * Helper function to set expectations for multiple calls to methods with different arguments + * @param MockObject $mock The mock object on which the method is expected to be called + * @param string $method The method name for which the expectations are set + * @param array $calls An array of expected argument arrays for each call + */ + private function expectMethodReturn( + $mock, + string $method, + array $calls + ): void { + $mock->method($method) + ->willReturnCallback(function (...$args) use (&$calls) { + [$expectedArgs, $returnValue] = array_shift($calls); + $this->assertSame($expectedArgs, $args); + return $returnValue; + }); + } + /** * @param string $codeVerifier The string that should be used as code_verifier * @param string $clientSecret The string that should be used as openproject_client_secret @@ -54,17 +92,25 @@ private function getConfigMock( $codeVerifier, $clientSecret, $startingPage = '{ page: "files" }' ) { $configMock = $this->getMockBuilder(IConfig::class)->getMock(); - $configMock - ->method('getAppValue') - ->withConsecutive( - ['integration_openproject', 'openproject_client_id'], - ['integration_openproject', 'openproject_client_secret'], - ['integration_openproject', 'openproject_instance_url'], - ['integration_openproject', 'openproject_client_id'], - ['integration_openproject', 'openproject_client_secret'], - )->willReturnOnConsecutiveCalls( - 'clientID', $clientSecret, 'http://openproject.org', 'clientID', 'clientSecret', - ); + // $configMock + // ->method('getAppValue') + // ->withConsecutive( + // ['integration_openproject', 'openproject_client_id'], + // ['integration_openproject', 'openproject_client_secret'], + // ['integration_openproject', 'openproject_instance_url'], + // ['integration_openproject', 'openproject_client_id'], + // ['integration_openproject', 'openproject_client_secret'], + // )->willReturnOnConsecutiveCalls( + // 'clientID', $clientSecret, 'http://openproject.org', 'clientID', 'clientSecret', + // ); + $this->expectMethodReturn($configMock, 'getAppValue', [ + [['integration_openproject', 'openproject_client_id', ''], 'clientID'], + [['integration_openproject', 'openproject_client_secret', ''], $clientSecret], + [['integration_openproject', 'openproject_instance_url', ''], 'http://openproject.org'], + [['integration_openproject', 'authorization_method', ''], OpenProjectAPIService::AUTH_METHOD_OAUTH], + [['integration_openproject', 'openproject_client_id', ''], 'clientID'], + [['integration_openproject', 'openproject_client_secret', ''], 'clientSecret'], + ]); $configMock ->method('getUserValue') ->withConsecutive( @@ -79,6 +125,12 @@ private function getConfigMock( $startingPage, 'oAuthRefreshToken', ); + // $this->expectMethodReturn($configMock, 'getUserValue', [ + // [['testUser', 'integration_openproject', 'oauth_state'], 'randomString'], + // [['testUser', 'integration_openproject', 'code_verifier'], $codeVerifier], + // [['testUser', 'integration_openproject', 'oauth_journey_starting_page'], $startingPage], + // [['testUser', 'integration_openproject', 'refresh_token'], 'oAuthRefreshToken'], + // ]); return $configMock; } @@ -166,13 +218,10 @@ public function testOauthRedirectSuccess():void { str_repeat("A", 128), str_repeat("S", 50)); $configMock ->method('setUserValue') - ->withConsecutive( - ['testUser', 'integration_openproject', 'token', 'oAuthAccessToken'], - ['testUser', 'integration_openproject', 'refresh_token', 'oAuthRefreshToken'], - ['testUser', 'integration_openproject', 'user_id', 1], - ['testUser', 'integration_openproject', 'user_name', 'Tripathi Himal'], - ['testUser', 'integration_openproject', 'oauth_connection_result', 'success'], + ->with( + 'testUser', 'integration_openproject', 'oauth_connection_result', 'success' ); + $urlGeneratorMock = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); @@ -185,12 +234,12 @@ public function testOauthRedirectSuccess():void { ->getMock(); $apiServiceMock - ->method('request') + ->method('initUserInfo') ->with( 'testUser', - 'users/me' + 'oAuthAccessToken' ) - ->willReturn(['lastName' => 'Himal', 'firstName' => 'Tripathi', 'id' => 1]); + ->willReturn(['user_name' => 'Tripathi Himal']); $apiServiceMock ->method('requestOAuthAccessToken') @@ -273,16 +322,11 @@ public function testOauthRedirectWrongState() { $configMock = $this->getConfigMock( str_repeat("A", 128), str_repeat("S", 50) ); - $configMock - ->expects($this->exactly(2)) - ->method('setUserValue') - ->withConsecutive( - ['testUser', 'integration_openproject', 'oauth_connection_result', 'error'], - [ - 'testUser', 'integration_openproject', 'oauth_connection_error_message', - 'Error during OAuth exchanges' - ], - ); + + $this->expectMethodCalls($configMock, 'setUserValue', [ + ['testUser', 'integration_openproject', 'oauth_connection_result', 'error', null], + ['testUser', 'integration_openproject', 'oauth_connection_error_message', 'Error during OAuth exchanges', null], + ]); $constructArgs = $this->getConfigControllerConstructArgs([ 'config' => $configMock, @@ -382,27 +426,32 @@ public function testOauthRedirectSecret($clientSecret, $valid) { $loggerMock->expects($this->never()) ->method('error'); // even the secret is valid, we get an error because the token request is not mocked + $calls = [ + ['testUser', 'integration_openproject', 'oauth_connection_result', 'error', null], + ['testUser', 'integration_openproject', 'oauth_connection_error_message', 'Error getting OAuth access token', null], + ]; $configMock->expects($this->exactly(2)) ->method('setUserValue') - ->withConsecutive( - ['testUser', 'integration_openproject', 'oauth_connection_result', 'error'], - [ - 'testUser', 'integration_openproject', 'oauth_connection_error_message', - 'Error getting OAuth access token' - ], - ); + ->willReturnCallback(function (...$args) use (&$calls) { + $expected = array_shift($calls); + $this->assertSame($expected, $args); + }); } else { $loggerMock->expects($this->once()) ->method('error'); + $calls = [ + ['testUser', 'integration_openproject', 'oauth_connection_result', 'error', null], + [ + 'testUser', 'integration_openproject', 'oauth_connection_error_message', + 'Error during OAuth exchanges', null + ], + ]; $configMock->expects($this->exactly(2)) ->method('setUserValue') - ->withConsecutive( - ['testUser', 'integration_openproject', 'oauth_connection_result', 'error'], - [ - 'testUser', 'integration_openproject', 'oauth_connection_error_message', - 'Error during OAuth exchanges' - ], - ); + ->willReturnCallback(function (...$args) use (&$calls) { + $expected = array_shift($calls); + $this->assertSame($expected, $args); + }); } $constructArgs = $this->getConfigControllerConstructArgs([ @@ -1265,20 +1314,13 @@ public function testOPOAuthTokenRevokeDoesNotOccurIfNoOPOAuthClientHasChanged() $configMock ->method('getAppValue') - ->withConsecutive( - ['integration_openproject', 'openproject_instance_url', ''], - ['integration_openproject', 'authorization_method', ''], - ['integration_openproject', 'openproject_client_id', ''], - ['integration_openproject', 'openproject_client_secret', ''], - ['integration_openproject', 'oPOAuthTokenRevokeStatus', ''] - ) - ->willReturnOnConsecutiveCalls( - $oldAdminConfig['openproject_instance_url'], - $oldAdminConfig['authorization_method'], - $oldAdminConfig['openproject_client_id'], - $oldAdminConfig['openproject_client_secret'], - '' - ); + ->willReturnMap([ + [Application::APP_ID, 'openproject_instance_url', '', $oldAdminConfig['openproject_instance_url']], + [Application::APP_ID, 'authorization_method', '', $oldAdminConfig['authorization_method']], + [Application::APP_ID, 'openproject_client_id', '', $oldAdminConfig['openproject_client_id']], + [Application::APP_ID, 'openproject_client_secret', '', $oldAdminConfig['openproject_client_secret']], + [Application::APP_ID, 'oPOAuthTokenRevokeStatus', '', ''], + ]); $configMock ->expects($this->exactly(2)) ->method('deleteAppValue') @@ -1522,30 +1564,19 @@ public function testSetAdminConfigOIDCAuthSetting( ->getMock(); $configMock ->method('getAppValue') - ->withConsecutive( - ['integration_openproject', 'openproject_instance_url', ''], - ['integration_openproject', 'authorization_method', ''], - ['integration_openproject', 'oidc_provider'], - ['integration_openproject', 'targeted_audience_client_id'], - ['integration_openproject', 'nc_oauth_client_id', ''], - ['integration_openproject', 'oPOAuthTokenRevokeStatus', ''], - ['integration_openproject', 'authorization_method', ''], - ['integration_openproject', 'oidc_provider'], - ['integration_openproject', 'targeted_audience_client_id'], - ['integration_openproject', 'openproject_instance_url'], - ) - ->willReturnOnConsecutiveCalls( - $oldCreds['openproject_instance_url'], - $oldCreds['authorization_method'], - $oldCreds['oidc_provider'], - $oldCreds['targeted_audience_client_id'], - '123', - '', - OpenProjectAPIService::AUTH_METHOD_OAUTH, - $credsToUpdate['oidc_provider'], - $credsToUpdate['targeted_audience_client_id'], - $credsToUpdate['openproject_instance_url'] - ); + ->willReturnMap([ + ['integration_openproject', 'openproject_instance_url', '', $oldCreds['openproject_instance_url']], + ['integration_openproject', 'authorization_method', '', $oldCreds['authorization_method']], + ['integration_openproject', 'oidc_provider', '', $oldCreds['oidc_provider']], + ['integration_openproject', 'targeted_audience_client_id', '', $oldCreds['targeted_audience_client_id']], + ['integration_openproject', 'nc_oauth_client_id', '', '123'], + ['integration_openproject', 'oPOAuthTokenRevokeStatus', '', ''], + ['integration_openproject', 'authorization_method', '', OpenProjectAPIService::AUTH_METHOD_OIDC], + ['integration_openproject', 'oidc_provider', '', $credsToUpdate['oidc_provider']], + ['integration_openproject', 'targeted_audience_client_id', '', $credsToUpdate['targeted_audience_client_id']], + ['integration_openproject', 'openproject_instance_url', '', $credsToUpdate['openproject_instance_url']], + + ]); $apiService = $this->getMockBuilder(OpenProjectAPIService::class) ->disableOriginalConstructor() diff --git a/tests/lib/Controller/FilesControllerTest.php b/tests/lib/Controller/FilesControllerTest.php index ba01f6eca..0d0b06e5f 100644 --- a/tests/lib/Controller/FilesControllerTest.php +++ b/tests/lib/Controller/FilesControllerTest.php @@ -187,20 +187,20 @@ public function testGetFileInfoFileExistingButCannotGetNameInContextOfOwner(): v public function testGetFilesInfoFourIdsRequestedOneExistsOneInTrashOneNotExisitingOneForbidden(): void { $folderMock = $this->getMockBuilder(Folder::class)->getMock(); $folderMock->method('getById') - ->withConsecutive([123], [759], [365], [956]) - ->willReturnOnConsecutiveCalls( + ->willReturnMap( [ - $this->getNodeMock('image/png', 123, 'file', '/testUser/files/logo.png') - ], - [], - [] + [123, [$this->getNodeMock('image/png', 123, 'file', '/testUser/files/logo.png')]], + [759, []], + [365, []], + [956, []] + ] ); $cachedMountFileInfoMock = $this->getMockBuilder( ICachedMountFileInfo::class )->getMock(); $cachedMountFileInfoMock->method('getInternalPath') - ->willReturnOnConsecutiveCalls( + ->willReturn( 'files/logo.png', 'files_trashbin/files/welcome.txt.d1648724302', '/anotherUser/files/logo.png' @@ -213,19 +213,20 @@ public function testGetFilesInfoFourIdsRequestedOneExistsOneInTrashOneNotExisiti $mountCacheMock = $this->getMockBuilder(IUserMountCache::class)->getMock(); $mountCacheMock->method('getMountsForFileId') - ->withConsecutive([123], [759], [365], [956]) - ->willReturnOnConsecutiveCalls( - [$cachedMountFileInfoMock], - [$cachedMountFileInfoMock], - [], // not found - [$cachedMountFileInfoMock], + ->willReturnMap( + [ + [123, null, [$cachedMountFileInfoMock]], + [759, null, [$cachedMountFileInfoMock]], + [365, null, []], + [956, null, [$cachedMountFileInfoMock]] + ] ); $filesController = $this->getFilesControllerMock( ['getDavPermissions'], $folderMock, $mountCacheMock ); $filesController->method('getDavPermissions') - ->willReturnOnConsecutiveCalls('RGDNVW', 'RGDNVW'); + ->willReturn('RGDNVW', 'RGDNVW'); $result = $filesController->getFilesInfo([123, 759, 365, 956]); assertSame( @@ -268,13 +269,12 @@ public function testGetFilesInfoOneIdRequestedFileExistsReturnsOneResult(): void public function testGetFilesInfoThreeIdsRequestedOneFileExistsReturnsOneResult(): void { $folderMock = $this->getMockBuilder(Folder::class)->getMock(); $folderMock->method('getById') - ->withConsecutive([123], [256], [365]) - ->willReturnOnConsecutiveCalls( + ->willReturnMap( [ - $this->getNodeMock('image/png', 123, 'file', '/testUser/files/logo.png') - ], - [], - [] + [123, [$this->getNodeMock('image/png', 123, 'file', '/testUser/files/logo.png')]], + [256, []], + [365, []] + ] ); $cachedMountFileInfoMock = $this->getMockBuilder( @@ -289,7 +289,7 @@ public function testGetFilesInfoThreeIdsRequestedOneFileExistsReturnsOneResult() $mountCacheMock = $this->getMockBuilder(IUserMountCache::class) ->getMock(); $mountCacheMock->method('getMountsForFileId') - ->willReturnOnConsecutiveCalls( + ->willReturn( [$cachedMountFileInfoMock], [], [] ); @@ -313,20 +313,18 @@ public function testGetFilesInfoThreeIdsRequestedOneFileExistsReturnsOneResult() public function testGetFilesInfoTwoIdsRequestedAllFilesExistsEachReturnsOneResult(): void { $folderMock = $this->getMockBuilder(Folder::class)->getMock(); $folderMock->method('getById') - ->withConsecutive([123], [365]) - ->willReturnOnConsecutiveCalls( + ->willReturnMap( [ - $this->getNodeMock('image/png', 123, 'file', '/testUser/files/logo.png') - ], - [ - $this->getNodeMock('image/png', 365, 'file', '/testUser/files/inFolder/image.png'), + [123, [$this->getNodeMock('image/png', 123, 'file', '/testUser/files/logo.png')]], + [365, [$this->getNodeMock('image/png', 365, 'file', '/testUser/files/inFolder/image.png')]] ] ); + $cachedMountFileInfoMock = $this->getMockBuilder( ICachedMountFileInfo::class )->getMock(); $cachedMountFileInfoMock->method('getInternalPath') - ->willReturnOnConsecutiveCalls( + ->willReturn( 'files/logo.png', 'files/inFolder/image.png', ); @@ -344,7 +342,7 @@ public function testGetFilesInfoTwoIdsRequestedAllFilesExistsEachReturnsOneResul ['getDavPermissions'], $folderMock, $mountCacheMock ); $filesController->method('getDavPermissions') - ->willReturnOnConsecutiveCalls('RGDNVW', 'RGDNVW'); + ->willReturn('RGDNVW'); $result = $filesController->getFilesInfo([123,365]); assertSame( [ @@ -359,13 +357,10 @@ public function testGetFilesInfoTwoIdsRequestedAllFilesExistsEachReturnsOneResul public function testGetFilesInfoTwoIdsRequestedAllFilesExistsEachReturnsMultipleResults(): void { $folderMock = $this->getMockBuilder(Folder::class)->getMock(); $folderMock->method('getById') - ->withConsecutive([123], [365]) - ->willReturnOnConsecutiveCalls( - [ - $this->getNodeMock('image/png', 123, 'file', '/testUser/files/logo.png'), - ], + ->willReturnMap( [ - $this->getNodeMock('image/png', 365, 'file', '/testUser/files/inFolder/image.png'), + [123, [$this->getNodeMock('image/png', 123, 'file', '/testUser/files/logo.png')]], + [365, [$this->getNodeMock('image/png', 365, 'file', '/testUser/files/inFolder/image.png')]] ] ); @@ -373,7 +368,7 @@ public function testGetFilesInfoTwoIdsRequestedAllFilesExistsEachReturnsMultiple ICachedMountFileInfo::class )->getMock(); $cachedMountFileInfoMock->method('getInternalPath') - ->willReturnOnConsecutiveCalls( + ->willReturn( 'files/logo.png', 'files/inFolder/image.png', ); @@ -391,7 +386,7 @@ public function testGetFilesInfoTwoIdsRequestedAllFilesExistsEachReturnsMultiple ['getDavPermissions'], $folderMock, $mountCacheMock ); $filesController->method('getDavPermissions') - ->willReturnOnConsecutiveCalls('RGDNVW', 'RGDNVW'); + ->willReturn('RGDNVW'); $result = $filesController->getFilesInfo([123,365]); assertSame( @@ -407,31 +402,36 @@ public function testGetFilesInfoTwoIdsRequestedAllFilesExistsEachReturnsMultiple public function testGetFilesInfoTwoIdsRequestedEachReturnsOneFolder(): void { $folderMock = $this->getMockBuilder(Folder::class)->getMock(); $folderMock->method('getById') - ->withConsecutive([2], [3]) - ->willReturnOnConsecutiveCalls( + ->willReturnMap([ [ - $this->getNodeMock( - 'httpd/unix-directory', - 2, - 'dir', - '/testUser/files/myFolder/a-sub-folder' - ) + 2, + [ + $this->getNodeMock( + 'httpd/unix-directory', + 2, + 'dir', + '/testUser/files/myFolder/a-sub-folder' + ) + ] ], [ - $this->getNodeMock( - 'httpd/unix-directory', - 3, - 'dir', - '/testUser/files' - ) - ] - ); + 3, + [ + $this->getNodeMock( + 'httpd/unix-directory', + 3, + 'dir', + '/testUser/files' + ) + ] + ], + ]); $cachedMountFileInfoMock = $this->getMockBuilder( ICachedMountFileInfo::class )->getMock(); $cachedMountFileInfoMock->method('getInternalPath') - ->willReturnOnConsecutiveCalls( + ->willReturn( 'files/myFolder/a-sub-folder', 'files' ); @@ -449,7 +449,7 @@ public function testGetFilesInfoTwoIdsRequestedEachReturnsOneFolder(): void { ['getDavPermissions'], $folderMock, $mountCacheMock ); $filesController->method('getDavPermissions') - ->willReturnOnConsecutiveCalls('RGDNVCK', 'RGDNVCK'); + ->willReturn('RGDNVCK', 'RGDNVCK'); $result = $filesController->getFilesInfo([2,3]); assertSame( @@ -507,31 +507,32 @@ public function testGetFilesInfoInvalidRequest(): void { public function testGetFilesInfoSendStringIds(): void { $folderMock = $this->getMockBuilder(Folder::class)->getMock(); $folderMock->method('getById') - ->withConsecutive([2], [3]) - ->willReturnOnConsecutiveCalls( - [ - $this->getNodeMock( + ->willReturnMap([ + [ 2, + [$this->getNodeMock( 'httpd/unix-directory', 2, 'dir', '/testUser/files/myFolder/a-sub-folder' - ) + )] ], - [ - $this->getNodeMock( - 'httpd/unix-directory', - 3, - 'dir', - '/testUser/files/testFolder' - ) + [ 3, + [ + $this->getNodeMock( + 'httpd/unix-directory', + 3, + 'dir', + '/testUser/files/testFolder' + ) + ] ] - ); + ]); $cachedMountFileInfoMock = $this->getMockBuilder( ICachedMountFileInfo::class )->getMock(); $cachedMountFileInfoMock->method('getInternalPath') - ->willReturnOnConsecutiveCalls( + ->willReturn( 'files/myFolder/a-sub-folder', '' ); @@ -549,7 +550,7 @@ public function testGetFilesInfoSendStringIds(): void { ['getDavPermissions'], $folderMock, $mountCacheMock ); $filesController->method('getDavPermissions') - ->willReturnOnConsecutiveCalls('RGDNVCK', 'RGDNVCK'); + ->willReturn('RGDNVCK', 'RGDNVCK'); $result = $filesController->getFilesInfo(["2","3"]); assertSame( diff --git a/tests/lib/Controller/OpenProjectAPIControllerTest.php b/tests/lib/Controller/OpenProjectAPIControllerTest.php index 0cd8ce349..070f35dbc 100644 --- a/tests/lib/Controller/OpenProjectAPIControllerTest.php +++ b/tests/lib/Controller/OpenProjectAPIControllerTest.php @@ -60,18 +60,20 @@ public function getConfigMock(string $authorizationMethod = '', $authToken = nul $configMock = $this->getMockBuilder(IConfig::class)->getMock(); $configMock ->method('getUserValue') - ->withConsecutive( - ['test','integration_openproject', 'token'], - ['test','integration_openproject', 'refresh_token'], - )->willReturnOnConsecutiveCalls($token, 'refreshToken'); + ->willReturnMap( + [ + ['test', 'integration_openproject', 'token', '', $token], + ['test', 'integration_openproject', 'refresh_token', '', 'refreshToken'] + ] + ); $opUrl = $opUrl ?? 'https://openproject.org'; $configMock ->method('getAppValue') - ->withConsecutive( - ['integration_openproject', 'openproject_instance_url'], - ['integration_openproject', 'authorization_method'], - )->willReturnOnConsecutiveCalls($opUrl, $authorizationMethod); + ->willReturnMap([ + ['integration_openproject', 'openproject_instance_url', '', $opUrl], + ['integration_openproject', 'authorization_method', '', $authorizationMethod], + ]); return $configMock; } diff --git a/tests/lib/Service/OpenProjectAPIServiceTest.php b/tests/lib/Service/OpenProjectAPIServiceTest.php index d9c501a30..8f7b0344c 100644 --- a/tests/lib/Service/OpenProjectAPIServiceTest.php +++ b/tests/lib/Service/OpenProjectAPIServiceTest.php @@ -726,29 +726,18 @@ private function getOpenProjectAPIService( $clientConfigMock = $this->getMockBuilder(IConfig::class)->getMock(); $clientConfigMock ->method('getSystemValueBool') - ->withConsecutive( - ['allow_local_remote_servers', false], - ['installed', false], - ['allow_local_remote_servers', false], - ['allow_local_remote_servers', false], - ['installed', false], - ['allow_local_remote_servers', false], - ['allow_local_remote_servers', false], - ['installed', false], - ['allow_local_remote_servers', false] - ) - ->willReturnOnConsecutiveCalls( - true, - true, - true, - true, - true, - true, - true, - true, - true + ->willReturnMap([ + ['allow_local_remote_servers', false, true], + ['installed', false, true], + ['allow_local_remote_servers', false, true], + ['allow_local_remote_servers', false, true], + ['installed', false, true], + ['allow_local_remote_servers', false, true], + ['allow_local_remote_servers', false, true], + ['installed', false, true], + ['allow_local_remote_servers', false, true] + ] ); - $clientService = $this->getMockBuilder(IClientService::class)->getMock(); $clientService->method('newClient')->willReturn($this->createMock(Client::class)); @@ -963,9 +952,10 @@ public function testSearchWorkPackageNotLinkedToAStorage(array $response, array public function testSearchWorkPackageByFileIdOnlyFileId() { $service = $this->getOpenProjectAPIServiceMock(); $service->method('request') - ->withConsecutive( + ->willReturnMap([ [ - 'user', 'work_packages', + 'user', + 'work_packages', [ 'filters' => '[' . '{"file_link_origin_id":{"operator":"=","values":["123"]}},'. @@ -973,12 +963,12 @@ public function testSearchWorkPackageByFileIdOnlyFileId() { '{"operator":"=","values":["https%3A%2F%2Fnc.my-server.org"]}}'. ']', 'sortBy' => '[["updatedAt","desc"]]', - ] - ], - ) - ->willReturnOnConsecutiveCalls( - ["_embedded" => ["elements" => [['id' => 1], ['id' => 2], ['id' => 3]]]] + ], + 'GET', + ["_embedded" => ["elements" => [['id' => 1], ['id' => 2], ['id' => 3]]]] + ]] ); + $result = $service->searchWorkPackage('user', null, 123); $this->assertSame([['id' => 1], ['id' => 2], ['id' => 3]], $result); } @@ -2218,14 +2208,12 @@ public function testRequestConnectException( ])); $configMock ->method('getUserValue') - ->withConsecutive( - ['','integration_openproject', 'token'], - ['','integration_openproject', 'token_expires_at'], - ['','integration_openproject', 'refresh_token'], - ) - ->willReturnOnConsecutiveCalls( - '', - '', + ->willReturnMap( + [ + ['','integration_openproject', 'token', '', ''], + ['','integration_openproject', 'token_expires_at', '', ''], + ['','integration_openproject', 'refresh_token', '', ''], + ] ); $constructArgs = $this->getOpenProjectAPIServiceConstructArgs([ @@ -2268,13 +2256,11 @@ public function testRequestClientServerException( ])); $configMock ->method('getUserValue') - ->withConsecutive( - ['','integration_openproject', 'token'], - ['','integration_openproject', 'refresh_token'], - ) - ->willReturnOnConsecutiveCalls( - '', - '', + ->willReturnMap( + [ + ['','integration_openproject', 'token', '', ''], + ['','integration_openproject', 'refresh_token', '', ''], + ] ); $constructArgs = $this->getOpenProjectAPIServiceConstructArgs([ @@ -4450,11 +4436,12 @@ public function testIsAdminAuditConfigSetCorrectly( $iAppManagerMock = $this->getMockBuilder(IAppManager::class)->getMock(); $configMock ->method('getSystemValue') - ->withConsecutive( - ['loglevel'], - ['logfile_audit'], - ['log.condition'] - )->willReturnOnConsecutiveCalls($logLevel, $pathToAuditLog, $logCondition); + ->willReturnMap([ + ['loglevel', '', $logLevel], + ['logfile_audit', '', $pathToAuditLog], + ['log.condition', '', $logCondition] + ] + ); $userManagerMock = $this->getMockBuilder(IUserManager::class) ->getMock(); $iAppManagerMock->method('isInstalled')->with('admin_audit')