2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Selenium TestCase for table related tests
6 * @package PhpMyAdmin-test
10 namespace PhpMyAdmin\Tests\Selenium
;
13 * DbStructureTest class
15 * @package PhpMyAdmin-test
16 * @subpackage Selenium
19 class DbStructureTest
extends TestBase
22 * Setup the browser environment to run the selenium test case
26 public function setUp()
30 "CREATE TABLE `test_table` ("
31 . " `id` int(11) NOT NULL AUTO_INCREMENT,"
32 . " `val` int(11) NOT NULL,"
33 . " PRIMARY KEY (`id`)"
37 "CREATE TABLE `test_table2` ("
38 . " `id` int(11) NOT NULL AUTO_INCREMENT,"
39 . " `val` int(11) NOT NULL,"
40 . " PRIMARY KEY (`id`)"
44 "INSERT INTO `test_table` (val) VALUES (2);"
49 * setUp function that can use the selenium session (called before each test)
53 public function setUpPage()
58 $this->navigateDatabase($this->database_name
);
60 // Let the Database page load
66 * Test for truncating a table
72 public function testTruncateTable()
74 $this->byXPath("(//a[contains(., 'Empty')])[1]")->click();
76 $this->waitForElement(
82 $this->waitForElement(
84 "//div[@class='success' and contains(., "
85 . "'MySQL returned an empty result')]"
89 $result = $this->dbQuery("SELECT count(*) as c FROM test_table");
90 $row = $result->fetch_assoc();
91 $this->assertEquals(0, $row['c']);
95 * Tests for dropping multiple tables
101 public function testDropMultipleTables()
103 $this->byCssSelector("label[for='tablesForm_checkall']")->click();
104 $this->select($this->byName("submit_mult"))
105 ->selectOptionByLabel("Drop");
106 $this->waitForElement("byId", "buttonYes")
109 $this->waitForElement(
111 "//*[contains(., 'No tables found in database')]"
114 $result = $this->dbQuery("SHOW TABLES;");
115 $this->assertEquals(0, $result->num_rows
);