Remove the MaxFileSize HTML generator
[phpmyadmin.git] / test / selenium / SqlQueryTest.php
blob74cffeac9b7a9f5aaec7045416990f10432e9d1c
1 <?php
2 /**
3 * Selenium TestCase for typing and executing SQL query tests
4 */
5 declare(strict_types=1);
7 namespace PhpMyAdmin\Tests\Selenium;
9 /**
10 * SqlQueryTest class
12 * @group selenium
14 class SqlQueryTest extends TestBase
16 /**
17 * Setup the browser environment to run the selenium test case
19 protected function setUp(): void
21 parent::setUp();
23 $this->dbQuery(
24 'CREATE TABLE `test_table` ('
25 . ' `id` int(11) NOT NULL AUTO_INCREMENT,'
26 . ' `val` int(11) NOT NULL,'
27 . ' PRIMARY KEY (`id`)'
28 . ')'
30 $this->dbQuery(
31 'INSERT INTO `test_table` (val) VALUES (2), (3), (4), (5);'
33 $this->login();
36 /**
37 * Test typing a SQL query on Server SQL page and submitting it
39 * @return void
41 public function testServerSqlQuery()
43 $this->waitForElement('partialLinkText', 'SQL')->click();
44 $this->waitAjax();
46 $this->typeInTextArea(
47 'SET @t1=1, @t2=2, @t3:=4;'
48 . 'SELECT 1 as `id`, @t1, @t2, @t3, @t4 := @t1+@t2+@t3;'
50 $this->byId('button_submit_query')->click();
51 $this->waitAjax();
53 $this->waitForElement('cssSelector', 'table.table_results');
54 $this->assertEquals(
56 $this->getCellByTableClass('table_results', 1, 1)
58 $this->assertEquals(
60 $this->getCellByTableClass('table_results', 1, 2)
62 $this->assertEquals(
64 $this->getCellByTableClass('table_results', 1, 3)
66 $this->assertEquals(
68 $this->getCellByTableClass('table_results', 1, 4)
70 $this->assertEquals(
72 $this->getCellByTableClass('table_results', 1, 5)
75 // test inline edit button
76 $this->_testInlineEdit();
79 /**
80 * Test typing a SQL query on Database SQL page and submitting it
82 * @return void
84 public function testDatabaseSqlQuery()
86 $this->navigateDatabase($this->database_name);
88 $this->waitForElement('partialLinkText', 'SQL')->click();
89 $this->waitAjax();
91 $this->typeInTextArea('SHOW TABLE STATUS');
92 $this->byId('button_submit_query')->click();
93 $this->waitAjax();
95 $this->waitForElement('cssSelector', 'table.table_results');
96 $this->assertEquals(
97 'test_table',
98 $this->getCellByTableClass('table_results', 1, 1)
100 $this->assertEquals(
101 'InnoDB',
102 $this->getCellByTableClass('table_results', 1, 2)
104 $this->assertEquals(
106 $this->getCellByTableClass('table_results', 1, 5)
109 // test inline edit button
110 $this->_testInlineEdit();
114 * Test typing a SQL query on Table SQL page and submitting it
116 * @return void
118 public function testTableSqlQuery()
120 $this->navigateTable('test_table');
122 $this->waitForElement('partialLinkText', 'SQL')->click();
123 $this->waitAjax();
125 $this->typeInTextArea('SELECT * FROM `test_table` WHERE `val` NOT IN (2, 3);');
126 $this->scrollToBottom();
127 $this->byId('button_submit_query')->click();
128 $this->waitAjax();
130 $this->waitForElement('cssSelector', 'table.table_results');
131 $this->assertEquals(
133 $this->getCellByTableClass('table_results', 1, 5)
135 $this->assertEquals(
137 $this->getCellByTableClass('table_results', 2, 5)
139 $this->assertEquals(
141 $this->getCellByTableClass('table_results', 1, 6)
143 $this->assertEquals(
145 $this->getCellByTableClass('table_results', 2, 6)
148 // test inline edit button
149 $this->_testInlineEdit();
153 * @return void
155 private function _testInlineEdit()
157 $this->waitForElement('cssSelector', 'a.inline_edit_sql')->click();
158 // empty current query
159 $this->typeInTextArea('', 1);
161 // type in next sql query
162 $this->typeInTextArea('SELECT 1', 1);
164 $this->scrollIntoView('sql_query_edit_save');
165 $this->byId('sql_query_edit_save')->click();
166 $this->waitAjax();
168 $this->waitForElement('cssSelector', 'table.table_results');
169 $this->assertEquals(
171 $this->getCellByTableClass('table_results', 1, 1)