if (!is_dir("{$test_static_dir}/{$server['desc']}"))
mkdir("{$test_static_dir}/{$server['desc']}");
+ $fd = opendir($test_src_dir);
+ $files = array();
+ while ($file = readdir($fd))
+ if (($file != '.') && ($file != '..'))
+ $files[] = $file;
+ sort($files);
/* include the tests creator scripts here
* in the order you want them executed.
* Each script append itself to the TestSuite.html file.
**/
- require("{$test_src_dir}/roles.php");
- require("{$test_src_dir}/cleantests.php");
+ foreach ($files as $testgroupfile)
+ require("{$test_src_dir}/{$testgroupfile}");
}
/* close the TestSuite.html file */
--- /dev/null
+<?php
+ global $testsuite_file, $test_static_dir;
+
+ /*
+ * 1/ create test database with altered name and owner
+ * 2/ alter its owner
+ * 3/ alter its name, owner and comment back to normal
+ * NB: droping database is in the cleantests.php tests
+ */
+ $t = new TestBuilder("{$test_static_dir}/{$server['desc']}/database.html", $server['desc'],
+ 'Database tests',
+ 'Create and Alter database.'
+ );
+
+ $t->login($admin_user, $admin_user_pass);
+
+/** 1 **/
+ $t->clickAndWait("link={$lang['strdatabases']}");
+ $t->clickAndWait("link={$lang['strcreatedatabase']}");
+
+ /* db name */
+ if ($data->hasAlterDatabaseRename())
+ $t->type('formName', "{$testdb}toalter");
+ else $t->type('formName', $testdb);
+ /* encoding*/
+ $t->select('formEncoding', 'SQL_ASCII');
+ /* comment*/
+ if ($data->hasSharedComments())
+ $t->type('formComment', "database comment to alter");
+ /* create */
+ $t->clickAndWait("//input[@value='{$lang['strcreate']}']");
+ $t->assertText("//p[@class='message']", $lang['strdatabasecreated']);
+
+/** 2 **/
+ if ($data->hasAlterDatabaseOwner()) {
+ $t->clickAndWait("link={$lang['strdatabases']}");
+ /* we don't need to check if hasAlterDatabaseRename here because
+ * hasAlterDatabase is actually calling it */
+ $t->clickAndWait("//tr/td/a[text()='{$testdb}toalter']/../../td/a[text()='{$lang['stralter']}']");
+ if ($data->hasAlterDatabaseOwner())
+ $t->select('owner', $super_user[$server['desc']]);
+ $t->clickAndWait('alter');
+ $t->assertText("//p[@class='message']", $lang['strdatabasealtered']);
+ }
+
+/** 3 **/
+ if ($data->hasAlterDatabase()) {
+ $t->clickAndWait("link={$lang['strdatabases']}");
+ /* we don't need to check if hasAlterDatabaseRename here because
+ * hasAlterDatabase is actually calling it */
+ $t->clickAndWait("//tr/td/a[text()='{$testdb}toalter']/../../td/a[text()='{$lang['stralter']}']");
+ $t->type('newname', $testdb);
+ /* owner */
+ if ($data->hasAlterDatabaseOwner())
+ $t->select('owner', $admin_user);
+ /* comment */
+ if ($data->hasSharedComments())
+ $t->type('dbcomment', "database comment");
+ /* alter */
+ $t->clickAndWait('alter');
+ $t->assertText("//p[@class='message']", $lang['strdatabasealtered']);
+ }
+
+ $t->logout();
+ $t->writeTests($testsuite_file);
+ unset($t);
+?>
global $testsuite_file, $test_static_dir;
/*
- * 1/ login as admin_user
- * 2/ drop user role/user
+ * 1/ login as user and try to drop database -> fail
+ * 2/ logout / login as admin_user and drop user role/user
* 3/ try to drop himself -> fail
- * 4/ logout & login as superuser
- * 5/ drop admin_user
+ * 4/ drop test database
+ * 5/ logout & login as superuser and drop admin_user
*/
$t = new TestBuilder("{$test_static_dir}/{$server['desc']}/cleantests.html", $server['desc'],
'Cleaner tests',
'Clean every created stuff for test.'
);
- /* 1 */
- $t->login($admin_user, $admin_pass);
+/** 1 **/
+ $t->login($user, $user_pass);
+ $t->clickAndWait("link={$lang['strdatabases']}");
+ $t->clickAndWait("//tr/td/a[text()='{$testdb}']/../../td/a[text()='{$lang['strdrop']}']");
+ $t->clickAndWait('drop');
+ $t->assertText('//p[@class=\'message\']', $lang['strdatabasedroppedbad']);
- /* 2 */
+/** 2 **/
+ $t->logout();
+ $t->login($admin_user, $admin_pass);
if ($data->hasRoles()) {
$t->clickAndWait("link={$lang['strroles']}");
$t->clickAndWait("//tr/td/a[text()='{$user}']/../../td/a[text()='{$lang['strdrop']}']");
$t->assertText('//p[@class=\'message\']', $lang['struserdropped']);
}
- /* 3 */
+/** 3 **/
if ($data->hasRoles()) {
$t->clickAndWait("link={$lang['strroles']}");
$t->clickAndWait("link={$admin_user}");
$t->assertText('//p[@class=\'message\']', $lang['struserdroppedbad']);
}
- /* 4 */
+/** 4 **/
+ $t->clickAndWait("link={$lang['strdatabases']}");
+ $t->clickAndWait("//tr/td/a[text()='{$testdb}']/../../td/a[text()='{$lang['strdrop']}']");
+ $t->clickAndWait('drop');
+ $t->assertText('//p[@class=\'message\']', $lang['strdatabasedropped']);
+
+/** 5 **/
$t->logout();
$t->login($super_user[$server['desc']], $super_pass[$server['desc']]);
- /* 5 */
if ($data->hasRoles()) {
/* drop adminuser */
$t->clickAndWait("link={$lang['strroles']}");
public function logout() {
global $lang;
- $this->test('clickAndWait', "link={$lang['strlogout']}");
+ $this->test('clickAndWait', "//div[@class='trail']/descendant::tr/td[1]/a/span[@class='label' and text()='phpPgAdmin']");
+ $this->test('clickAndWait', "link={$lang['strservers']}");
+ $this->test('clickAndWait', "//tr/td/a[text()='{$this->servDesc}']/../../td/a[text()='{$lang['strlogout']}']");
+
$this->test('assertText', "//p[@class='message']",
sprintf($lang['strlogoutmsg'], $this->servDesc)
);
$this->test('type', $selector, $value);
}
+ /**
+ * Add a selenium select test to the file
+ * @param $selector the selector to select the object to work on (second column)
+ * @param $value (optional) the expected (or not) value (third column)
+ */
+ public function select($selector, $value) {
+ $this->test('select', $selector, $value);
+ }
+
/**
* Add a selenium click test to the file
* @param $selector the selector to select the object to work on (second column)