Passed
Push — master ( abc21e...c2c96d )
by Maurício
13:02
created

OperationsTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\Tests;
6
7
use PhpMyAdmin\Operations;
8
use PhpMyAdmin\Relation;
9
10
use function array_merge;
11
12
/**
13
 * @covers \PhpMyAdmin\Operations
14
 */
15
class OperationsTest extends AbstractTestCase
16
{
17
    /** @var Operations */
18
    private $object;
19
20
    protected function setUp(): void
21
    {
22
        parent::setUp();
23
24
        $this->object = new Operations($this->dbi, new Relation($this->dbi));
25
    }
26
27
    /**
28
     * @dataProvider providerGetPartitionMaintenanceChoices
29
     */
30
    public function testGetPartitionMaintenanceChoices(string $tableName, array $extraChoice): void
31
    {
32
        global $db, $table;
33
34
        $db = 'database';
35
        $table = $tableName;
36
37
        $choices = [
38
            'ANALYZE' => 'Analyze',
39
            'CHECK' => 'Check',
40
            'OPTIMIZE' => 'Optimize',
41
            'REBUILD' => 'Rebuild',
42
            'REPAIR' => 'Repair',
43
            'TRUNCATE' => 'Truncate',
44
        ];
45
        $expected = array_merge($choices, $extraChoice);
46
47
        $actual = $this->object->getPartitionMaintenanceChoices();
48
        $this->assertEquals($expected, $actual);
49
    }
50
51
    /**
52
     * @psalm-return array<string, array{0: string, 1: array<string, string>}>
53
     */
54
    public function providerGetPartitionMaintenanceChoices(): array
55
    {
56
        return [
57
            'no partition method' => ['no_partition_method', ['COALESCE' => 'Coalesce']],
58
            'RANGE partition method' => ['range_partition_method', ['DROP' => 'Drop']],
59
            'RANGE COLUMNS partition method' => ['range_columns_partition_method', ['DROP' => 'Drop']],
60
            'LIST partition method' => ['list_partition_method', ['DROP' => 'Drop']],
61
            'LIST COLUMNS partition method' => ['list_columns_partition_method', ['DROP' => 'Drop']],
62
        ];
63
    }
64
}
65