From 203366631d95f7e6bad7b38609ec59eed3dd43a4 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi Date: Mon, 24 Apr 2023 16:34:57 +0545 Subject: [PATCH 1/3] Fix unit test failing on CI Signed-off-by: Swikriti Tripathi --- .../lib/Service/OpenProjectAPIServiceTest.php | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/lib/Service/OpenProjectAPIServiceTest.php b/tests/lib/Service/OpenProjectAPIServiceTest.php index 6437a901b..df6ef1527 100644 --- a/tests/lib/Service/OpenProjectAPIServiceTest.php +++ b/tests/lib/Service/OpenProjectAPIServiceTest.php @@ -227,9 +227,28 @@ private function getOpenProjectAPIService( $clientConfigMock = $this->getMockBuilder(IConfig::class)->getMock(); $clientConfigMock - ->method('getSystemValueBool') - ->with('allow_local_remote_servers', false) - ->willReturn(true); + ->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 + ); if (version_compare(OC_Util::getVersionString(), '26') >= 0) { //changed from nextcloud 26 From b1a24ddbb2fccd6982d6d29506c03f6a58b81244 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi Date: Tue, 25 Apr 2023 09:43:51 +0545 Subject: [PATCH 2/3] seperate according to version Signed-off-by: Swikriti Tripathi --- tests/lib/Service/OpenProjectAPIServiceTest.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/lib/Service/OpenProjectAPIServiceTest.php b/tests/lib/Service/OpenProjectAPIServiceTest.php index df6ef1527..3a3a3c211 100644 --- a/tests/lib/Service/OpenProjectAPIServiceTest.php +++ b/tests/lib/Service/OpenProjectAPIServiceTest.php @@ -226,7 +226,9 @@ private function getOpenProjectAPIService( $client = new GuzzleClient(); $clientConfigMock = $this->getMockBuilder(IConfig::class)->getMock(); - $clientConfigMock + + if (version_compare(OC_Util::getVersionString(), '26') >= 0) { + $clientConfigMock ->method('getSystemValueBool') ->withConsecutive( ['allow_local_remote_servers', false], @@ -249,8 +251,6 @@ private function getOpenProjectAPIService( true, true ); - - if (version_compare(OC_Util::getVersionString(), '26') >= 0) { //changed from nextcloud 26 // @phpstan-ignore-next-line $ocClient = new Client( @@ -260,6 +260,10 @@ private function getOpenProjectAPIService( $this->createMock(IRemoteHostValidator::class) // @phpstan-ignore-line ); } elseif (version_compare(OC_Util::getVersionString(), '24') >= 0) { + $clientConfigMock + ->method('getSystemValueBool') + ->with('allow_local_remote_servers', false) + ->willReturn(true); //changed from nextcloud 24 // @phpstan-ignore-next-line $ocClient = new Client( @@ -269,6 +273,10 @@ private function getOpenProjectAPIService( $this->createMock(\OC\Http\Client\LocalAddressChecker::class) // @phpstan-ignore-line ); } else { + $clientConfigMock + ->method('getSystemValueBool') + ->with('allow_local_remote_servers', false) + ->willReturn(true); // @phpstan-ignore-next-line $ocClient = new Client( $clientConfigMock, // @phpstan-ignore-line From e5d85da9eac6bc2ff1f0539a7ad8f813f1f6f353 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi Date: Tue, 25 Apr 2023 10:12:20 +0545 Subject: [PATCH 3/3] seperate according to version Signed-off-by: Swikriti Tripathi --- .../lib/Service/OpenProjectAPIServiceTest.php | 61 ++++++++++++------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/tests/lib/Service/OpenProjectAPIServiceTest.php b/tests/lib/Service/OpenProjectAPIServiceTest.php index 3a3a3c211..69260d577 100644 --- a/tests/lib/Service/OpenProjectAPIServiceTest.php +++ b/tests/lib/Service/OpenProjectAPIServiceTest.php @@ -227,30 +227,45 @@ private function getOpenProjectAPIService( $clientConfigMock = $this->getMockBuilder(IConfig::class)->getMock(); - if (version_compare(OC_Util::getVersionString(), '26') >= 0) { + if (version_compare(OC_Util::getVersionString(), '27') >= 0) { $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 - ); + ->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 + ); + //changed from nextcloud 26 + // @phpstan-ignore-next-line + $ocClient = new Client( + $clientConfigMock, // @phpstan-ignore-line + $certificateManager, // @phpstan-ignore-line + $client, // @phpstan-ignore-line + $this->createMock(IRemoteHostValidator::class) // @phpstan-ignore-line + ); + } elseif (version_compare(OC_Util::getVersionString(), '26') >= 0) { + $clientConfigMock + ->method('getSystemValueBool') + ->with('allow_local_remote_servers', false) + ->willReturn(true); + //changed from nextcloud 26 // @phpstan-ignore-next-line $ocClient = new Client(