Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8fd176ffab
@ -9,12 +9,12 @@
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
* PmaSeleniumDbStoredProceduresTest class
|
||||
* PmaSeleniumDbProceduresTest class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
class PmaSeleniumDbStoredProceduresTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
class PmaSeleniumDbProceduresTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
/**
|
||||
* Name of database for the test
|
||||
@ -9,12 +9,12 @@
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
* PmaSeleniumTablesBrowseDataTest class
|
||||
* PmaSeleniumTableBrowseTest class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
class PmaSeleniumTablesBrowseDataTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
class PmaSeleniumTableBrowseTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
/**
|
||||
* Name of database for the test
|
||||
@ -9,12 +9,12 @@
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
* PmaSeleniumTablesTest class
|
||||
* PmaSeleniumTableCreateTest class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
class PmaSeleniumTablesTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
class PmaSeleniumTableCreateTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
/**
|
||||
* Name of database for the test
|
||||
@ -9,12 +9,12 @@
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
* PmaSeleniumTablesInsertDataTest class
|
||||
* PmaSeleniumTableInsertTest class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
class PmaSeleniumTablesInsertDataTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
class PmaSeleniumTableInsertTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
/**
|
||||
* Name of database for the test
|
||||
@ -31,7 +31,8 @@ class PmaSeleniumTablesInsertDataTest extends PHPUnit_Extensions_Selenium2TestCa
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
* Setup the browser environment to run the selenium t
|
||||
* est case
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
260
test/selenium/PmaSeleniumTableOperationsTest.php
Normal file
260
test/selenium/PmaSeleniumTableOperationsTest.php
Normal file
@ -0,0 +1,260 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium TestCase for table related tests
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
* PmaSeleniumTableOperationsTest class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
class PmaSeleniumTableOperationsTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
/**
|
||||
* Name of database for the test
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dbname;
|
||||
|
||||
/**
|
||||
* Helper Object
|
||||
*
|
||||
* @var obj
|
||||
*/
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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(
|
||||
"CREATE TABLE `test_table` ("
|
||||
. " `id` int(11) NOT NULL AUTO_INCREMENT,"
|
||||
. " `val` int(11) NOT NULL,"
|
||||
. " `val2` int(11) NOT NULL,"
|
||||
. " PRIMARY KEY (`id`)"
|
||||
. ")"
|
||||
);
|
||||
$this->_helper->dbQuery("INSERT INTO test_table (val) VALUES (22)");
|
||||
$this->_helper->dbQuery("INSERT INTO test_table (val) VALUES (33)");
|
||||
}
|
||||
|
||||
/**
|
||||
* setUp function that can use the selenium session (called before each test)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->byLinkText($this->_dbname)->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//a[contains(., 'test_table')]"
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElement("byId", "table_results");
|
||||
$more = $this->_helper->waitForElement("byLinkText", "More");
|
||||
$this->moveto($more);
|
||||
$this->byXPath("//a[contains(., 'Operations')]")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//legend[contains(., 'Alter table order by')]"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for changing a table order
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testChangeTableOrder()
|
||||
{
|
||||
$this->select($this->byName("order_field"))
|
||||
->selectOptionByLabel("val");
|
||||
|
||||
$this->byId("order_order_desc")->click();
|
||||
$this->byXPath("(//input[@value='Go'])[1]")->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and "
|
||||
. "contains(., 'Your SQL query has been executed successfully')]"
|
||||
);
|
||||
|
||||
$this->byLinkText("Browse")->click();
|
||||
$this->_helper->waitForElement("byId", "table_results");
|
||||
|
||||
$this->assertEquals(
|
||||
"2",
|
||||
$this->_helper->getTable("table_results.1.5")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for moving a table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testMoveTable()
|
||||
{
|
||||
$this->byCssSelector("form#moveTableForm input[name='new_name']")->value("2");
|
||||
|
||||
$this->byXPath("(//input[@value='Go'])[2]")->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and "
|
||||
. "contains(., 'Table `" . $this->_dbname . "`.`test_table` has been "
|
||||
. "moved to `" . $this->_dbname . "`.`test_table2`.')]"
|
||||
);
|
||||
|
||||
$result = $this->_helper->dbQuery("SHOW TABLES");
|
||||
$row = $result->fetch_assoc();
|
||||
$this->assertEquals(
|
||||
"test_table2",
|
||||
$row["Tables_in_" . $this->_dbname]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for renaming a table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRenameTable()
|
||||
{
|
||||
$this->byCssSelector("form#tableOptionsForm input[name='new_name']")
|
||||
->value("2");
|
||||
|
||||
$this->byName("comment")->value("foobar");
|
||||
|
||||
$this->byXPath("(//input[@value='Go'])[3]")->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and "
|
||||
. "contains(., 'Table test_table has been renamed to test_table2')]"
|
||||
);
|
||||
|
||||
$this->assertNotNull(
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//span[@id='span_table_comment' and contains(., 'foobar')]"
|
||||
)
|
||||
);
|
||||
|
||||
$result = $this->_helper->dbQuery("SHOW TABLES");
|
||||
$row = $result->fetch_assoc();
|
||||
$this->assertEquals(
|
||||
"test_table2",
|
||||
$row["Tables_in_" . $this->_dbname]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for copying a table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCopyTable()
|
||||
{
|
||||
$this->byCssSelector("form#copyTable input[name='new_name']")->value("2");
|
||||
$this->byCssSelector("label[for='what_data']")->click();
|
||||
$this->byXPath("(//input[@value='Go'])[4]")->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and "
|
||||
. "contains(., 'Table `" . $this->_dbname . "`.`test_table` has been "
|
||||
. "copied to `" . $this->_dbname . "`.`test_table2`.')]"
|
||||
);
|
||||
|
||||
$result = $this->_helper->dbQuery("SELECT COUNT(*) as c FROM test_table2");
|
||||
$row = $result->fetch_assoc();
|
||||
$this->assertEquals(
|
||||
2,
|
||||
$row["c"]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for truncating a table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTruncateTable()
|
||||
{
|
||||
$this->byId("truncate_tbl_anchor")->click();
|
||||
$this->byXPath("//button[contains(., 'OK')]")->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and "
|
||||
. "contains(., 'MySQL returned an empty result set')]"
|
||||
);
|
||||
|
||||
$result = $this->_helper->dbQuery("SELECT COUNT(*) as c FROM test_table");
|
||||
$row = $result->fetch_assoc();
|
||||
$this->assertEquals(
|
||||
0,
|
||||
$row["c"]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for dropping a table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDropTable()
|
||||
{
|
||||
$this->byId("drop_tbl_anchor")->click();
|
||||
$this->byXPath("//button[contains(., 'OK')]")->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and "
|
||||
. "contains(., 'MySQL returned an empty result set')]"
|
||||
);
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//a[@class='tabactive' and contains(., 'Structure')]"
|
||||
);
|
||||
|
||||
$result = $this->_helper->dbQuery("SHOW TABLES");
|
||||
$this->assertEquals(
|
||||
0,
|
||||
$result->num_rows
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear Down function for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
$this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname);
|
||||
}
|
||||
}
|
||||
173
test/selenium/PmaSeleniumTableStructureTest.php
Normal file
173
test/selenium/PmaSeleniumTableStructureTest.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium TestCase for table related tests
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
* PmaSeleniumTableStructureTest class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
class PmaSeleniumTableStructureTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
/**
|
||||
* Name of database for the test
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dbname;
|
||||
|
||||
/**
|
||||
* Helper Object
|
||||
*
|
||||
* @var obj
|
||||
*/
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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(
|
||||
"CREATE TABLE `test_table` ("
|
||||
. " `id` int(11) NOT NULL AUTO_INCREMENT,"
|
||||
. " `val` int(11) NOT NULL,"
|
||||
. " `val2` int(11) NOT NULL,"
|
||||
. " PRIMARY KEY (`id`)"
|
||||
. ")"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* setUp function that can use the selenium session (called before each test)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->byLinkText($this->_dbname)->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"(//a[contains(., 'Structure')])[2]"
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElement("byId", "tablestructure");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for adding a new column
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddColumn()
|
||||
{
|
||||
$this->byCssSelector("label[for='field_where_after']")->click();
|
||||
$this->byCssSelector("input[value='Go']")->click();
|
||||
|
||||
$this->_helper->waitForElement("byClassName", "append_fields_form");
|
||||
|
||||
$this->byId("field_0_1")->value('val3');
|
||||
$this->byCssSelector("input[name='do_save_data']")->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Table test_table has been altered successfully')]"
|
||||
);
|
||||
|
||||
$this->byLinkText("Structure")->click();
|
||||
$this->_helper->waitForElement("byId", "tablestructure");
|
||||
|
||||
$this->assertEquals(
|
||||
"val3",
|
||||
$this->byCssSelector('label[for=checkbox_row_2]')->text()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"int(11)",
|
||||
$this->_helper->getTable("tablestructure.2.4")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for changing a column
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testChangeColumn()
|
||||
{
|
||||
$this->byXPath("(//a[contains(., 'Change')])[2]")->click();
|
||||
|
||||
$this->_helper->waitForElement("byClassName", "append_fields_form");
|
||||
|
||||
$this->assertEquals("val", $this->byId("field_0_1")->value());
|
||||
$this->byId("field_0_1")->clear();
|
||||
$this->byId("field_0_1")->value('val3');
|
||||
$this->byCssSelector("input[name='do_save_data']")->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Table test_table has been altered successfully')]"
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"val3",
|
||||
$this->byCssSelector('label[for=checkbox_row_2]')->text()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for dropping columns
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDropColumns()
|
||||
{
|
||||
$this->byCssSelector('label[for=checkbox_row_2]')->click();
|
||||
$this->byCssSelector('label[for=checkbox_row_3]')->click();
|
||||
$this->byXPath("//button[@class='mult_submit' and contains(., 'Drop')]")->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byCssSelector", "input[id='buttonYes']"
|
||||
)
|
||||
->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Your SQL query has been executed successfully')]"
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->_helper->isElementPresent(
|
||||
'byCssSelector', 'label[for=checkbox_row_2]'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear Down function for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
$this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user