login(); } private function getToDBOperations(): void { $this->gotoHomepage(); $this->navigateDatabase($this->databaseName); $this->expandMore(); $this->waitForElement('partialLinkText', 'Operations')->click(); $this->waitForElement('xpath', '//div[contains(., \'Rename database to\')]'); } /** * Test for adding database comment * * @group large */ public function testDbComment(): void { $this->skipIfNotPMADB(); $this->getToDBOperations(); $this->byName('comment')->sendKeys('comment_foobar'); $this->byCssSelector("form#formDatabaseComment input[type='submit']")->click(); $this->assertNotNull( $this->waitForElement( 'xpath', "//span[@class='breadcrumb-comment' and contains(., 'comment_foobar')]", ), ); } /** * Test for renaming database * * @group large */ public function testRenameDB(): void { $this->getToDBOperations(); $newDbName = $this->databaseName . 'rename'; $this->scrollIntoView('createTableMinimalForm'); $this->byCssSelector('form#rename_db_form input[name=newname]') ->sendKeys($newDbName); $this->byCssSelector("form#rename_db_form input[type='submit']")->click(); $this->waitForElement('id', 'functionConfirmOkButton')->click(); $this->waitForElement('xpath', "//a[contains(text(),'Database: ') and contains(text(),'" . $newDbName . "')]"); $this->dbQuery( 'SHOW DATABASES LIKE \'' . $newDbName . '\'', function () use ($newDbName): void { $this->assertTrue($this->isElementPresent('className', 'table_results')); $this->assertEquals($newDbName, $this->getCellByTableClass('table_results', 1, 1)); }, ); $this->dbQuery( 'SHOW DATABASES LIKE \'' . $this->databaseName . '\'', function (): void { $this->assertFalse($this->isElementPresent('className', 'table_results')); }, ); $this->databaseName = $newDbName; } /** * Test for copying database * * @group large */ public function testCopyDb(): void { $this->getToDBOperations(); $this->reloadPage();// Reload or scrolling will not work .. $newDbName = $this->databaseName . 'copy'; $this->scrollIntoView('renameDbNameInput'); $this->byCssSelector('form#copy_db_form input[name=newname]') ->sendKeys($newDbName); $this->scrollIntoView('copy_db_form', -150); $this->byCssSelector('form#copy_db_form input[name="submit_copy"]')->click(); $this->waitForElement( 'xpath', "//div[@class='alert alert-success' and contains(., 'Database " . $this->databaseName . ' has been copied to ' . $newDbName . "')]", ); $this->dbQuery( 'SHOW DATABASES LIKE \'' . $newDbName . '\'', function () use ($newDbName): void { $this->assertTrue($this->isElementPresent('className', 'table_results')); $this->assertEquals($newDbName, $this->getCellByTableClass('table_results', 1, 1)); }, ); $this->dbQuery('DROP DATABASE `' . $newDbName . '`;'); } }