1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace PhpMyAdmin\Tests; |
6
|
|
|
|
7
|
|
|
use PhpMyAdmin\IndexColumn; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @covers \PhpMyAdmin\IndexColumn |
12
|
|
|
*/ |
13
|
|
|
class IndexColumnTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
/** @var IndexColumn */ |
16
|
|
|
private $object; |
17
|
|
|
|
18
|
|
|
protected function setUp(): void |
19
|
|
|
{ |
20
|
|
|
$this->object = new IndexColumn(); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testGetNull(): void |
24
|
|
|
{ |
25
|
|
|
$this->assertEquals('', $this->object->getNull()); |
26
|
|
|
$this->assertEquals('No', $this->object->getNull(true)); |
27
|
|
|
$this->object->set(['Null' => 'YES']); |
28
|
|
|
$this->assertEquals('YES', $this->object->getNull()); |
29
|
|
|
$this->assertEquals('Yes', $this->object->getNull(true)); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testGetSeqInIndex(): void |
33
|
|
|
{ |
34
|
|
|
$this->assertEquals(1, $this->object->getSeqInIndex()); |
35
|
|
|
$this->object->set(['Seq_in_index' => 2]); |
36
|
|
|
$this->assertEquals(2, $this->object->getSeqInIndex()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testGetSubPart(): void |
40
|
|
|
{ |
41
|
|
|
$this->assertNull($this->object->getSubPart()); |
42
|
|
|
$this->object->set(['Sub_part' => 2]); |
43
|
|
|
$this->assertEquals(2, $this->object->getSubPart()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testGetCompareData(): void |
47
|
|
|
{ |
48
|
|
|
$this->assertEquals( |
49
|
|
|
['Column_name' => '', 'Seq_in_index' => 1, 'Collation' => null, 'Sub_part' => null, 'Null' => ''], |
50
|
|
|
$this->object->getCompareData() |
51
|
|
|
); |
52
|
|
|
$object = new IndexColumn([ |
53
|
|
|
'Column_name' => 'name', |
54
|
|
|
'Seq_in_index' => 2, |
55
|
|
|
'Collation' => 'collation', |
56
|
|
|
'Sub_part' => 2, |
57
|
|
|
'Null' => 'NO', |
58
|
|
|
]); |
59
|
|
|
$this->assertEquals( |
60
|
|
|
[ |
61
|
|
|
'Column_name' => 'name', |
62
|
|
|
'Seq_in_index' => 2, |
63
|
|
|
'Collation' => 'collation', |
64
|
|
|
'Sub_part' => 2, |
65
|
|
|
'Null' => 'NO', |
66
|
|
|
], |
67
|
|
|
$object->getCompareData() |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function testGetName(): void |
72
|
|
|
{ |
73
|
|
|
$this->assertEquals('', $this->object->getName()); |
74
|
|
|
$this->object->set(['Column_name' => 'name']); |
75
|
|
|
$this->assertEquals('name', $this->object->getName()); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function testGetCardinality(): void |
79
|
|
|
{ |
80
|
|
|
$this->assertNull($this->object->getCardinality()); |
81
|
|
|
$this->object->set(['Cardinality' => 2]); |
82
|
|
|
$this->assertEquals(2, $this->object->getCardinality()); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function testGetCollation(): void |
86
|
|
|
{ |
87
|
|
|
$this->assertNull($this->object->getCollation()); |
88
|
|
|
$this->object->set(['Collation' => 'collation']); |
89
|
|
|
$this->assertEquals('collation', $this->object->getCollation()); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|