diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 0c4d923c1d..65d1e87e05 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -190,3 +190,47 @@ jobs:
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: build/logs/clover.xml
+
+ test-php-with-newer-phpunit:
+ name: Test on PHP ${{ matrix.php }} with PHPUnit ${{ matrix.phpunit }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - { php: '8.3', phpunit: '12' }
+ - { php: '8.4', phpunit: '13' }
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v7
+ with:
+ persist-credentials: false
+
+ - name: Install gettext and generate translation files
+ run: |
+ sudo apt-get install -y gettext
+ ./bin/generate-mo --quiet
+
+ - name: Set up PHP ${{ matrix.php }}
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ extensions: mbstring, iconv, mysqli, zip, gd, bz2
+
+ - name: Update composer.json
+ shell: bash
+ env:
+ PHPUNIT_VERSION: ${{ matrix.phpunit }}
+ run: |
+ composer config --unset platform --no-interaction --ansi
+ composer remove --dev vimeo/psalm psalm/plugin-phpunit --no-update --no-interaction --ansi
+ composer require --dev phpunit/phpunit:^"$PHPUNIT_VERSION" --no-update --no-interaction --ansi
+ composer validate --strict
+
+ - name: Install Composer dependencies
+ uses: ramsey/composer-install@v4
+ with:
+ dependency-versions: highest
+
+ - name: Run PHP tests
+ run: vendor/bin/phpunit --testsuite unit --no-coverage --no-logging --display-all-issues
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index ab0de2b52f..b9e94f451f 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -13896,6 +13896,12 @@ parameters:
count: 3
path: tests/unit/Config/PageSettingsTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Config/ServerConfigChecksTest.php
+
-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertArrayHasKey\(\) with ''notice'' and array\{blowfish_secret\: ''aaaaaaaaaaaaaaaaaaa…'', Servers\: array\{1\: array\{host\: ''localhost'', auth_type\: ''cookie''\}\}\} will always evaluate to false\.$#'
identifier: staticMethod.impossibleType
@@ -14130,6 +14136,12 @@ parameters:
count: 1
path: tests/unit/Config/UserPreferencesTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/ConfigStorage/RelationTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -14238,6 +14250,12 @@ parameters:
count: 2
path: tests/unit/Controllers/Database/EventsControllerTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Controllers/Database/PrivilegesControllerTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -14274,6 +14292,12 @@ parameters:
count: 1
path: tests/unit/Controllers/Database/Structure/RealRowCountControllerTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Controllers/Database/StructureControllerTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -14346,6 +14370,12 @@ parameters:
count: 1
path: tests/unit/Controllers/Database/StructureControllerTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Controllers/Export/ExportControllerTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -14517,6 +14547,12 @@ parameters:
count: 1
path: tests/unit/Controllers/Server/Databases/DestroyControllerTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Controllers/Server/Databases/DestroyControllerTest.php
+
-
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
identifier: argument.type
@@ -14595,6 +14631,12 @@ parameters:
count: 1
path: tests/unit/Controllers/Server/ShowEngineControllerTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Controllers/Server/Status/AdvisorControllerTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -14862,6 +14904,12 @@ parameters:
count: 1
path: tests/unit/Controllers/Server/Status/VariablesControllerTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Controllers/Server/VariablesControllerTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -14967,6 +15015,12 @@ parameters:
count: 1
path: tests/unit/Controllers/Table/IndexRenameControllerTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Controllers/Table/IndexesControllerTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -14976,6 +15030,12 @@ parameters:
count: 2
path: tests/unit/Controllers/Table/IndexesControllerTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Controllers/Table/PrivilegesControllerTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -14994,6 +15054,12 @@ parameters:
count: 1
path: tests/unit/Controllers/Table/PrivilegesControllerTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Controllers/Table/RelationControllerTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -15081,6 +15147,12 @@ parameters:
count: 2
path: tests/unit/Controllers/ThemeSetControllerTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Controllers/Triggers/IndexControllerTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -15177,6 +15249,12 @@ parameters:
count: 1
path: tests/unit/Crypto/CryptoTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Database/CentralColumnsTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -15219,6 +15297,18 @@ parameters:
count: 1
path: tests/unit/Database/EventsTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Database/EventsTest.php
+
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Database/RoutinesTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -15291,6 +15381,12 @@ parameters:
count: 1
path: tests/unit/Dbal/DbiDummyTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 2
+ path: tests/unit/Dbal/DbiMysqliTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -15411,6 +15507,12 @@ parameters:
count: 1
path: tests/unit/Export/ExportTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Export/OptionsTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -15468,6 +15570,12 @@ parameters:
count: 2
path: tests/unit/Gis/Ds/PolygonTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Gis/GisGeometryTest.php
+
-
message: '#^Cannot access offset ''data_length'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
@@ -15705,6 +15813,12 @@ parameters:
count: 1
path: tests/unit/InsertEditTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 4
+ path: tests/unit/InsertEditTest.php
+
-
message: '#^Method PhpMyAdmin\\Tests\\InsertEditTest\:\:parseString\(\) should return string but returns mixed\.$#'
identifier: return.type
@@ -15774,6 +15888,12 @@ parameters:
count: 8
path: tests/unit/Navigation/Nodes/NodeTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Navigation/Nodes/NodeTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -15783,6 +15903,12 @@ parameters:
count: 4
path: tests/unit/Navigation/Nodes/ObjectFetcherTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/NormalizationTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -15993,6 +16119,12 @@ parameters:
count: 2
path: tests/unit/Plugins/Auth/AuthenticationConfigTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Plugins/Auth/AuthenticationConfigTest.php
+
-
message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{user\: ''username'', password\: ''password''\}\.$#'
identifier: assign.propertyType
@@ -16083,6 +16215,12 @@ parameters:
count: 2
path: tests/unit/Plugins/Auth/AuthenticationHttpTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Plugins/Auth/AuthenticationSignonTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16131,6 +16269,12 @@ parameters:
count: 1
path: tests/unit/Plugins/Export/ExportHtmlwordTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Plugins/Export/ExportHtmlwordTest.php
+
-
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
identifier: argument.type
@@ -16143,6 +16287,12 @@ parameters:
count: 1
path: tests/unit/Plugins/Export/ExportHtmlwordTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Plugins/Export/ExportLatexTest.php
+
-
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, string\|false given\.$#'
identifier: argument.type
@@ -16155,6 +16305,12 @@ parameters:
count: 1
path: tests/unit/Plugins/Export/ExportLatexTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Plugins/Export/ExportMediawikiTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16164,6 +16320,18 @@ parameters:
count: 1
path: tests/unit/Plugins/Export/ExportOdtTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Plugins/Export/ExportOdtTest.php
+
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Plugins/Export/ExportSqlTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16197,6 +16365,36 @@ parameters:
count: 2
path: tests/unit/Plugins/Export/ExportXmlTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 3
+ path: tests/unit/Plugins/Import/ImportCsvTest.php
+
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Plugins/Import/ImportLdiTest.php
+
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 2
+ path: tests/unit/Plugins/Import/ImportMediawikiTest.php
+
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Plugins/Import/ImportShpTest.php
+
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Plugins/Import/ImportXmlTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16278,6 +16476,18 @@ parameters:
count: 1
path: tests/unit/PluginsTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Properties/Options/OptionsPropertyGroupTest.php
+
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Properties/Options/OptionsPropertyOneItemTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16341,6 +16551,12 @@ parameters:
count: 1
path: tests/unit/Server/PluginsTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Server/PrivilegesTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16491,6 +16707,12 @@ parameters:
count: 1
path: tests/unit/Stubs/ResponseRenderer.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/SystemDatabaseTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16500,6 +16722,12 @@ parameters:
count: 1
path: tests/unit/SystemDatabaseTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/SystemDatabaseTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16509,6 +16737,18 @@ parameters:
count: 1
path: tests/unit/Table/ColumnsDefinitionTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Table/IndexesTest.php
+
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Table/IndexesTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
@@ -16518,6 +16758,12 @@ parameters:
count: 1
path: tests/unit/Table/SearchTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/Table/TableTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16590,6 +16836,18 @@ parameters:
count: 2
path: tests/unit/Tracking/TrackingTest.php
+ -
+ message: '#^Dynamic call to static method PHPUnit\\Framework\\TestCase\:\:createStub\(\)\.$#'
+ identifier: staticMethod.dynamicCall
+ count: 1
+ path: tests/unit/Tracking/TrackingTest.php
+
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/TransformationsTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16677,6 +16935,12 @@ parameters:
count: 4
path: tests/unit/UrlTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/UtilTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16800,6 +17064,12 @@ parameters:
count: 2
path: tests/unit/Utils/SessionCacheTest.php
+ -
+ message: '#^Attribute class PHPUnit\\Framework\\Attributes\\AllowMockObjectsWithoutExpectations does not exist\.$#'
+ identifier: attribute.notFound
+ count: 1
+ path: tests/unit/VersionInformationTest.php
+
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index f86744684e..0df845a89d 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -8763,6 +8763,9 @@
sessionID]]>
+
+
+
@@ -8943,6 +8946,9 @@
+
+
+
@@ -9007,6 +9013,9 @@
+
+
+
@@ -9085,12 +9094,18 @@
+
+
+
+
+
+
@@ -9232,6 +9247,9 @@
+
+
+
@@ -9344,6 +9362,9 @@
+
+
+
@@ -9405,12 +9426,18 @@
+
+
+
+
+
+
@@ -9420,6 +9447,9 @@
+
+
+
@@ -9478,6 +9508,9 @@
+
+
+
@@ -9557,6 +9590,9 @@
+
+
+
@@ -9584,6 +9620,9 @@
+
+
+
@@ -9723,6 +9762,9 @@
+
+
+
@@ -9774,6 +9816,9 @@
+
+
+
@@ -10015,6 +10060,9 @@
+
+
+
@@ -10148,6 +10196,9 @@
+
+
+
@@ -10198,6 +10249,9 @@
+
+
+
@@ -10214,12 +10268,20 @@
+
+
+
+
+
+
+
+
@@ -10262,6 +10324,16 @@
settings]]>
+
+
+
+
+
+
+
+
+
+
@@ -10301,6 +10373,9 @@
+
+
+
@@ -10396,12 +10471,20 @@
+
+
+
+
+
+
+
+
@@ -10416,6 +10499,9 @@
+
+
+
@@ -10461,6 +10547,9 @@
+
+
+
@@ -10542,6 +10631,9 @@
+
+
+
@@ -10636,5 +10728,8 @@
+
+
+
diff --git a/tests/unit/ApplicationTest.php b/tests/unit/ApplicationTest.php
index d87a1580f6..cedbbe574b 100644
--- a/tests/unit/ApplicationTest.php
+++ b/tests/unit/ApplicationTest.php
@@ -27,7 +27,7 @@ final class ApplicationTest extends AbstractTestCase
#[BackupStaticProperties(true)]
public function testRunWithConfigError(): void
{
- $config = self::createMock(Config::class);
+ $config = $this->createMock(Config::class);
$config->expects(self::once())->method('loadFromFile')
->willThrowException(new ConfigException('Failed to load phpMyAdmin configuration.'));
$config->config = new Config\Settings([]);
diff --git a/tests/unit/Config/ServerConfigChecksTest.php b/tests/unit/Config/ServerConfigChecksTest.php
index 5419a9c853..4ba3aa9c7e 100644
--- a/tests/unit/Config/ServerConfigChecksTest.php
+++ b/tests/unit/Config/ServerConfigChecksTest.php
@@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Config;
use PhpMyAdmin\Config\ConfigFile;
use PhpMyAdmin\Config\ServerConfigChecks;
use PhpMyAdmin\Tests\AbstractTestCase;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use ReflectionException;
@@ -19,6 +20,7 @@ use function str_repeat;
use const SODIUM_CRYPTO_SECRETBOX_KEYBYTES;
#[CoversClass(ServerConfigChecks::class)]
+#[AllowMockObjectsWithoutExpectations]
class ServerConfigChecksTest extends AbstractTestCase
{
private string $sessionID;
diff --git a/tests/unit/Config/UserPreferencesTest.php b/tests/unit/Config/UserPreferencesTest.php
index 09d0fc4eea..29565aeb11 100644
--- a/tests/unit/Config/UserPreferencesTest.php
+++ b/tests/unit/Config/UserPreferencesTest.php
@@ -103,9 +103,7 @@ class UserPreferencesTest extends AbstractTestCase
]);
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$query = 'SELECT `config_data`, UNIX_TIMESTAMP(`timevalue`) ts '
. 'FROM `pma\'db`.`testconf` WHERE `username` = \'user\'';
@@ -114,8 +112,7 @@ class UserPreferencesTest extends AbstractTestCase
->method('fetchSingleRow')
->with($query, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser)
->willReturn(['ts' => '123', 'config_data' => json_encode([1, 2])]);
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$userPreferences = new UserPreferences(
@@ -188,9 +185,7 @@ class UserPreferencesTest extends AbstractTestCase
$query2 = 'UPDATE `pmadb`.`testconf` SET `timevalue` = NOW(), `config_data` = \''
. json_encode([1]) . '\' WHERE `username` = \'user\'';
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('fetchValue')
@@ -202,8 +197,7 @@ class UserPreferencesTest extends AbstractTestCase
->with($query2, ConnectionType::ControlUser)
->willReturn(self::createStub(DummyResult::class));
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$userPreferences = new UserPreferences(
@@ -224,9 +218,7 @@ class UserPreferencesTest extends AbstractTestCase
$query2 = 'INSERT INTO `pmadb`.`testconf` (`username`, `timevalue`,`config_data`) '
. 'VALUES (\'user\', NOW(), \'' . json_encode([1]) . '\')';
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('fetchValue')
@@ -242,8 +234,7 @@ class UserPreferencesTest extends AbstractTestCase
->method('getError')
->with(ConnectionType::ControlUser)
->willReturn('err1');
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$userPreferences = new UserPreferences(
diff --git a/tests/unit/ConfigStorage/RelationCleanupTest.php b/tests/unit/ConfigStorage/RelationCleanupTest.php
index 81c807c94e..be8a10fc3e 100644
--- a/tests/unit/ConfigStorage/RelationCleanupTest.php
+++ b/tests/unit/ConfigStorage/RelationCleanupTest.php
@@ -17,7 +17,7 @@ class RelationCleanupTest extends AbstractTestCase
{
public function testColumnWithoutRelations(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::never())->method('queryAsControlUser');
(new RelationCleanup($dbi, new Relation($dbi)))->column('database', 'table', 'column');
@@ -37,8 +37,8 @@ class RelationCleanupTest extends AbstractTestCase
RelationParameters::COLUMN_INFO => 'column_info',
]));
- $dbi = self::createMock(DatabaseInterface::class);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$result = self::createStub(ResultInterface::class);
$dbi->expects(self::exactly(4))->method('queryAsControlUser')->willReturnMap([
@@ -69,7 +69,7 @@ class RelationCleanupTest extends AbstractTestCase
public function testTableWithoutRelations(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::never())->method('queryAsControlUser');
(new RelationCleanup($dbi, new Relation($dbi)))->table('database', 'table');
@@ -96,8 +96,8 @@ class RelationCleanupTest extends AbstractTestCase
RelationParameters::NAVIGATION_HIDING => 'navigationhiding',
]));
- $dbi = self::createMock(DatabaseInterface::class);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$result = self::createStub(ResultInterface::class);
$dbi->expects(self::exactly(7))->method('queryAsControlUser')->willReturnMap([
@@ -119,7 +119,7 @@ class RelationCleanupTest extends AbstractTestCase
public function testDatabaseWithoutRelations(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::never())->method('queryAsControlUser');
(new RelationCleanup($dbi, new Relation($dbi)))->database('database');
@@ -152,8 +152,8 @@ class RelationCleanupTest extends AbstractTestCase
RelationParameters::CENTRAL_COLUMNS => 'central_columns',
]));
- $dbi = self::createMock(DatabaseInterface::class);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$result = self::createStub(ResultInterface::class);
$dbi->expects(self::exactly(11))->method('queryAsControlUser')->willReturnMap([
@@ -175,7 +175,7 @@ class RelationCleanupTest extends AbstractTestCase
public function testUserWithoutRelations(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::never())->method('queryAsControlUser');
(new RelationCleanup($dbi, new Relation($dbi)))->user('user');
@@ -210,8 +210,8 @@ class RelationCleanupTest extends AbstractTestCase
RelationParameters::DESIGNER_SETTINGS => 'designer_settings',
]));
- $dbi = self::createMock(DatabaseInterface::class);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$result = self::createStub(ResultInterface::class);
$dbi->expects(self::exactly(10))->method('queryAsControlUser')->willReturnMap([
diff --git a/tests/unit/ConfigStorage/RelationTest.php b/tests/unit/ConfigStorage/RelationTest.php
index 379419a64e..b852985e55 100644
--- a/tests/unit/ConfigStorage/RelationTest.php
+++ b/tests/unit/ConfigStorage/RelationTest.php
@@ -16,6 +16,7 @@ use PhpMyAdmin\Message;
use PhpMyAdmin\SqlParser\Utils\ForeignKey;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DummyResult;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Medium;
@@ -25,6 +26,7 @@ use function implode;
#[CoversClass(Relation::class)]
#[Medium]
+#[AllowMockObjectsWithoutExpectations]
class RelationTest extends AbstractTestCase
{
/**
@@ -132,16 +134,13 @@ class RelationTest extends AbstractTestCase
$config = Config::getInstance();
$config->selectedServer['DisableIS'] = false;
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$getColumnsResult = [
new Column('field1', 'int(11)', null, false, '', null, '', '', 'Comment1'),
new Column('field2', 'text', null, false, '', null, '', '', 'Comment1'),
];
- $dbi->expects(self::any())->method('getColumns')
- ->willReturn($getColumnsResult);
+ $dbi->method('getColumns')->willReturn($getColumnsResult);
$relation = new Relation($dbi);
@@ -166,20 +165,12 @@ class RelationTest extends AbstractTestCase
*/
public function testPMATryUpgradeTransformations(): void
{
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())
- ->method('tryQueryAsControlUser')
- ->willReturn($resultStub);
- $resultStub->expects(self::any())
- ->method('numRows')
- ->willReturn(0);
- $dbi->expects(self::any())
- ->method('getError')
- ->willReturn('Error', '');
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('tryQueryAsControlUser')->willReturn($resultStub);
+ $resultStub->method('numRows')->willReturn(0);
+ $dbi->method('getError')->willReturn('Error', '');
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
diff --git a/tests/unit/ConfigStorage/UserGroupsTest.php b/tests/unit/ConfigStorage/UserGroupsTest.php
index 9b7be12b9a..3454301f67 100644
--- a/tests/unit/ConfigStorage/UserGroupsTest.php
+++ b/tests/unit/ConfigStorage/UserGroupsTest.php
@@ -49,11 +49,9 @@ class UserGroupsTest extends AbstractTestCase
{
$expectedQuery = 'SELECT * FROM `pmadb`.`usergroups` ORDER BY `usergroup` ASC';
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQueryAsControlUser')
->with($expectedQuery)
@@ -98,12 +96,12 @@ class UserGroupsTest extends AbstractTestCase
$userGrpDelQuery = 'DELETE FROM `pmadb`.`usergroups` WHERE `usergroup`=\'ug\'';
$result = self::createStub(ResultInterface::class);
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(2))->method('queryAsControlUser')->willReturnMap([
[$userDelQuery, $result],
[$userGrpDelQuery, $result],
]);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
UserGroups::delete($dbi, $this->configurableMenusFeature, 'ug');
@@ -119,12 +117,10 @@ class UserGroupsTest extends AbstractTestCase
self::assertStringContainsString('createMock(DummyResult::class);
$expectedQuery = 'SELECT * FROM `pmadb`.`usergroups` WHERE `usergroup`=\'user
group\'';
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQueryAsControlUser')
->with($expectedQuery)
@@ -134,7 +130,7 @@ class UserGroupsTest extends AbstractTestCase
->willReturnCallback(static function (): Generator {
yield ['usergroup' => 'user
group', 'tab' => 'server_sql', 'allowed' => 'Y'];
});
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
DatabaseInterface::$instance = $dbi;
diff --git a/tests/unit/Controllers/CollationConnectionControllerTest.php b/tests/unit/Controllers/CollationConnectionControllerTest.php
index a80c1e0dbc..87428f7942 100644
--- a/tests/unit/Controllers/CollationConnectionControllerTest.php
+++ b/tests/unit/Controllers/CollationConnectionControllerTest.php
@@ -21,12 +21,12 @@ class CollationConnectionControllerTest extends AbstractTestCase
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['collation_connection', null, 'utf8mb4_general_ci']]);
- $response = self::createMock(ResponseRenderer::class);
+ $response = $this->createMock(ResponseRenderer::class);
$response->expects(self::once())->method('redirect')
->with('index.php?route=/' . Url::getCommonRaw([], '&'));
$response->expects(self::once())->method('response')->willReturn(ResponseFactory::create()->createResponse());
- $userPreferencesHandler = self::createMock(UserPreferencesHandler::class);
+ $userPreferencesHandler = $this->createMock(UserPreferencesHandler::class);
$userPreferencesHandler->expects(self::once())->method('setUserValue')
->with('DefaultConnectionCollation', 'utf8mb4_general_ci', 'utf8mb4_unicode_ci');
$userPreferencesHandler->expects(self::once())->method('updateConfigValue')
diff --git a/tests/unit/Controllers/Database/PrivilegesControllerTest.php b/tests/unit/Controllers/Database/PrivilegesControllerTest.php
index a887b8bf02..5388155ee5 100644
--- a/tests/unit/Controllers/Database/PrivilegesControllerTest.php
+++ b/tests/unit/Controllers/Database/PrivilegesControllerTest.php
@@ -14,11 +14,13 @@ use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DbiDummy;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
use PhpMyAdmin\Url;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use function __;
#[CoversClass(PrivilegesController::class)]
+#[AllowMockObjectsWithoutExpectations]
class PrivilegesControllerTest extends AbstractTestCase
{
protected DatabaseInterface $dbi;
@@ -51,7 +53,7 @@ class PrivilegesControllerTest extends AbstractTestCase
$privileges = [];
- $serverPrivileges = self::createMock(Privileges::class);
+ $serverPrivileges = $this->createMock(Privileges::class);
$serverPrivileges->method('getAllPrivileges')
->willReturn($privileges);
diff --git a/tests/unit/Controllers/Database/StructureControllerTest.php b/tests/unit/Controllers/Database/StructureControllerTest.php
index ca54863aef..c1e1070c96 100644
--- a/tests/unit/Controllers/Database/StructureControllerTest.php
+++ b/tests/unit/Controllers/Database/StructureControllerTest.php
@@ -18,12 +18,14 @@ use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseStub;
use PhpMyAdmin\Tracking\TrackingChecker;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
#[CoversClass(StructureController::class)]
+#[AllowMockObjectsWithoutExpectations]
class StructureControllerTest extends AbstractTestCase
{
private ResponseStub $response;
@@ -46,20 +48,13 @@ class StructureControllerTest extends AbstractTestCase
Current::$table = 'table';
Current::$database = 'db';
- $table = $this->getMockBuilder(Table::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $table = $this->createMock(Table::class);
// Expect the table will have 6 rows
- $table->expects(self::any())->method('getRealRowCountTable')
- ->willReturn(6);
- $table->expects(self::any())->method('countRecords')
- ->willReturn(6);
+ $table->method('getRealRowCountTable')->willReturn(6);
+ $table->method('countRecords')->willReturn(6);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())->method('getTable')
- ->willReturn($table);
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('getTable')->willReturn($table);
DatabaseInterface::$instance = $dbi;
diff --git a/tests/unit/Controllers/Export/ExportControllerTest.php b/tests/unit/Controllers/Export/ExportControllerTest.php
index 7262ca9423..12aa58906a 100644
--- a/tests/unit/Controllers/Export/ExportControllerTest.php
+++ b/tests/unit/Controllers/Export/ExportControllerTest.php
@@ -26,6 +26,7 @@ use PhpMyAdmin\Tests\FieldHelper;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
use PhpMyAdmin\Theme\ThemeManager;
use PhpMyAdmin\ZipExtension;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use ReflectionProperty;
@@ -44,6 +45,7 @@ use const MYSQLI_TYPE_DECIMAL;
use const MYSQLI_TYPE_STRING;
#[CoversClass(ExportController::class)]
+#[AllowMockObjectsWithoutExpectations]
final class ExportControllerTest extends AbstractTestCase
{
public function testExportController(): void
diff --git a/tests/unit/Controllers/LogoutControllerTest.php b/tests/unit/Controllers/LogoutControllerTest.php
index 1b9c0ed7c2..cde912555f 100644
--- a/tests/unit/Controllers/LogoutControllerTest.php
+++ b/tests/unit/Controllers/LogoutControllerTest.php
@@ -23,7 +23,7 @@ final class LogoutControllerTest extends AbstractTestCase
$expectedResponse = ResponseFactory::create()->createResponse();
- $authPlugin = self::createMock(AuthenticationPlugin::class);
+ $authPlugin = $this->createMock(AuthenticationPlugin::class);
$authPlugin->expects(self::once())->method('logOut')->willReturn($expectedResponse);
$factory = self::createStub(AuthenticationPluginFactory::class);
diff --git a/tests/unit/Controllers/Server/Databases/DestroyControllerTest.php b/tests/unit/Controllers/Server/Databases/DestroyControllerTest.php
index 14c02e3ea5..46b31ebf4e 100644
--- a/tests/unit/Controllers/Server/Databases/DestroyControllerTest.php
+++ b/tests/unit/Controllers/Server/Databases/DestroyControllerTest.php
@@ -30,9 +30,7 @@ class DestroyControllerTest extends AbstractTestCase
public function testDropDatabases(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$response = new ResponseRenderer();
diff --git a/tests/unit/Controllers/Server/PluginsControllerTest.php b/tests/unit/Controllers/Server/PluginsControllerTest.php
index de312d09df..0074d4852b 100644
--- a/tests/unit/Controllers/Server/PluginsControllerTest.php
+++ b/tests/unit/Controllers/Server/PluginsControllerTest.php
@@ -57,11 +57,9 @@ class PluginsControllerTest extends AbstractTestCase
'PLUGIN_STATUS' => 'ACTIVE',
];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('query')
->willReturn($resultStub);
diff --git a/tests/unit/Controllers/Server/Status/AdvisorControllerTest.php b/tests/unit/Controllers/Server/Status/AdvisorControllerTest.php
index 8d99bf2284..6b503635da 100644
--- a/tests/unit/Controllers/Server/Status/AdvisorControllerTest.php
+++ b/tests/unit/Controllers/Server/Status/AdvisorControllerTest.php
@@ -13,10 +13,12 @@ use PhpMyAdmin\Server\Status\Data;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
#[CoversClass(AdvisorController::class)]
+#[AllowMockObjectsWithoutExpectations]
class AdvisorControllerTest extends AbstractTestCase
{
private ResponseRenderer $response;
@@ -89,7 +91,7 @@ class AdvisorControllerTest extends AbstractTestCase
],
];
- $advisor = self::createMock(Advisor::class);
+ $advisor = $this->createMock(Advisor::class);
$advisor->method('run')->willReturn($advisorData);
$controller = new AdvisorController($this->response, $this->template, $this->data, $advisor);
diff --git a/tests/unit/Controllers/Server/VariablesControllerTest.php b/tests/unit/Controllers/Server/VariablesControllerTest.php
index e5ff9b1815..334d1ed94a 100644
--- a/tests/unit/Controllers/Server/VariablesControllerTest.php
+++ b/tests/unit/Controllers/Server/VariablesControllerTest.php
@@ -18,6 +18,7 @@ use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseStub;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use ReflectionMethod;
@@ -28,6 +29,7 @@ use function htmlspecialchars;
use function str_replace;
#[CoversClass(VariablesController::class)]
+#[AllowMockObjectsWithoutExpectations]
class VariablesControllerTest extends AbstractTestCase
{
private DatabaseInterface&MockObject $mockedDbi;
@@ -42,9 +44,7 @@ class VariablesControllerTest extends AbstractTestCase
Current::$table = 'table';
Config::getInstance()->selectedServer['DisableIS'] = false;
- $this->mockedDbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->mockedDbi = $this->createMock(DatabaseInterface::class);
//this data is needed when PhpMyAdmin\Server\Status\Data constructs
$serverSessionVariables = [
@@ -62,8 +62,7 @@ class VariablesControllerTest extends AbstractTestCase
['SHOW GLOBAL VARIABLES;', 0, 1, ConnectionType::User, $serverGlobalVariables],
];
- $this->mockedDbi->expects(self::any())->method('fetchResult')
- ->willReturnMap($fetchResult);
+ $this->mockedDbi->method('fetchResult')->willReturnMap($fetchResult);
}
public function testIndex(): void
@@ -128,7 +127,7 @@ class VariablesControllerTest extends AbstractTestCase
//name is_numeric and the value type is byte
$args = [$nameForValueByte, '3'];
- $voidProviderMock = $this->getMockBuilder(ServerVariablesVoidProvider::class)->getMock();
+ $voidProviderMock = $this->createMock(ServerVariablesVoidProvider::class);
$voidProviderMock
->expects(self::exactly(2))
diff --git a/tests/unit/Controllers/Table/ChangeRowsControllerTest.php b/tests/unit/Controllers/Table/ChangeRowsControllerTest.php
index 513fae5a15..d89e1dbd04 100644
--- a/tests/unit/Controllers/Table/ChangeRowsControllerTest.php
+++ b/tests/unit/Controllers/Table/ChangeRowsControllerTest.php
@@ -32,7 +32,7 @@ class ChangeRowsControllerTest extends AbstractTestCase
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
->withParsedBody(['rows_to_delete' => 'row']);
- $mock = self::createMock(ChangeController::class);
+ $mock = $this->createMock(ChangeController::class);
$mock->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
@@ -46,7 +46,7 @@ class ChangeRowsControllerTest extends AbstractTestCase
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
->withParsedBody(['goto' => 'goto']);
- $mock = self::createMock(ChangeController::class);
+ $mock = $this->createMock(ChangeController::class);
$mock->expects(self::never())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
@@ -63,7 +63,7 @@ class ChangeRowsControllerTest extends AbstractTestCase
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
->withParsedBody(['goto' => 'goto', 'rows_to_delete' => ['key1' => 'row1', 'key2' => 'row2']]);
- $mock = self::createMock(ChangeController::class);
+ $mock = $this->createMock(ChangeController::class);
$mock->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
diff --git a/tests/unit/Controllers/Table/IndexesControllerTest.php b/tests/unit/Controllers/Table/IndexesControllerTest.php
index 8210214da4..7ed4a5612b 100644
--- a/tests/unit/Controllers/Table/IndexesControllerTest.php
+++ b/tests/unit/Controllers/Table/IndexesControllerTest.php
@@ -20,6 +20,7 @@ use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseStub;
use PhpMyAdmin\Url;
use PhpMyAdmin\UrlParams;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use ReflectionMethod;
@@ -27,6 +28,7 @@ use function __;
use function sprintf;
#[CoversClass(IndexesController::class)]
+#[AllowMockObjectsWithoutExpectations]
class IndexesControllerTest extends AbstractTestCase
{
/**
@@ -52,9 +54,7 @@ class IndexesControllerTest extends AbstractTestCase
*/
public function testDisplayFormAction(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$indexs = [
['Schema' => 'Schema1', 'Key_name' => 'Key_name1', 'Column_name' => 'Column_name1'],
@@ -62,23 +62,16 @@ class IndexesControllerTest extends AbstractTestCase
['Schema' => 'Schema3', 'Key_name' => 'Key_name3', 'Column_name' => 'Column_name3'],
];
- $dbi->expects(self::any())->method('getTableIndexes')
- ->willReturn($indexs);
+ $dbi->method('getTableIndexes')->willReturn($indexs);
DatabaseInterface::$instance = $dbi;
- $table = $this->getMockBuilder(Table::class)
- ->disableOriginalConstructor()
- ->getMock();
- $table->expects(self::any())->method('getStatusInfo')
- ->willReturn('');
- $table->expects(self::any())->method('isView')
- ->willReturn(false);
- $table->expects(self::any())->method('getNameAndTypeOfTheColumns')
- ->willReturn(['field_name' => 'field_type']);
+ $table = $this->createMock(Table::class);
+ $table->method('getStatusInfo')->willReturn('');
+ $table->method('isView')->willReturn(false);
+ $table->method('getNameAndTypeOfTheColumns')->willReturn(['field_name' => 'field_type']);
- $dbi->expects(self::any())->method('getTable')
- ->willReturn($table);
+ $dbi->method('getTable')->willReturn($table);
$response = new ResponseStub();
$index = new Index();
diff --git a/tests/unit/Controllers/Table/PrivilegesControllerTest.php b/tests/unit/Controllers/Table/PrivilegesControllerTest.php
index d0cb649a01..f330eb8a8f 100644
--- a/tests/unit/Controllers/Table/PrivilegesControllerTest.php
+++ b/tests/unit/Controllers/Table/PrivilegesControllerTest.php
@@ -13,11 +13,13 @@ use PhpMyAdmin\Server\Privileges;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
use PhpMyAdmin\Url;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use function __;
#[CoversClass(PrivilegesController::class)]
+#[AllowMockObjectsWithoutExpectations]
class PrivilegesControllerTest extends AbstractTestCase
{
/**
@@ -51,7 +53,7 @@ class PrivilegesControllerTest extends AbstractTestCase
$privileges = [];
- $serverPrivileges = self::createMock(Privileges::class);
+ $serverPrivileges = $this->createMock(Privileges::class);
$serverPrivileges->method('getAllPrivileges')
->willReturn($privileges);
diff --git a/tests/unit/Controllers/Table/RelationControllerTest.php b/tests/unit/Controllers/Table/RelationControllerTest.php
index 82a2f820cb..5acd2e0ffa 100644
--- a/tests/unit/Controllers/Table/RelationControllerTest.php
+++ b/tests/unit/Controllers/Table/RelationControllerTest.php
@@ -14,10 +14,12 @@ use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseStub;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
#[CoversClass(RelationController::class)]
+#[AllowMockObjectsWithoutExpectations]
class RelationControllerTest extends AbstractTestCase
{
private ResponseStub $response;
@@ -42,9 +44,7 @@ class RelationControllerTest extends AbstractTestCase
$_POST['foreignDb'] = 'db';
$_POST['foreignTable'] = 'table';
- $this->dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->dbi = $this->createMock(DatabaseInterface::class);
$this->response = new ResponseStub();
$this->template = new Template($config);
@@ -59,17 +59,12 @@ class RelationControllerTest extends AbstractTestCase
public function testGetDropdownValueForTableActionIsView(): void
{
$viewColumns = ['viewCol', 'viewCol2', 'viewCol3'];
- $tableMock = $this->getMockBuilder(Table::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $tableMock = $this->createMock(Table::class);
// Test the situation when the table is a view
- $tableMock->expects(self::any())->method('isView')
- ->willReturn(true);
- $tableMock->expects(self::any())->method('getColumns')
- ->willReturn($viewColumns);
+ $tableMock->method('isView')->willReturn(true);
+ $tableMock->method('getColumns')->willReturn($viewColumns);
- $this->dbi->expects(self::any())->method('getTable')
- ->willReturn($tableMock);
+ $this->dbi->method('getTable')->willReturn($tableMock);
$ctrl = new RelationController(
$this->response,
@@ -93,17 +88,12 @@ class RelationControllerTest extends AbstractTestCase
public function testGetDropdownValueForTableActionNotView(): void
{
$indexedColumns = ['primaryTableCol'];
- $tableMock = $this->getMockBuilder(Table::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $tableMock = $this->createMock(Table::class);
// Test the situation when the table is a view
- $tableMock->expects(self::any())->method('isView')
- ->willReturn(false);
- $tableMock->expects(self::any())->method('getIndexedColumns')
- ->willReturn($indexedColumns);
+ $tableMock->method('isView')->willReturn(false);
+ $tableMock->method('getIndexedColumns')->willReturn($indexedColumns);
- $this->dbi->expects(self::any())->method('getTable')
- ->willReturn($tableMock);
+ $this->dbi->method('getTable')->willReturn($tableMock);
$ctrl = new RelationController(
$this->response,
@@ -131,9 +121,7 @@ class RelationControllerTest extends AbstractTestCase
->method('query')
->willReturn($resultStub);
- $resultStub->expects(self::any())
- ->method('fetchAllColumn')
- ->willReturn(['table']);
+ $resultStub->method('fetchAllColumn')->willReturn(['table']);
$ctrl = new RelationController(
$this->response,
diff --git a/tests/unit/Controllers/Table/Structure/SaveControllerTest.php b/tests/unit/Controllers/Table/Structure/SaveControllerTest.php
index 7fe3de143a..0a763e13b8 100644
--- a/tests/unit/Controllers/Table/Structure/SaveControllerTest.php
+++ b/tests/unit/Controllers/Table/Structure/SaveControllerTest.php
@@ -91,7 +91,7 @@ class SaveControllerTest extends AbstractTestCase
$request = self::createStub(ServerRequest::class);
- $mock = self::createMock(StructureController::class);
+ $mock = $this->createMock(StructureController::class);
$mock->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
diff --git a/tests/unit/Controllers/Table/Structure/SpatialControllerTest.php b/tests/unit/Controllers/Table/Structure/SpatialControllerTest.php
index 2742152da6..84c76b7ae0 100644
--- a/tests/unit/Controllers/Table/Structure/SpatialControllerTest.php
+++ b/tests/unit/Controllers/Table/Structure/SpatialControllerTest.php
@@ -33,7 +33,7 @@ class SpatialControllerTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['selected_fld', [], ['test_field']]]);
- $controllerStub = self::createMock(StructureController::class);
+ $controllerStub = $this->createMock(StructureController::class);
$controllerStub->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
@@ -62,7 +62,7 @@ class SpatialControllerTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['selected_fld', [], ['test_field1', 'test_field2']]]);
- $controllerStub = self::createMock(StructureController::class);
+ $controllerStub = $this->createMock(StructureController::class);
$controllerStub->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
@@ -88,7 +88,7 @@ class SpatialControllerTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['selected_fld', [], null]]);
- $controllerStub = self::createMock(StructureController::class);
+ $controllerStub = $this->createMock(StructureController::class);
$controllerStub->expects(self::never())->method('__invoke');
$response = new ResponseRenderer();
@@ -119,7 +119,7 @@ class SpatialControllerTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['selected_fld', [], ['test_field']]]);
- $controllerStub = self::createMock(StructureController::class);
+ $controllerStub = $this->createMock(StructureController::class);
$controllerStub->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
diff --git a/tests/unit/Controllers/Table/Structure/UniqueControllerTest.php b/tests/unit/Controllers/Table/Structure/UniqueControllerTest.php
index 7f474a80a5..00e1b098a4 100644
--- a/tests/unit/Controllers/Table/Structure/UniqueControllerTest.php
+++ b/tests/unit/Controllers/Table/Structure/UniqueControllerTest.php
@@ -33,7 +33,7 @@ class UniqueControllerTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['selected_fld', [], ['test_field']]]);
- $controllerStub = self::createMock(StructureController::class);
+ $controllerStub = $this->createMock(StructureController::class);
$controllerStub->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
@@ -62,7 +62,7 @@ class UniqueControllerTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['selected_fld', [], ['test_field1', 'test_field2']]]);
- $controllerStub = self::createMock(StructureController::class);
+ $controllerStub = $this->createMock(StructureController::class);
$controllerStub->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
@@ -88,7 +88,7 @@ class UniqueControllerTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['selected_fld', [], null]]);
- $controllerStub = self::createMock(StructureController::class);
+ $controllerStub = $this->createMock(StructureController::class);
$controllerStub->expects(self::never())->method('__invoke');
$response = new ResponseRenderer();
@@ -119,7 +119,7 @@ class UniqueControllerTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['selected_fld', [], ['test_field']]]);
- $controllerStub = self::createMock(StructureController::class);
+ $controllerStub = $this->createMock(StructureController::class);
$controllerStub->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
diff --git a/tests/unit/Controllers/ThemeSetControllerTest.php b/tests/unit/Controllers/ThemeSetControllerTest.php
index a029ea6054..944e3ef794 100644
--- a/tests/unit/Controllers/ThemeSetControllerTest.php
+++ b/tests/unit/Controllers/ThemeSetControllerTest.php
@@ -33,11 +33,11 @@ class ThemeSetControllerTest extends AbstractTestCase
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['set_theme' => 'theme_name', 'themeColorMode' => '']);
- $themeManager = self::createMock(ThemeManager::class);
+ $themeManager = $this->createMock(ThemeManager::class);
$themeManager->expects(self::once())->method('setActiveTheme')->with(self::equalTo('theme_name'));
$themeManager->expects(self::once())->method('setThemeCookie');
- $userPreferences = self::createMock(UserPreferences::class);
+ $userPreferences = $this->createMock(UserPreferences::class);
$userPreferences->expects(self::once())->method('load')
->willReturn(['config_data' => ['ThemeDefault' => 'pmahomme']]);
$userPreferences->expects(self::once())->method('save')
@@ -55,11 +55,11 @@ class ThemeSetControllerTest extends AbstractTestCase
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['set_theme' => $themeName]);
- $themeManager = self::createMock(ThemeManager::class);
+ $themeManager = $this->createMock(ThemeManager::class);
$themeManager->expects(self::never())->method('setActiveTheme');
$themeManager->expects(self::never())->method('setThemeCookie');
- $userPreferences = self::createMock(UserPreferences::class);
+ $userPreferences = $this->createMock(UserPreferences::class);
$userPreferences->expects(self::never())->method('load');
$userPreferences->expects(self::never())->method('save');
diff --git a/tests/unit/Controllers/Triggers/IndexControllerTest.php b/tests/unit/Controllers/Triggers/IndexControllerTest.php
index 069cf9164b..826eda4334 100644
--- a/tests/unit/Controllers/Triggers/IndexControllerTest.php
+++ b/tests/unit/Controllers/Triggers/IndexControllerTest.php
@@ -15,12 +15,14 @@ use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
use PhpMyAdmin\Triggers\Triggers;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use ReflectionClass;
#[CoversClass(IndexController::class)]
#[CoversClass(Triggers::class)]
+#[AllowMockObjectsWithoutExpectations]
final class IndexControllerTest extends AbstractTestCase
{
public function testWithTriggers(): void
@@ -350,9 +352,7 @@ final class IndexControllerTest extends AbstractTestCase
);
$request = $this->createMock(ServerRequest::class);
- $request->expects(self::any())
- ->method('getParsedBodyParam')
- ->willReturn('foo');
+ $request->method('getParsedBodyParam')->willReturn('foo');
$output = $method->invoke($indexController, $request);
self::assertSame($out, $output);
diff --git a/tests/unit/Database/CentralColumnsTest.php b/tests/unit/Database/CentralColumnsTest.php
index d0210d83c6..9453b26be3 100644
--- a/tests/unit/Database/CentralColumnsTest.php
+++ b/tests/unit/Database/CentralColumnsTest.php
@@ -16,6 +16,7 @@ use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Types;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
@@ -28,6 +29,7 @@ use function array_slice;
#[CoversClass(CentralColumns::class)]
#[PreserveGlobalState(false)]
#[RunTestsInSeparateProcesses]
+#[AllowMockObjectsWithoutExpectations]
class CentralColumnsTest extends AbstractTestCase
{
private CentralColumns $centralColumns;
@@ -120,34 +122,22 @@ class CentralColumnsTest extends AbstractTestCase
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters);
// mock DBI
- $this->dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->dbi = $this->createMock(DatabaseInterface::class);
$this->dbi->types = new Types($this->dbi);
DatabaseInterface::$instance = $this->dbi;
// set some common expectations
- $this->dbi->expects(self::any())
- ->method('selectDb')
- ->willReturn(true);
- $this->dbi->expects(self::any())
- ->method('getColumns')
- ->willReturn([
- 'id' => new Column('id', 'integer', null, false, '', null, '', '', ''),
- 'col1' => new Column('col1', 'varchar(100)', null, true, '', null, '', '', ''),
- 'col2' => new Column('col2', 'DATETIME', null, false, '', null, '', '', ''),
- ]);
- $this->dbi->expects(self::any())
- ->method('getColumnNames')
- ->willReturn(['id', 'col1', 'col2']);
- $this->dbi->expects(self::any())
- ->method('tryQuery')
- ->willReturn(self::createStub(DummyResult::class));
- $this->dbi->expects(self::any())
- ->method('getTables')
- ->willReturn(['PMA_table', 'PMA_table1', 'PMA_table2']);
- $this->dbi->expects(self::any())->method('quoteString')
- ->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
+ $this->dbi->method('selectDb')->willReturn(true);
+ $this->dbi->method('getColumns')->willReturn([
+ 'id' => new Column('id', 'integer', null, false, '', null, '', '', ''),
+ 'col1' => new Column('col1', 'varchar(100)', null, true, '', null, '', '', ''),
+ 'col2' => new Column('col2', 'DATETIME', null, false, '', null, '', '', ''),
+ ]);
+ $this->dbi->method('getColumnNames')->willReturn(['id', 'col1', 'col2']);
+ $this->dbi->method('tryQuery')->willReturn(self::createStub(DummyResult::class));
+ $this->dbi->method('getTables')->willReturn(['PMA_table', 'PMA_table1', 'PMA_table2']);
+ $this->dbi->method('quoteString')
+ ->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$this->centralColumns = new CentralColumns($this->dbi);
}
@@ -223,12 +213,8 @@ class CentralColumnsTest extends AbstractTestCase
*/
public function testMakeConsistentWithList(): void
{
- $this->dbi->expects(self::any())
- ->method('fetchResult')
- ->willReturn(self::COLUMN_DATA);
- $this->dbi->expects(self::any())
- ->method('fetchValue')
- ->willReturn('PMA_table=CREATE table `PMA_table` (id integer)');
+ $this->dbi->method('fetchResult')->willReturn(self::COLUMN_DATA);
+ $this->dbi->method('fetchValue')->willReturn('PMA_table=CREATE table `PMA_table` (id integer)');
self::assertTrue(
$this->centralColumns->makeConsistentWithList(
'phpmyadmin',
@@ -297,8 +283,7 @@ class CentralColumnsTest extends AbstractTestCase
*/
public function testGetHtmlForEditingPage(): void
{
- $this->dbi->expects(self::any())
- ->method('fetchResultSimple')
+ $this->dbi->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/DesignerTest.php b/tests/unit/Database/DesignerTest.php
index dc2fc2caa0..3aa0428a64 100644
--- a/tests/unit/Database/DesignerTest.php
+++ b/tests/unit/Database/DesignerTest.php
@@ -49,9 +49,7 @@ class DesignerTest extends AbstractTestCase
{
$resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQueryAsControlUser')
@@ -68,7 +66,7 @@ class DesignerTest extends AbstractTestCase
'2' => 'page2',
]);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
DatabaseInterface::$instance = $dbi;
diff --git a/tests/unit/Database/EventsTest.php b/tests/unit/Database/EventsTest.php
index a1576ec716..2359339979 100644
--- a/tests/unit/Database/EventsTest.php
+++ b/tests/unit/Database/EventsTest.php
@@ -146,9 +146,7 @@ class EventsTest extends AbstractTestCase
unset($_POST);
$_POST = $request;
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
DatabaseInterface::$instance = $dbi;
self::assertSame($query, $this->events->getQueryFromRequest());
diff --git a/tests/unit/Database/RoutinesTest.php b/tests/unit/Database/RoutinesTest.php
index 7da464fe18..37ac18e3eb 100644
--- a/tests/unit/Database/RoutinesTest.php
+++ b/tests/unit/Database/RoutinesTest.php
@@ -13,10 +13,12 @@ use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Types;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
#[CoversClass(Routines::class)]
+#[AllowMockObjectsWithoutExpectations]
class RoutinesTest extends AbstractTestCase
{
private Routines $routines;
@@ -232,16 +234,12 @@ class RoutinesTest extends AbstractTestCase
{
$config = Config::getInstance();
$oldDbi = DatabaseInterface::getInstance();
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->types = new Types($dbi);
- $dbi->expects(self::any())
- ->method('quoteString')
- ->willReturnMap([
- ['foo', ConnectionType::User, "'foo'"],
- ["foo's bar", ConnectionType::User, "'foo\'s bar'"],
- ]);
+ $dbi->method('quoteString')->willReturnMap([
+ ['foo', ConnectionType::User, "'foo'"],
+ ["foo's bar", ConnectionType::User, "'foo\'s bar'"],
+ ]);
DatabaseInterface::$instance = $dbi;
$routines = new Routines($dbi, $config);
diff --git a/tests/unit/Database/SearchTest.php b/tests/unit/Database/SearchTest.php
index 6f921503ef..6a542dcb34 100644
--- a/tests/unit/Database/SearchTest.php
+++ b/tests/unit/Database/SearchTest.php
@@ -33,20 +33,16 @@ class SearchTest extends AbstractTestCase
$_POST = [];
//mock DBI
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
- $dbi->expects(self::any())
- ->method('getColumns')
+ $dbi->method('getColumns')
->with('pma', 'table1')
->willReturn([
new Column('column1', '', null, false, '', null, '', '', ''),
new Column('column2', '', null, false, '', null, '', '', ''),
]);
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
DatabaseInterface::$instance = $dbi;
diff --git a/tests/unit/DbTableExistsTest.php b/tests/unit/DbTableExistsTest.php
index 863ef093bf..967effb756 100644
--- a/tests/unit/DbTableExistsTest.php
+++ b/tests/unit/DbTableExistsTest.php
@@ -27,7 +27,7 @@ final class DbTableExistsTest extends AbstractTestCase
public function testHasDatabaseWithNoDatabase(): void
{
$db = DatabaseName::from('test_db');
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('selectDb')->with($db)->willReturn(false);
$dbTableExists = new DbTableExists($dbi);
self::assertFalse($dbTableExists->selectDatabase($db));
diff --git a/tests/unit/Dbal/DbiMysqliTest.php b/tests/unit/Dbal/DbiMysqliTest.php
index f90e26bc52..46a5573317 100644
--- a/tests/unit/Dbal/DbiMysqliTest.php
+++ b/tests/unit/Dbal/DbiMysqliTest.php
@@ -40,7 +40,7 @@ class DbiMysqliTest extends AbstractTestCase
public function testSelectDb(): void
{
$databaseName = 'test';
- $mysqli = self::createMock(mysqli::class);
+ $mysqli = $this->createMock(mysqli::class);
$mysqli->expects(self::once())
->method('select_db')
->with(self::equalTo($databaseName))
@@ -55,7 +55,7 @@ class DbiMysqliTest extends AbstractTestCase
public function testRealMultiQuery(): void
{
$query = 'test';
- $mysqli = self::createMock(mysqli::class);
+ $mysqli = $this->createMock(mysqli::class);
$mysqli->expects(self::once())
->method('multi_query')
->with(self::equalTo($query))
@@ -70,8 +70,8 @@ class DbiMysqliTest extends AbstractTestCase
public function testrealQuery(): void
{
$query = 'test';
- $mysqliResult = self::createMock(mysqli_result::class);
- $mysqli = self::createMock(mysqli::class);
+ $mysqliResult = $this->createStub(mysqli_result::class);
+ $mysqli = $this->createMock(mysqli::class);
$mysqli->expects(self::once())
->method('query')
->with(self::equalTo($query))
@@ -85,7 +85,7 @@ class DbiMysqliTest extends AbstractTestCase
*/
public function testNextResult(): void
{
- $mysqli = self::createMock(mysqli::class);
+ $mysqli = $this->createMock(mysqli::class);
$mysqli->expects(self::once())
->method('next_result')
->willReturn(true);
@@ -98,8 +98,8 @@ class DbiMysqliTest extends AbstractTestCase
*/
public function testStoreResult(): void
{
- $mysqli = self::createMock(mysqli::class);
- $mysqliResult = self::createMock(mysqli_result::class);
+ $mysqli = $this->createMock(mysqli::class);
+ $mysqliResult = $this->createStub(mysqli_result::class);
$mysqli->expects(self::once())
->method('store_result')
->willReturn($mysqliResult);
@@ -113,7 +113,7 @@ class DbiMysqliTest extends AbstractTestCase
public function testEscapeString(): void
{
$string = 'test';
- $mysqli = self::createMock(mysqli::class);
+ $mysqli = $this->createMock(mysqli::class);
$mysqli->expects(self::once())
->method('real_escape_string')
->willReturn($string);
diff --git a/tests/unit/Dbal/MysqliResultTest.php b/tests/unit/Dbal/MysqliResultTest.php
index db7a02ce61..195bf7d4b8 100644
--- a/tests/unit/Dbal/MysqliResultTest.php
+++ b/tests/unit/Dbal/MysqliResultTest.php
@@ -22,7 +22,7 @@ class MysqliResultTest extends AbstractTestCase
public function testFetchAssoc(): void
{
$expected = [['foo' => 'bar'], null];
- $mysqliResult = self::createMock(mysqli_result::class);
+ $mysqliResult = $this->createMock(mysqli_result::class);
$mysqliResult->expects(self::exactly(2))
->method('fetch_assoc')
->willReturn(...$expected);
@@ -39,7 +39,7 @@ class MysqliResultTest extends AbstractTestCase
public function testFetchRow(): void
{
$expected = [['bar'], null];
- $mysqliResult = self::createMock(mysqli_result::class);
+ $mysqliResult = $this->createMock(mysqli_result::class);
$mysqliResult->expects(self::exactly(2))
->method('fetch_row')
->willReturn(...$expected);
@@ -56,7 +56,7 @@ class MysqliResultTest extends AbstractTestCase
public function testDataSeek(): void
{
$offset = 1;
- $mysqliResult = self::createMock(mysqli_result::class);
+ $mysqliResult = $this->createMock(mysqli_result::class);
$mysqliResult->expects(self::once())
->method('data_seek')
->with(self::equalTo($offset))
@@ -72,7 +72,7 @@ class MysqliResultTest extends AbstractTestCase
*/
public function testFetchAllColumn(): void
{
- $mysqliResult = self::createMock(mysqli_result::class);
+ $mysqliResult = $this->createMock(mysqli_result::class);
$mysqliResult->expects(self::exactly(3))
->method('fetch_all')
->willReturnMap([
diff --git a/tests/unit/Display/ResultsTest.php b/tests/unit/Display/ResultsTest.php
index 1ea4ff13d2..085beead22 100644
--- a/tests/unit/Display/ResultsTest.php
+++ b/tests/unit/Display/ResultsTest.php
@@ -620,9 +620,7 @@ class ResultsTest extends AbstractTestCase
]),
]);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
// MIME transformations
$dbi->expects(self::exactly(1))
diff --git a/tests/unit/Error/ErrorTest.php b/tests/unit/Error/ErrorTest.php
index 622d616f01..e95727263b 100644
--- a/tests/unit/Error/ErrorTest.php
+++ b/tests/unit/Error/ErrorTest.php
@@ -118,7 +118,7 @@ class ErrorTest extends AbstractTestCase
public function testGetBacktraceDisplay(): void
{
self::assertStringContainsString(
- 'PHPUnit\Framework\TestRunner->run()',
+ '->run()',
$this->object->getBacktraceDisplay(),
);
}
@@ -136,7 +136,7 @@ class ErrorTest extends AbstractTestCase
$actual,
);
self::assertStringContainsString(
- 'PHPUnit\Framework\TestRunner->run()'
+ '->run()'
. '',
$actual,
);
diff --git a/tests/unit/Export/OptionsTest.php b/tests/unit/Export/OptionsTest.php
index 779188ca2a..259a3b48a9 100644
--- a/tests/unit/Export/OptionsTest.php
+++ b/tests/unit/Export/OptionsTest.php
@@ -23,9 +23,11 @@ use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Theme\ThemeManager;
use PhpMyAdmin\Util;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(Options::class)]
+#[AllowMockObjectsWithoutExpectations]
class OptionsTest extends AbstractTestCase
{
private Options $export;
@@ -68,12 +70,9 @@ class OptionsTest extends AbstractTestCase
$numTablesStr = '10';
$unlimNumRowsStr = 'unlim_num_rows_str';
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
- $dbi->expects(self::any())->method('getCompatibilities')
- ->willReturn([]);
+ $dbi->method('getCompatibilities')->willReturn([]);
DatabaseInterface::$instance = $dbi;
diff --git a/tests/unit/Gis/GisGeometryTest.php b/tests/unit/Gis/GisGeometryTest.php
index 891b12c078..dd019c24c6 100644
--- a/tests/unit/Gis/GisGeometryTest.php
+++ b/tests/unit/Gis/GisGeometryTest.php
@@ -8,12 +8,14 @@ use PhpMyAdmin\Gis\Ds\Extent;
use PhpMyAdmin\Gis\Ds\ScaleData;
use PhpMyAdmin\Gis\GisGeometry;
use PhpMyAdmin\Tests\AbstractTestCase;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use ReflectionMethod;
#[CoversClass(GisGeometry::class)]
+#[AllowMockObjectsWithoutExpectations]
class GisGeometryTest extends AbstractTestCase
{
protected GisGeometry&MockObject $object;
diff --git a/tests/unit/Http/Handler/ApplicationHandlerTest.php b/tests/unit/Http/Handler/ApplicationHandlerTest.php
index 194e41c47e..8e4f3dfae7 100644
--- a/tests/unit/Http/Handler/ApplicationHandlerTest.php
+++ b/tests/unit/Http/Handler/ApplicationHandlerTest.php
@@ -19,11 +19,11 @@ final class ApplicationHandlerTest extends TestCase
{
public function testHandleReturnsResponse(): void
{
- $responseRendererMock = self::createMock(ResponseRenderer::class);
+ $responseRendererMock = $this->createMock(ResponseRenderer::class);
$responseRendererMock->expects(self::never())->method('response');
$request = self::createStub(ServerRequest::class);
$responseStub = new Response(self::createStub(ResponseInterface::class));
- $appMock = self::createMock(Application::class);
+ $appMock = $this->createMock(Application::class);
$appMock->expects(self::once())->method('handle')->with($request)->willReturn($responseStub);
$handler = new ApplicationHandler($appMock, $responseRendererMock);
$response = $handler->handle($request);
@@ -33,10 +33,10 @@ final class ApplicationHandlerTest extends TestCase
public function testHandleThrowsExit(): void
{
$responseStub = new Response(self::createStub(ResponseInterface::class));
- $responseRendererMock = self::createMock(ResponseRenderer::class);
+ $responseRendererMock = $this->createMock(ResponseRenderer::class);
$responseRendererMock->expects(self::once())->method('response')->willReturn($responseStub);
$request = self::createStub(ServerRequest::class);
- $appMock = self::createMock(Application::class);
+ $appMock = $this->createMock(Application::class);
$appMock->expects(self::once())->method('handle')->with($request)->willThrowException(new ExitException());
$handler = new ApplicationHandler($appMock, $responseRendererMock);
$response = $handler->handle($request);
diff --git a/tests/unit/Http/Handler/QueueRequestHandlerTest.php b/tests/unit/Http/Handler/QueueRequestHandlerTest.php
index 4120cb5ed5..6cba639a9f 100644
--- a/tests/unit/Http/Handler/QueueRequestHandlerTest.php
+++ b/tests/unit/Http/Handler/QueueRequestHandlerTest.php
@@ -21,7 +21,7 @@ final class QueueRequestHandlerTest extends TestCase
public function testQueue(): void
{
$responseFactory = ResponseFactory::create();
- $container = self::createMock(ContainerInterface::class);
+ $container = $this->createMock(ContainerInterface::class);
$container->expects(self::exactly(3))->method('get')->willReturnMap([
[EarlyReturn::class, new EarlyReturn($responseFactory)],
[First::class, new First()],
@@ -46,7 +46,7 @@ final class QueueRequestHandlerTest extends TestCase
public function testQueueWithEarlyReturn(): void
{
$responseFactory = ResponseFactory::create();
- $container = self::createMock(ContainerInterface::class);
+ $container = $this->createMock(ContainerInterface::class);
$container->expects(self::exactly(2))->method('get')->willReturnMap([
[EarlyReturn::class, new EarlyReturn($responseFactory)],
[First::class, new First()],
diff --git a/tests/unit/Http/Middleware/AuthenticationTest.php b/tests/unit/Http/Middleware/AuthenticationTest.php
index e9efdcd8fe..5bf6c465a5 100644
--- a/tests/unit/Http/Middleware/AuthenticationTest.php
+++ b/tests/unit/Http/Middleware/AuthenticationTest.php
@@ -22,7 +22,7 @@ final class AuthenticationTest extends AbstractTestCase
{
public function testAuthenticationWithoutSelectServer(): void
{
- $configMock = self::createMock(Config::class);
+ $configMock = $this->createMock(Config::class);
$configMock->expects(self::once())->method('hasSelectedServer')->willReturn(false);
$dbi = $this->createDatabaseInterface();
diff --git a/tests/unit/Http/Middleware/RecentTableHandlingTest.php b/tests/unit/Http/Middleware/RecentTableHandlingTest.php
index acecd33e10..08e4b67e14 100644
--- a/tests/unit/Http/Middleware/RecentTableHandlingTest.php
+++ b/tests/unit/Http/Middleware/RecentTableHandlingTest.php
@@ -35,7 +35,7 @@ final class RecentTableHandlingTest extends AbstractTestCase
->withQueryParams(['db' => 'test_db', 'table' => 'test_table']);
$response = ResponseFactory::create()->createResponse();
- $handler = self::createMock(RequestHandlerInterface::class);
+ $handler = $this->createMock(RequestHandlerInterface::class);
$handler->method('handle')->with($request)->willReturn($response);
$reflectionProperty = new ReflectionProperty(RecentFavoriteTables::class, 'instances');
diff --git a/tests/unit/Http/Middleware/StatementHistoryTest.php b/tests/unit/Http/Middleware/StatementHistoryTest.php
index 47395ffa2b..964096e308 100644
--- a/tests/unit/Http/Middleware/StatementHistoryTest.php
+++ b/tests/unit/Http/Middleware/StatementHistoryTest.php
@@ -29,7 +29,7 @@ final class StatementHistoryTest extends AbstractTestCase
$config->selectedServer['user'] = 'test_user';
$dbi = self::createStub(DatabaseInterface::class);
$dbi->method('isConnected')->willReturn(true);
- $history = self::createMock(History::class);
+ $history = $this->createMock(History::class);
$history->expects(self::once())->method('setHistory')->with(
self::identicalTo('test_db'),
self::identicalTo('test_table'),
@@ -56,7 +56,7 @@ final class StatementHistoryTest extends AbstractTestCase
$dbi = self::createStub(DatabaseInterface::class);
$dbi->method('isConnected')->willReturn($isConnected);
- $history = self::createMock(History::class);
+ $history = $this->createMock(History::class);
$history->expects(self::never())->method('setHistory');
$statementHistory = new StatementHistory(new Config(), $history, $dbi);
diff --git a/tests/unit/Http/Middleware/UrlParamsSettingTest.php b/tests/unit/Http/Middleware/UrlParamsSettingTest.php
index 84dcd3f428..ddc174630b 100644
--- a/tests/unit/Http/Middleware/UrlParamsSettingTest.php
+++ b/tests/unit/Http/Middleware/UrlParamsSettingTest.php
@@ -26,7 +26,7 @@ final class UrlParamsSettingTest extends AbstractTestCase
->withQueryParams(['goto' => 'index.php?route=/', 'back' => 'index.php?route=/']);
$response = self::createStub(ResponseInterface::class);
- $handler = self::createMock(RequestHandlerInterface::class);
+ $handler = $this->createMock(RequestHandlerInterface::class);
$handler->method('handle')->with($request)->willReturn($response);
$urlParamsSetting = new UrlParamsSetting(self::createStub(Config::class));
diff --git a/tests/unit/InsertEditTest.php b/tests/unit/InsertEditTest.php
index 830d93fcb6..02ab3f0734 100644
--- a/tests/unit/InsertEditTest.php
+++ b/tests/unit/InsertEditTest.php
@@ -151,12 +151,10 @@ class InsertEditTest extends AbstractTestCase
{
$clauses = ['a=1', 'b="fo\o"'];
- $resultStub1 = self::createMock(DummyResult::class);
- $resultStub2 = self::createMock(DummyResult::class);
+ $resultStub1 = $this->createMock(DummyResult::class);
+ $resultStub2 = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(2))
->method('query')
@@ -207,11 +205,9 @@ class InsertEditTest extends AbstractTestCase
'orgname' => 'orgname',
]);
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createStub(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getFieldsMeta')
@@ -241,11 +237,9 @@ class InsertEditTest extends AbstractTestCase
public function testLoadFirstRow(): void
{
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createStub(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('query')
@@ -883,9 +877,7 @@ class InsertEditTest extends AbstractTestCase
);
// Case 3 (bit)
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
DatabaseInterface::$instance = $dbi;
$config = Config::getInstance();
@@ -1058,11 +1050,9 @@ class InsertEditTest extends AbstractTestCase
$row = ['1' => 1];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('query')
@@ -1216,9 +1206,7 @@ class InsertEditTest extends AbstractTestCase
Warning::fromArray(['Level' => 'Warning', 'Code' => '1002', 'Message' => 'Message 2']),
];
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getWarnings')
@@ -1254,11 +1242,9 @@ class InsertEditTest extends AbstractTestCase
$map['f']['foreign_field'] = 'f';
$map = new Foreigners($map);
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQuery')
@@ -2049,11 +2035,9 @@ class InsertEditTest extends AbstractTestCase
$_POST['where_clause'] = [];
$_POST['where_clause'][0] = 1;
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::exactly(3))
->method('tryQuery')
@@ -2104,9 +2088,7 @@ class InsertEditTest extends AbstractTestCase
*/
public function testGetTableColumns(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('selectDb')
@@ -2151,11 +2133,9 @@ class InsertEditTest extends AbstractTestCase
*/
public function testDetermineInsertOrEdit(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createStub(DummyResult::class);
$dbi->expects(self::exactly(2))
->method('query')
@@ -2207,18 +2187,14 @@ class InsertEditTest extends AbstractTestCase
$config = Config::getInstance();
$config->set('ShowPropertyComments', false);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getColumns')
->with('db', 'table')
->willReturn([new Column('d', 'd', null, false, '', null, '', '', 'b')]);
- $dbi->expects(self::any())
- ->method('getTable')
- ->willReturn(new Table('table', 'db', $dbi));
+ $dbi->method('getTable')->willReturn(new Table('table', 'db', $dbi));
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
diff --git a/tests/unit/Navigation/NavigationTest.php b/tests/unit/Navigation/NavigationTest.php
index 8aec6cd21e..cc32765ef9 100644
--- a/tests/unit/Navigation/NavigationTest.php
+++ b/tests/unit/Navigation/NavigationTest.php
@@ -56,13 +56,11 @@ class NavigationTest extends AbstractTestCase
$expectedQuery = 'INSERT INTO `pmadb`.`navigationhiding`'
. '(`username`, `item_name`, `item_type`, `db_name`, `table_name`)'
. " VALUES ('user','itemName','itemType','db','')";
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQueryAsControlUser')
->with($expectedQuery);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
DatabaseInterface::$instance = $dbi;
@@ -79,14 +77,12 @@ class NavigationTest extends AbstractTestCase
$expectedQuery = 'DELETE FROM `pmadb`.`navigationhiding`'
. " WHERE `username`='user' AND `item_name`='itemName'"
. " AND `item_type`='itemType' AND `db_name`='db'";
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQueryAsControlUser')
->with($expectedQuery);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
DatabaseInterface::$instance = $dbi;
$config = Config::getInstance();
diff --git a/tests/unit/Navigation/Nodes/NodeTableTest.php b/tests/unit/Navigation/Nodes/NodeTableTest.php
index 1dcf75b9bb..70a69cb10b 100644
--- a/tests/unit/Navigation/Nodes/NodeTableTest.php
+++ b/tests/unit/Navigation/Nodes/NodeTableTest.php
@@ -72,7 +72,7 @@ class NodeTableTest extends AbstractTestCase
{
$config = Config::getInstance();
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('fetchResultSimple')
->willReturnOnConsecutiveCalls(
@@ -103,8 +103,8 @@ class NodeTableTest extends AbstractTestCase
$config->selectedServer['DisableIS'] = true;
$config->set('MaxNavigationItems', 2);
- $dbi = self::createMock(DatabaseInterface::class);
- $resultStub = self::createMock(DummyResult::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('tryQuery')
->with('SHOW COLUMNS FROM `node` FROM `DB`')
@@ -135,7 +135,7 @@ class NodeTableTest extends AbstractTestCase
{
$config = Config::getInstance();
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('fetchSingleColumn')
->willReturnOnConsecutiveCalls(
@@ -166,8 +166,8 @@ class NodeTableTest extends AbstractTestCase
$config->selectedServer['DisableIS'] = true;
$config->set('MaxNavigationItems', 2);
- $dbi = self::createMock(DatabaseInterface::class);
- $resultStub = self::createMock(DummyResult::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$dbi->expects(self::once())
@@ -202,8 +202,8 @@ class NodeTableTest extends AbstractTestCase
$config->selectedServer['DisableIS'] = true;
$config->set('MaxNavigationItems', 2);
- $dbi = self::createMock(DatabaseInterface::class);
- $resultStub = self::createMock(DummyResult::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('tryQuery')
->with('SHOW INDEXES FROM `node` FROM `DB`')
diff --git a/tests/unit/Navigation/Nodes/NodeTest.php b/tests/unit/Navigation/Nodes/NodeTest.php
index 8713d665ab..5a34267049 100644
--- a/tests/unit/Navigation/Nodes/NodeTest.php
+++ b/tests/unit/Navigation/Nodes/NodeTest.php
@@ -352,9 +352,9 @@ final class NodeTest extends AbstractTestCase
$expectedSql .= "CONCAT(SCHEMA_NAME, '_')) ";
$expectedSql .= 'ORDER BY SCHEMA_NAME ASC';
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('fetchSingleColumn')->with($expectedSql);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$node = new Node($dbi, $config, 'node');
@@ -376,7 +376,7 @@ final class NodeTest extends AbstractTestCase
$expectedSql .= 'ORDER BY `SCHEMA_NAME` ';
$expectedSql .= 'LIMIT 10, 20';
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('fetchSingleColumn')->with($expectedSql);
$node = new Node($dbi, $config, 'node');
@@ -392,9 +392,9 @@ final class NodeTest extends AbstractTestCase
$config->selectedServer['DisableIS'] = true;
$config->set('FirstLevelNavigationItems', 2);
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQuery')
->with("SHOW DATABASES WHERE TRUE AND `Database` LIKE '%db%' ")
@@ -410,9 +410,9 @@ final class NodeTest extends AbstractTestCase
. " LOCATE('db_', CONCAT(`Database`, '_')) = 1"
. " OR LOCATE('aa_', CONCAT(`Database`, '_')) = 1 )",
);
- $dbi->expects(self::any())->method('escapeMysqlWildcards')
+ $dbi->method('escapeMysqlWildcards')
->willReturnArgument(0);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$node = new Node($dbi, $config, 'node');
@@ -429,9 +429,9 @@ final class NodeTest extends AbstractTestCase
$config->set('NavigationTreeEnableGrouping', false);
$config->set('FirstLevelNavigationItems', 2);
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQuery')
->with("SHOW DATABASES WHERE TRUE AND `Database` LIKE '%db%' ")
@@ -466,7 +466,7 @@ final class NodeTest extends AbstractTestCase
$query .= 'WHERE TRUE ';
$query .= ') t ';
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('fetchValue')->with($query);
$node = new Node($dbi, $config, 'node');
@@ -486,7 +486,7 @@ final class NodeTest extends AbstractTestCase
$query .= 'FROM INFORMATION_SCHEMA.SCHEMATA ';
$query .= 'WHERE TRUE ';
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('fetchValue')->with($query);
$node = new Node($dbi, $config, 'node');
@@ -502,10 +502,10 @@ final class NodeTest extends AbstractTestCase
$config = Config::getInstance();
$config->selectedServer['DisableIS'] = true;
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createStub(DummyResult::class);
// test with no search clause
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQuery')
->with('SHOW DATABASES WHERE TRUE ')
@@ -515,14 +515,14 @@ final class NodeTest extends AbstractTestCase
self::assertSame(0, $node->getPresence(new UserPrivileges()));
// test with a search clause
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQuery')
->with("SHOW DATABASES WHERE TRUE AND `Database` LIKE '%dbname%' ")
->willReturn($resultStub);
- $dbi->expects(self::any())->method('escapeMysqlWildcards')
+ $dbi->method('escapeMysqlWildcards')
->willReturnArgument(0);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$node = new Node($dbi, $config, 'node');
diff --git a/tests/unit/NormalizationTest.php b/tests/unit/NormalizationTest.php
index 53cec5dbd0..8e1a237646 100644
--- a/tests/unit/NormalizationTest.php
+++ b/tests/unit/NormalizationTest.php
@@ -17,6 +17,7 @@ use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Transformations;
use PhpMyAdmin\Types;
use PhpMyAdmin\UserPrivileges;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use ReflectionMethod;
use stdClass;
@@ -26,6 +27,7 @@ use function _pgettext;
use function json_encode;
#[CoversClass(Normalization::class)]
+#[AllowMockObjectsWithoutExpectations]
class NormalizationTest extends AbstractTestCase
{
protected DatabaseInterface $dbi;
@@ -46,25 +48,17 @@ class NormalizationTest extends AbstractTestCase
$config = Config::getInstance();
//mock DBI
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->types = new Types($dbi);
DatabaseInterface::$instance = $dbi;
// set expectations
- $dbi->expects(self::any())
- ->method('selectDb')
- ->willReturn(true);
- $dbi->expects(self::any())
- ->method('getColumns')
- ->willReturn([
- 'id' => new Column('id', 'integer', null, false, '', null, '', '', ''),
- 'col1' => new Column('col1', 'varchar(100)', null, false, '', null, '', '', ''),
- 'col2' => new Column('col2', 'DATETIME', null, false, '', null, '', '', ''),
- ]);
- $dbi->expects(self::any())
- ->method('getColumnNames')
- ->willReturn(['id', 'col1', 'col2']);
+ $dbi->method('selectDb')->willReturn(true);
+ $dbi->method('getColumns')->willReturn([
+ 'id' => new Column('id', 'integer', null, false, '', null, '', '', ''),
+ 'col1' => new Column('col1', 'varchar(100)', null, false, '', null, '', '', ''),
+ 'col2' => new Column('col2', 'DATETIME', null, false, '', null, '', '', ''),
+ ]);
+ $dbi->method('getColumnNames')->willReturn(['id', 'col1', 'col2']);
$map = [
['PMA_db', 'PMA_table1', ConnectionType::User, []],
['PMA_db', 'PMA_table', ConnectionType::User, [['Key_name' => 'PRIMARY', 'Column_name' => 'id']]],
@@ -75,15 +69,9 @@ class NormalizationTest extends AbstractTestCase
[['Key_name' => 'PRIMARY','Column_name' => 'id'], ['Key_name' => 'PRIMARY','Column_name' => 'col1']],
],
];
- $dbi->expects(self::any())
- ->method('getTableIndexes')
- ->willReturnMap($map);
- $dbi->expects(self::any())
- ->method('tryQuery')
- ->willReturn(self::createStub(DummyResult::class));
- $dbi->expects(self::any())
- ->method('fetchSingleRow')
- ->willReturn(['`id`_cnt' => 0, '`col1`_cnt' => 0, '`col2`_cnt' => 0]);
+ $dbi->method('getTableIndexes')->willReturnMap($map);
+ $dbi->method('tryQuery')->willReturn(self::createStub(DummyResult::class));
+ $dbi->method('fetchSingleRow')->willReturn(['`id`_cnt' => 0, '`col1`_cnt' => 0, '`col2`_cnt' => 0]);
$relation = new Relation($dbi);
$this->normalization = new Normalization(
diff --git a/tests/unit/Plugins/Auth/AuthenticationConfigTest.php b/tests/unit/Plugins/Auth/AuthenticationConfigTest.php
index fc38fae0b1..95283f6794 100644
--- a/tests/unit/Plugins/Auth/AuthenticationConfigTest.php
+++ b/tests/unit/Plugins/Auth/AuthenticationConfigTest.php
@@ -84,9 +84,7 @@ class AuthenticationConfigTest extends AbstractTestCase
{
Config::getInstance()->settings['Servers'] = [1];
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
DatabaseInterface::$instance = $dbi;
$response = $this->object->showFailure(AuthenticationFailure::deniedByDatabaseServer());
diff --git a/tests/unit/Plugins/Auth/AuthenticationCookieTest.php b/tests/unit/Plugins/Auth/AuthenticationCookieTest.php
index 5b58d8f1b8..96c2904aab 100644
--- a/tests/unit/Plugins/Auth/AuthenticationCookieTest.php
+++ b/tests/unit/Plugins/Auth/AuthenticationCookieTest.php
@@ -657,9 +657,7 @@ class AuthenticationCookieTest extends AbstractTestCase
$_COOKIE['pmaAuth-2'] = 'pass';
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getError')
@@ -694,9 +692,7 @@ class AuthenticationCookieTest extends AbstractTestCase
->method('showLoginForm')
->willThrowException(new ExitException());
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getError')
diff --git a/tests/unit/Plugins/Auth/AuthenticationHttpTest.php b/tests/unit/Plugins/Auth/AuthenticationHttpTest.php
index e1bea1b0f9..e3128d7526 100644
--- a/tests/unit/Plugins/Auth/AuthenticationHttpTest.php
+++ b/tests/unit/Plugins/Auth/AuthenticationHttpTest.php
@@ -229,9 +229,7 @@ class AuthenticationHttpTest extends AbstractTestCase
$_REQUEST = [];
Current::$server = 0;
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(3))
->method('getError')
diff --git a/tests/unit/Plugins/Auth/AuthenticationSignonTest.php b/tests/unit/Plugins/Auth/AuthenticationSignonTest.php
index 15a4898a5f..9fadf39926 100644
--- a/tests/unit/Plugins/Auth/AuthenticationSignonTest.php
+++ b/tests/unit/Plugins/Auth/AuthenticationSignonTest.php
@@ -13,6 +13,7 @@ use PhpMyAdmin\Exceptions\ExitException;
use PhpMyAdmin\Plugins\Auth\AuthenticationSignon;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use function session_get_cookie_params;
@@ -22,6 +23,7 @@ use function session_name;
use const PHP_VERSION_ID;
#[CoversClass(AuthenticationSignon::class)]
+#[AllowMockObjectsWithoutExpectations]
class AuthenticationSignonTest extends AbstractTestCase
{
protected AuthenticationSignon $object;
@@ -299,9 +301,7 @@ class AuthenticationSignonTest extends AbstractTestCase
->method('showLoginForm')
->willThrowException(new ExitException());
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getError')
@@ -332,9 +332,7 @@ class AuthenticationSignonTest extends AbstractTestCase
->method('showLoginForm')
->willThrowException(new ExitException());
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getError')
diff --git a/tests/unit/Plugins/Export/ExportHtmlwordTest.php b/tests/unit/Plugins/Export/ExportHtmlwordTest.php
index eceafd7404..e99576f2db 100644
--- a/tests/unit/Plugins/Export/ExportHtmlwordTest.php
+++ b/tests/unit/Plugins/Export/ExportHtmlwordTest.php
@@ -289,9 +289,7 @@ final class ExportHtmlwordTest extends AbstractTestCase
{
$keys = [['Non_unique' => 0, 'Column_name' => 'name1'], ['Non_unique' => 1, 'Column_name' => 'name2']];
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getTableIndexes')
@@ -326,11 +324,9 @@ final class ExportHtmlwordTest extends AbstractTestCase
// case 1
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(2))
->method('fetchResult')
@@ -397,11 +393,9 @@ final class ExportHtmlwordTest extends AbstractTestCase
// case 2
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(2))
->method('fetchResult')
@@ -455,9 +449,7 @@ final class ExportHtmlwordTest extends AbstractTestCase
// case 3
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getTableIndexes')
@@ -641,9 +633,7 @@ final class ExportHtmlwordTest extends AbstractTestCase
public function testExportTableCallsExportStructureMethod(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$exportHtmlword = $this->getExportHtmlword($dbi);
diff --git a/tests/unit/Plugins/Export/ExportLatexTest.php b/tests/unit/Plugins/Export/ExportLatexTest.php
index aab299e869..a0a49eff6a 100644
--- a/tests/unit/Plugins/Export/ExportLatexTest.php
+++ b/tests/unit/Plugins/Export/ExportLatexTest.php
@@ -515,11 +515,9 @@ final class ExportLatexTest extends AbstractTestCase
// case 1
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getTableIndexes')
@@ -601,11 +599,9 @@ final class ExportLatexTest extends AbstractTestCase
// case 2
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(2))
->method('fetchResult')
@@ -663,9 +659,7 @@ final class ExportLatexTest extends AbstractTestCase
// case 3
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getTableIndexes')
@@ -744,9 +738,7 @@ final class ExportLatexTest extends AbstractTestCase
public function testExportTableCallsExportStructureMethod(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['latex_structure_or_data' => 'structure']);
diff --git a/tests/unit/Plugins/Export/ExportMediawikiTest.php b/tests/unit/Plugins/Export/ExportMediawikiTest.php
index 4791b1fd22..3911f93ca8 100644
--- a/tests/unit/Plugins/Export/ExportMediawikiTest.php
+++ b/tests/unit/Plugins/Export/ExportMediawikiTest.php
@@ -197,9 +197,7 @@ final class ExportMediawikiTest extends AbstractTestCase
*/
public function testExportStructure(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$columns = [
new Column('name1', 'set(abc)enum123', null, true, 'PRI', '', '', '', ''),
@@ -296,9 +294,7 @@ final class ExportMediawikiTest extends AbstractTestCase
public function testExportTableCallsExportStructureMethod(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['mediawiki_structure_or_data' => 'structure']);
diff --git a/tests/unit/Plugins/Export/ExportOdsTest.php b/tests/unit/Plugins/Export/ExportOdsTest.php
index fc000debf0..d306895108 100644
--- a/tests/unit/Plugins/Export/ExportOdsTest.php
+++ b/tests/unit/Plugins/Export/ExportOdsTest.php
@@ -189,9 +189,7 @@ final class ExportOdsTest extends AbstractTestCase
public function testExportData(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$fields = [
FieldHelper::fromArray(['type' => -1]),
@@ -207,7 +205,7 @@ final class ExportOdsTest extends AbstractTestCase
FieldHelper::fromArray(['type' => MYSQLI_TYPE_DECIMAL]),
FieldHelper::fromArray(['type' => MYSQLI_TYPE_STRING]),
];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('getFieldsMeta')
@@ -261,9 +259,7 @@ final class ExportOdsTest extends AbstractTestCase
public function testExportDataWithFieldNames(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$fields = [
FieldHelper::fromArray([
@@ -278,7 +274,7 @@ final class ExportOdsTest extends AbstractTestCase
]),
];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('getFieldsMeta')
@@ -316,13 +312,11 @@ final class ExportOdsTest extends AbstractTestCase
);
// with no row count
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$flags = [];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('getFieldsMeta')
diff --git a/tests/unit/Plugins/Export/ExportOdtTest.php b/tests/unit/Plugins/Export/ExportOdtTest.php
index c9a0d2d0eb..44cea87d1e 100644
--- a/tests/unit/Plugins/Export/ExportOdtTest.php
+++ b/tests/unit/Plugins/Export/ExportOdtTest.php
@@ -309,9 +309,7 @@ final class ExportOdtTest extends AbstractTestCase
public function testExportData(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$fields = [
FieldHelper::fromArray(['type' => -1]),
@@ -323,7 +321,7 @@ final class ExportOdtTest extends AbstractTestCase
FieldHelper::fromArray(['type' => MYSQLI_TYPE_DECIMAL, 'flags' => MYSQLI_NUM_FLAG]),
FieldHelper::fromArray(['type' => MYSQLI_TYPE_STRING]),
];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('getFieldsMeta')
@@ -369,9 +367,7 @@ final class ExportOdtTest extends AbstractTestCase
public function testExportDataWithFieldNames(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$fields = [
FieldHelper::fromArray([
@@ -386,7 +382,7 @@ final class ExportOdtTest extends AbstractTestCase
]),
];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('getFieldsMeta')
@@ -426,13 +422,11 @@ final class ExportOdtTest extends AbstractTestCase
);
// with no row count
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$flags = [];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('getFieldsMeta')
@@ -509,11 +503,9 @@ final class ExportOdtTest extends AbstractTestCase
public function testGetTableDef(): void
{
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(2))
->method('fetchResult')
@@ -581,11 +573,9 @@ final class ExportOdtTest extends AbstractTestCase
// case 2
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(2))
->method('fetchResult')
@@ -846,9 +836,7 @@ final class ExportOdtTest extends AbstractTestCase
public function testExportTableCallsExportStructureMethod(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['odt_structure_or_data' => 'structure']);
diff --git a/tests/unit/Plugins/Export/ExportPdfTest.php b/tests/unit/Plugins/Export/ExportPdfTest.php
index 5a18775994..9d545481b4 100644
--- a/tests/unit/Plugins/Export/ExportPdfTest.php
+++ b/tests/unit/Plugins/Export/ExportPdfTest.php
@@ -145,9 +145,7 @@ final class ExportPdfTest extends AbstractTestCase
public function testExportFooter(): void
{
- $pdf = $this->getMockBuilder(Pdf::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $pdf = $this->createMock(Pdf::class);
$pdf->expects(self::once())
->method('getPDFData')
@@ -186,9 +184,7 @@ final class ExportPdfTest extends AbstractTestCase
{
$dbi = $this->createDatabaseInterface();
- $pdf = $this->getMockBuilder(Pdf::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $pdf = $this->createMock(Pdf::class);
$pdf->expects(self::once())
->method('mysqlReport')
diff --git a/tests/unit/Plugins/Export/ExportSqlTest.php b/tests/unit/Plugins/Export/ExportSqlTest.php
index 490b36c2b5..aaf7d40256 100644
--- a/tests/unit/Plugins/Export/ExportSqlTest.php
+++ b/tests/unit/Plugins/Export/ExportSqlTest.php
@@ -33,6 +33,7 @@ use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\FieldHelper;
use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Transformations;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Medium;
use ReflectionMethod;
@@ -51,6 +52,7 @@ use const MYSQLI_UNIQUE_KEY_FLAG;
#[CoversClass(ExportSql::class)]
#[Medium]
+#[AllowMockObjectsWithoutExpectations]
final class ExportSqlTest extends AbstractTestCase
{
protected function setUp(): void
@@ -83,9 +85,7 @@ final class ExportSqlTest extends AbstractTestCase
public function testSetProperties(): void
{
// test with hide structure and hide sql as false
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(2))
->method('getCompatibilities')
@@ -369,9 +369,7 @@ final class ExportSqlTest extends AbstractTestCase
ExportSql::$oldTimezone = 'GMT';
OutputHandler::$asFile = true;
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('query')
@@ -394,9 +392,7 @@ final class ExportSqlTest extends AbstractTestCase
OutputHandler::$asFile = true;
Current::$charset = 'utf-8';
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('tryQuery')
@@ -448,9 +444,7 @@ final class ExportSqlTest extends AbstractTestCase
public function testExportDBCreate(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getDbCollation')
@@ -483,9 +477,7 @@ final class ExportSqlTest extends AbstractTestCase
self::assertStringContainsString('USE `db`;', $result);
// case2: no backquotes
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getDbCollation')
@@ -521,10 +513,8 @@ final class ExportSqlTest extends AbstractTestCase
'sql_structure_or_data' => 'data',
]);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$exportSql = $this->getExportSql($dbi);
@@ -573,9 +563,7 @@ final class ExportSqlTest extends AbstractTestCase
public function testExportEvents(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('fetchSingleColumn')
@@ -588,7 +576,7 @@ final class ExportSqlTest extends AbstractTestCase
['SHOW CREATE EVENT `db`.`f1`', 'Create Event', ConnectionType::User, 'f1event'],
['SHOW CREATE EVENT `db`.`f2`', 'Create Event', ConnectionType::User, 'f2event'],
]);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
@@ -626,9 +614,7 @@ final class ExportSqlTest extends AbstractTestCase
public function testGetTableDefStandIn(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getColumns')
@@ -653,14 +639,11 @@ final class ExportSqlTest extends AbstractTestCase
public function testGetTableDefForView(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
- $dbi->expects(self::any())
- ->method('getColumns')
+ $dbi->method('getColumns')
->with('db', 'view')
->willReturn([
new Column(
@@ -693,14 +676,11 @@ final class ExportSqlTest extends AbstractTestCase
);
// case 2
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
- $dbi->expects(self::any())
- ->method('getColumns')
+ $dbi->method('getColumns')
->with('db', 'view')
->willReturn([
new Column(
@@ -852,9 +832,7 @@ final class ExportSqlTest extends AbstractTestCase
]);
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::exactly(2))
->method('fetchResult')
@@ -974,9 +952,7 @@ final class ExportSqlTest extends AbstractTestCase
public function testExportData(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$fields = [
FieldHelper::fromArray([
@@ -1010,7 +986,7 @@ final class ExportSqlTest extends AbstractTestCase
]),
];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('getFieldsMeta')
@@ -1029,12 +1005,10 @@ final class ExportSqlTest extends AbstractTestCase
$resultStub->expects(self::exactly(2))
->method('fetchRow')
->willReturn([null, 'test', '10', '6', "\x00\x0a\x0d\x1a"], []);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
- $tableObj = $this->getMockBuilder(Table::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $tableObj = $this->createMock(Table::class);
$tableObj->expects(self::once())
->method('isMerge')
->willReturn(false);
@@ -1042,9 +1016,7 @@ final class ExportSqlTest extends AbstractTestCase
->method('isView')
->willReturn(false);
- $dbi->expects(self::any())
- ->method('getTable')
- ->willReturn($tableObj);
+ $dbi->method('getTable')->willReturn($tableObj);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody([
@@ -1083,9 +1055,7 @@ final class ExportSqlTest extends AbstractTestCase
public function testExportDataWithUpdate(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$fields = [
FieldHelper::fromArray([
@@ -1108,7 +1078,7 @@ final class ExportSqlTest extends AbstractTestCase
]),
];
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
$dbi->expects(self::once())
->method('getFieldsMeta')
@@ -1128,9 +1098,7 @@ final class ExportSqlTest extends AbstractTestCase
->method('fetchRow')
->willReturn([null, null], []);
- $tableObj = $this->getMockBuilder(Table::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $tableObj = $this->createMock(Table::class);
$tableObj->expects(self::once())
->method('isMerge')
->willReturn(false);
@@ -1138,9 +1106,7 @@ final class ExportSqlTest extends AbstractTestCase
->method('isView')
->willReturn(false);
- $dbi->expects(self::any())
- ->method('getTable')
- ->willReturn($tableObj);
+ $dbi->method('getTable')->willReturn($tableObj);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody([
@@ -1168,13 +1134,9 @@ final class ExportSqlTest extends AbstractTestCase
public function testExportDataWithIsView(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
- $tableObj = $this->getMockBuilder(Table::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $tableObj = $this->createMock(Table::class);
$tableObj->expects(self::once())
->method('isMerge')
->willReturn(false);
@@ -1182,9 +1144,7 @@ final class ExportSqlTest extends AbstractTestCase
->method('isView')
->willReturn(true);
- $dbi->expects(self::any())
- ->method('getTable')
- ->willReturn($tableObj);
+ $dbi->method('getTable')->willReturn($tableObj);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['sql_backquotes' => 'true', 'sql_include_comments' => 'On']);
@@ -1205,17 +1165,13 @@ final class ExportSqlTest extends AbstractTestCase
public function testExportDataWithError(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('getError')
->willReturn('err');
- $tableObj = $this->getMockBuilder(Table::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $tableObj = $this->createMock(Table::class);
$tableObj->expects(self::once())
->method('isMerge')
->willReturn(false);
@@ -1223,9 +1179,7 @@ final class ExportSqlTest extends AbstractTestCase
->method('isView')
->willReturn(false);
- $dbi->expects(self::any())
- ->method('getTable')
- ->willReturn($tableObj);
+ $dbi->method('getTable')->willReturn($tableObj);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['sql_include_comments' => 'On']);
diff --git a/tests/unit/Plugins/Export/ExportTexytextTest.php b/tests/unit/Plugins/Export/ExportTexytextTest.php
index 6b7889ce61..2925da81ec 100644
--- a/tests/unit/Plugins/Export/ExportTexytextTest.php
+++ b/tests/unit/Plugins/Export/ExportTexytextTest.php
@@ -228,9 +228,7 @@ final class ExportTexytextTest extends AbstractTestCase
public function testGetTableDef(): void
{
// case 1
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$keys = [['Non_unique' => 0, 'Column_name' => 'cname'], ['Non_unique' => 1, 'Column_name' => 'cname2']];
diff --git a/tests/unit/Plugins/Import/ImportCsvTest.php b/tests/unit/Plugins/Import/ImportCsvTest.php
index ba1dc72b59..249f22404e 100644
--- a/tests/unit/Plugins/Import/ImportCsvTest.php
+++ b/tests/unit/Plugins/Import/ImportCsvTest.php
@@ -81,9 +81,7 @@ final class ImportCsvTest extends AbstractTestCase
$importHandle = new File(ImportSettings::$importFile);
$importHandle->open();
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$importCsv = $this->getImportCsv($dbi);
@@ -120,9 +118,7 @@ final class ImportCsvTest extends AbstractTestCase
$importHandle = new File(ImportSettings::$importFile);
$importHandle->open();
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$importCsv = $this->getImportCsv($dbi);
@@ -179,9 +175,7 @@ final class ImportCsvTest extends AbstractTestCase
$importHandle = new File(ImportSettings::$importFile);
$importHandle->open();
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$importCsv = $this->getImportCsv($dbi);
diff --git a/tests/unit/Plugins/Import/ImportLdiTest.php b/tests/unit/Plugins/Import/ImportLdiTest.php
index 738e825199..db5c1c53c1 100644
--- a/tests/unit/Plugins/Import/ImportLdiTest.php
+++ b/tests/unit/Plugins/Import/ImportLdiTest.php
@@ -16,6 +16,7 @@ use PhpMyAdmin\Plugins\Import\ImportLdi;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Medium;
@@ -23,6 +24,7 @@ use function __;
#[CoversClass(ImportLdi::class)]
#[Medium]
+#[AllowMockObjectsWithoutExpectations]
final class ImportLdiTest extends AbstractTestCase
{
/**
@@ -75,18 +77,15 @@ final class ImportLdiTest extends AbstractTestCase
*/
public function testGetPropertiesAutoLdi(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi->expects(self::any())->method('tryQuery')
- ->willReturn($resultStub);
+ $dbi->method('tryQuery')->willReturn($resultStub);
- $resultStub->expects(self::any())->method('numRows')
- ->willReturn(10);
+ $resultStub->method('numRows')->willReturn(10);
- $resultStub->expects(self::any())->method('fetchValue')
- ->willReturn('ON');
+ $resultStub->method('fetchValue')->willReturn('ON');
$config = new Config();
$config->settings['Import']['ldi_local_option'] = 'auto';
@@ -109,8 +108,8 @@ final class ImportLdiTest extends AbstractTestCase
public function testDoImport(): void
{
ImportSettings::$sqlQueryDisabled = false; //will show the import SQL detail
- $dbi = self::createMock(DatabaseInterface::class);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$importHandle = new File(ImportSettings::$importFile);
@@ -157,8 +156,8 @@ final class ImportLdiTest extends AbstractTestCase
public function testDoImportLDISetting(): void
{
ImportSettings::$sqlQueryDisabled = false; //will show the import SQL detail
- $dbi = self::createMock(DatabaseInterface::class);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
diff --git a/tests/unit/Plugins/Import/ImportMediawikiTest.php b/tests/unit/Plugins/Import/ImportMediawikiTest.php
index 59e2c90f43..76708b67de 100644
--- a/tests/unit/Plugins/Import/ImportMediawikiTest.php
+++ b/tests/unit/Plugins/Import/ImportMediawikiTest.php
@@ -78,9 +78,7 @@ final class ImportMediawikiTest extends AbstractTestCase
*/
public function testDoImport(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$importHandle = new File(ImportSettings::$importFile);
$importHandle->open();
@@ -117,9 +115,7 @@ final class ImportMediawikiTest extends AbstractTestCase
public function testDoImportWithEmptyTable(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createStub(DatabaseInterface::class);
$importHandle = new File('tests/test_data/__slashes.mediawiki');
$importHandle->open();
diff --git a/tests/unit/Plugins/Import/ImportShpTest.php b/tests/unit/Plugins/Import/ImportShpTest.php
index e4a00b3727..b50ce1371b 100644
--- a/tests/unit/Plugins/Import/ImportShpTest.php
+++ b/tests/unit/Plugins/Import/ImportShpTest.php
@@ -65,11 +65,7 @@ final class ImportShpTest extends AbstractTestCase
$importHandle = new File($filename);
$importHandle->setDecompressContent(true);
$importHandle->open();
-
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $importCsv = $this->getImportShp($dbi);
+ $importCsv = $this->getImportShp($this->createStub(DatabaseInterface::class));
Current::$message = null;
Import::$hasError = false;
diff --git a/tests/unit/Plugins/Import/ImportXmlTest.php b/tests/unit/Plugins/Import/ImportXmlTest.php
index 66f732500a..29d5be3a03 100644
--- a/tests/unit/Plugins/Import/ImportXmlTest.php
+++ b/tests/unit/Plugins/Import/ImportXmlTest.php
@@ -13,6 +13,7 @@ use PhpMyAdmin\Import\ImportSettings;
use PhpMyAdmin\Plugins\Import\ImportXml;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Medium;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
@@ -23,6 +24,7 @@ use function __;
#[RequiresPhpExtension('xml')]
#[RequiresPhpExtension('xmlwriter')]
#[Medium]
+#[AllowMockObjectsWithoutExpectations]
final class ImportXmlTest extends AbstractTestCase
{
/**
@@ -81,11 +83,8 @@ final class ImportXmlTest extends AbstractTestCase
#[RequiresPhpExtension('simplexml')]
public function testDoImport(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$importHandle = new File(ImportSettings::$importFile);
@@ -130,11 +129,8 @@ final class ImportXmlTest extends AbstractTestCase
#[RequiresPhpExtension('simplexml')]
public function testDoImportDatasetGIS(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
ImportSettings::$importFile = 'tests/test_data/phpmyadmin_importXML_GIS_For_Testing.xml';
@@ -183,11 +179,8 @@ final class ImportXmlTest extends AbstractTestCase
#[RequiresPhpExtension('simplexml')]
public function testDoImportNumericStringValues(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
ImportSettings::$importFile = 'tests/test_data/phpmyadmin_importXML_Numeric_String_For_Testing.xml';
@@ -228,11 +221,8 @@ final class ImportXmlTest extends AbstractTestCase
{
ImportSettings::$importFile = 'tests/test_data/phpmyadmin_importXML_No_Database_For_Testing.xml';
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$importHandle = new File(ImportSettings::$importFile);
diff --git a/tests/unit/Plugins/TwoFactor/WebAuthnTest.php b/tests/unit/Plugins/TwoFactor/WebAuthnTest.php
index e7a084e362..356b0b2a04 100644
--- a/tests/unit/Plugins/TwoFactor/WebAuthnTest.php
+++ b/tests/unit/Plugins/TwoFactor/WebAuthnTest.php
@@ -74,7 +74,7 @@ class WebAuthnTest extends AbstractTestCase
'allowCredentials' => [['type' => 'public-key', 'id' => 'cHVibGljS2V5Q3JlZGVudGlhbElkMQ']],
'timeout' => 60000,
];
- $server = self::createMock(Server::class);
+ $server = $this->createMock(Server::class);
$server->expects(self::once())->method('getCredentialRequestOptions')->with(
self::equalTo('test_user'),
self::anything(),
@@ -126,7 +126,7 @@ class WebAuthnTest extends AbstractTestCase
'timeout' => 60000,
'attestation' => 'none',
];
- $server = self::createMock(Server::class);
+ $server = $this->createMock(Server::class);
$server->expects(self::once())->method('getCredentialCreationOptions')->with(
self::equalTo('test_user'),
self::anything(),
@@ -178,7 +178,7 @@ class WebAuthnTest extends AbstractTestCase
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['webauthn_creation_response', '', '{}']]);
- $server = self::createMock(Server::class);
+ $server = $this->createMock(Server::class);
$server->expects(self::once())->method('parseAndValidateAttestationResponse')
->willThrowException(new WebAuthnException());
@@ -199,7 +199,7 @@ class WebAuthnTest extends AbstractTestCase
// base64url of publicKeyCredentialId1
$credential = ['publicKeyCredentialId' => 'cHVibGljS2V5Q3JlZGVudGlhbElkMQ', 'userHandle' => 'userHandle'];
- $server = self::createMock(Server::class);
+ $server = $this->createMock(Server::class);
$server->expects(self::once())->method('parseAndValidateAttestationResponse')->with(
self::equalTo('{}'),
self::equalTo('{}'),
@@ -249,7 +249,7 @@ class WebAuthnTest extends AbstractTestCase
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['webauthn_request_response', '', '{}']]);
- $server = self::createMock(Server::class);
+ $server = $this->createMock(Server::class);
$server->expects(self::once())->method('parseAndValidateAssertionResponse')
->willThrowException(new WebAuthnException());
@@ -280,7 +280,7 @@ class WebAuthnTest extends AbstractTestCase
],
];
- $server = self::createMock(Server::class);
+ $server = $this->createMock(Server::class);
$server->expects(self::once())->method('parseAndValidateAssertionResponse')->with(
self::equalTo('{}'),
self::equalTo([['type' => 'public-key', 'id' => 'cHVibGljS2V5Q3JlZGVudGlhbElkMQ']]),
diff --git a/tests/unit/Properties/Options/OptionsPropertyGroupTest.php b/tests/unit/Properties/Options/OptionsPropertyGroupTest.php
index dc10482854..bb16a987a8 100644
--- a/tests/unit/Properties/Options/OptionsPropertyGroupTest.php
+++ b/tests/unit/Properties/Options/OptionsPropertyGroupTest.php
@@ -7,10 +7,12 @@ namespace PhpMyAdmin\Tests\Properties\Options;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
use PhpMyAdmin\Properties\Options\OptionsPropertyGroup;
use PhpMyAdmin\Tests\AbstractTestCase;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
#[CoversClass(OptionsPropertyGroup::class)]
+#[AllowMockObjectsWithoutExpectations]
class OptionsPropertyGroupTest extends AbstractTestCase
{
protected OptionsPropertyGroup&MockObject $stub;
diff --git a/tests/unit/Properties/Options/OptionsPropertyOneItemTest.php b/tests/unit/Properties/Options/OptionsPropertyOneItemTest.php
index 1dca3664b2..f41a4af789 100644
--- a/tests/unit/Properties/Options/OptionsPropertyOneItemTest.php
+++ b/tests/unit/Properties/Options/OptionsPropertyOneItemTest.php
@@ -6,10 +6,12 @@ namespace PhpMyAdmin\Tests\Properties\Options;
use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
use PhpMyAdmin\Tests\AbstractTestCase;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
#[CoversClass(OptionsPropertyOneItem::class)]
+#[AllowMockObjectsWithoutExpectations]
class OptionsPropertyOneItemTest extends AbstractTestCase
{
protected OptionsPropertyOneItem&MockObject $stub;
diff --git a/tests/unit/Server/Privileges/AccountLockingTest.php b/tests/unit/Server/Privileges/AccountLockingTest.php
index 181a605cfc..eb0421df0f 100644
--- a/tests/unit/Server/Privileges/AccountLockingTest.php
+++ b/tests/unit/Server/Privileges/AccountLockingTest.php
@@ -16,7 +16,7 @@ class AccountLockingTest extends TestCase
{
public function testLockWithValidAccount(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('isMariaDB')->willReturn(true);
$dbi->expects(self::once())->method('getVersion')->willReturn(100402);
$dbi->expects(self::exactly(2))->method('quoteString')
@@ -33,7 +33,7 @@ class AccountLockingTest extends TestCase
public function testLockWithInvalidAccount(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('isMariaDB')->willReturn(true);
$dbi->expects(self::once())->method('getVersion')->willReturn(100402);
$dbi->expects(self::exactly(2))->method('quoteString')
@@ -54,7 +54,7 @@ class AccountLockingTest extends TestCase
public function testLockWithUnsupportedServer(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('isMariaDB')->willReturn(true);
$dbi->expects(self::once())->method('getVersion')->willReturn(100401);
$dbi->expects(self::never())->method('quoteString');
@@ -71,7 +71,7 @@ class AccountLockingTest extends TestCase
public function testUnlockWithValidAccount(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('isMariaDB')->willReturn(true);
$dbi->expects(self::once())->method('getVersion')->willReturn(100402);
$dbi->expects(self::exactly(2))->method('quoteString')
@@ -88,7 +88,7 @@ class AccountLockingTest extends TestCase
public function testUnlockWithInvalidAccount(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('isMariaDB')->willReturn(true);
$dbi->expects(self::once())->method('getVersion')->willReturn(100402);
$dbi->expects(self::exactly(2))->method('quoteString')
@@ -109,7 +109,7 @@ class AccountLockingTest extends TestCase
public function testUnlockWithUnsupportedServer(): void
{
- $dbi = self::createMock(DatabaseInterface::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())->method('isMariaDB')->willReturn(false);
$dbi->expects(self::once())->method('getVersion')->willReturn(50705);
$dbi->expects(self::never())->method('quoteString');
diff --git a/tests/unit/Server/PrivilegesTest.php b/tests/unit/Server/PrivilegesTest.php
index 924270580c..27e6b2b990 100644
--- a/tests/unit/Server/PrivilegesTest.php
+++ b/tests/unit/Server/PrivilegesTest.php
@@ -24,6 +24,7 @@ use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Url;
use PhpMyAdmin\UserPrivileges;
use PhpMyAdmin\Util;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Medium;
@@ -38,6 +39,7 @@ use function preg_quote;
#[CoversClass(Privileges::class)]
#[Medium]
+#[AllowMockObjectsWithoutExpectations]
class PrivilegesTest extends AbstractTestCase
{
protected DatabaseInterface $dbi;
@@ -520,14 +522,10 @@ class PrivilegesTest extends AbstractTestCase
$_POST['max_user_connections'] = 40;
//Mock DBI
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
- $dbi->expects(self::any())->method('getVersion')
- ->willReturn(8003);
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi->method('getVersion')->willReturn(8003);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$serverPrivileges->dbi = $dbi;
@@ -563,14 +561,10 @@ class PrivilegesTest extends AbstractTestCase
$_POST['max_user_connections'] = 40;
//Mock DBI
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
- $dbi->expects(self::any())->method('getVersion')
- ->willReturn(80011);
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi->method('getVersion')->willReturn(80011);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$serverPrivileges->dbi = $dbi;
@@ -941,17 +935,13 @@ class PrivilegesTest extends AbstractTestCase
$serverPrivileges->username = 'pma_username';
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$fieldsInfo = [
['COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80],
['COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40],
];
- $dbi->expects(self::any())->method('fetchResult')
- ->willReturn($fieldsInfo);
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi->method('fetchResult')->willReturn($fieldsInfo);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$serverPrivileges->dbi = $dbi;
@@ -1006,20 +996,15 @@ class PrivilegesTest extends AbstractTestCase
$dbi = $this->createDatabaseInterface();
$serverPrivileges = $this->getPrivileges($dbi);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$fieldsInfo = [
['COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80],
['COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40],
];
- $dbi->expects(self::any())->method('fetchResult')
- ->willReturn($fieldsInfo);
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi->method('fetchResult')->willReturn($fieldsInfo);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
- $dbi->expects(self::any())->method('isGrantUser')
- ->willReturn(true);
+ $dbi->method('isGrantUser')->willReturn(true);
$serverPrivileges->dbi = $dbi;
@@ -1780,20 +1765,11 @@ class PrivilegesTest extends AbstractTestCase
$resultStub = $this->createMock(DummyResult::class);
//Mock DBI
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())
- ->method('query')
- ->willReturn($resultStub);
- $dbi->expects(self::any())
- ->method('fetchResult')
- ->willReturn(['db', 'columns_priv']);
- $resultStub->expects(self::any())
- ->method('fetchAssoc')
- ->willReturn(['User' => 'pmauser', 'Host' => 'local'], []);
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('query')->willReturn($resultStub);
+ $dbi->method('fetchResult')->willReturn(['db', 'columns_priv']);
+ $resultStub->method('fetchAssoc')->willReturn(['User' => 'pmauser', 'Host' => 'local'], []);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$serverPrivileges->dbi = $dbi;
@@ -1821,17 +1797,10 @@ class PrivilegesTest extends AbstractTestCase
$resultStub = self::createStub(DummyResult::class);
//Mock DBI
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())
- ->method('tryQuery')
- ->willReturn($resultStub, $resultStub, false);
- $dbi->expects(self::any())
- ->method('getError')
- ->willReturn('Some error occurred!');
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('tryQuery')->willReturn($resultStub, $resultStub, false);
+ $dbi->method('getError')->willReturn('Some error occurred!');
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$serverPrivileges->dbi = $dbi;
diff --git a/tests/unit/SystemDatabaseTest.php b/tests/unit/SystemDatabaseTest.php
index fc4cd7d139..16c9516e9c 100644
--- a/tests/unit/SystemDatabaseTest.php
+++ b/tests/unit/SystemDatabaseTest.php
@@ -11,6 +11,7 @@ use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\SystemColumn;
use PhpMyAdmin\SystemDatabase;
use PhpMyAdmin\Tests\Stubs\DummyResult;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use ReflectionProperty;
@@ -18,6 +19,7 @@ use const MYSQLI_TYPE_STRING;
#[CoversClass(SystemDatabase::class)]
#[CoversClass(SystemColumn::class)]
+#[AllowMockObjectsWithoutExpectations]
class SystemDatabaseTest extends AbstractTestCase
{
/**
@@ -37,18 +39,11 @@ class SystemDatabaseTest extends AbstractTestCase
*/
Config::getInstance()->selectedServer['pmadb'] = '';
- $resultStub = self::createMock(DummyResult::class);
+ $dbi = $this->createMock(DatabaseInterface::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi->method('tryQuery')->willReturn($this->createStub(DummyResult::class));
- $dbi->expects(self::any())
- ->method('tryQuery')
- ->willReturn($resultStub);
-
- $dbi->expects(self::any())
- ->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$relationParameters = RelationParameters::fromArray([
@@ -85,18 +80,16 @@ class SystemDatabaseTest extends AbstractTestCase
*/
public function testPMAGetNewTransformationDataSql(): void
{
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $resultStub->expects(self::any())
- ->method('fetchAssoc')
- ->willReturn([
- 'table_name' => 'table_name',
- 'column_name' => 'column_name',
- 'comment' => 'comment',
- 'mimetype' => 'mimetype',
- 'transformation' => 'transformation',
- 'transformation_options' => 'transformation_options',
- ]);
+ $resultStub->method('fetchAssoc')->willReturn([
+ 'table_name' => 'table_name',
+ 'column_name' => 'column_name',
+ 'comment' => 'comment',
+ 'mimetype' => 'mimetype',
+ 'transformation' => 'transformation',
+ 'transformation_options' => 'transformation_options',
+ ]);
$db = 'PMA_db';
$columnMap = [new SystemColumn('table_name', 'column_name', null)];
diff --git a/tests/unit/Table/IndexesTest.php b/tests/unit/Table/IndexesTest.php
index 8de0baf554..7445a370bc 100644
--- a/tests/unit/Table/IndexesTest.php
+++ b/tests/unit/Table/IndexesTest.php
@@ -11,10 +11,12 @@ use PhpMyAdmin\Message;
use PhpMyAdmin\Table\Indexes;
use PhpMyAdmin\Table\Table;
use PhpMyAdmin\Tests\AbstractTestCase;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
#[CoversClass(Indexes::class)]
+#[AllowMockObjectsWithoutExpectations]
class IndexesTest extends AbstractTestCase
{
private DatabaseInterface&MockObject $dbi;
@@ -26,17 +28,14 @@ class IndexesTest extends AbstractTestCase
Current::$database = 'db';
Current::$table = 'table';
- $this->dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->dbi = $this->createMock(DatabaseInterface::class);
}
public function testGetSqlQueryForRename(): void
{
$sqlQuery = 'ALTER TABLE `db`.`table` RENAME INDEX `0` TO `ABC`;';
- $this->dbi->expects(self::any())->method('getVersion')
- ->willReturn(50700);
+ $this->dbi->method('getVersion')->willReturn(50700);
$index = new Index(['Key_name' => 'ABC']);
@@ -59,11 +58,8 @@ class IndexesTest extends AbstractTestCase
public function testGetSqlQueryForIndexCreateOrEdit(): void
{
- $table = $this->getMockBuilder(Table::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->dbi->expects(self::any())->method('getTable')
- ->willReturn($table);
+ $table = $this->createStub(Table::class);
+ $this->dbi->method('getTable')->willReturn($table);
$indexes = new Indexes($this->dbi);
$db = 'pma_db';
diff --git a/tests/unit/Table/TableTest.php b/tests/unit/Table/TableTest.php
index f9e16867c1..6880de07d5 100644
--- a/tests/unit/Table/TableTest.php
+++ b/tests/unit/Table/TableTest.php
@@ -22,6 +22,7 @@ use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\FieldHelper;
use PhpMyAdmin\Tests\Stubs\DbiDummy;
use PhpMyAdmin\Tests\Stubs\DummyResult;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
@@ -31,6 +32,7 @@ use ReflectionProperty;
use const MYSQLI_TYPE_STRING;
#[CoversClass(Table::class)]
+#[AllowMockObjectsWithoutExpectations]
class TableTest extends AbstractTestCase
{
private DatabaseInterface&MockObject $mockedDbi;
@@ -243,39 +245,31 @@ class TableTest extends AbstractTestCase
$resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$databaseList = self::createStub(ListDatabase::class);
$databaseList->method('exists')->willReturn(true);
- $dbi->expects(self::any())->method('getDatabaseList')->willReturn($databaseList);
+ $dbi->method('getDatabaseList')->willReturn($databaseList);
- $dbi->expects(self::any())->method('fetchResult')
- ->willReturnMap($fetchResult);
+ $dbi->method('fetchResult')->willReturnMap($fetchResult);
- $dbi->expects(self::any())->method('fetchResultSimple')
- ->willReturnMap($fetchResultSimple);
+ $dbi->method('fetchResultSimple')->willReturnMap($fetchResultSimple);
- $dbi->expects(self::any())->method('fetchResultMultidimensional')
- ->willReturnMap($fetchResultMultidimensional);
+ $dbi->method('fetchResultMultidimensional')->willReturnMap($fetchResultMultidimensional);
- $dbi->expects(self::any())->method('fetchValue')
- ->willReturnMap($fetchValue);
+ $dbi->method('fetchValue')->willReturnMap($fetchValue);
$cache = new Cache();
- $dbi->expects(self::any())->method('getCache')
- ->willReturn($cache);
+ $dbi->method('getCache')->willReturn($cache);
- $dbi->expects(self::any())->method('getColumnNames')
- ->willReturnMap([
- [
- 'PMA',
- 'PMA_BookMark',
- ConnectionType::User,
- ['column1', 'column3', 'column5', 'ACCESSIBLE', 'ADD', 'ALL'],
- ],
- ]);
+ $dbi->method('getColumnNames')->willReturnMap([
+ [
+ 'PMA',
+ 'PMA_BookMark',
+ ConnectionType::User,
+ ['column1', 'column3', 'column5', 'ACCESSIBLE', 'ADD', 'ALL'],
+ ],
+ ]);
$databases = [];
$databaseName = 'PMA';
@@ -286,26 +280,20 @@ class TableTest extends AbstractTestCase
$databases[$databaseName]['SCHEMA_INDEX_LENGTH'] = 10;
$databases[$databaseName]['SCHEMA_LENGTH'] = 10;
- $dbi->expects(self::any())->method('getTablesFull')
- ->willReturn($databases);
+ $dbi->method('getTablesFull')->willReturn($databases);
- $dbi->expects(self::any())->method('query')
- ->willReturn($resultStub);
+ $dbi->method('query')->willReturn($resultStub);
- $dbi->expects(self::any())->method('insertId')
- ->willReturn(10);
+ $dbi->method('insertId')->willReturn(10);
- $resultStub->expects(self::any())->method('fetchAssoc')
- ->willReturn([]);
+ $resultStub->method('fetchAssoc')->willReturn([]);
$value = ['Auto_increment' => 'Auto_increment'];
- $dbi->expects(self::any())->method('fetchSingleRow')
- ->willReturn($value);
+ $dbi->method('fetchSingleRow')->willReturn($value);
- $resultStub->expects(self::any())->method('fetchRow')
- ->willReturn([]);
+ $resultStub->method('fetchRow')->willReturn([]);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
DatabaseInterface::$instance = $dbi;
@@ -1247,7 +1235,7 @@ class TableTest extends AbstractTestCase
$table = 'PMA_BookMark';
$db = 'PMA';
- $this->mockedDbi->expects(self::any())->method('tryQuery')->willReturn(self::createStub(DummyResult::class));
+ $this->mockedDbi->method('tryQuery')->willReturn(self::createStub(DummyResult::class));
$table = new Table($table, $db, $this->mockedDbi);
@@ -1327,9 +1315,7 @@ class TableTest extends AbstractTestCase
*/
public function testGetColumnsMeta(): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$resultStub = self::createStub(DummyResult::class);
@@ -1415,28 +1401,18 @@ class TableTest extends AbstractTestCase
$resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())
- ->method('tryQuery')
- ->willReturn($resultStub);
- $resultStub->expects(self::any())
- ->method('numRows')
- ->willReturn(0, 10, 200);
- $dbi->expects(self::any())
- ->method('fetchResult')
- ->willReturn(
- ['`one_ind`', '`sec_ind`'],
- [], // No Uniques found
- );
- $dbi->expects(self::any())
- ->method('fetchResultMultidimensional')
- ->willReturn(
- [['`one_pk`']],
- [], // No Indexed found
- [], // No Uniques found
- );
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('tryQuery')->willReturn($resultStub);
+ $resultStub->method('numRows')->willReturn(0, 10, 200);
+ $dbi->method('fetchResult')->willReturn(
+ ['`one_ind`', '`sec_ind`'],
+ [], // No Uniques found
+ );
+ $dbi->method('fetchResultMultidimensional')->willReturn(
+ [['`one_pk`']],
+ [], // No Indexed found
+ [], // No Uniques found
+ );
DatabaseInterface::$instance = $dbi;
@@ -1465,13 +1441,10 @@ class TableTest extends AbstractTestCase
public function testCountRecords(): void
{
$resultStub = $this->createMock(DummyResult::class);
- $resultStub->expects(self::any())
- ->method('numRows')
- ->willReturn(20);
+ $resultStub->method('numRows')->willReturn(20);
$dbi = clone $this->mockedDbi;
- $dbi->expects(self::any())->method('tryQuery')
- ->willReturn($resultStub);
+ $dbi->method('tryQuery')->willReturn($resultStub);
$table = 'PMA_BookMark';
$db = 'PMA';
@@ -1526,8 +1499,7 @@ class TableTest extends AbstractTestCase
['aa', 'ad', new Table('ad', 'aa', $this->mockedDbi)],
];
- $this->mockedDbi->expects(self::any())->method('getTable')
- ->willReturnMap($getTableMap);
+ $this->mockedDbi->method('getTable')->willReturnMap($getTableMap);
$object = new TableMover($this->mockedDbi, new Relation($this->mockedDbi));
@@ -1571,47 +1543,44 @@ class TableTest extends AbstractTestCase
// Renaming DB with a view bug
$resultStub = $this->createMock(DummyResult::class);
- $this->mockedDbi->expects(self::any())->method('tryQuery')
- ->willReturnMap([
- [
- 'SHOW CREATE TABLE `aa`.`ad`',
- ConnectionType::User,
- false,
- true,
- $resultStub,
- ],
- [
- 'SHOW TABLE STATUS FROM `aa` WHERE Name = \'ad\'',
- ConnectionType::User,
- false,
- true,
- $resultStub,
- ],
- ['USE `aa`', ConnectionType::User, false, true, $resultStub],
- [
- 'RENAME TABLE `PMA`.`PMA_BookMark` TO `PMA`.`PMA_.BookMark`;',
- ConnectionType::User,
- false,
- true,
- false,
- ],
- [
- 'RENAME TABLE `aa`.`ad` TO `bb`.`ad`;',
- ConnectionType::User,
- false,
- true,
- false,
- ],
- ]);
- $resultStub->expects(self::any())
- ->method('fetchRow')
- ->willReturn([
- 'ad',
- 'CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost`' .
- ' SQL SECURITY DEFINER VIEW `ad` AS select `aa`.`bb`.`ac` AS `ac` from `bb`',
- 'utf8mb4',
- 'utf8mb4_unicode_ci',
- ]);
+ $this->mockedDbi->method('tryQuery')->willReturnMap([
+ [
+ 'SHOW CREATE TABLE `aa`.`ad`',
+ ConnectionType::User,
+ false,
+ true,
+ $resultStub,
+ ],
+ [
+ 'SHOW TABLE STATUS FROM `aa` WHERE Name = \'ad\'',
+ ConnectionType::User,
+ false,
+ true,
+ $resultStub,
+ ],
+ ['USE `aa`', ConnectionType::User, false, true, $resultStub],
+ [
+ 'RENAME TABLE `PMA`.`PMA_BookMark` TO `PMA`.`PMA_.BookMark`;',
+ ConnectionType::User,
+ false,
+ true,
+ false,
+ ],
+ [
+ 'RENAME TABLE `aa`.`ad` TO `bb`.`ad`;',
+ ConnectionType::User,
+ false,
+ true,
+ false,
+ ],
+ ]);
+ $resultStub->method('fetchRow')->willReturn([
+ 'ad',
+ 'CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost`'
+ . ' SQL SECURITY DEFINER VIEW `ad` AS select `aa`.`bb`.`ac` AS `ac` from `bb`',
+ 'utf8mb4',
+ 'utf8mb4_unicode_ci',
+ ]);
Current::$sqlQuery = '';
$return = $object->moveCopy('aa', 'ad', 'bb', 'ad', MoveScope::Move, MoveMode::WholeDatabase, true);
diff --git a/tests/unit/Tracking/TrackerTest.php b/tests/unit/Tracking/TrackerTest.php
index b17fb1c438..1428efb19a 100644
--- a/tests/unit/Tracking/TrackerTest.php
+++ b/tests/unit/Tracking/TrackerTest.php
@@ -157,9 +157,7 @@ class TrackerTest extends AbstractTestCase
$resultStub = self::createStub(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
/**
* set up mock objects
@@ -189,12 +187,10 @@ class TrackerTest extends AbstractTestCase
[$showCreateTableQuery, ConnectionType::User, false, true, $resultStub],
]);
- $dbi->expects(self::any())->method('query')
- ->willReturn($resultStub);
+ $dbi->method('query')->willReturn($resultStub);
- $dbi->expects(self::any())->method('getCompatibilities')
- ->willReturn([]);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('getCompatibilities')->willReturn([]);
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
DatabaseInterface::$instance = $dbi;
@@ -213,9 +209,7 @@ class TrackerTest extends AbstractTestCase
$resultStub = self::createStub(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$expectedMainQuery = '/*NOTRACK*/' . "\n" . 'INSERT INTO `pmadb`.`tracking` (db_name, table_name, version,'
. ' date_created, date_updated, schema_snapshot, schema_sql, data_sql, tracking)'
@@ -228,7 +222,7 @@ class TrackerTest extends AbstractTestCase
->with(self::matches($expectedMainQuery))
->willReturn($resultStub);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
DatabaseInterface::$instance = $dbi;
@@ -252,9 +246,7 @@ class TrackerTest extends AbstractTestCase
string|int $newState = '1',
string|null $type = null,
): void {
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$resultStub = self::createStub(DummyResult::class);
@@ -268,7 +260,7 @@ class TrackerTest extends AbstractTestCase
->with($sqlQuery)
->willReturn($resultStub);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
DatabaseInterface::$instance = $dbi;
diff --git a/tests/unit/Tracking/TrackingTest.php b/tests/unit/Tracking/TrackingTest.php
index 4a34fd255f..22de9dd500 100644
--- a/tests/unit/Tracking/TrackingTest.php
+++ b/tests/unit/Tracking/TrackingTest.php
@@ -572,11 +572,9 @@ final class TrackingTest extends AbstractTestCase
*/
public function testDeleteTracking(): void
{
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createStub(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$sqlQuery = "/*NOTRACK*/\n"
. 'DELETE FROM `pmadb`.`tracking`'
@@ -587,7 +585,7 @@ final class TrackingTest extends AbstractTestCase
->method('queryAsControlUser')
->with($sqlQuery)
->willReturn($resultStub);
- $dbi->expects(self::any())->method('quoteString')
+ $dbi->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
$tracking = new Tracking(
@@ -640,11 +638,9 @@ final class TrackingTest extends AbstractTestCase
#[DataProvider('getTrackedDataProvider')]
public function testGetTrackedData(array $fetchArrayReturn, TrackedData $expected): void
{
- $resultStub = self::createMock(DummyResult::class);
+ $resultStub = $this->createMock(DummyResult::class);
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects(self::once())
->method('queryAsControlUser')
diff --git a/tests/unit/TransformationsTest.php b/tests/unit/TransformationsTest.php
index 62bfd16cac..c2424ff647 100644
--- a/tests/unit/TransformationsTest.php
+++ b/tests/unit/TransformationsTest.php
@@ -9,11 +9,13 @@ use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Transformations;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use ReflectionProperty;
#[CoversClass(Transformations::class)]
+#[AllowMockObjectsWithoutExpectations]
class TransformationsTest extends AbstractTestCase
{
private Transformations $transformations;
@@ -188,12 +190,8 @@ class TransformationsTest extends AbstractTestCase
public function testClear(): void
{
// Mock dbi
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $dbi->expects(self::any())
- ->method('tryQuery')
- ->willReturn(self::createStub(DummyResult::class));
+ $dbi = $this->createMock(DatabaseInterface::class);
+ $dbi->method('tryQuery')->willReturn(self::createStub(DummyResult::class));
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, null);
diff --git a/tests/unit/UtilTest.php b/tests/unit/UtilTest.php
index ee307e50f8..afe885ef91 100644
--- a/tests/unit/UtilTest.php
+++ b/tests/unit/UtilTest.php
@@ -14,6 +14,7 @@ use PhpMyAdmin\SqlParser\Token;
use PhpMyAdmin\Util;
use PhpMyAdmin\Utils\SessionCache;
use PhpMyAdmin\Version;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
@@ -35,6 +36,7 @@ use const LC_ALL;
use const LOCALE_PATH;
#[CoversClass(Util::class)]
+#[AllowMockObjectsWithoutExpectations]
class UtilTest extends AbstractTestCase
{
/**
@@ -1373,17 +1375,11 @@ SQL;
#[DataProvider('provideForTestIsUUIDSupported')]
public function testIsUUIDSupported(bool $isMariaDB, int $version, bool $expected): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
- $dbi->expects(self::any())
- ->method('isMariaDB')
- ->willReturn($isMariaDB);
+ $dbi->method('isMariaDB')->willReturn($isMariaDB);
- $dbi->expects(self::any())
- ->method('getVersion')
- ->willReturn($version);
+ $dbi->method('getVersion')->willReturn($version);
DatabaseInterface::$instance = $dbi;
self::assertSame(Util::isUUIDSupported(), $expected);
diff --git a/tests/unit/Utils/ForeignKeyTest.php b/tests/unit/Utils/ForeignKeyTest.php
index 1e3d61daa6..b6aeb95db1 100644
--- a/tests/unit/Utils/ForeignKeyTest.php
+++ b/tests/unit/Utils/ForeignKeyTest.php
@@ -74,9 +74,7 @@ class ForeignKeyTest extends AbstractTestCase
#[DataProvider('providerCheckInit')]
public function testHandleDisableCheckInit(string $checksValue, string $setVariableParam): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
DatabaseInterface::$instance = $dbi;
$_REQUEST['fk_checks'] = $checksValue;
@@ -95,9 +93,7 @@ class ForeignKeyTest extends AbstractTestCase
#[DataProvider('providerCheckInit')]
public function testHandleDisableCheckInitVarFalse(string $checksValue, string $setVariableParam): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
DatabaseInterface::$instance = $dbi;
$_REQUEST['fk_checks'] = $checksValue;
@@ -122,9 +118,7 @@ class ForeignKeyTest extends AbstractTestCase
#[DataProvider('providerCheckCleanup')]
public function testHandleDisableCheckCleanup(bool $checkValue, string $setVariableParam): void
{
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
DatabaseInterface::$instance = $dbi;
$dbi->expects(self::once())
diff --git a/tests/unit/Utils/GisTest.php b/tests/unit/Utils/GisTest.php
index 2e8f050e78..a41511cc78 100644
--- a/tests/unit/Utils/GisTest.php
+++ b/tests/unit/Utils/GisTest.php
@@ -36,9 +36,7 @@ class GisTest extends AbstractTestCase
bool $SRIDOption,
int $mysqlVersion,
): void {
- $dbi = $this->getMockBuilder(DatabaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $dbi = $this->createMock(DatabaseInterface::class);
$dbi->expects($SRIDOption ? self::once() : self::exactly(2))
->method('getVersion')
diff --git a/tests/unit/VersionInformationTest.php b/tests/unit/VersionInformationTest.php
index e41742bbc8..f02ac62397 100644
--- a/tests/unit/VersionInformationTest.php
+++ b/tests/unit/VersionInformationTest.php
@@ -8,6 +8,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\Release;
use PhpMyAdmin\Utils\HttpRequest;
use PhpMyAdmin\VersionInformation;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
@@ -16,6 +17,7 @@ use PHPUnit\Framework\Attributes\Large;
#[CoversClass(VersionInformation::class)]
#[CoversClass(Release::class)]
#[Large]
+#[AllowMockObjectsWithoutExpectations]
class VersionInformationTest extends AbstractTestCase
{
/** @var Release[] */
@@ -251,9 +253,7 @@ class VersionInformationTest extends AbstractTestCase
->onlyMethods(['getPHPVersion'])
->getMock();
- $mockVersionInfo->expects(self::any())
- ->method('getPHPVersion')
- ->willReturn('5.2.4');
+ $mockVersionInfo->method('getPHPVersion')->willReturn('5.2.4');
self::assertTrue($mockVersionInfo->evaluateVersionCondition('PHP', '<=5.3'));
self::assertTrue($mockVersionInfo->evaluateVersionCondition('PHP', '<5.3'));