3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Tests\Selenium\Table
;
7 use PhpMyAdmin\Tests\Selenium\TestBase
;
8 use PHPUnit\Framework\Attributes\CoversNothing
;
9 use PHPUnit\Framework\Attributes\Large
;
15 class CreateTest
extends TestBase
17 protected function setUp(): void
22 $this->navigateDatabase($this->databaseName
);
28 public function testCreateTable(): void
33 $this->waitForElement('id', 'createTableMinimalForm');
34 $this->byId('createTableNameInput')->sendKeys('test_table');
35 $numFieldsInput = $this->byId('createTableNumFieldsInput');
36 $numFieldsInput->clear();
37 $numFieldsInput->sendKeys('4');
38 $this->byCssSelector('#createTableMinimalForm input[value=Create]')->click();
41 $this->waitForElement('name', 'do_save_data');
43 $this->waitForElement('id', 'field_1_7')->click(); // null
44 $this->waitForElement('id', 'field_0_9')->click(); // auto increment
47 $columnTextDetails = [
48 'field_0_1' => 'test_id',
50 'field_0_10' => 'comm1',
51 'field_1_1' => 'test_column',
53 'field_1_10' => 'comm2',
56 foreach ($columnTextDetails as $field => $val) {
57 $this->byId($field)->sendKeys($val);
60 $columnDropdownDetails = [
61 'field_0_6' => 'UNSIGNED',
62 'field_1_2' => 'VARCHAR',
63 'field_1_5' => 'utf8mb4_general_ci',
64 'field_1_4' => 'As defined:',
67 foreach ($columnDropdownDetails as $selector => $value) {
68 $this->waitForElement(
70 '//select[@id=\'' . $selector . '\']//option[contains(text(), \'' . $value . '\')]',
74 $this->byName('field_default_value[1]')->sendKeys('def');
76 $this->scrollToBottom();
77 $ele = $this->waitForElement('name', 'do_save_data');
81 $this->waitForElement('cssSelector', 'li.last.nav_node_table');
85 $this->waitForElement('partialLinkText', 'test_table');
87 $this->tableStructureAssertions();
91 * Make assertions for table structure
93 private function tableStructureAssertions(): void
95 $this->navigateTable('test_table', true);
99 // go to structure page
100 $this->waitForElement('partialLinkText', 'Structure')->click();
102 $this->waitForElement('id', 'tablestructure');
103 $this->waitForElement('id', 'table_structure_id');
105 // make assertions for first row
106 self
::assertStringContainsString(
108 $this->byCssSelector('label[for=checkbox_row_1]')->getText(),
113 $this->getCellByTableId('tablestructure', 1, 4),
118 $this->getCellByTableId('tablestructure', 1, 6),
123 $this->getCellByTableId('tablestructure', 1, 7),
128 $this->getCellByTableId('tablestructure', 1, 8),
132 $this->getCellByTableId('tablestructure', 1, 9),
137 $this->getCellByTableId('tablestructure', 1, 10),
140 self
::assertFalse($this->isElementPresent(
142 'table#tablestructure tbody tr:nth-child(1) ul li.primary a',
145 // make assertions for second row
146 self
::assertStringContainsString(
148 $this->byCssSelector('label[for=checkbox_row_2]')->getText(),
153 $this->getCellByTableId('tablestructure', 2, 4),
157 'utf8mb4_general_ci',
158 $this->getCellByTableId('tablestructure', 2, 5),
163 $this->getCellByTableId('tablestructure', 2, 7),
168 $this->getCellByTableId('tablestructure', 2, 8),
171 self
::assertTrue($this->isElementPresent(
173 'table#tablestructure tbody tr:nth-child(2) ul li.primary a',