1
|
|
|
<?php |
2
|
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */ |
3
|
|
|
/** |
4
|
|
|
* Holds EnginesControllerTest class |
5
|
|
|
* |
6
|
|
|
* @package PhpMyAdmin-test |
7
|
|
|
*/ |
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
namespace PhpMyAdmin\Tests\Controllers\Server; |
11
|
|
|
|
12
|
|
|
use PhpMyAdmin\Config; |
13
|
|
|
use PhpMyAdmin\Controllers\Server\EnginesController; |
14
|
|
|
use PhpMyAdmin\DatabaseInterface; |
15
|
|
|
use PhpMyAdmin\Response; |
16
|
|
|
use PhpMyAdmin\StorageEngine; |
17
|
|
|
use PhpMyAdmin\Url; |
18
|
|
|
use PhpMyAdmin\Util; |
19
|
|
|
use PHPStan\Testing\TestCase; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Tests for EnginesController class |
23
|
|
|
* |
24
|
|
|
* @package PhpMyAdmin-test |
25
|
|
|
*/ |
26
|
|
|
class EnginesControllerTest extends TestCase |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Prepares environment for the test. |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
protected function setUp(): void |
34
|
|
|
{ |
35
|
|
|
$GLOBALS['PMA_Config'] = new Config(); |
36
|
|
|
$GLOBALS['PMA_Config']->enableBc(); |
37
|
|
|
|
38
|
|
|
$GLOBALS['server'] = 1; |
39
|
|
|
$GLOBALS['db'] = 'db'; |
40
|
|
|
$GLOBALS['table'] = 'table'; |
41
|
|
|
$GLOBALS['PMA_PHP_SELF'] = 'index.php'; |
42
|
|
|
$GLOBALS['cfg']['Server']['DisableIS'] = false; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return void |
47
|
|
|
*/ |
48
|
|
|
public function testIndex(): void |
49
|
|
|
{ |
50
|
|
|
$controller = new EnginesController( |
51
|
|
|
Response::getInstance(), |
52
|
|
|
$GLOBALS['dbi'] |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$actual = $controller->index(); |
56
|
|
|
|
57
|
|
|
$this->assertContains( |
58
|
|
|
'<th>Storage Engine</th>', |
59
|
|
|
$actual |
60
|
|
|
); |
61
|
|
|
$this->assertContains( |
62
|
|
|
'<th>Description</th>', |
63
|
|
|
$actual |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
$this->assertContains( |
67
|
|
|
'<td>Federated MySQL storage engine</td>', |
68
|
|
|
$actual |
69
|
|
|
); |
70
|
|
|
$this->assertContains( |
71
|
|
|
'FEDERATED', |
72
|
|
|
$actual |
73
|
|
|
); |
74
|
|
|
$this->assertContains( |
75
|
|
|
'server_engines.php?engine=FEDERATED', |
76
|
|
|
$actual |
77
|
|
|
); |
78
|
|
|
|
79
|
|
|
$this->assertContains( |
80
|
|
|
'<td>dummy comment</td>', |
81
|
|
|
$actual |
82
|
|
|
); |
83
|
|
|
$this->assertContains( |
84
|
|
|
'dummy', |
85
|
|
|
$actual |
86
|
|
|
); |
87
|
|
|
$this->assertContains( |
88
|
|
|
'server_engines.php?engine=dummy', |
89
|
|
|
$actual |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return void |
95
|
|
|
*/ |
96
|
|
|
public function testShow(): void |
97
|
|
|
{ |
98
|
|
|
$dbi = $this->getMockBuilder(DatabaseInterface::class) |
99
|
|
|
->disableOriginalConstructor() |
100
|
|
|
->getMock(); |
101
|
|
|
$GLOBALS['dbi'] = $dbi; |
102
|
|
|
|
103
|
|
|
$controller = new EnginesController( |
104
|
|
|
Response::getInstance(), |
105
|
|
|
$GLOBALS['dbi'] |
106
|
|
|
); |
107
|
|
|
|
108
|
|
|
$actual = $controller->show([ |
109
|
|
|
'engine' => 'Pbxt', |
110
|
|
|
'page' => 'page', |
111
|
|
|
]); |
112
|
|
|
|
113
|
|
|
$enginePlugin = StorageEngine::getEngine('Pbxt'); |
114
|
|
|
|
115
|
|
|
$this->assertContains( |
116
|
|
|
htmlspecialchars($enginePlugin->getTitle()), |
117
|
|
|
$actual |
118
|
|
|
); |
119
|
|
|
|
120
|
|
|
$this->assertContains( |
121
|
|
|
Util::showMySQLDocu($enginePlugin->getMysqlHelpPage()), |
122
|
|
|
$actual |
123
|
|
|
); |
124
|
|
|
|
125
|
|
|
$this->assertContains( |
126
|
|
|
htmlspecialchars($enginePlugin->getComment()), |
127
|
|
|
$actual |
128
|
|
|
); |
129
|
|
|
|
130
|
|
|
$this->assertContains( |
131
|
|
|
__('Variables'), |
132
|
|
|
$actual |
133
|
|
|
); |
134
|
|
|
$this->assertContains( |
135
|
|
|
Url::getCommon([ |
136
|
|
|
'engine' => 'Pbxt', |
137
|
|
|
'page' => 'Documentation' |
138
|
|
|
]), |
139
|
|
|
$actual |
140
|
|
|
); |
141
|
|
|
|
142
|
|
|
$this->assertContains( |
143
|
|
|
Url::getCommon(['engine' => 'Pbxt']), |
144
|
|
|
$actual |
145
|
|
|
); |
146
|
|
|
$this->assertContains( |
147
|
|
|
$enginePlugin->getSupportInformationMessage(), |
148
|
|
|
$actual |
149
|
|
|
); |
150
|
|
|
$this->assertContains( |
151
|
|
|
'There is no detailed status information available for this ' |
152
|
|
|
. 'storage engine.', |
153
|
|
|
$actual |
154
|
|
|
); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|