3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Tests\Selenium
;
7 use PHPUnit\Framework\Attributes\CoversNothing
;
10 class SqlQueryTest
extends TestBase
13 * Setup the browser environment to run the selenium test case
15 protected function setUp(): void
20 'USE `' . $this->databaseName
. '`;'
21 . 'CREATE TABLE `test_table` ('
22 . ' `id` int(11) NOT NULL AUTO_INCREMENT,'
23 . ' `val` int(11) NOT NULL,'
24 . ' PRIMARY KEY (`id`)'
26 . 'INSERT INTO `test_table` (val) VALUES (2), (3), (4), (5);',
32 * Test typing a SQL query on Server SQL page and submitting it
34 public function testServerSqlQuery(): void
36 $this->waitForElement('partialLinkText', 'SQL')->click();
39 $this->typeInTextArea('SET @t1=1, @t2=2, @t3:=4;SELECT 1 as `id`, @t1, @t2, @t3, @t4 := @t1+@t2+@t3;');
40 $this->byId('button_submit_query')->click();
43 $this->waitForElement('cssSelector', 'table.table_results');
46 $this->getCellByTableClass('table_results', 1, 1),
50 $this->getCellByTableClass('table_results', 1, 2),
54 $this->getCellByTableClass('table_results', 1, 3),
58 $this->getCellByTableClass('table_results', 1, 4),
62 $this->getCellByTableClass('table_results', 1, 5),
65 // test inline edit button
66 $this->assertInlineEdit();
70 * Test typing a SQL query on Database SQL page and submitting it
72 public function testDatabaseSqlQuery(): void
74 $this->navigateDatabase($this->databaseName
);
76 $this->waitForElement('partialLinkText', 'SQL')->click();
79 $this->typeInTextArea('SHOW TABLE STATUS');
80 $this->byId('button_submit_query')->click();
83 $this->waitForElement('cssSelector', 'table.table_results');
86 $this->getCellByTableClass('table_results', 1, 1),
90 $this->getCellByTableClass('table_results', 1, 2),
94 $this->getCellByTableClass('table_results', 1, 5),
97 // test inline edit button
98 $this->assertInlineEdit();
102 * Test typing a SQL query on Table SQL page and submitting it
104 public function testTableSqlQuery(): void
106 $this->navigateTable('test_table');
108 $this->waitForElement('partialLinkText', 'SQL')->click();
111 $this->typeInTextArea('SELECT * FROM `test_table` WHERE `val` NOT IN (2, 3);');
112 $this->scrollToBottom();
113 $this->byId('button_submit_query')->click();
116 $this->waitForElement('cssSelector', 'table.table_results');
119 $this->getCellByTableClass('table_results', 1, 5),
123 $this->getCellByTableClass('table_results', 2, 5),
127 $this->getCellByTableClass('table_results', 1, 6),
131 $this->getCellByTableClass('table_results', 2, 6),
134 // test inline edit button
135 $this->assertInlineEdit();
138 private function assertInlineEdit(): void
140 $this->waitForElement('cssSelector', 'a.inline_edit_sql')->click();
141 // empty current query
142 $this->typeInTextArea('', 1);
144 // type in next sql query
145 $this->typeInTextArea('SELECT 1', 1);
147 $this->scrollIntoView('sql_query_edit_save');
148 $this->byId('sql_query_edit_save')->click();
151 $this->waitForElement('cssSelector', 'table.table_results');
154 $this->getCellByTableClass('table_results', 1, 1),