From 9ac96ef407ad2bbb0e07203e5bee1090525ce469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 17 Feb 2014 19:29:29 +0100 Subject: [PATCH] Convert database operations test 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/PmaSeleniumDbOperationsTest.php | 49 ++++++++----------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/phpunit.xml.nocoverage b/phpunit.xml.nocoverage index 653f463e64..a553c93931 100644 --- a/phpunit.xml.nocoverage +++ b/phpunit.xml.nocoverage @@ -33,6 +33,7 @@ test/selenium/PmaSeleniumLoginTest.php test/selenium/PmaSeleniumXssTest.php test/selenium/PmaSeleniumDbStructureTest.php + test/selenium/PmaSeleniumDbOperationsTest.php diff --git a/test/selenium/PmaSeleniumDbOperationsTest.php b/test/selenium/PmaSeleniumDbOperationsTest.php index 47f57c4257..1b477c4e95 100644 --- a/test/selenium/PmaSeleniumDbOperationsTest.php +++ b/test/selenium/PmaSeleniumDbOperationsTest.php @@ -6,7 +6,9 @@ * @package PhpMyAdmin-test * @subpackage Selenium */ -require_once 'Helper.php'; + +require_once 'TestBase.php'; + /** * PmaSeleniumDbOperationsTest class @@ -14,7 +16,7 @@ require_once 'Helper.php'; * @package PhpMyAdmin-test * @subpackage Selenium */ -class PmaSeleniumDbOperationsTest extends PHPUnit_Extensions_Selenium2TestCase +class PmaSeleniumDbOperationsTest extends PMA_SeleniumBase { /** * Name of database for the test @@ -23,13 +25,6 @@ class PmaSeleniumDbOperationsTest extends PHPUnit_Extensions_Selenium2TestCase */ private $_dbname; - /** - * Helper Object - * - * @var Helper - */ - private $_helper; - /** * Setup the browser environment to run the selenium test case * @@ -37,13 +32,11 @@ class PmaSeleniumDbOperationsTest 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); + parent::setUp(); + $this->dbConnect(); + $this->_dbname = TESTSUITE_DATABASE; + $this->dbQuery('CREATE DATABASE ' . $this->_dbname); + $this->dbQuery('USE ' . $this->_dbname); } /** @@ -53,10 +46,10 @@ class PmaSeleniumDbOperationsTest 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("byLinkText", "Operations")->click(); - $this->_helper->waitForElement( + $this->waitForElement("byLinkText", "Operations")->click(); + $this->waitForElement( "byXPath", "//legend[contains(., 'Database comment:')]" ); } @@ -72,7 +65,7 @@ class PmaSeleniumDbOperationsTest extends PHPUnit_Extensions_Selenium2TestCase $this->byXPath("(//input[@value='Go'])[1]")->click(); $this->assertNotNull( - $this->_helper->waitForElement( + $this->waitForElement( "byXPath", "//span[@id='span_table_comment' and contains(., 'comment_foobar')]" ) @@ -91,21 +84,21 @@ class PmaSeleniumDbOperationsTest extends PHPUnit_Extensions_Selenium2TestCase $this->byXPath("(//input[@value='Go'])[3]")->click(); - $this->_helper->waitForElement( + $this->waitForElement( "byXPath", "//button[contains(., 'OK')]" )->click(); - $this->_helper->waitForElement( + $this->waitForElement( "byXPath", "//a[@class='item' and contains(., 'Database: pma_test_db_renamed')]" ); - $result = $this->_helper->dbQuery( + $result = $this->dbQuery( "SHOW DATABASES LIKE 'pma_test_db_renamed';" ); $this->assertEquals(1, $result->num_rows); - $result = $this->_helper->dbQuery( + $result = $this->dbQuery( "SHOW DATABASES LIKE '" . $this->_dbname . "';" ); $this->assertEquals(0, $result->num_rows); @@ -125,18 +118,18 @@ class PmaSeleniumDbOperationsTest extends PHPUnit_Extensions_Selenium2TestCase $this->byXPath("(//input[@value='Go'])[4]")->click(); - $this->_helper->waitForElement( + $this->waitForElement( "byXPath", "//div[@class='success' and contains(., 'Database " . $this->_dbname . " has been copied to pma_test_db_copy')]" ); - $result = $this->_helper->dbQuery( + $result = $this->dbQuery( "SHOW DATABASES LIKE 'pma_test_db_copy';" ); $this->assertEquals(1, $result->num_rows); - $this->_helper->dbQuery("DROP DATABASE pma_test_db_copy"); + $this->dbQuery("DROP DATABASE pma_test_db_copy"); } /** @@ -146,6 +139,6 @@ class PmaSeleniumDbOperationsTest extends PHPUnit_Extensions_Selenium2TestCase */ public function tearDown() { - $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname); + $this->dbQuery('DROP DATABASE ' . $this->_dbname); } }