From 422cb3050a73b875a165adac05ea399db26b8434 Mon Sep 17 00:00:00 2001 From: Smita Kumari Date: Thu, 3 Jul 2014 17:09:35 +0530 Subject: [PATCH] Selenium test for normalization to 1NF Signed-off-by: Smita Kumari --- .../selenium/PmaSeleniumNormalizationTest.php | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 test/selenium/PmaSeleniumNormalizationTest.php diff --git a/test/selenium/PmaSeleniumNormalizationTest.php b/test/selenium/PmaSeleniumNormalizationTest.php new file mode 100644 index 0000000000..325aefb6c3 --- /dev/null +++ b/test/selenium/PmaSeleniumNormalizationTest.php @@ -0,0 +1,171 @@ +dbQuery( + "CREATE TABLE `test_table` (" + . " `id` int(11) NOT NULL AUTO_INCREMENT," + . " `val` int(11) NOT NULL," + . " `val2` varchar(64) NOT NULL," + . "PRIMARY KEY(id)" + . ")" + ); + } + + /** + * setUp function that can use the selenium session + * + * @return void + */ + public function setUpPage() + { + $this->login(); + $this->navigateTable('test_table'); + $this->waitForElement( + "byXPath", + "(//a[contains(., 'Structure')])" + )->click(); + $this->waitForElement("byId", "tablestructure"); + $this->byLinkText('Improve table structure')->click(); + $this->waitForElement("byId", "normalizeTable"); + } + + /** + * Test for normalization to 1NF + * + * @return void + * + * @group large + */ + public function testNormalizationTo1NF() + { + $this->assertTrue( + $this->isElementPresent('byCssSelector', 'fieldset') + ); + $this->assertEquals( + "First step of normalization (1NF)", + $this->byCssSelector('label[for=normalizeTo_1nf]')->text() + ); + $this->assertTrue( + $this->isElementPresent( + 'byCssSelector', 'input[id=normalizeTo_1nf][type=radio]:checked' + ) + ); + $this->byCssSelector('input[name=submit_normalize]')->click(); + $this->waitForElement('byId', 'mainContent'); + $this->_test1NFSteps(); + } + + /** + * assertions in 1NF steps 1.1, 1.2, 1.3 + * + * @return void + */ + private function _test1NFSteps() + { + $this->assertEquals( + "First step of normalization (1NF)", + $this->byCssSelector('#page_content h3')->text() + ); + $this->assertTrue($this->isElementPresent( + 'byCssSelector', '#mainContent h4' + ) + ); + $this->assertTrue($this->isElementPresent( + 'byCssSelector', '#mainContent #newCols' + ) + ); + $this->assertTrue($this->isElementPresent( + 'byCssSelector', '.tblFooters' + ) + ); + $this->assertTrue($this->isElementPresent( + 'byCssSelector', '#selectNonAtomicCol option[value=val2]' + ) + ); + $this->assertFalse($this->isElementPresent( + 'byCssSelector', '#selectNonAtomicCol option[value=val]' + ) + ); + $this->assertTrue($this->isElementPresent( + 'byCssSelector', '#selectNonAtomicCol option[value=no_such_col]' + ) + ); + $this->select($this->byId('selectNonAtomicCol'))->selectOptionByValue('no_such_col'); + $this->waitForElement( + "byXPath", + "//legend[contains(., 'Step 1.2 Have primary key')]" + ); + $text = $this->byCssSelector("#mainContent h4")->text(); + $this->assertContains("Primary key already exist.", $text); + $this->waitForElement( + "byXPath", + "//legend[contains(., 'Step 1.3 Remove redundant columns')]" + ); + $this->assertTrue($this->isElementPresent( + 'byCssSelector','#mainContent #extra' + )); + $this->assertTrue($this->isElementPresent( + 'byCssSelector', '#extra input[value=val2][type=checkbox]' + ) + ); + $this->assertTrue($this->isElementPresent( + 'byCssSelector', '#extra input[value=id][type=checkbox]' + ) + ); + $this->byCssSelector('#extra input[value=id][type=checkbox]')->click(); + $this->byCssSelector("#removeRedundant")->click(); + $this->waitForElement( + "byXPath", + "//legend[contains(., 'Step 1.2 Have primary key')]" + ); + $this->assertTrue($this->isElementPresent( + 'byLinkText', 'Add a primary key on existing column(s)' + ) + ); + $this->byId('addNewPrimary')->click(); + $this->waitForElement("byId", "table_columns"); + $this->byId('saveNewPrimary')->click(); + $this->waitForElement( + "byXPath", + "//legend[contains(., 'Step 1.3 Remove redundant columns')]" + ); + $this->assertTrue($this->isElementPresent( + 'byCssSelector', '#extra input[value=test_table_id][type=checkbox]' + ) + ); + $this->byCssSelector('input[value="No redundant column"]')->click(); + $this->waitForElement( + "byXPath", + "//legend[contains(., 'End of step')]" + ); + $this->assertContains( + "The first step of normalization is complete for table 'test_table'.", + $this->byCssSelector("#mainContent h4")->text() + ); + } +} \ No newline at end of file