Waiting for ajax_message_num_1 works only on first AJAX request and we're doing more of them. This should remove need for many consequent sleeps as we were actually not properly waiting for element. Also it's better to wrap this logic in separate method as it is used in many places in the code. Signed-off-by: Michal Čihař <michal@cihar.com>
107 lines
2.6 KiB
PHP
107 lines
2.6 KiB
PHP
<?php
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
|
/**
|
|
* Selenium TestCase for creating and deleting databases
|
|
*
|
|
* @package PhpMyAdmin-test
|
|
* @subpackage Selenium
|
|
*/
|
|
|
|
require_once 'TestBase.php';
|
|
|
|
/**
|
|
* PmaSeleniumCreateDropDatabaseTest class
|
|
*
|
|
* @package PhpMyAdmin-test
|
|
* @subpackage Selenium
|
|
* @group selenium
|
|
*/
|
|
class PMA_SeleniumCreateDropDatabaseTest extends PMA_SeleniumBase
|
|
{
|
|
/**
|
|
* Setup the browser environment to run the selenium test case
|
|
*
|
|
* @return void
|
|
*/
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
/* TODO: For now this tests needs superuser for deleting database */
|
|
$this->skipIfNotSuperUser();
|
|
}
|
|
|
|
public function setUpPage()
|
|
{
|
|
parent::setUpPage();
|
|
$this->login();
|
|
}
|
|
|
|
/**
|
|
* Creates a database and drops it
|
|
*
|
|
* @return void
|
|
*
|
|
* @group large
|
|
*/
|
|
public function testCreateDropDatabase()
|
|
{
|
|
// Drop database if it exists
|
|
$this->dbQuery(
|
|
'DROP DATABASE IF EXISTS ' . $this->database_name . ';'
|
|
);
|
|
|
|
$this->waitForElement('byPartialLinkText','Databases')->click();
|
|
$this->waitAjax();
|
|
|
|
$element = $this->waitForElement('byId', 'text_create_db');
|
|
$element->clear();
|
|
$element->value($this->database_name);
|
|
|
|
$this->byId("buttonGo")->click();
|
|
|
|
$element = $this->waitForElement('byLinkText', 'Database: ' . $this->database_name);
|
|
|
|
$result = $this->dbQuery(
|
|
'SHOW DATABASES LIKE \'' . $this->database_name . '\';'
|
|
);
|
|
$this->assertEquals(1, $result->num_rows);
|
|
|
|
$this->_dropDatabase();
|
|
}
|
|
|
|
/**
|
|
* Drops a database, called after testCreateDropDatabase
|
|
*
|
|
* @return void
|
|
*/
|
|
private function _dropDatabase()
|
|
{
|
|
$this->gotoHomepage();
|
|
|
|
$this->byPartialLinkText('Databases')->click();
|
|
$this->waitAjax();
|
|
|
|
$this->scrollToBottom();
|
|
$this->byCssSelector(
|
|
"input[name='selected_dbs[]'][value='" . $this->database_name . "']"
|
|
)->click();
|
|
|
|
$this->byCssSelector("button.mult_submit")->click();
|
|
$this->byCssSelector("button.submitOK")->click();
|
|
|
|
$this->waitForElementNotPresent(
|
|
"byCssSelector",
|
|
"input[name='selected_dbs[]'][value='" . $this->database_name . "']"
|
|
);
|
|
|
|
$this->waitForElement(
|
|
"byCssSelector", "span.ajax_notification div.success"
|
|
);
|
|
|
|
$result = $this->dbQuery(
|
|
'SHOW DATABASES LIKE \'' . $this->database_name . '\';'
|
|
);
|
|
$this->assertEquals(0, $result->num_rows);
|
|
}
|
|
}
|