1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace PhpMyAdmin\Tests; |
6
|
|
|
|
7
|
|
|
use PhpMyAdmin\InternalRelations; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @covers \PhpMyAdmin\InternalRelations |
12
|
|
|
*/ |
13
|
|
|
class InternalRelationsTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
public function testGetInformationSchema(): void |
16
|
|
|
{ |
17
|
|
|
$tables = InternalRelations::getInformationSchema(); |
18
|
|
|
$this->assertIsArray($tables); |
19
|
|
|
foreach ($tables as $tableName => $table) { |
20
|
|
|
$this->assertIsString($tableName); |
21
|
|
|
$this->assertIsArray($table); |
22
|
|
|
foreach ($table as $fieldName => $field) { |
23
|
|
|
$this->assertIsString($fieldName); |
24
|
|
|
$this->assertIsArray($field); |
25
|
|
|
$this->assertArrayHasKey('foreign_db', $field); |
26
|
|
|
$this->assertArrayHasKey('foreign_table', $field); |
27
|
|
|
$this->assertArrayHasKey('foreign_field', $field); |
28
|
|
|
$this->assertIsString($field['foreign_db']); |
29
|
|
|
$this->assertIsString($field['foreign_table']); |
30
|
|
|
$this->assertIsString($field['foreign_field']); |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testGetMySql(): void |
36
|
|
|
{ |
37
|
|
|
$tables = InternalRelations::getMySql(); |
38
|
|
|
$this->assertIsArray($tables); |
39
|
|
|
foreach ($tables as $tableName => $table) { |
40
|
|
|
$this->assertIsString($tableName); |
41
|
|
|
$this->assertIsArray($table); |
42
|
|
|
foreach ($table as $fieldName => $field) { |
43
|
|
|
$this->assertIsString($fieldName); |
44
|
|
|
$this->assertIsArray($field); |
45
|
|
|
$this->assertArrayHasKey('foreign_db', $field); |
46
|
|
|
$this->assertArrayHasKey('foreign_table', $field); |
47
|
|
|
$this->assertArrayHasKey('foreign_field', $field); |
48
|
|
|
$this->assertIsString($field['foreign_db']); |
49
|
|
|
$this->assertIsString($field['foreign_table']); |
50
|
|
|
$this->assertIsString($field['foreign_field']); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|