Translated using Weblate (Danish)
[phpmyadmin.git] / test / selenium / PmaSeleniumDbOperationsTest.php
blob898e9782ba5df09a40da6d2ed227b40589db3f0b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Selenium TestCase for table related tests
6 * @package PhpMyAdmin-test
7 * @subpackage Selenium
8 */
9 require_once 'Helper.php';
11 /**
12 * PmaSeleniumDbOperationsTest class
14 * @package PhpMyAdmin-test
15 * @subpackage Selenium
17 class PmaSeleniumDbOperationsTest extends PHPUnit_Extensions_Selenium2TestCase
19 /**
20 * Name of database for the test
22 * @var string
24 private $_dbname;
26 /**
27 * Helper Object
29 * @var Helper
31 private $_helper;
33 /**
34 * Setup the browser environment to run the selenium test case
36 * @return void
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);
49 /**
50 * setUp function that can use the selenium session (called before each test)
52 * @return void
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:')]"
64 /**
65 * Test for adding database comment
67 * @return void
69 public function testDbComment()
71 $this->byName("comment")->value("comment_foobar");
72 $this->byXPath("(//input[@value='Go'])[1]")->click();
74 $this->assertNotNull(
75 $this->_helper->waitForElement(
76 "byXPath",
77 "//span[@id='span_table_comment' and contains(., 'comment_foobar')]"
82 /**
83 * Test for renaming database
85 * @return void
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')]"
96 )->click();
98 $this->_helper->waitForElement(
99 "byXPath",
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
119 * @return void
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(
129 "byXPath",
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
145 * @return void
147 public function tearDown()
149 $this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname);