Skip to content

Commit

Permalink
Merge pull request phpmyadmin#19274 from MauricioFauth/phpunit-11-compat
Browse files Browse the repository at this point in the history
Fix compatibility with PHPUnit 11
  • Loading branch information
MauricioFauth authored Aug 29, 2024
2 parents 7a8887b + 2c597e3 commit cab792d
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 49 deletions.
7 changes: 7 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13188,6 +13188,11 @@
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
</file>
<file src="tests/unit/Controllers/Table/Structure/MoveColumnsControllerTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[providerForTestGenerateAlterTableSql]]></code>
</PossiblyUnusedMethod>
</file>
<file src="tests/unit/Controllers/Table/Structure/SpatialControllerTest.php">
<DeprecatedMethod>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
Expand Down Expand Up @@ -13895,6 +13900,8 @@
<code><![CDATA[provGetColumnAlphaName]]></code>
<code><![CDATA[provGetColumnNumberFromName]]></code>
<code><![CDATA[provGetDecimalSize]]></code>
<code><![CDATA[provPMACheckIfRollbackPossibleNegative]]></code>
<code><![CDATA[provPMACheckIfRollbackPossiblePositive]]></code>
<code><![CDATA[providerContentWithByteOrderMarks]]></code>
</PossiblyUnusedMethod>
<TypeDoesNotContainNull>
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Config/ConfigFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
use PhpMyAdmin\Config\Settings;
use PhpMyAdmin\Tests\AbstractTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;
use stdClass;

use function array_keys;
use function count;

#[CoversClass(ConfigFile::class)]
#[Medium]
class ConfigFileTest extends AbstractTestCase
{
/**
Expand Down Expand Up @@ -275,7 +276,6 @@ public function testConfigFileSetInUserPreferences(): void
/**
* Test for ConfigFile::getFlatDefaultConfig
*/
#[Group('medium')]
public function testGetFlatDefaultConfig(): void
{
$flatDefaultConfig = $this->object->getFlatDefaultConfig();
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/Config/FormDisplayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
use PhpMyAdmin\Current;
use PhpMyAdmin\Tests\AbstractTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;
use ReflectionClass;
use ReflectionMethod;
use ReflectionProperty;

use function function_exists;

#[CoversClass(FormDisplay::class)]
#[Medium]
class FormDisplayTest extends AbstractTestCase
{
protected FormDisplay $object;
Expand Down Expand Up @@ -50,7 +51,6 @@ protected function tearDown(): void
/**
* Test for FormDisplay::registerForm
*/
#[Group('medium')]
public function testRegisterForm(): void
{
$reflection = new ReflectionClass(FormDisplay::class);
Expand Down Expand Up @@ -81,7 +81,6 @@ public function testRegisterForm(): void
/**
* Test for FormDisplay::process
*/
#[Group('medium')]
public function testProcess(): void
{
self::assertFalse(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Config/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
use PhpMyAdmin\Config\Form;
use PhpMyAdmin\Tests\AbstractTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;
use ReflectionClass;
use ReflectionProperty;

use function array_keys;
use function preg_match;

#[CoversClass(Form::class)]
#[Medium]
class FormTest extends AbstractTestCase
{
protected Form $object;
Expand Down Expand Up @@ -50,7 +51,6 @@ protected function tearDown(): void
/**
* Test for Form::__constructor
*/
#[Group('medium')]
public function testContructor(): void
{
self::assertSame(1, $this->object->index);
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/ConfigStorage/UserGroupsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Url;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;

#[CoversClass(UserGroups::class)]
#[Medium]
class UserGroupsTest extends AbstractTestCase
{
private ConfigurableMenusFeature $configurableMenusFeature;
Expand All @@ -44,7 +45,6 @@ protected function setUp(): void
/**
* Tests UserGroups::getHtmlForUserGroupsTable() function when there are no user groups
*/
#[Group('medium')]
public function testGetHtmlForUserGroupsTableWithNoUserGroups(): void
{
$expectedQuery = 'SELECT * FROM `pmadb`.`usergroups` ORDER BY `usergroup` ASC';
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;
use ReflectionProperty;

use function define;
Expand Down Expand Up @@ -41,6 +42,7 @@
use const PHP_OS;

#[CoversClass(Config::class)]
#[Medium]
class ConfigTest extends AbstractTestCase
{
protected Config $object;
Expand Down Expand Up @@ -126,7 +128,6 @@ public function testLoadConfigs(): void
/**
* Test for CheckSystem
*/
#[Group('medium')]
public function testCheckSystem(): void
{
$this->object->checkSystem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseStub;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use ReflectionClass;

use function preg_replace;

/** @covers \PhpMyAdmin\Controllers\Table\Structure\MoveColumnsController */
#[CoversClass(MoveColumnsController::class)]
class MoveColumnsControllerTest extends AbstractTestCase
{
/**
* @param array<int,string> $columnNames
* @psalm-param list<string> $columnNames
*
* @dataProvider providerForTestGenerateAlterTableSql
*/
#[DataProvider('providerForTestGenerateAlterTableSql')]
public function testGenerateAlterTableSql(string $createStatement, array $columnNames, string|null $expected): void
{
$class = new ReflectionClass(MoveColumnsController::class);
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/EncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpMyAdmin\Encoding;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;

use function _setlocale;
Expand All @@ -23,6 +24,7 @@
use const PHP_INT_SIZE;

#[CoversClass(Encoding::class)]
#[Medium]
class EncodingTest extends AbstractTestCase
{
protected function setUp(): void
Expand All @@ -42,7 +44,6 @@ protected function tearDown(): void
/**
* Test for Encoding::convertString
*/
#[Group('medium')]
public function testNoConversion(): void
{
self::assertSame(
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/Error/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use PhpMyAdmin\Tests\AbstractTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;
use Throwable;

use function array_keys;
Expand All @@ -26,6 +26,7 @@
use const E_WARNING;

#[CoversClass(ErrorHandler::class)]
#[Medium]
class ErrorHandlerTest extends AbstractTestCase
{
protected ErrorHandler $object;
Expand Down Expand Up @@ -121,7 +122,6 @@ public function testCheckSavedErrors(): void
/**
* Test for countErrors
*/
#[Group('medium')]
public function testCountErrors(): void
{
$this->object->addError('Compile Error', E_WARNING, 'error.txt', 15);
Expand All @@ -134,7 +134,6 @@ public function testCountErrors(): void
/**
* Test for sliceErrors
*/
#[Group('medium')]
public function testSliceErrors(): void
{
$this->object->addError('Compile Error', E_WARNING, 'error.txt', 15);
Expand Down Expand Up @@ -164,7 +163,6 @@ public function testSliceErrors(): void
/**
* Test for sliceErrors with 10 elements as an example
*/
#[Group('medium')]
public function testSliceErrorsOtherExample(): void
{
for ($i = 0; $i < 10; $i++) {
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/FooterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
use PhpMyAdmin\Footer;
use PhpMyAdmin\Template;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;

use function json_encode;

#[CoversClass(Footer::class)]
#[Medium]
class FooterTest extends AbstractTestCase
{
/** @var mixed[] store private attributes of PhpMyAdmin\Footer */
Expand Down Expand Up @@ -64,7 +65,6 @@ protected function tearDown(): void
/**
* Test for getDebugMessage
*/
#[Group('medium')]
public function testGetDebugMessage(): void
{
$config = Config::getInstance();
Expand Down Expand Up @@ -114,7 +114,6 @@ public function testGetScripts(): void
/**
* Test for displaying footer
*/
#[Group('medium')]
public function testDisplay(): void
{
$footer = new Footer(new Template(), Config::getInstance());
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Html/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
use PhpMyAdmin\Utils\SessionCache;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;

use function __;
use function _pgettext;
use function htmlspecialchars;
use function urlencode;

#[CoversClass(Generator::class)]
#[Medium]
class GeneratorTest extends AbstractTestCase
{
/**
Expand All @@ -38,7 +39,6 @@ protected function setUp(): void
/**
* Test for getDbLink
*/
#[Group('medium')]
public function testGetDbLinkNull(): void
{
Current::$database = 'test_db';
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/Import/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ public static function provDetectType(): array
* Test for checkIfRollbackPossible
*
* @param string $sqlQuery SQL Query for which rollback is possible
*
* @dataProvider provPMACheckIfRollbackPossiblePositive
*/
#[DataProvider('provPMACheckIfRollbackPossiblePositive')]
public function testCheckIfRollbackPossiblePositive(string $sqlQuery): void
{
Current::$database = 'PMA';
Expand Down Expand Up @@ -258,9 +257,8 @@ public static function provPMACheckIfRollbackPossiblePositive(): array
* Negative test for checkIfRollbackPossible
*
* @param string $sqlQuery SQL Query for which rollback is possible
*
* @dataProvider provPMACheckIfRollbackPossibleNegative
*/
#[DataProvider('provPMACheckIfRollbackPossibleNegative')]
public function testCheckIfRollbackPossibleNegative(string $sqlQuery): void
{
Current::$database = 'PMA';
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/LanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PhpMyAdmin\LanguageManager;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Large;

use function _ngettext;
use function count;
Expand All @@ -19,6 +19,7 @@

#[CoversClass(Language::class)]
#[CoversClass(LanguageManager::class)]
#[Large]
class LanguageTest extends AbstractTestCase
{
private LanguageManager $manager;
Expand Down Expand Up @@ -237,7 +238,6 @@ public static function selectDataProvider(): array
* @param string $locale locale name
*/
#[DataProvider('listLocales')]
#[Group('large')]
public function testGettext(string $locale): void
{
Config::getInstance()->set('FilterLanguages', '');
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Replication/ReplicationGuiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;

#[CoversClass(ReplicationGui::class)]
#[Medium]
class ReplicationGuiTest extends AbstractTestCase
{
/**
Expand Down Expand Up @@ -52,7 +53,6 @@ protected function setUp(): void
$this->replicationGui = new ReplicationGui(new Replication(DatabaseInterface::getInstance()), new Template());
}

#[Group('medium')]
public function testGetHtmlForPrimaryReplication(): void
{
$html = $this->replicationGui->getHtmlForPrimaryReplication(null, false, 'primary_add_user', null, null);
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/Server/PrivilegesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use PhpMyAdmin\Util;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;
use ReflectionMethod;
use ReflectionProperty;

Expand All @@ -36,6 +36,7 @@
use function preg_quote;

#[CoversClass(Privileges::class)]
#[Medium]
class PrivilegesTest extends AbstractTestCase
{
protected DatabaseInterface $dbi;
Expand Down Expand Up @@ -567,7 +568,6 @@ public function testUpdatePrivilegesAfterMySql8Dot11(): void
);
}

#[Group('medium')]
public function testGetHtmlToDisplayPrivilegesTable(): void
{
$GLOBALS['hostname'] = 'hostname';
Expand Down Expand Up @@ -950,7 +950,6 @@ public function testGetWithClauseForAddUserAndUpdatePrivs(): void
self::assertStringContainsString($expect, $sqlQuery);
}

#[Group('medium')]
public function testGetHtmlForAddUser(): void
{
$dbi = $this->createDatabaseInterface();
Expand Down
Loading

0 comments on commit cab792d

Please sign in to comment.