From ec057385f8ba444ea5aaeddce0d0cceebe8c1b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 17 Feb 2014 19:04:19 +0100 Subject: [PATCH] Adjust database structure tests to new model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- phpunit.xml.nocoverage | 1 + test/selenium/PmaSeleniumDbStructureTest.php | 48 ++++++++------------ 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/phpunit.xml.nocoverage b/phpunit.xml.nocoverage index f1361a410c..653f463e64 100644 --- a/phpunit.xml.nocoverage +++ b/phpunit.xml.nocoverage @@ -32,6 +32,7 @@ test/selenium/PmaSeleniumLoginTest.php test/selenium/PmaSeleniumXssTest.php + test/selenium/PmaSeleniumDbStructureTest.php diff --git a/test/selenium/PmaSeleniumDbStructureTest.php b/test/selenium/PmaSeleniumDbStructureTest.php index 829c676ab9..c7f008badc 100644 --- a/test/selenium/PmaSeleniumDbStructureTest.php +++ b/test/selenium/PmaSeleniumDbStructureTest.php @@ -6,7 +6,8 @@ * @package PhpMyAdmin-test * @subpackage Selenium */ -require_once 'Helper.php'; + +require_once 'TestBase.php'; /** * PmaSeleniumDbStructureTest class @@ -14,7 +15,7 @@ require_once 'Helper.php'; * @package PhpMyAdmin-test * @subpackage Selenium */ -class PmaSeleniumDbStructureTest extends PHPUnit_Extensions_Selenium2TestCase +class PMA_SeleniumDbStructureTest extends PHPUnit_Extensions_Selenium2TestCase { /** * Name of database for the test @@ -23,13 +24,6 @@ class PmaSeleniumDbStructureTest extends PHPUnit_Extensions_Selenium2TestCase */ private $_dbname; - /** - * Helper Object - * - * @var Helper - */ - private $_helper; - /** * Setup the browser environment to run the selenium test case * @@ -37,28 +31,26 @@ class PmaSeleniumDbStructureTest extends PHPUnit_Extensions_Selenium2TestCase */ public function setUp() { - $this->_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( + parent::setUp(); + $this->dbConnect(); + $this->_dbname = TESTSUITE_DATABASE; + $this->dbQuery('CREATE DATABASE IF NOT EXISTS ' . $this->_dbname); + $this->dbQuery('USE ' . $this->_dbname); + $this->dbQuery( "CREATE TABLE `test_table` (" . " `id` int(11) NOT NULL AUTO_INCREMENT," . " `val` int(11) NOT NULL," . " PRIMARY KEY (`id`)" . ")" ); - $this->_helper->dbQuery( + $this->dbQuery( "CREATE TABLE `test_table2` (" . " `id` int(11) NOT NULL AUTO_INCREMENT," . " `val` int(11) NOT NULL," . " PRIMARY KEY (`id`)" . ")" ); - $this->_helper->dbQuery( + $this->dbQuery( "INSERT INTO `test_table` (val) VALUES (2);" ); } @@ -70,9 +62,9 @@ class PmaSeleniumDbStructureTest extends PHPUnit_Extensions_Selenium2TestCase */ public function setUpPage() { - $this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD); + $this->login(TESTSUITE_USER, TESTSUITE_PASSWORD); $this->byLinkText($this->_dbname)->click(); - $this->_helper->waitForElement( + $this->waitForElement( "byXPath", "//a[contains(., 'test_table')]" ); } @@ -86,20 +78,20 @@ class PmaSeleniumDbStructureTest extends PHPUnit_Extensions_Selenium2TestCase { $this->byXPath("(//a[contains(., 'Empty')])[1]")->click(); - $this->_helper->waitForElement( + $this->waitForElement( "byXPath", "//button[contains(., 'OK')]" )->click(); $this->assertNotNull( - $this->_helper->waitForElement( + $this->waitForElement( "byXPath", "//div[@class='success' and contains(., " . "'MySQL returned an empty result')]" ) ); - $result = $this->_helper->dbQuery("SELECT count(*) as c FROM test_table"); + $result = $this->dbQuery("SELECT count(*) as c FROM test_table"); $row = $result->fetch_assoc(); $this->assertEquals(0, $row['c']); } @@ -114,15 +106,15 @@ class PmaSeleniumDbStructureTest extends PHPUnit_Extensions_Selenium2TestCase $this->byCssSelector("label[for='tablesForm_checkall']")->click(); $this->select($this->byName("submit_mult")) ->selectOptionByLabel("Drop"); - $this->_helper->waitForElement("byCssSelector", "input[id='buttonYes']") + $this->waitForElement("byCssSelector", "input[id='buttonYes']") ->click(); - $this->_helper->waitForElement( + $this->waitForElement( "byXPath", "//p[contains(., 'No tables found in database')]" ); - $result = $this->_helper->dbQuery("SHOW TABLES;"); + $result = $this->dbQuery("SHOW TABLES;"); $this->assertEquals(0, $result->num_rows); } @@ -133,6 +125,6 @@ class PmaSeleniumDbStructureTest extends PHPUnit_Extensions_Selenium2TestCase */ public function tearDown() { - $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); + $this->dbQuery('DROP DATABASE ' . $this->_dbname); } }