From b4cdcbf82009ffaa72b5a9976c6d16ebca2ae41b Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Sat, 1 Aug 2026 07:54:31 +0200 Subject: [PATCH] Fix PHPUnit deprecations Signed-off-by: Liviu-Mihail Concioiu --- tests/unit/Database/CentralColumnsTest.php | 3 ++- tests/unit/Database/SearchTest.php | 4 +--- tests/unit/Http/Middleware/RecentTableHandlingTest.php | 2 +- tests/unit/Http/Middleware/UrlParamsSettingTest.php | 2 +- tests/unit/Plugins/Export/ExportSqlTest.php | 6 ++++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/unit/Database/CentralColumnsTest.php b/tests/unit/Database/CentralColumnsTest.php index 9453b26be3..e095323725 100644 --- a/tests/unit/Database/CentralColumnsTest.php +++ b/tests/unit/Database/CentralColumnsTest.php @@ -283,7 +283,8 @@ class CentralColumnsTest extends AbstractTestCase */ public function testGetHtmlForEditingPage(): void { - $this->dbi->method('fetchResultSimple') + $this->dbi->expects(self::once()) + ->method('fetchResultSimple') ->with( 'SELECT * FROM `phpmyadmin`.`pma_central_columns` ' . "WHERE db_name = 'phpmyadmin' AND col_name IN ('col1','col2');", diff --git a/tests/unit/Database/SearchTest.php b/tests/unit/Database/SearchTest.php index 6a542dcb34..11b7aeb5e5 100644 --- a/tests/unit/Database/SearchTest.php +++ b/tests/unit/Database/SearchTest.php @@ -32,11 +32,9 @@ class SearchTest extends AbstractTestCase Current::$database = 'pma'; $_POST = []; - //mock DBI - $dbi = $this->createMock(DatabaseInterface::class); + $dbi = $this->createStub(DatabaseInterface::class); $dbi->method('getColumns') - ->with('pma', 'table1') ->willReturn([ new Column('column1', '', null, false, '', null, '', '', ''), new Column('column2', '', null, false, '', null, '', '', ''), diff --git a/tests/unit/Http/Middleware/RecentTableHandlingTest.php b/tests/unit/Http/Middleware/RecentTableHandlingTest.php index 08e4b67e14..87659413fa 100644 --- a/tests/unit/Http/Middleware/RecentTableHandlingTest.php +++ b/tests/unit/Http/Middleware/RecentTableHandlingTest.php @@ -36,7 +36,7 @@ final class RecentTableHandlingTest extends AbstractTestCase $response = ResponseFactory::create()->createResponse(); $handler = $this->createMock(RequestHandlerInterface::class); - $handler->method('handle')->with($request)->willReturn($response); + $handler->expects(self::once())->method('handle')->with($request)->willReturn($response); $reflectionProperty = new ReflectionProperty(RecentFavoriteTables::class, 'instances'); $reflectionProperty->setValue(null, []); diff --git a/tests/unit/Http/Middleware/UrlParamsSettingTest.php b/tests/unit/Http/Middleware/UrlParamsSettingTest.php index ddc174630b..79d6ec62ec 100644 --- a/tests/unit/Http/Middleware/UrlParamsSettingTest.php +++ b/tests/unit/Http/Middleware/UrlParamsSettingTest.php @@ -27,7 +27,7 @@ final class UrlParamsSettingTest extends AbstractTestCase $response = self::createStub(ResponseInterface::class); $handler = $this->createMock(RequestHandlerInterface::class); - $handler->method('handle')->with($request)->willReturn($response); + $handler->expects(self::once())->method('handle')->with($request)->willReturn($response); $urlParamsSetting = new UrlParamsSetting(self::createStub(Config::class)); self::assertSame($response, $urlParamsSetting->process($request, $handler)); diff --git a/tests/unit/Plugins/Export/ExportSqlTest.php b/tests/unit/Plugins/Export/ExportSqlTest.php index aaf7d40256..368782047f 100644 --- a/tests/unit/Plugins/Export/ExportSqlTest.php +++ b/tests/unit/Plugins/Export/ExportSqlTest.php @@ -643,7 +643,8 @@ final class ExportSqlTest extends AbstractTestCase $dbi->method('quoteString') ->willReturnCallback(static fn (string $string): string => "'" . $string . "'"); - $dbi->method('getColumns') + $dbi->expects(self::once()) + ->method('getColumns') ->with('db', 'view') ->willReturn([ new Column( @@ -680,7 +681,8 @@ final class ExportSqlTest extends AbstractTestCase $dbi->method('quoteString') ->willReturnCallback(static fn (string $string): string => "'" . $string . "'"); - $dbi->method('getColumns') + $dbi->expects(self::once()) + ->method('getColumns') ->with('db', 'view') ->willReturn([ new Column(