diff --git a/test/classes/AbstractNetworkTestCase.php b/test/classes/AbstractNetworkTestCase.php index 69ace9c303da..6166d302adf3 100644 --- a/test/classes/AbstractNetworkTestCase.php +++ b/test/classes/AbstractNetworkTestCase.php @@ -42,7 +42,7 @@ public function mockResponse(...$param): MockObject { $mockResponse = $this->getMockBuilder(Response::class) ->disableOriginalConstructor() - ->setMethods([ + ->onlyMethods([ 'header', 'headersSent', 'disable', diff --git a/test/classes/Config/FormDisplayTest.php b/test/classes/Config/FormDisplayTest.php index 7483638c93f0..4aaee7dc3a48 100644 --- a/test/classes/Config/FormDisplayTest.php +++ b/test/classes/Config/FormDisplayTest.php @@ -107,7 +107,7 @@ public function testProcess(): void $this->object = $this->getMockBuilder(FormDisplay::class) ->disableOriginalConstructor() - ->setMethods(['save']) + ->onlyMethods(['save']) ->getMock(); $attrForms = new ReflectionProperty(FormDisplay::class, 'forms'); diff --git a/test/classes/Config/FormTest.php b/test/classes/Config/FormTest.php index 2a61f445b25f..f110b03be382 100644 --- a/test/classes/Config/FormTest.php +++ b/test/classes/Config/FormTest.php @@ -268,7 +268,7 @@ public function testLoadForm(): void { $this->object = $this->getMockBuilder(Form::class) ->disableOriginalConstructor() - ->setMethods(['readFormPaths', 'readTypes']) + ->onlyMethods(['readFormPaths', 'readTypes']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -293,7 +293,7 @@ public function testCleanGroupPaths(): void { $this->object = $this->getMockBuilder(Form::class) ->disableOriginalConstructor() - ->setMethods(['readFormPaths', 'readTypes']) + ->onlyMethods(['readFormPaths', 'readTypes']) ->getMock(); $this->object->expects($this->exactly(1))->method('readFormPaths')->with([ diff --git a/test/classes/Config/ServerConfigChecksTest.php b/test/classes/Config/ServerConfigChecksTest.php index e7c8684d3a5f..62bd5e46989f 100644 --- a/test/classes/Config/ServerConfigChecksTest.php +++ b/test/classes/Config/ServerConfigChecksTest.php @@ -62,7 +62,7 @@ public function testManyErrors(): void $_SESSION[$this->sessionID]['ZipDump'] = true; $configChecker = $this->getMockBuilder(ServerConfigChecks::class) - ->setMethods(['functionExists']) + ->onlyMethods(['functionExists']) ->setConstructorArgs([$GLOBALS['ConfigFile']]) ->getMock(); diff --git a/test/classes/ErrorReportTest.php b/test/classes/ErrorReportTest.php index 0c031734a20a..1e68cae0b497 100644 --- a/test/classes/ErrorReportTest.php +++ b/test/classes/ErrorReportTest.php @@ -117,7 +117,7 @@ public function testSend(): void $return = 'return'; $httpRequest = $this->getMockBuilder(HttpRequest::class) - ->setMethods(['create']) + ->onlyMethods(['create']) ->getMock(); $httpRequest->expects($this->once()) ->method('create') diff --git a/test/classes/InsertEditTest.php b/test/classes/InsertEditTest.php index 93b547a447f0..c3eb91869492 100644 --- a/test/classes/InsertEditTest.php +++ b/test/classes/InsertEditTest.php @@ -271,7 +271,7 @@ public function testShowEmptyResultMessageOrSetUniqueCondition(): void $responseMock = $this->getMockBuilder(Response::class) ->disableOriginalConstructor() - ->setMethods(['addHtml']) + ->onlyMethods(['addHtml']) ->getMock(); $restoreInstance = Response::getInstance(); @@ -2773,7 +2773,7 @@ public function testIsInsertRow(): void $scriptsMock = $this->getMockBuilder(Scripts::class) ->disableOriginalConstructor() - ->setMethods(['addFile']) + ->onlyMethods(['addFile']) ->getMock(); $scriptsMock->expects($this->exactly(2)) @@ -2781,7 +2781,7 @@ public function testIsInsertRow(): void $headerMock = $this->getMockBuilder(Header::class) ->disableOriginalConstructor() - ->setMethods(['getScripts']) + ->onlyMethods(['getScripts']) ->getMock(); $headerMock->expects($this->once()) @@ -2790,7 +2790,7 @@ public function testIsInsertRow(): void $responseMock = $this->getMockBuilder(Response::class) ->disableOriginalConstructor() - ->setMethods(['getHeader']) + ->onlyMethods(['getHeader']) ->getMock(); $responseMock->expects($this->once()) @@ -3886,7 +3886,7 @@ public function testDetermineInsertOrEdit(): void $responseMock = $this->getMockBuilder(Response::class) ->disableOriginalConstructor() - ->setMethods(['addHtml']) + ->onlyMethods(['addHtml']) ->getMock(); $restoreInstance = Response::getInstance(); diff --git a/test/classes/Plugins/Auth/AuthenticationCookieTest.php b/test/classes/Plugins/Auth/AuthenticationCookieTest.php index 20f292b30625..cafb97987ad4 100644 --- a/test/classes/Plugins/Auth/AuthenticationCookieTest.php +++ b/test/classes/Plugins/Auth/AuthenticationCookieTest.php @@ -99,7 +99,7 @@ private function getAuthErrorMockResponse(): void // mock footer $mockFooter = $this->getMockBuilder(Footer::class) ->disableOriginalConstructor() - ->setMethods(['setMinimal']) + ->onlyMethods(['setMinimal']) ->getMock(); $mockFooter->expects($this->once()) @@ -110,7 +110,7 @@ private function getAuthErrorMockResponse(): void $mockHeader = $this->getMockBuilder(Header::class) ->disableOriginalConstructor() - ->setMethods( + ->onlyMethods( [ 'setBodyId', 'setTitle', @@ -157,7 +157,7 @@ private function getAuthErrorMockResponse(): void $mockErrorHandler = $this->getMockBuilder(ErrorHandler::class) ->disableOriginalConstructor() - ->setMethods(['hasDisplayErrors']) + ->onlyMethods(['hasDisplayErrors']) ->getMock(); $mockErrorHandler->expects($this->once()) @@ -604,7 +604,7 @@ public function testAuthCheckDecryptUser(): void // mock for blowfish function $this->object = $this->getMockBuilder(AuthenticationCookie::class) ->disableOriginalConstructor() - ->setMethods(['cookieDecrypt']) + ->onlyMethods(['cookieDecrypt']) ->getMock(); $this->object->expects($this->once()) @@ -643,7 +643,7 @@ public function testAuthCheckDecryptPassword(): void // mock for blowfish function $this->object = $this->getMockBuilder(AuthenticationCookie::class) ->disableOriginalConstructor() - ->setMethods(['cookieDecrypt']) + ->onlyMethods(['cookieDecrypt']) ->getMock(); $this->object->expects($this->at(1)) @@ -686,7 +686,7 @@ public function testAuthCheckAuthFails(): void // mock for blowfish function $this->object = $this->getMockBuilder(AuthenticationCookie::class) ->disableOriginalConstructor() - ->setMethods(['showFailure', 'cookieDecrypt']) + ->onlyMethods(['showFailure', 'cookieDecrypt']) ->getMock(); $this->object->expects($this->once()) @@ -780,7 +780,7 @@ public function testAuthFailsNoPass(): void { $this->object = $this->getMockBuilder(AuthenticationCookie::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $GLOBALS['server'] = 2; @@ -861,7 +861,7 @@ public function testAuthFailsDeny(): void { $this->object = $this->getMockBuilder(AuthenticationCookie::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $GLOBALS['server'] = 2; @@ -883,7 +883,7 @@ public function testAuthFailsActivity(): void { $this->object = $this->getMockBuilder(AuthenticationCookie::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $GLOBALS['server'] = 2; @@ -909,7 +909,7 @@ public function testAuthFailsDBI(): void { $this->object = $this->getMockBuilder(AuthenticationCookie::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $GLOBALS['server'] = 2; @@ -942,7 +942,7 @@ public function testAuthFailsErrno(): void { $this->object = $this->getMockBuilder(AuthenticationCookie::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $dbi = $this->getMockBuilder(DatabaseInterface::class) diff --git a/test/classes/Plugins/Auth/AuthenticationHttpTest.php b/test/classes/Plugins/Auth/AuthenticationHttpTest.php index 52a83eb47208..e6866ef9bf7c 100644 --- a/test/classes/Plugins/Auth/AuthenticationHttpTest.php +++ b/test/classes/Plugins/Auth/AuthenticationHttpTest.php @@ -59,7 +59,7 @@ public function doMockResponse($set_minimal, $body_id, $set_title, ...$headers): // mock footer $mockFooter = $this->getMockBuilder(Footer::class) ->disableOriginalConstructor() - ->setMethods(['setMinimal']) + ->onlyMethods(['setMinimal']) ->getMock(); $mockFooter->expects($this->exactly($set_minimal)) @@ -70,7 +70,7 @@ public function doMockResponse($set_minimal, $body_id, $set_title, ...$headers): $mockHeader = $this->getMockBuilder(Header::class) ->disableOriginalConstructor() - ->setMethods( + ->onlyMethods( [ 'setBodyId', 'setTitle', @@ -415,7 +415,7 @@ public function testAuthFails(): void $this->object = $this->getMockBuilder(AuthenticationHttp::class) ->disableOriginalConstructor() - ->setMethods(['authForm']) + ->onlyMethods(['authForm']) ->getMock(); $this->object->expects($this->exactly(2)) diff --git a/test/classes/Plugins/Auth/AuthenticationSignonTest.php b/test/classes/Plugins/Auth/AuthenticationSignonTest.php index b8b96b2017bf..9c3b1b4296e6 100644 --- a/test/classes/Plugins/Auth/AuthenticationSignonTest.php +++ b/test/classes/Plugins/Auth/AuthenticationSignonTest.php @@ -238,7 +238,7 @@ public function testAuthFailsForbidden(): void $this->object = $this->getMockBuilder(AuthenticationSignon::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -260,7 +260,7 @@ public function testAuthFailsDeny(): void $this->object = $this->getMockBuilder(AuthenticationSignon::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -281,7 +281,7 @@ public function testAuthFailsTimeout(): void $this->object = $this->getMockBuilder(AuthenticationSignon::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -306,7 +306,7 @@ public function testAuthFailsMySQLError(): void $this->object = $this->getMockBuilder(AuthenticationSignon::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -338,7 +338,7 @@ public function testAuthFailsConnect(): void $this->object = $this->getMockBuilder(AuthenticationSignon::class) ->disableOriginalConstructor() - ->setMethods(['showLoginForm']) + ->onlyMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -366,7 +366,7 @@ public function testSetCookieParamsDefaults(): void { $this->object = $this->getMockBuilder(AuthenticationSignon::class) ->disableOriginalConstructor() - ->setMethods(['setCookieParams']) + ->onlyMethods(['setCookieParams']) ->getMock(); $this->object->setCookieParams([]); diff --git a/test/classes/Plugins/Export/ExportHtmlwordTest.php b/test/classes/Plugins/Export/ExportHtmlwordTest.php index 5ef85a222d66..9674022c7a74 100644 --- a/test/classes/Plugins/Export/ExportHtmlwordTest.php +++ b/test/classes/Plugins/Export/ExportHtmlwordTest.php @@ -372,7 +372,7 @@ public function testExportData(): void public function testGetTableDefStandIn(): void { $this->object = $this->getMockBuilder(ExportHtmlword::class) - ->setMethods(['formatOneColumnDefinition']) + ->onlyMethods(['formatOneColumnDefinition']) ->getMock(); // case 1 @@ -423,7 +423,7 @@ public function testGetTableDefStandIn(): void public function testGetTableDef(): void { $this->object = $this->getMockBuilder(ExportHtmlword::class) - ->setMethods(['formatOneColumnDefinition']) + ->onlyMethods(['formatOneColumnDefinition']) ->getMock(); $keys = [ @@ -730,7 +730,7 @@ public function testExportStructure(): void ->will($this->returnValue(1)); $this->object = $this->getMockBuilder(ExportHtmlword::class) - ->setMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) + ->onlyMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) ->getMock(); $this->object->expects($this->at(0)) diff --git a/test/classes/Plugins/Export/ExportOdtTest.php b/test/classes/Plugins/Export/ExportOdtTest.php index faa4af106a56..215a4a5131d4 100644 --- a/test/classes/Plugins/Export/ExportOdtTest.php +++ b/test/classes/Plugins/Export/ExportOdtTest.php @@ -602,7 +602,7 @@ public function testGetTableDefStandIn(): void $this->object = $this->getMockBuilder(ExportOdt::class) ->disableOriginalConstructor() - ->setMethods(['formatOneColumnDefinition']) + ->onlyMethods(['formatOneColumnDefinition']) ->getMock(); $this->object->expects($this->at(0)) @@ -635,7 +635,7 @@ public function testGetTableDefStandIn(): void public function testGetTableDef(): void { $this->object = $this->getMockBuilder(ExportOdt::class) - ->setMethods(['formatOneColumnDefinition']) + ->onlyMethods(['formatOneColumnDefinition']) ->getMock(); // case 1 @@ -884,7 +884,7 @@ public function testExportStructure(): void ->will($this->returnValue(1)); $this->object = $this->getMockBuilder(ExportOdt::class) - ->setMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) + ->onlyMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) ->getMock(); $this->object->expects($this->at(0)) diff --git a/test/classes/Plugins/Export/ExportSqlTest.php b/test/classes/Plugins/Export/ExportSqlTest.php index 57c580b25e40..ea1504f48981 100644 --- a/test/classes/Plugins/Export/ExportSqlTest.php +++ b/test/classes/Plugins/Export/ExportSqlTest.php @@ -1279,7 +1279,7 @@ public function testExportStructure(): void ); $this->object = $this->getMockBuilder(ExportSql::class) - ->setMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) + ->onlyMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) ->getMock(); $this->object->expects($this->at(0)) diff --git a/test/classes/Plugins/Export/ExportTexytextTest.php b/test/classes/Plugins/Export/ExportTexytextTest.php index 5825167f4d07..897b3167f32b 100644 --- a/test/classes/Plugins/Export/ExportTexytextTest.php +++ b/test/classes/Plugins/Export/ExportTexytextTest.php @@ -302,7 +302,7 @@ public function testGetTableDefStandIn(): void $this->object = $this->getMockBuilder(ExportTexytext::class) ->disableOriginalConstructor() - ->setMethods(['formatOneColumnDefinition']) + ->onlyMethods(['formatOneColumnDefinition']) ->getMock(); $this->object->expects($this->at(0)) @@ -326,7 +326,7 @@ public function testGetTableDefStandIn(): void public function testGetTableDef(): void { $this->object = $this->getMockBuilder(ExportTexytext::class) - ->setMethods(['formatOneColumnDefinition']) + ->onlyMethods(['formatOneColumnDefinition']) ->getMock(); // case 1 @@ -469,7 +469,7 @@ public function testExportStructure(): void ->will($this->returnValue(1)); $this->object = $this->getMockBuilder(ExportTexytext::class) - ->setMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) + ->onlyMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) ->getMock(); $this->object->expects($this->at(0)) diff --git a/test/classes/RelationCleanupTest.php b/test/classes/RelationCleanupTest.php index 97683ca174e2..e10c0c04d00b 100644 --- a/test/classes/RelationCleanupTest.php +++ b/test/classes/RelationCleanupTest.php @@ -77,7 +77,7 @@ protected function setUp(): void $this->relation = $this->getMockBuilder(Relation::class) ->disableOriginalConstructor() - ->setMethods(['queryAsControlUser']) + ->onlyMethods(['queryAsControlUser']) ->getMock(); $this->relationCleanup = new RelationCleanup($GLOBALS['dbi'], $this->relation); } diff --git a/test/classes/Setup/FormProcessingTest.php b/test/classes/Setup/FormProcessingTest.php index e38fd94eafdc..d4cbd54d57c5 100644 --- a/test/classes/Setup/FormProcessingTest.php +++ b/test/classes/Setup/FormProcessingTest.php @@ -50,7 +50,7 @@ public function testProcessFormSet(): void // case 1 $formDisplay = $this->getMockBuilder(FormDisplay::class) ->disableOriginalConstructor() - ->setMethods(['process', 'getDisplay']) + ->onlyMethods(['process', 'getDisplay']) ->getMock(); $formDisplay->expects($this->once()) @@ -66,7 +66,7 @@ public function testProcessFormSet(): void // case 2 $formDisplay = $this->getMockBuilder(FormDisplay::class) ->disableOriginalConstructor() - ->setMethods(['process', 'hasErrors', 'displayErrors']) + ->onlyMethods(['process', 'hasErrors', 'displayErrors']) ->getMock(); $formDisplay->expects($this->once()) @@ -108,7 +108,7 @@ public function testProcessFormSet(): void // case 3 $formDisplay = $this->getMockBuilder(FormDisplay::class) ->disableOriginalConstructor() - ->setMethods(['process', 'hasErrors']) + ->onlyMethods(['process', 'hasErrors']) ->getMock(); $formDisplay->expects($this->once()) diff --git a/test/classes/TwoFactorTest.php b/test/classes/TwoFactorTest.php index 233ba78e17c9..0f9e1fda1178 100644 --- a/test/classes/TwoFactorTest.php +++ b/test/classes/TwoFactorTest.php @@ -45,7 +45,7 @@ public function getTwoFactorMock(string $user, array $config): TwoFactor $config['settings'] = []; } $result = $this->getMockBuilder(TwoFactor::class) - ->setMethods(['readConfig']) + ->onlyMethods(['readConfig']) ->disableOriginalConstructor() ->getMock(); $result->method('readConfig')->willReturn($config); diff --git a/test/classes/UtilTest.php b/test/classes/UtilTest.php index 0909533a3ee8..5a81cde33a25 100644 --- a/test/classes/UtilTest.php +++ b/test/classes/UtilTest.php @@ -2412,7 +2412,7 @@ public function testCurrentUserHasNotUserPrivilege(): void public function testCurrentUserHasNotUserPrivilegeButDbPrivilege(): void { $dbi = $this->getMockBuilder(DatabaseInterface::class) - ->setMethods(['getCurrentUserAndHost', 'fetchValue']) + ->onlyMethods(['getCurrentUserAndHost', 'fetchValue']) ->disableOriginalConstructor() ->getMock(); @@ -2446,7 +2446,7 @@ public function testCurrentUserHasNotUserPrivilegeButDbPrivilege(): void public function testCurrentUserHasNotUserPrivilegeAndNotDbPrivilege(): void { $dbi = $this->getMockBuilder(DatabaseInterface::class) - ->setMethods(['getCurrentUserAndHost', 'fetchValue']) + ->onlyMethods(['getCurrentUserAndHost', 'fetchValue']) ->disableOriginalConstructor() ->getMock(); @@ -2480,7 +2480,7 @@ public function testCurrentUserHasNotUserPrivilegeAndNotDbPrivilege(): void public function testCurrentUserHasNotUserPrivilegeAndNotDbPrivilegeButTablePrivilege(): void { $dbi = $this->getMockBuilder(DatabaseInterface::class) - ->setMethods(['getCurrentUserAndHost', 'fetchValue']) + ->onlyMethods(['getCurrentUserAndHost', 'fetchValue']) ->disableOriginalConstructor() ->getMock(); @@ -2520,7 +2520,7 @@ public function testCurrentUserHasNotUserPrivilegeAndNotDbPrivilegeButTablePrivi public function testCurrentUserHasNotUserPrivilegeAndNotDbPrivilegeAndNotTablePrivilege(): void { $dbi = $this->getMockBuilder(DatabaseInterface::class) - ->setMethods(['getCurrentUserAndHost', 'fetchValue']) + ->onlyMethods(['getCurrentUserAndHost', 'fetchValue']) ->disableOriginalConstructor() ->getMock(); diff --git a/test/classes/VersionInformationTest.php b/test/classes/VersionInformationTest.php index b7ffa59f4766..990ed7ffb80d 100644 --- a/test/classes/VersionInformationTest.php +++ b/test/classes/VersionInformationTest.php @@ -175,7 +175,7 @@ public function testGetLatestCompatibleVersionWithSingleServer(): void ]; $mockVersionInfo = $this->getMockBuilder(VersionInformation::class) - ->setMethods(['evaluateVersionCondition']) + ->onlyMethods(['evaluateVersionCondition']) ->getMock(); $mockVersionInfo->expects($this->at(0)) @@ -209,7 +209,7 @@ public function testGetLatestCompatibleVersionWithMultipleServers(): void ]; $mockVersionInfo = $this->getMockBuilder(VersionInformation::class) - ->setMethods(['evaluateVersionCondition']) + ->onlyMethods(['evaluateVersionCondition']) ->getMock(); $mockVersionInfo->expects($this->at(0)) @@ -238,7 +238,7 @@ public function testGetLatestCompatibleVersionWithOldPHPVersion(): void ]; $mockVersionInfo = $this->getMockBuilder(VersionInformation::class) - ->setMethods(['evaluateVersionCondition']) + ->onlyMethods(['evaluateVersionCondition']) ->getMock(); $mockVersionInfo->expects($this->at(0)) @@ -283,7 +283,7 @@ public function testGetLatestCompatibleVersionWithNewPHPVersion( $GLOBALS['cfg']['Servers'] = []; $mockVersionInfo = $this->getMockBuilder(VersionInformation::class) - ->setMethods(['evaluateVersionCondition']) + ->onlyMethods(['evaluateVersionCondition']) ->getMock(); $i = 0; @@ -550,7 +550,7 @@ public function dataProviderVersionConditions(): array public function testEvaluateVersionCondition(): void { $mockVersionInfo = $this->getMockBuilder(VersionInformation::class) - ->setMethods(['getPHPVersion']) + ->onlyMethods(['getPHPVersion']) ->getMock(); $mockVersionInfo->expects($this->any())