3 * Holds ProcessesControllerTest
6 declare(strict_types
=1);
8 namespace PhpMyAdmin\Tests\Controllers\Server\Status
;
10 use PhpMyAdmin\Controllers\Server\Status\ProcessesController
;
11 use PhpMyAdmin\Server\Status\Data
;
12 use PhpMyAdmin\Template
;
13 use PhpMyAdmin\Tests\AbstractTestCase
;
14 use PhpMyAdmin\Tests\Stubs\Response
;
16 use function htmlspecialchars
;
18 class ProcessesControllerTest
extends AbstractTestCase
23 protected function setUp(): void
26 $GLOBALS['text_dir'] = 'ltr';
27 parent
::setGlobalConfig();
28 $GLOBALS['PMA_Config']->enableBc();
31 $GLOBALS['server'] = 1;
32 $GLOBALS['db'] = 'db';
33 $GLOBALS['table'] = 'table';
34 $GLOBALS['PMA_PHP_SELF'] = 'index.php';
35 $GLOBALS['cfg']['Server']['DisableIS'] = false;
36 $GLOBALS['cfg']['Server']['host'] = 'localhost';
38 $this->data
= new Data();
41 public function testIndex(): void
43 $response = new Response();
45 $controller = new ProcessesController(
53 $html = $response->getHTMLResult();
55 $this->assertStringContainsString(
56 'Note: Enabling the auto refresh here might cause '
57 . 'heavy traffic between the web server and the MySQL server.',
61 $this->assertStringContainsString(
62 '<div class="tabLinks row">',
65 $this->assertStringContainsString(
66 '<a id="toggleRefresh" href="#">',
69 $this->assertStringContainsString(
73 $this->assertStringContainsString(
77 $this->assertStringContainsString(
78 '<select id="id_refreshRate"',
81 $this->assertStringContainsString(
82 '<option value="5" selected>',
85 $this->assertStringContainsString(
90 $this->assertStringContainsString(
91 '<table id="tableprocesslist" '
92 . 'class="data clearfloat noclick sortable">',
95 $this->assertStringContainsString(
99 $this->assertStringContainsString(
103 $this->assertStringContainsString(
104 'index.php?route=/server/status/processes',
108 $_POST['full'] = '1';
109 $_POST['column_name'] = 'Database';
110 $_POST['order_by_field'] = 'db';
111 $_POST['sort_order'] = 'ASC';
113 $controller->index();
114 $html = $response->getHTMLResult();
116 $this->assertStringContainsString(
117 'Truncate shown queries',
120 $this->assertStringContainsString(
124 $this->assertStringContainsString(
129 $_POST['column_name'] = 'Host';
130 $_POST['order_by_field'] = 'Host';
131 $_POST['sort_order'] = 'DESC';
133 $controller->index();
134 $html = $response->getHTMLResult();
136 $this->assertStringContainsString(
140 $this->assertStringContainsString(
146 public function testRefresh(): void
153 'Command' => 'Command1',
158 $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 12;
160 $response = new Response();
161 $response->setAjax(true);
163 $controller = new ProcessesController(
170 $_POST['full'] = '1';
171 $_POST['order_by_field'] = 'process';
172 $_POST['sort_order'] = 'DESC';
174 $controller->refresh();
175 $html = $response->getHTMLResult();
177 $this->assertStringContainsString(
178 'index.php?route=/server/status/processes',
181 $killProcess = 'data-post="'
182 . Url
::getCommon(['kill' => $process['Id']], '') . '"';
183 $this->assertStringContainsString(
187 $this->assertStringContainsString(
191 $this->assertStringContainsString(
196 //validate 2: $process['User']
197 $this->assertStringContainsString(
198 htmlspecialchars($process['User']),
202 //validate 3: $process['Host']
203 $this->assertStringContainsString(
204 htmlspecialchars($process['Host']),
208 //validate 4: $process['db']
209 $this->assertStringContainsString(
214 //validate 5: $process['Command']
215 $this->assertStringContainsString(
216 htmlspecialchars($process['Command']),
220 //validate 6: $process['Time']
221 $this->assertStringContainsString(
226 //validate 7: $process['state']
227 $this->assertStringContainsString(
232 //validate 8: $process['info']
233 $this->assertStringContainsString(