Visitar URL original
Add unit test for `Partition::havePartitioning` · phpmyadmin/phpmyadmin@7aca256 · GitHub
Skip to content

Commit 7aca256

Browse files
committed
Add unit test for Partition::havePartitioning
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent f8bba12 commit 7aca256

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

‎test/classes/Partitioning/PartitionTest.php‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpMyAdmin\Tests\Partitioning;
66

7+
use PhpMyAdmin\DatabaseInterface;
78
use PhpMyAdmin\Partitioning\Partition;
89
use PhpMyAdmin\Tests\AbstractTestCase;
910

@@ -25,4 +26,51 @@ public function testGetPartitionMethodWithRangeMethod(): void
2526
$actual = Partition::getPartitionMethod('database', 'range_partition_method');
2627
$this->assertEquals('RANGE', $actual);
2728
}
29+
30+
/**
31+
* @param string|false $varValue
32+
* @param array<int, array<string, string>> $pluginValue
33+
*
34+
* @dataProvider providerForTestHavePartitioning
35+
* @runInSeparateProcess
36+
* @preserveGlobalState disabled
37+
*/
38+
public function testHavePartitioning(bool $expected, int $version, $varValue, array $pluginValue): void
39+
{
40+
$mock = $this->createStub(DatabaseInterface::class);
41+
$mock->method('getVersion')->willReturn($version);
42+
$mock->method('fetchValue')->willReturn($varValue);
43+
$mock->method('fetchResult')->willReturn($pluginValue);
44+
$GLOBALS['dbi'] = $mock;
45+
$this->assertSame($expected, Partition::havePartitioning());
46+
}
47+
48+
/**
49+
* @return array<string, array<int, bool|int|string|array<int, array<string, string>>>>
50+
* @psalm-return array<string, array{bool, positive-int, string|false, list<array{Name: string}>}>
51+
*/
52+
public function providerForTestHavePartitioning(): array
53+
{
54+
return [
55+
'5.5.0 with partitioning support' => [true, 50500, '1', []],
56+
'5.5.0 without partitioning support' => [false, 50500, '0', []],
57+
'5.6.0 with partitioning support' => [
58+
true,
59+
50600,
60+
false,
61+
[
62+
['Name' => 'mysql_native_password'],
63+
['Name' => 'partition'],
64+
['Name' => 'InnoDB'],
65+
],
66+
],
67+
'5.6.0 without partitioning support' => [
68+
false,
69+
50600,
70+
false,
71+
[['Name' => 'mysql_native_password'], ['Name' => 'InnoDB']],
72+
],
73+
'8.0.0' => [true, 80000, false, []],
74+
];
75+
}
2876
}

‎test/classes/StorageEngineTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ protected function tearDown(): void
5555
}
5656

5757
/**
58-
* Test for getStorageEngines
58+
* @runInSeparateProcess
59+
* @preserveGlobalState disabled
5960
*/
6061
public function testGetStorageEngines(): void
6162
{

‎test/classes/TransformationsTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ public function getOptionsData(): array
100100
}
101101

102102
/**
103-
* Test for getting available types.
103+
* @runInSeparateProcess
104+
* @preserveGlobalState disabled
104105
*/
105106
public function testGetTypes(): void
106107
{

0 commit comments

Comments
 (0)