Fix some tests with PHP 8.1
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
d02918ef5b
commit
9920b877f9
@ -6,7 +6,6 @@ namespace PhpMyAdmin\Tests;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
use function array_merge;
|
||||
use function array_replace_recursive;
|
||||
@ -1123,16 +1122,11 @@ class ConfigTest extends AbstractTestCase
|
||||
*
|
||||
* @param array $settings settings array
|
||||
* @param array $expected expected result
|
||||
* @param bool $error error
|
||||
*
|
||||
* @dataProvider serverSettingsProvider
|
||||
*/
|
||||
public function testCheckServers(array $settings, array $expected, bool $error = false): void
|
||||
public function testCheckServers(array $settings, array $expected): void
|
||||
{
|
||||
if ($error) {
|
||||
$this->expectException(Exception::class);
|
||||
}
|
||||
|
||||
$this->object->settings['Servers'] = $settings;
|
||||
$this->object->checkServers();
|
||||
if ($expected === null) {
|
||||
@ -1167,14 +1161,24 @@ class ConfigTest extends AbstractTestCase
|
||||
'host' => '',
|
||||
],
|
||||
],
|
||||
'invalid' => [
|
||||
['invalid' => ['host' => '127.0.0.1']],
|
||||
['host' => '127.0.0.1'],
|
||||
true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @group with-trigger-error
|
||||
*/
|
||||
public function testCheckServersWithInvalidServer(): void
|
||||
{
|
||||
$this->expectError();
|
||||
$this->expectErrorMessage('Invalid server index: invalid');
|
||||
|
||||
$this->object->settings['Servers'] = ['invalid' => ['host' => '127.0.0.1'], 1 => ['host' => '127.0.0.1']];
|
||||
$this->object->checkServers();
|
||||
$expected = array_merge($this->object->defaultServer, ['host' => '127.0.0.1']);
|
||||
|
||||
$this->assertEquals($expected, $this->object->settings['Servers'][1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for selectServer
|
||||
*
|
||||
|
||||
@ -179,11 +179,12 @@ class DbiMysqliTest extends AbstractTestCase
|
||||
public function testStoreResult(): void
|
||||
{
|
||||
$mysqli = $this->createMock(mysqli::class);
|
||||
$mysqliResult = $this->createMock(mysqli_result::class);
|
||||
$mysqli->expects($this->once())
|
||||
->method('store_result')
|
||||
->willReturn(true);
|
||||
->willReturn($mysqliResult);
|
||||
|
||||
$this->assertTrue($this->object->storeResult($mysqli));
|
||||
$this->assertInstanceOf(mysqli_result::class, $this->object->storeResult($mysqli));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests\Navigation;
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
use PhpMyAdmin\Navigation\Nodes\Node;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
/**
|
||||
* @covers \PhpMyAdmin\Navigation\NodeFactory
|
||||
@ -56,15 +55,23 @@ class NodeFactoryTest extends AbstractTestCase
|
||||
$this->assertTrue($node->isGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group with-trigger-error
|
||||
*/
|
||||
public function testFileError(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectError();
|
||||
$this->expectErrorMessage('Could not load class "PhpMyAdmin\Navigation\Nodes\Node"');
|
||||
NodeFactory::getInstance('NodeDoesNotExist');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group with-trigger-error
|
||||
*/
|
||||
public function testClassNameError(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectError();
|
||||
$this->expectErrorMessage('Invalid class name "Node", using default of "Node"');
|
||||
NodeFactory::getInstance('Invalid');
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,8 @@ class OperationsTest extends AbstractTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$GLOBALS['server'] = 1;
|
||||
|
||||
$this->object = new Operations($this->dbi, new Relation($this->dbi));
|
||||
}
|
||||
|
||||
|
||||
@ -13,12 +13,14 @@ class PartitionTest extends AbstractTestCase
|
||||
{
|
||||
public function testGetPartitionMethodReturnsNull(): void
|
||||
{
|
||||
$GLOBALS['server'] = 1;
|
||||
$actual = Partition::getPartitionMethod('database', 'no_partition_method');
|
||||
$this->assertNull($actual);
|
||||
}
|
||||
|
||||
public function testGetPartitionMethodWithRangeMethod(): void
|
||||
{
|
||||
$GLOBALS['server'] = 1;
|
||||
$actual = Partition::getPartitionMethod('database', 'range_partition_method');
|
||||
$this->assertEquals('RANGE', $actual);
|
||||
}
|
||||
|
||||
@ -22,6 +22,13 @@
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
<exclude>
|
||||
<!-- Exclude tests that do not work with convert*ToExceptions="false" -->
|
||||
<group>with-trigger-error</group>
|
||||
</exclude>
|
||||
</groups>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">.</directory>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user