2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Selenium TestCase for table related tests
6 * @package PhpMyAdmin-test
9 require_once 'Helper.php';
12 * PmaSeleniumDbOperationsTest class
14 * @package PhpMyAdmin-test
15 * @subpackage Selenium
17 class PmaSeleniumDbOperationsTest
extends PHPUnit_Extensions_Selenium2TestCase
20 * Name of database for the test
34 * Setup the browser environment to run the selenium test case
38 public function setUp()
40 $this->_helper
= new Helper($this);
41 $this->setBrowser($this->_helper
->getBrowserString());
42 $this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST
. TESTSUITE_PHPMYADMIN_URL
);
43 $this->_helper
->dbConnect();
44 $this->_dbname
= 'pma_db_test';
45 $this->_helper
->dbQuery('CREATE DATABASE ' . $this->_dbname
);
46 $this->_helper
->dbQuery('USE ' . $this->_dbname
);
50 * setUp function that can use the selenium session (called before each test)
54 public function setUpPage()
56 $this->_helper
->login(TESTSUITE_USER
, TESTSUITE_PASSWORD
);
57 $this->byLinkText($this->_dbname
)->click();
58 $this->_helper
->waitForElement("byLinkText", "Operations")->click();
59 $this->_helper
->waitForElement(
60 "byXPath", "//legend[contains(., 'Database comment:')]"
65 * Test for adding database comment
69 public function testDbComment()
71 $this->byName("comment")->value("comment_foobar");
72 $this->byXPath("(//input[@value='Go'])[1]")->click();
75 $this->_helper
->waitForElement(
77 "//span[@id='span_table_comment' and contains(., 'comment_foobar')]"
83 * Test for renaming database
87 public function testRenameDB()
89 $this->byCssSelector("form#rename_db_form input[name=newname]")
90 ->value("pma_test_db_renamed");
92 $this->byXPath("(//input[@value='Go'])[3]")->click();
94 $this->_helper
->waitForElement(
95 "byXPath", "//button[contains(., 'OK')]"
98 $this->_helper
->waitForElement(
100 "//a[@class='item' and contains(., 'Database: pma_test_db_renamed')]"
103 $result = $this->_helper
->dbQuery(
104 "SHOW DATABASES LIKE 'pma_test_db_renamed';"
106 $this->assertEquals(1, $result->num_rows
);
108 $result = $this->_helper
->dbQuery(
109 "SHOW DATABASES LIKE '". $this->_dbname
."';"
111 $this->assertEquals(0, $result->num_rows
);
113 $this->_dbname
= "pma_test_db_renamed";
117 * Test for copying database
121 public function testCopyDb()
123 $this->byCssSelector("form#copy_db_form input[name=newname]")
124 ->value("pma_test_db_copy");
126 $this->byXPath("(//input[@value='Go'])[4]")->click();
128 $this->_helper
->waitForElement(
130 "//div[@class='success' and contains(., 'Database " . $this->_dbname
." "
131 . "has been copied to pma_test_db_copy')]"
134 $result = $this->_helper
->dbQuery(
135 "SHOW DATABASES LIKE 'pma_test_db_copy';"
137 $this->assertEquals(1, $result->num_rows
);
139 $this->_helper
->dbQuery("DROP DATABASE pma_test_db_copy");
143 * Tear Down function for test cases
147 public function tearDown()
149 $this->_helper
->dbQuery('DROP DATABASE ' . $this->_dbname
);