From 1c1fe3d35052e09c7b91ef0bbc0b0770ed704d67 Mon Sep 17 00:00:00 2001 From: ayushchd Date: Sun, 25 Aug 2013 18:48:50 +0530 Subject: [PATCH 1/4] Selenium tests related to table structure --- .../PmaSeleniumTableStructureTest.php | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 test/selenium/PmaSeleniumTableStructureTest.php diff --git a/test/selenium/PmaSeleniumTableStructureTest.php b/test/selenium/PmaSeleniumTableStructureTest.php new file mode 100644 index 0000000000..e8e96db6db --- /dev/null +++ b/test/selenium/PmaSeleniumTableStructureTest.php @@ -0,0 +1,173 @@ +_helper = new Helper($this); + $this->setBrowser($this->_helper->getBrowserString()); + $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); + $this->_helper->dbConnect(); + $this->_dbname = 'pma_db_test'; + $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); + $this->_helper->dbQuery('USE ' . $this->_dbname); + $this->_helper->dbQuery( + "CREATE TABLE `test_table` (" + . " `id` int(11) NOT NULL AUTO_INCREMENT," + . " `val` int(11) NOT NULL," + . " `val2` int(11) NOT NULL," + . " PRIMARY KEY (`id`)" + . ")" + ); + } + + /** + * setUp function that can use the selenium session (called before each test) + * + * @return void + */ + public function setUpPage() + { + $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); + $this->byLinkText($this->_dbname)->click(); + + $this->_helper->waitForElement( + "byXPath", + "(//a[contains(., 'Structure')])[2]" + )->click(); + + $this->_helper->waitForElement("byId", "tablestructure"); + } + + /** + * Test for adding a new column + * + * @return void + */ + public function testAddColumn() + { + $this->byCssSelector("label[for='field_where_after']")->click(); + $this->byCssSelector("input[value='Go']")->click(); + + $this->_helper->waitForElement("byClassName", "append_fields_form"); + + $this->byId("field_0_1")->value('val3'); + $this->byCssSelector("input[name='do_save_data']")->click(); + + $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and contains(., 'Table test_table has been altered successfully')]" + ); + + $this->byLinkText("Structure")->click(); + $this->_helper->waitForElement("byId", "tablestructure"); + + $this->assertEquals( + "val3", + $this->byCssSelector('label[for=checkbox_row_2]')->text() + ); + + $this->assertEquals( + "int(11)", + $this->_helper->getTable("tablestructure.2.4") + ); + } + + /** + * Test for changing a column + * + * @return void + */ + public function testChangeColumn() + { + $this->byXPath("(//a[contains(., 'Change')])[2]")->click(); + + $this->_helper->waitForElement("byClassName", "append_fields_form"); + + $this->assertEquals("val", $this->byId("field_0_1")->value()); + $this->byId("field_0_1")->clear(); + $this->byId("field_0_1")->value('val3'); + $this->byCssSelector("input[name='do_save_data']")->click(); + + $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and contains(., 'Table test_table has been altered successfully')]" + ); + + $this->assertEquals( + "val3", + $this->byCssSelector('label[for=checkbox_row_2]')->text() + ); + } + + /** + * Test for dropping columns + * + * @return void + */ + public function testDropColumns() + { + $this->byCssSelector('label[for=checkbox_row_2]')->click(); + $this->byCssSelector('label[for=checkbox_row_3]')->click(); + $this->byXPath("//button[@class='mult_submit' and contains(., 'Drop')]")->click(); + + $this->_helper->waitForElement( + "byCssSelector", "input[id='buttonYes']" + ) + ->click(); + + $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and contains(., 'Your SQL query has been executed successfully')]" + ); + + $this->assertFalse( + $this->_helper->isElementPresent( + 'byCssSelector', 'label[for=checkbox_row_2]' + ) + ); + } + + /** + * Tear Down function for test cases + * + * @return void + */ + public function tearDown() + { + $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); + } +} From b98f24b7d8397b05d19a7e1964102b3beab124cf Mon Sep 17 00:00:00 2001 From: ayushchd Date: Sun, 25 Aug 2013 19:52:55 +0530 Subject: [PATCH 2/4] Selenium tests for table operations --- .../PmaSeleniumTableOperationsTest.php | 260 ++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 test/selenium/PmaSeleniumTableOperationsTest.php diff --git a/test/selenium/PmaSeleniumTableOperationsTest.php b/test/selenium/PmaSeleniumTableOperationsTest.php new file mode 100644 index 0000000000..c4753a37e5 --- /dev/null +++ b/test/selenium/PmaSeleniumTableOperationsTest.php @@ -0,0 +1,260 @@ +_helper = new Helper($this); + $this->setBrowser($this->_helper->getBrowserString()); + $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); + $this->_helper->dbConnect(); + $this->_dbname = 'pma_db_test'; + $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); + $this->_helper->dbQuery('USE ' . $this->_dbname); + $this->_helper->dbQuery( + "CREATE TABLE `test_table` (" + . " `id` int(11) NOT NULL AUTO_INCREMENT," + . " `val` int(11) NOT NULL," + . " `val2` int(11) NOT NULL," + . " PRIMARY KEY (`id`)" + . ")" + ); + $this->_helper->dbQuery("INSERT INTO test_table (val) VALUES (22)"); + $this->_helper->dbQuery("INSERT INTO test_table (val) VALUES (33)"); + } + + /** + * setUp function that can use the selenium session (called before each test) + * + * @return void + */ + public function setUpPage() + { + $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); + $this->byLinkText($this->_dbname)->click(); + + $this->_helper->waitForElement( + "byXPath", + "//a[contains(., 'test_table')]" + )->click(); + + $this->_helper->waitForElement("byId", "table_results"); + $more = $this->_helper->waitForElement("byLinkText", "More"); + $this->moveto($more); + $this->byXPath("//a[contains(., 'Operations')]")->click(); + $this->_helper->waitForElement( + "byXPath", + "//legend[contains(., 'Alter table order by')]" + ); + } + + /** + * Test for changing a table order + * + * @return void + */ + public function testChangeTableOrder() + { + $this->select($this->byName("order_field")) + ->selectOptionByLabel("val"); + + $this->byId("order_order_desc")->click(); + $this->byXPath("(//input[@value='Go'])[1]")->click(); + + $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and " + . "contains(., 'Your SQL query has been executed successfully')]" + ); + + $this->byLinkText("Browse")->click(); + $this->_helper->waitForElement("byId", "table_results"); + + $this->assertEquals( + "2", + $this->_helper->getTable("table_results.1.5") + ); + } + + /** + * Test for moving a table + * + * @return void + */ + public function testMoveTable() + { + $this->byCssSelector("form#moveTableForm input[name='new_name']")->value("2"); + + $this->byXPath("(//input[@value='Go'])[2]")->click(); + + $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and " + . "contains(., 'Table `" . $this->_dbname . "`.`test_table` has been " + . "moved to `" . $this->_dbname . "`.`test_table2`.')]" + ); + + $result = $this->_helper->dbQuery("SHOW TABLES"); + $row = $result->fetch_assoc(); + $this->assertEquals( + "test_table2", + $row["Tables_in_" . $this->_dbname] + ); + } + + /** + * Test for renaming a table + * + * @return void + */ + public function testRenameTable() + { + $this->byCssSelector("form#tableOptionsForm input[name='new_name']") + ->value("2"); + + $this->byName("comment")->value("foobar"); + + $this->byXPath("(//input[@value='Go'])[3]")->click(); + + $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and " + . "contains(., 'Table test_table has been renamed to test_table2')]" + ); + + $this->assertNotNull( + $this->_helper->waitForElement( + "byXPath", + "//span[@id='span_table_comment' and contains(., 'foobar')]" + ) + ); + + $result = $this->_helper->dbQuery("SHOW TABLES"); + $row = $result->fetch_assoc(); + $this->assertEquals( + "test_table2", + $row["Tables_in_" . $this->_dbname] + ); + } + + /** + * Test for copying a table + * + * @return void + */ + public function testCopyTable() + { + $this->byCssSelector("form#copyTable input[name='new_name']")->value("2"); + $this->byCssSelector("label[for='what_data']")->click(); + $this->byXPath("(//input[@value='Go'])[4]")->click(); + + $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and " + . "contains(., 'Table `" . $this->_dbname . "`.`test_table` has been " + . "copied to `" . $this->_dbname . "`.`test_table2`.')]" + ); + + $result = $this->_helper->dbQuery("SELECT COUNT(*) as c FROM test_table2"); + $row = $result->fetch_assoc(); + $this->assertEquals( + 2, + $row["c"] + ); + } + + /** + * Test for truncating a table + * + * @return void + */ + public function testTruncateTable() + { + $this->byId("truncate_tbl_anchor")->click(); + $this->byXPath("//button[contains(., 'OK')]")->click(); + + $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and " + . "contains(., 'MySQL returned an empty result set')]" + ); + + $result = $this->_helper->dbQuery("SELECT COUNT(*) as c FROM test_table"); + $row = $result->fetch_assoc(); + $this->assertEquals( + 0, + $row["c"] + ); + } + + /** + * Test for dropping a table + * + * @return void + */ + public function testDropTable() + { + $this->byId("drop_tbl_anchor")->click(); + $this->byXPath("//button[contains(., 'OK')]")->click(); + + $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and " + . "contains(., 'MySQL returned an empty result set')]" + ); + + $this->_helper->waitForElement( + "byXPath", + "//a[@class='tabactive' and contains(., 'Structure')]" + ); + + $result = $this->_helper->dbQuery("SHOW TABLES"); + $this->assertEquals( + 0, + $result->num_rows + ); + } + + /** + * Tear Down function for test cases + * + * @return void + */ + public function tearDown() + { + $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); + } +} From 004d5d51b6cd772db2fb6510bb416dfc8197ab76 Mon Sep 17 00:00:00 2001 From: ayushchd Date: Sun, 25 Aug 2013 20:01:29 +0530 Subject: [PATCH 3/4] More sensible file names --- test/selenium/PmaSeleniumDbProceduresTest.php | 230 ++++++++++++ test/selenium/PmaSeleniumTableBrowseTest.php | 353 ++++++++++++++++++ test/selenium/PmaSeleniumTableCreateTest.php | 195 ++++++++++ test/selenium/PmaSeleniumTableInsertTest.php | 169 +++++++++ 4 files changed, 947 insertions(+) create mode 100644 test/selenium/PmaSeleniumDbProceduresTest.php create mode 100644 test/selenium/PmaSeleniumTableBrowseTest.php create mode 100644 test/selenium/PmaSeleniumTableCreateTest.php create mode 100644 test/selenium/PmaSeleniumTableInsertTest.php diff --git a/test/selenium/PmaSeleniumDbProceduresTest.php b/test/selenium/PmaSeleniumDbProceduresTest.php new file mode 100644 index 0000000000..a7169584c5 --- /dev/null +++ b/test/selenium/PmaSeleniumDbProceduresTest.php @@ -0,0 +1,230 @@ +_helper = new Helper($this); + $this->setBrowser($this->_helper->getBrowserString()); + $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); + $this->_helper->dbConnect(); + $this->_dbname = 'pma_db_test'; + $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); + $this->_helper->dbQuery('USE ' . $this->_dbname); + $this->_helper->dbQuery( + "CREATE TABLE `test_table` (" + . " `id` int(11) NOT NULL AUTO_INCREMENT," + . " `name` varchar(20) NOT NULL," + . " `datetimefield` datetime NOT NULL," + . " PRIMARY KEY (`id`)" + . ")" + ); + + } + + /** + * setUp function that can use the selenium session (called before each test) + * + * @return void + */ + public function setUpPage() + { + $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); + $this->byLinkText($this->_dbname)->click(); + } + + /** + * Creates procedure for tests + * + * @return void + */ + private function _procedureSQL() + { + $this->_helper->dbQuery( + "CREATE PROCEDURE `test_procedure`(IN `inp` VARCHAR(10), OUT `outp` INT)" + . " NOT DETERMINISTIC READS SQL DATA SQL SECURITY DEFINER SELECT char_" + . "length(inp) + count(*) FROM test_table INTO outp" + ); + } + + /** + * Create a procedure + * + * @return void + */ + public function testAddProcedure() + { + $more = $this->_helper->waitForElement("byLinkText", "More"); + $this->moveto($more); + $ele = $this->_helper->waitForElement("byPartialLinkText", "Routines"); + $ele->click(); + + $ele = $this->_helper->waitForElement("byLinkText", "Add routine"); + $ele->click(); + + $this->_helper->waitForElement("byClassName", "rte_form"); + + $this->byName("item_name")->value("test_procedure"); + + $this->byName("item_param_name[0]")->value("inp"); + $this->select( + $this->byName("item_param_type[0]") + )->selectOptionByLabel("VARCHAR"); + $this->byName("item_param_length[0]")->value("10"); + + $this->byCssSelector("input[value='Add parameter']")->click(); + + $this->select( + $this->byName("item_param_dir[1]") + )->selectOptionByLabel("OUT"); + $ele = $this->_helper->waitForElement("byName", "item_param_name[1]"); + $ele->value("outp"); + + $proc = "SELECT char_length(inp) + count(*) FROM test_table INTO outp"; + $this->_helper->typeInTextArea($proc); + + $this->select( + $this->byName("item_sqldataaccess") + )->selectOptionByLabel("READS SQL DATA"); + + $this->byXPath("//button[contains(., 'Go')]")->click(); + + $ele = $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and contains(., 'Routine `test_procedure` has been created')]" + ); + + $result = $this->_helper->dbQuery( + "SHOW PROCEDURE STATUS WHERE Db='" . $this->_dbname . "'" + ); + + $this->assertEquals(1, $result->num_rows); + $this->_executeProcedure("abcabcabcabcabcabcabc", 10); + } + + /** + * Test for editing procedure + * + * @return void + */ + public function testEditProcedure() + { + $this->_procedureSQL(); + $more = $this->_helper->waitForElement("byLinkText", "More"); + $this->moveto($more); + $ele = $this->_helper->waitForElement("byPartialLinkText", "Routines"); + $ele->click(); + + $this->_helper->waitForElement( + "byXPath", + "//legend[contains(., 'Routines')]" + ); + + $this->byLinkText("Edit")->click(); + $this->_helper->waitForElement("byClassName", "rte_form"); + $this->byName("item_param_length[0]")->clear(); + $this->byName("item_param_length[0]")->value("12"); + + $this->byXPath("//button[contains(., 'Go')]")->click(); + + $ele = $this->_helper->waitForElement( + "byXPath", + "//div[@class='success' and contains(., 'Routine `test_procedure` has been modified')]" + ); + + $this->_executeProcedure("abcabcabcabcabcabcabc", 12); + } + + /** + * Test for dropping procedure + * + * @return void + */ + public function testDropProcedure() + { + $this->_procedureSQL(); + $more = $this->_helper->waitForElement("byLinkText", "More"); + $this->moveto($more); + $ele = $this->_helper->waitForElement("byPartialLinkText", "Routines"); + $ele->click(); + + $this->_helper->waitForElement( + "byXPath", + "//legend[contains(., 'Routines')]" + ); + + $this->byLinkText("Drop")->click(); + $this->_helper->waitForElement( + "byXPath", "//button[contains(., 'OK')]" + )->click(); + + $this->_helper->waitForElement("byId", "nothing2display"); + + usleep(1000000); + $result = $this->_helper->dbQuery( + "SHOW PROCEDURE STATUS WHERE Db='" . $this->_dbname . "'" + ); + $this->assertEquals(0, $result->num_rows); + } + + /** + * Execute procedure + * + * @return void + */ + private function _executeProcedure($text, $length) + { + $this->_helper->waitForElement("byLinkText", "Execute")->click(); + $this->_helper->waitForElement("byName", "params[inp]")->value($text); + $this->byCssSelector("div.ui-dialog-buttonset button:nth-child(1)")->click(); + $this->_helper->waitForElement( + "byCssSelector", + "span#PMA_slidingMessage table tbody" + ); + $head = $this->byCssSelector("span#PMA_slidingMessage table tbody")->text(); + $this->assertEquals("outp\n$length", $head); + } + + /** + * Tear Down function for test cases + * + * @return void + */ + public function tearDown() + { + $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); + } +} diff --git a/test/selenium/PmaSeleniumTableBrowseTest.php b/test/selenium/PmaSeleniumTableBrowseTest.php new file mode 100644 index 0000000000..fb89ee2504 --- /dev/null +++ b/test/selenium/PmaSeleniumTableBrowseTest.php @@ -0,0 +1,353 @@ +_helper = new Helper($this); + $this->setBrowser($this->_helper->getBrowserString()); + $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); + $this->_helper->dbConnect(); + $this->_dbname = 'pma_db_' . time(); + $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); + $this->_helper->dbQuery('USE ' . $this->_dbname); + $this->_helper->dbQuery( + "CREATE TABLE `test_table` (" + . " `id` int(11) NOT NULL AUTO_INCREMENT," + . " `name` varchar(20) NOT NULL," + . " `datetimefield` datetime NOT NULL," + . " PRIMARY KEY (`id`)" + . ")" + ); + $this->_helper->dbQuery( + "INSERT INTO `test_table` (`id`, `name`, `datetimefield`) VALUES" + . " (1, 'abcd', '2011-01-20 02:00:02')," + . " (2, 'foo', '2010-01-20 02:00:02')," + . " (3, 'Abcd', '2012-01-20 02:00:02')" + ); + } + + /** + * setUp function that can use the selenium session (called before each test) + * + * @return void + */ + public function setUpPage() + { + $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); + $this->byLinkText($this->_dbname)->click(); + $this->_helper->waitForElement("byLinkText", "test_table"); + $this->byLinkText("Browse")->click(); + $this->_helper->waitForElement("byId", "table_results"); + } + + /** + * Test sorting of records in browse table + * + * @return void + */ + public function testSortRecords() + { + // case 1 + $this->byLinkText("name")->click(); + $this->_helper->waitForElementNotPresent("byId", "loading_parent"); + usleep(100); + + $this->assertEquals( + "1", + $this->_helper->getTable("table_results.1.5") + ); + + $this->assertEquals( + "3", + $this->_helper->getTable("table_results.2.5") + ); + + $this->assertEquals( + "2", + $this->_helper->getTable("table_results.3.5") + ); + + // case 2 + $this->byLinkText("name")->click(); + $this->_helper->waitForElementNotPresent("byId", "loading_parent"); + usleep(100); + + $this->assertEquals( + "2", + $this->_helper->getTable("table_results.1.5") + ); + + $this->assertEquals( + "1", + $this->_helper->getTable("table_results.2.5") + ); + + $this->assertEquals( + "3", + $this->_helper->getTable("table_results.3.5") + ); + + // case 2 + $this->byLinkText("datetimefield")->click(); + $this->_helper->waitForElementNotPresent("byId", "loading_parent"); + usleep(100); + + $this->assertEquals( + "3", + $this->_helper->getTable("table_results.1.5") + ); + + $this->assertEquals( + "1", + $this->_helper->getTable("table_results.2.5") + ); + + $this->assertEquals( + "2", + $this->_helper->getTable("table_results.3.5") + ); + + // case 4 + $this->byLinkText("datetimefield")->click(); + $this->_helper->waitForElementNotPresent("byId", "loading_parent"); + usleep(100); + + $this->assertEquals( + "2", + $this->_helper->getTable("table_results.1.5") + ); + + $this->assertEquals( + "1", + $this->_helper->getTable("table_results.2.5") + ); + + $this->assertEquals( + "3", + $this->_helper->getTable("table_results.3.5") + ); + } + + /** + * Test Edit Record + * + * @return void + */ + public function testChangeRecords() + { + $this->byCssSelector( + "table#table_results tbody tr:nth-child(2) td:nth-child(2) a" + )->click(); + $this->_helper->waitForElement("byId", "insertForm"); + + $this->assertEquals( + "2", + $this->byId("field_1_3")->value() + ); + + $this->assertEquals( + "foo", + $this->byId("field_2_3")->value() + ); + + $this->assertEquals( + "2010-01-20 02:00:02", + $this->byId("field_3_3")->value() + ); + + $this->byId("field_2_3")->clear(); + $this->byId("field_2_3")->value("foobar"); + $this->byId("field_3_3")->clear(); + $this->byId("field_3_3")->value("2009-01-20 02:00:02"); + + $this->byId("buttonYes")->click(); + + $success = $this->_helper->waitForElement("byClassName", "success"); + $this->assertContains("1 row affected", $success->text()); + + $this->assertEquals( + "foobar", + $this->_helper->getTable("table_results.2.6") + ); + + $this->assertEquals( + "2009-01-20 02:00:02", + $this->_helper->getTable("table_results.2.7") + ); + } + + /** + * Test edit record by double click + * + * @return void + */ + public function testChangeRecordsByDoubleClick() + { + $element = $this->byCssSelector( + "table#table_results tbody tr:nth-child(1) td:nth-child(6)" + ); + + $this->moveto($element); + $this->doubleclick(); + + $this->assertEquals( + $this->byCssSelector("textarea.edit_box")->value(), + "abcd" + ); + + $this->byCssSelector("textarea.edit_box")->clear(); + $this->byCssSelector("textarea.edit_box")->value("abcde"); + $this->keys(PHPUnit_Extensions_Selenium2TestCase_Keys::RETURN_); + + $success = $this->_helper->waitForElement( + "byCssSelector", "span.ajax_notification div.success" + ); + $this->assertContains("1 row affected", $success->text()); + + $this->assertEquals( + "abcde", + $this->_helper->getTable("table_results.1.6") + ); + } + + /** + * Test copy and insert record + * + * @return void + */ + public function testCopyRecords() + { + $this->byCssSelector( + "table#table_results tbody tr:nth-child(3) td:nth-child(3) a" + )->click(); + + $this->_helper->waitForElement("byId", "insertForm"); + + $this->assertEquals( + "Abcd", + $this->byId("field_2_3")->value() + ); + + $this->assertEquals( + "2012-01-20 02:00:02", + $this->byId("field_3_3")->value() + ); + + $this->byId("field_2_3")->clear(); + $this->byId("field_2_3")->value("ABCDEFG"); + $this->byId("field_3_3")->clear(); + $this->byId("field_3_3")->value("2012-01-20 02:05:02"); + + $this->byId("buttonYes")->click(); + $success = $this->_helper->waitForElement("byClassName", "success"); + $this->assertContains("1 row inserted", $success->text()); + + $this->assertEquals( + "ABCDEFG", + $this->_helper->getTable("table_results.4.6") + ); + + $this->assertEquals( + "2012-01-20 02:05:02", + $this->_helper->getTable("table_results.4.7") + ); + } + + /** + * Test search table + * + * @return void + */ + public function testSearchRecords() + { + $this->byLinkText("Search")->click(); + $this->_helper->waitForElement("byId", "tbl_search_form"); + + $this->byId("fieldID_1")->value("abcd"); + $select = $this->select($this->byName("criteriaColumnOperators[1]")); + $select->selectOptionByLabel("LIKE %...%"); + + $this->byName("submit")->click(); + $success = $this->_helper->waitForElement("byClassName", "success"); + $this->assertContains("Showing rows", $success->text()); + + $this->assertEquals( + "1", + $this->_helper->getTable("table_results.1.5") + ); + + $this->assertEquals( + "3", + $this->_helper->getTable("table_results.2.5") + ); + } + + /** + * Test delete multiple records + * + * @return void + */ + public function testDeleteRecords() + { + $this->byId("id_rows_to_delete1_left")->click(); + $this->byId("id_rows_to_delete2_left")->click(); + + $this->byCssSelector("button[value=delete]")->click(); + $this->_helper->waitForElement("byCssSelector", "fieldset.confirmation"); + + $this->byId("buttonYes")->click(); + $success = $this->_helper->waitForElement("byClassName", "success"); + $this->assertContains("Showing rows", $success->text()); + + $this->assertFalse( + $this->_helper->isElementPresent( + "byCssSelector", "table#table_results tbody tr:nth-child(2)" + ) + ); + + } + + /** + * Teardown for test cases (drops database) + * + * @return void + */ + public function tearDown() + { + $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); + } +} diff --git a/test/selenium/PmaSeleniumTableCreateTest.php b/test/selenium/PmaSeleniumTableCreateTest.php new file mode 100644 index 0000000000..d63f487478 --- /dev/null +++ b/test/selenium/PmaSeleniumTableCreateTest.php @@ -0,0 +1,195 @@ +_helper = new Helper($this); + $this->setBrowser($this->_helper->getBrowserString()); + $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); + $this->_helper->dbConnect(); + $this->_dbname = 'pma_db_' . time(); + $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); + } + + /** + * Creates a table + * + * @return void + */ + public function testCreateTable() + { + $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); + $this->byLinkText($this->_dbname)->click(); + + $this->_helper->waitForElement('byId', 'create_table_form_minimal'); + $this->byCssSelector( + "form#create_table_form_minimal input[name=table]" + )->value("test_table"); + $this->byName("num_fields")->value("4"); + $this->byCssSelector('input[value=Go]')->click(); + $this->_helper->waitForElement('byName', 'do_save_data'); + + // column details + $column_text_details = array( + "field_0_1" => "test_id", + "field_0_3" => "14", + "field_0_10" => "comm1", + "field_1_1" => "test_column", + "field_1_3" => "10", + "field_1_10" => "comm2", + ); + + foreach ($column_text_details as $field => $val) { + $this->byId($field)->value($val); + } + + $column_dropdown_details = array( + "field_0_6" => "UNSIGNED", + "field_0_8" => "PRIMARY", + "field_1_2" => "VARCHAR", + "field_1_5" => "utf8_general_ci", + "field_1_4" => "As defined:" + ); + + foreach ($column_dropdown_details as $selector => $value) { + $sel = $this->select($this->byId($selector)); + $sel->selectOptionByLabel($value); + } + + $this->byName("field_default_value[1]")->value("def"); + $this->byId("field_0_9")->click(); // auto increment + $this->byId("field_1_7")->click(); // null + + // post + $this->byName("do_save_data")->click(); + $this->_helper->waitForElement("byLinkText", "test_table"); + + $this->_tableStructureAssertions(); + } + + /** + * Make assertions for table structure + * + * @return void + */ + private function _tableStructureAssertions() + { + // go to structure page + $this->byLinkText("Structure")->click(); + $this->_helper->waitForElement("byId", "tablestructure"); + + // make assertions for first row + $this->assertContains( + "test_id", + $this->byCssSelector('label[for=checkbox_row_1]')->text() + ); + + $this->assertEquals( + "int(14)", + $this->_helper->getTable("tablestructure.1.4") + ); + + $this->assertEquals( + "UNSIGNED", + $this->_helper->getTable("tablestructure.1.6") + ); + + $this->assertEquals( + "No", + $this->_helper->getTable("tablestructure.1.7") + ); + + $this->assertEquals( + "None", + $this->_helper->getTable("tablestructure.1.8") + ); + + $this->assertEquals( + "AUTO_INCREMENT", + $this->_helper->getTable("tablestructure.1.9") + ); + + $this->assertFalse( + $this->_helper->isElementPresent( + 'byCssSelector', + 'table#tablestructure tbody tr:nth-child(1) ul.table-structure-actions li.primary a' + ) + ); + + // make assertions for second row + $this->assertContains( + "test_column", + $this->byCssSelector('label[for=checkbox_row_2]')->text() + ); + + $this->assertEquals( + "varchar(10)", + $this->_helper->getTable("tablestructure.2.4") + ); + + $this->assertEquals( + "utf8_general_ci", + $this->_helper->getTable("tablestructure.2.5") + ); + + $this->assertEquals( + "Yes", + $this->_helper->getTable("tablestructure.2.7") + ); + + $this->assertEquals( + "def", + $this->_helper->getTable("tablestructure.2.8") + ); + + $this->assertFalse( + $this->_helper->isElementPresent( + 'byCssSelector', 'css=ul.table-structure-actions:nth-child(2) li.primary a' + ) + ); + } + + /** + * Tear down functions for test cases + * + * @return void + */ + public function tearDown() + { + $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); + } +} diff --git a/test/selenium/PmaSeleniumTableInsertTest.php b/test/selenium/PmaSeleniumTableInsertTest.php new file mode 100644 index 0000000000..8d3cfd61ea --- /dev/null +++ b/test/selenium/PmaSeleniumTableInsertTest.php @@ -0,0 +1,169 @@ +_helper = new Helper($this); + $this->setBrowser($this->_helper->getBrowserString()); + $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); + $this->_helper->dbConnect(); + $this->_dbname = 'pma_db_' . time(); + $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); + $this->_helper->dbQuery('USE ' . $this->_dbname); + $this->_helper->dbQuery( + "CREATE TABLE `test_table` (" + . " `id` int(11) NOT NULL AUTO_INCREMENT," + . " `name` varchar(20) NOT NULL," + . " `datetimefield` datetime NOT NULL," + . " PRIMARY KEY (`id`)" + . ")" + ); + + } + + /** + * setUp function that can use the selenium session (called before each test) + * + * @return void + */ + public function setUpPage() + { + $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); + $this->byLinkText($this->_dbname)->click(); + $this->_helper->waitForElement("byLinkText", "test_table"); + } + + /** + * Insert data into table + * + * @return void + */ + public function testAddData() + { + $this->byLinkText("Insert")->click(); + $this->_helper->waitForElement("byId", "insertForm"); + + $this->byId("field_1_3")->value("1"); + $this->byId("field_2_3")->value("abcd"); + $this->byId("field_3_3")->value("2011-01-20 02:00:02"); + $this->byId("field_5_3")->value("foo"); + $this->byId("field_6_3")->value("2010-01-20 02:00:02"); + + $select = $this->select($this->byName("after_insert")); + $select->selectOptionByLabel("Insert another new row"); + + // post + $this->byId("buttonYes")->click(); + $ele = $this->_helper->waitForElement("byClassName", "success"); + $this->assertContains("2 rows inserted", $ele->text()); + + $this->byId("field_2_3")->value("Abcd"); + $this->byId("field_3_3")->value("2012-01-20 02:00:02"); + + // post + $this->byCssSelector( + "input[value=Go]" + )->click(); + + $this->_helper->waitForElementNotPresent("byId", "loading_parent"); + $ele = $this->_helper->waitForElement("byClassName", "success"); + $this->assertContains("1 row inserted", $ele->text()); + $this->_assertDataPresent(); + } + + private function _assertDataPresent() + { + $this->byLinkText("Browse")->click(); + $this->_helper->waitForElement("byId", "table_results"); + + $this->assertEquals( + "1", + $this->_helper->getTable("table_results.1.5") + ); + + $this->assertEquals( + "abcd", + $this->_helper->getTable("table_results.1.6") + ); + + $this->assertEquals( + "2011-01-20 02:00:02", + $this->_helper->getTable("table_results.1.7") + ); + + $this->assertEquals( + "2", + $this->_helper->getTable("table_results.2.5") + ); + + $this->assertEquals( + "foo", + $this->_helper->getTable("table_results.2.6") + ); + + $this->assertEquals( + "2010-01-20 02:00:02", + $this->_helper->getTable("table_results.2.7") + ); + + $this->assertEquals( + "3", + $this->_helper->getTable("table_results.3.5") + ); + + $this->assertEquals( + "Abcd", + $this->_helper->getTable("table_results.3.6") + ); + + $this->assertEquals( + "2012-01-20 02:00:02", + $this->_helper->getTable("table_results.3.7") + ); + } + + /** + * Tear Down function for test cases + * + * @return void + */ + public function tearDown() + { + $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); + } +} From 0d94929ae110ee0c42bf4ac241890ca0b82b0931 Mon Sep 17 00:00:00 2001 From: ayushchd Date: Mon, 26 Aug 2013 02:18:05 +0530 Subject: [PATCH 4/4] Remove old test files --- .../PmaSeleniumDbStoredProceduresTest.php | 230 ------------ .../PmaSeleniumTablesBrowseDataTest.php | 353 ------------------ .../PmaSeleniumTablesInsertDataTest.php | 168 --------- test/selenium/PmaSeleniumTablesTest.php | 195 ---------- 4 files changed, 946 deletions(-) delete mode 100644 test/selenium/PmaSeleniumDbStoredProceduresTest.php delete mode 100644 test/selenium/PmaSeleniumTablesBrowseDataTest.php delete mode 100644 test/selenium/PmaSeleniumTablesInsertDataTest.php delete mode 100644 test/selenium/PmaSeleniumTablesTest.php diff --git a/test/selenium/PmaSeleniumDbStoredProceduresTest.php b/test/selenium/PmaSeleniumDbStoredProceduresTest.php deleted file mode 100644 index 13363222a7..0000000000 --- a/test/selenium/PmaSeleniumDbStoredProceduresTest.php +++ /dev/null @@ -1,230 +0,0 @@ -_helper = new Helper($this); - $this->setBrowser($this->_helper->getBrowserString()); - $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); - $this->_helper->dbConnect(); - $this->_dbname = 'pma_db_test'; - $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); - $this->_helper->dbQuery('USE ' . $this->_dbname); - $this->_helper->dbQuery( - "CREATE TABLE `test_table` (" - . " `id` int(11) NOT NULL AUTO_INCREMENT," - . " `name` varchar(20) NOT NULL," - . " `datetimefield` datetime NOT NULL," - . " PRIMARY KEY (`id`)" - . ")" - ); - - } - - /** - * setUp function that can use the selenium session (called before each test) - * - * @return void - */ - public function setUpPage() - { - $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); - $this->byLinkText($this->_dbname)->click(); - } - - /** - * Creates procedure for tests - * - * @return void - */ - private function _procedureSQL() - { - $this->_helper->dbQuery( - "CREATE PROCEDURE `test_procedure`(IN `inp` VARCHAR(10), OUT `outp` INT)" - . " NOT DETERMINISTIC READS SQL DATA SQL SECURITY DEFINER SELECT char_" - . "length(inp) + count(*) FROM test_table INTO outp" - ); - } - - /** - * Create a procedure - * - * @return void - */ - public function testAddProcedure() - { - $more = $this->_helper->waitForElement("byLinkText", "More"); - $this->moveto($more); - $ele = $this->_helper->waitForElement("byPartialLinkText", "Routines"); - $ele->click(); - - $ele = $this->_helper->waitForElement("byLinkText", "Add routine"); - $ele->click(); - - $this->_helper->waitForElement("byClassName", "rte_form"); - - $this->byName("item_name")->value("test_procedure"); - - $this->byName("item_param_name[0]")->value("inp"); - $this->select( - $this->byName("item_param_type[0]") - )->selectOptionByLabel("VARCHAR"); - $this->byName("item_param_length[0]")->value("10"); - - $this->byCssSelector("input[value='Add parameter']")->click(); - - $this->select( - $this->byName("item_param_dir[1]") - )->selectOptionByLabel("OUT"); - $ele = $this->_helper->waitForElement("byName", "item_param_name[1]"); - $ele->value("outp"); - - $proc = "SELECT char_length(inp) + count(*) FROM test_table INTO outp"; - $this->_helper->typeInTextArea($proc); - - $this->select( - $this->byName("item_sqldataaccess") - )->selectOptionByLabel("READS SQL DATA"); - - $this->byXPath("//button[contains(., 'Go')]")->click(); - - $ele = $this->_helper->waitForElement( - "byXPath", - "//div[@class='success' and contains(., 'Routine `test_procedure` has been created')]" - ); - - $result = $this->_helper->dbQuery( - "SHOW PROCEDURE STATUS WHERE Db='" . $this->_dbname . "'" - ); - - $this->assertEquals(1, $result->num_rows); - $this->_executeProcedure("abcabcabcabcabcabcabc", 10); - } - - /** - * Test for editing procedure - * - * @return void - */ - public function testEditProcedure() - { - $this->_procedureSQL(); - $more = $this->_helper->waitForElement("byLinkText", "More"); - $this->moveto($more); - $ele = $this->_helper->waitForElement("byPartialLinkText", "Routines"); - $ele->click(); - - $this->_helper->waitForElement( - "byXPath", - "//legend[contains(., 'Routines')]" - ); - - $this->byLinkText("Edit")->click(); - $this->_helper->waitForElement("byClassName", "rte_form"); - $this->byName("item_param_length[0]")->clear(); - $this->byName("item_param_length[0]")->value("12"); - - $this->byXPath("//button[contains(., 'Go')]")->click(); - - $ele = $this->_helper->waitForElement( - "byXPath", - "//div[@class='success' and contains(., 'Routine `test_procedure` has been modified')]" - ); - - $this->_executeProcedure("abcabcabcabcabcabcabc", 12); - } - - /** - * Test for dropping procedure - * - * @return void - */ - public function testDropProcedure() - { - $this->_procedureSQL(); - $more = $this->_helper->waitForElement("byLinkText", "More"); - $this->moveto($more); - $ele = $this->_helper->waitForElement("byPartialLinkText", "Routines"); - $ele->click(); - - $this->_helper->waitForElement( - "byXPath", - "//legend[contains(., 'Routines')]" - ); - - $this->byLinkText("Drop")->click(); - $this->_helper->waitForElement( - "byXPath", "//button[contains(., 'OK')]" - )->click(); - - $this->_helper->waitForElement("byId", "nothing2display"); - - usleep(1000000); - $result = $this->_helper->dbQuery( - "SHOW PROCEDURE STATUS WHERE Db='" . $this->_dbname . "'" - ); - $this->assertEquals(0, $result->num_rows); - } - - /** - * Execute procedure - * - * @return void - */ - private function _executeProcedure($text, $length) - { - $this->_helper->waitForElement("byLinkText", "Execute")->click(); - $this->_helper->waitForElement("byName", "params[inp]")->value($text); - $this->byCssSelector("div.ui-dialog-buttonset button:nth-child(1)")->click(); - $this->_helper->waitForElement( - "byCssSelector", - "span#PMA_slidingMessage table tbody" - ); - $head = $this->byCssSelector("span#PMA_slidingMessage table tbody")->text(); - $this->assertEquals("outp\n$length", $head); - } - - /** - * Tear Down function for test cases - * - * @return void - */ - public function tearDown() - { - $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); - } -} diff --git a/test/selenium/PmaSeleniumTablesBrowseDataTest.php b/test/selenium/PmaSeleniumTablesBrowseDataTest.php deleted file mode 100644 index ad6c366580..0000000000 --- a/test/selenium/PmaSeleniumTablesBrowseDataTest.php +++ /dev/null @@ -1,353 +0,0 @@ -_helper = new Helper($this); - $this->setBrowser($this->_helper->getBrowserString()); - $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); - $this->_helper->dbConnect(); - $this->_dbname = 'pma_db_' . time(); - $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); - $this->_helper->dbQuery('USE ' . $this->_dbname); - $this->_helper->dbQuery( - "CREATE TABLE `test_table` (" - . " `id` int(11) NOT NULL AUTO_INCREMENT," - . " `name` varchar(20) NOT NULL," - . " `datetimefield` datetime NOT NULL," - . " PRIMARY KEY (`id`)" - . ")" - ); - $this->_helper->dbQuery( - "INSERT INTO `test_table` (`id`, `name`, `datetimefield`) VALUES" - . " (1, 'abcd', '2011-01-20 02:00:02')," - . " (2, 'foo', '2010-01-20 02:00:02')," - . " (3, 'Abcd', '2012-01-20 02:00:02')" - ); - } - - /** - * setUp function that can use the selenium session (called before each test) - * - * @return void - */ - public function setUpPage() - { - $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); - $this->byLinkText($this->_dbname)->click(); - $this->_helper->waitForElement("byLinkText", "test_table"); - $this->byLinkText("Browse")->click(); - $this->_helper->waitForElement("byId", "table_results"); - } - - /** - * Test sorting of records in browse table - * - * @return void - */ - public function testSortRecords() - { - // case 1 - $this->byLinkText("name")->click(); - $this->_helper->waitForElementNotPresent("byId", "loading_parent"); - usleep(100); - - $this->assertEquals( - "1", - $this->_helper->getTable("table_results.1.5") - ); - - $this->assertEquals( - "3", - $this->_helper->getTable("table_results.2.5") - ); - - $this->assertEquals( - "2", - $this->_helper->getTable("table_results.3.5") - ); - - // case 2 - $this->byLinkText("name")->click(); - $this->_helper->waitForElementNotPresent("byId", "loading_parent"); - usleep(100); - - $this->assertEquals( - "2", - $this->_helper->getTable("table_results.1.5") - ); - - $this->assertEquals( - "1", - $this->_helper->getTable("table_results.2.5") - ); - - $this->assertEquals( - "3", - $this->_helper->getTable("table_results.3.5") - ); - - // case 2 - $this->byLinkText("datetimefield")->click(); - $this->_helper->waitForElementNotPresent("byId", "loading_parent"); - usleep(100); - - $this->assertEquals( - "3", - $this->_helper->getTable("table_results.1.5") - ); - - $this->assertEquals( - "1", - $this->_helper->getTable("table_results.2.5") - ); - - $this->assertEquals( - "2", - $this->_helper->getTable("table_results.3.5") - ); - - // case 4 - $this->byLinkText("datetimefield")->click(); - $this->_helper->waitForElementNotPresent("byId", "loading_parent"); - usleep(100); - - $this->assertEquals( - "2", - $this->_helper->getTable("table_results.1.5") - ); - - $this->assertEquals( - "1", - $this->_helper->getTable("table_results.2.5") - ); - - $this->assertEquals( - "3", - $this->_helper->getTable("table_results.3.5") - ); - } - - /** - * Test Edit Record - * - * @return void - */ - public function testChangeRecords() - { - $this->byCssSelector( - "table#table_results tbody tr:nth-child(2) td:nth-child(2) a" - )->click(); - $this->_helper->waitForElement("byId", "insertForm"); - - $this->assertEquals( - "2", - $this->byId("field_1_3")->value() - ); - - $this->assertEquals( - "foo", - $this->byId("field_2_3")->value() - ); - - $this->assertEquals( - "2010-01-20 02:00:02", - $this->byId("field_3_3")->value() - ); - - $this->byId("field_2_3")->clear(); - $this->byId("field_2_3")->value("foobar"); - $this->byId("field_3_3")->clear(); - $this->byId("field_3_3")->value("2009-01-20 02:00:02"); - - $this->byId("buttonYes")->click(); - - $success = $this->_helper->waitForElement("byClassName", "success"); - $this->assertContains("1 row affected", $success->text()); - - $this->assertEquals( - "foobar", - $this->_helper->getTable("table_results.2.6") - ); - - $this->assertEquals( - "2009-01-20 02:00:02", - $this->_helper->getTable("table_results.2.7") - ); - } - - /** - * Test edit record by double click - * - * @return void - */ - public function testChangeRecordsByDoubleClick() - { - $element = $this->byCssSelector( - "table#table_results tbody tr:nth-child(1) td:nth-child(6)" - ); - - $this->moveto($element); - $this->doubleclick(); - - $this->assertEquals( - $this->byCssSelector("textarea.edit_box")->value(), - "abcd" - ); - - $this->byCssSelector("textarea.edit_box")->clear(); - $this->byCssSelector("textarea.edit_box")->value("abcde"); - $this->keys(PHPUnit_Extensions_Selenium2TestCase_Keys::RETURN_); - - $success = $this->_helper->waitForElement( - "byCssSelector", "span.ajax_notification div.success" - ); - $this->assertContains("1 row affected", $success->text()); - - $this->assertEquals( - "abcde", - $this->_helper->getTable("table_results.1.6") - ); - } - - /** - * Test copy and insert record - * - * @return void - */ - public function testCopyRecords() - { - $this->byCssSelector( - "table#table_results tbody tr:nth-child(3) td:nth-child(3) a" - )->click(); - - $this->_helper->waitForElement("byId", "insertForm"); - - $this->assertEquals( - "Abcd", - $this->byId("field_2_3")->value() - ); - - $this->assertEquals( - "2012-01-20 02:00:02", - $this->byId("field_3_3")->value() - ); - - $this->byId("field_2_3")->clear(); - $this->byId("field_2_3")->value("ABCDEFG"); - $this->byId("field_3_3")->clear(); - $this->byId("field_3_3")->value("2012-01-20 02:05:02"); - - $this->byId("buttonYes")->click(); - $success = $this->_helper->waitForElement("byClassName", "success"); - $this->assertContains("1 row inserted", $success->text()); - - $this->assertEquals( - "ABCDEFG", - $this->_helper->getTable("table_results.4.6") - ); - - $this->assertEquals( - "2012-01-20 02:05:02", - $this->_helper->getTable("table_results.4.7") - ); - } - - /** - * Test search table - * - * @return void - */ - public function testSearchRecords() - { - $this->byLinkText("Search")->click(); - $this->_helper->waitForElement("byId", "tbl_search_form"); - - $this->byId("fieldID_1")->value("abcd"); - $select = $this->select($this->byName("criteriaColumnOperators[1]")); - $select->selectOptionByLabel("LIKE %...%"); - - $this->byName("submit")->click(); - $success = $this->_helper->waitForElement("byClassName", "success"); - $this->assertContains("Showing rows", $success->text()); - - $this->assertEquals( - "1", - $this->_helper->getTable("table_results.1.5") - ); - - $this->assertEquals( - "3", - $this->_helper->getTable("table_results.2.5") - ); - } - - /** - * Test delete multiple records - * - * @return void - */ - public function testDeleteRecords() - { - $this->byId("id_rows_to_delete1_left")->click(); - $this->byId("id_rows_to_delete2_left")->click(); - - $this->byCssSelector("button[value=delete]")->click(); - $this->_helper->waitForElement("byCssSelector", "fieldset.confirmation"); - - $this->byId("buttonYes")->click(); - $success = $this->_helper->waitForElement("byClassName", "success"); - $this->assertContains("Showing rows", $success->text()); - - $this->assertFalse( - $this->_helper->isElementPresent( - "byCssSelector", "table#table_results tbody tr:nth-child(2)" - ) - ); - - } - - /** - * Teardown for test cases (drops database) - * - * @return void - */ - public function tearDown() - { - $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); - } -} diff --git a/test/selenium/PmaSeleniumTablesInsertDataTest.php b/test/selenium/PmaSeleniumTablesInsertDataTest.php deleted file mode 100644 index 079071b3e7..0000000000 --- a/test/selenium/PmaSeleniumTablesInsertDataTest.php +++ /dev/null @@ -1,168 +0,0 @@ -_helper = new Helper($this); - $this->setBrowser($this->_helper->getBrowserString()); - $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); - $this->_helper->dbConnect(); - $this->_dbname = 'pma_db_' . time(); - $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); - $this->_helper->dbQuery('USE ' . $this->_dbname); - $this->_helper->dbQuery( - "CREATE TABLE `test_table` (" - . " `id` int(11) NOT NULL AUTO_INCREMENT," - . " `name` varchar(20) NOT NULL," - . " `datetimefield` datetime NOT NULL," - . " PRIMARY KEY (`id`)" - . ")" - ); - - } - - /** - * setUp function that can use the selenium session (called before each test) - * - * @return void - */ - public function setUpPage() - { - $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); - $this->byLinkText($this->_dbname)->click(); - $this->_helper->waitForElement("byLinkText", "test_table"); - } - - /** - * Insert data into table - * - * @return void - */ - public function testAddData() - { - $this->byLinkText("Insert")->click(); - $this->_helper->waitForElement("byId", "insertForm"); - - $this->byId("field_1_3")->value("1"); - $this->byId("field_2_3")->value("abcd"); - $this->byId("field_3_3")->value("2011-01-20 02:00:02"); - $this->byId("field_5_3")->value("foo"); - $this->byId("field_6_3")->value("2010-01-20 02:00:02"); - - $select = $this->select($this->byName("after_insert")); - $select->selectOptionByLabel("Insert another new row"); - - // post - $this->byId("buttonYes")->click(); - $ele = $this->_helper->waitForElement("byClassName", "success"); - $this->assertContains("2 rows inserted", $ele->text()); - - $this->byId("field_2_3")->value("Abcd"); - $this->byId("field_3_3")->value("2012-01-20 02:00:02"); - - // post - $this->byCssSelector( - "input[value=Go]" - )->click(); - - $this->_helper->waitForElementNotPresent("byId", "loading_parent"); - $ele = $this->_helper->waitForElement("byClassName", "success"); - $this->assertContains("1 row inserted", $ele->text()); - $this->_assertDataPresent(); - } - - private function _assertDataPresent() - { - $this->byLinkText("Browse")->click(); - $this->_helper->waitForElement("byId", "table_results"); - - $this->assertEquals( - "1", - $this->_helper->getTable("table_results.1.5") - ); - - $this->assertEquals( - "abcd", - $this->_helper->getTable("table_results.1.6") - ); - - $this->assertEquals( - "2011-01-20 02:00:02", - $this->_helper->getTable("table_results.1.7") - ); - - $this->assertEquals( - "2", - $this->_helper->getTable("table_results.2.5") - ); - - $this->assertEquals( - "foo", - $this->_helper->getTable("table_results.2.6") - ); - - $this->assertEquals( - "2010-01-20 02:00:02", - $this->_helper->getTable("table_results.2.7") - ); - - $this->assertEquals( - "3", - $this->_helper->getTable("table_results.3.5") - ); - - $this->assertEquals( - "Abcd", - $this->_helper->getTable("table_results.3.6") - ); - - $this->assertEquals( - "2012-01-20 02:00:02", - $this->_helper->getTable("table_results.3.7") - ); - } - - /** - * Tear Down function for test cases - * - * @return void - */ - public function tearDown() - { - $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); - } -} diff --git a/test/selenium/PmaSeleniumTablesTest.php b/test/selenium/PmaSeleniumTablesTest.php deleted file mode 100644 index 987c18cb10..0000000000 --- a/test/selenium/PmaSeleniumTablesTest.php +++ /dev/null @@ -1,195 +0,0 @@ -_helper = new Helper($this); - $this->setBrowser($this->_helper->getBrowserString()); - $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL); - $this->_helper->dbConnect(); - $this->_dbname = 'pma_db_' . time(); - $this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname); - } - - /** - * Creates a table - * - * @return void - */ - public function testCreateTable() - { - $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); - $this->byLinkText($this->_dbname)->click(); - - $this->_helper->waitForElement('byId', 'create_table_form_minimal'); - $this->byCssSelector( - "form#create_table_form_minimal input[name=table]" - )->value("test_table"); - $this->byName("num_fields")->value("4"); - $this->byCssSelector('input[value=Go]')->click(); - $this->_helper->waitForElement('byName', 'do_save_data'); - - // column details - $column_text_details = array( - "field_0_1" => "test_id", - "field_0_3" => "14", - "field_0_10" => "comm1", - "field_1_1" => "test_column", - "field_1_3" => "10", - "field_1_10" => "comm2", - ); - - foreach ($column_text_details as $field => $val) { - $this->byId($field)->value($val); - } - - $column_dropdown_details = array( - "field_0_6" => "UNSIGNED", - "field_0_8" => "PRIMARY", - "field_1_2" => "VARCHAR", - "field_1_5" => "utf8_general_ci", - "field_1_4" => "As defined:" - ); - - foreach ($column_dropdown_details as $selector => $value) { - $sel = $this->select($this->byId($selector)); - $sel->selectOptionByLabel($value); - } - - $this->byName("field_default_value[1]")->value("def"); - $this->byId("field_0_9")->click(); // auto increment - $this->byId("field_1_7")->click(); // null - - // post - $this->byName("do_save_data")->click(); - $this->_helper->waitForElement("byLinkText", "test_table"); - - $this->_tableStructureAssertions(); - } - - /** - * Make assertions for table structure - * - * @return void - */ - private function _tableStructureAssertions() - { - // go to structure page - $this->byLinkText("Structure")->click(); - $this->_helper->waitForElement("byId", "tablestructure"); - - // make assertions for first row - $this->assertContains( - "test_id", - $this->byCssSelector('label[for=checkbox_row_1]')->text() - ); - - $this->assertEquals( - "int(14)", - $this->_helper->getTable("tablestructure.1.4") - ); - - $this->assertEquals( - "UNSIGNED", - $this->_helper->getTable("tablestructure.1.6") - ); - - $this->assertEquals( - "No", - $this->_helper->getTable("tablestructure.1.7") - ); - - $this->assertEquals( - "None", - $this->_helper->getTable("tablestructure.1.8") - ); - - $this->assertEquals( - "AUTO_INCREMENT", - $this->_helper->getTable("tablestructure.1.9") - ); - - $this->assertFalse( - $this->_helper->isElementPresent( - 'byCssSelector', - 'table#tablestructure tbody tr:nth-child(1) ul.table-structure-actions li.primary a' - ) - ); - - // make assertions for second row - $this->assertContains( - "test_column", - $this->byCssSelector('label[for=checkbox_row_2]')->text() - ); - - $this->assertEquals( - "varchar(10)", - $this->_helper->getTable("tablestructure.2.4") - ); - - $this->assertEquals( - "utf8_general_ci", - $this->_helper->getTable("tablestructure.2.5") - ); - - $this->assertEquals( - "Yes", - $this->_helper->getTable("tablestructure.2.7") - ); - - $this->assertEquals( - "def", - $this->_helper->getTable("tablestructure.2.8") - ); - - $this->assertFalse( - $this->_helper->isElementPresent( - 'byCssSelector', 'css=ul.table-structure-actions:nth-child(2) li.primary a' - ) - ); - } - - /** - * Tear down functions for test cases - * - * @return void - */ - public function tearDown() - { - $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); - } -}