From 3c0c7c0da2e0c7fb6dd73106c396646f7dd1d3bc Mon Sep 17 00:00:00 2001 From: "Jehan-Guillaume (ioguix) de Rorthais" Date: Fri, 30 Dec 2011 00:36:12 +0100 Subject: [PATCH] Make selenium tests full dynamics, no more build_tests.php required. --- .gitignore | 2 - build_tests.php | 107 --------- intro.php | 2 +- libraries/errorhandler.inc.php | 3 +- tests/selenium/README | 49 ++-- tests/selenium/TestSuite.php | 52 +++++ tests/selenium/src/01-roles.php | 261 ++++++++++----------- tests/selenium/src/04-database.php | 129 ++++++----- tests/selenium/src/06-schema.php | 93 ++++---- tests/selenium/src/08-domaine.php | 218 +++++++++--------- tests/selenium/src/10-table.php | 333 ++++++++++++++------------- tests/selenium/src/15-sequence.php | 219 +++++++++--------- tests/selenium/src/20-constraint.php | 199 ++++++++-------- tests/selenium/src/25-column.php | 173 +++++++------- tests/selenium/src/30-view.php | 193 ++++++++-------- tests/selenium/src/35-index.php | 85 +++---- tests/selenium/src/99-cleantests.php | 257 +++++++++++---------- tests/selenium/src/skeleton.php-dist | 48 ++++ tests/selenium/testBuilder.class.php | 77 ++++--- 19 files changed, 1261 insertions(+), 1239 deletions(-) delete mode 100755 build_tests.php create mode 100755 tests/selenium/TestSuite.php create mode 100644 tests/selenium/src/skeleton.php-dist diff --git a/.gitignore b/.gitignore index d753bfab7..afa3529a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ selenium/tests/config.inc.php tests/selenium/config.test.php -tests/selenium/TestSuite.html -tests/selenium/static diff --git a/build_tests.php b/build_tests.php deleted file mode 100755 index d4de2960a..000000000 --- a/build_tests.php +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/php - - - Test suite for PPA - \n"); - fclose($fd); - - /* Loop on the servers given in the conf/config.inc.conf file */ - foreach ($conf['servers'] as $server) { - // Is this server in our list of configured servers? - if (!in_array($server['desc'],$test_servers)) - continue; - - /* connect to the server to get its version - * and test its feature along the tests */ - $_c = new Connection($server['host'], - $server['port'], - $server['sslmode'], - $super_user[$server['desc']], - $super_pass[$server['desc']], - $server['defaultdb'] - ); - - $_type = $data = null; - if (! $_c->conn->isConnected()) - die ("Connection to {$server['desc']} failed !\n"); - else { - if (($_type = $_c->getDriver($platform)) === null) { - die( printf($lang['strpostgresqlversionnotsupported'], $postgresqlMinVer)); - } - /* create the database handler we are going to use in the tests creator scripts */ - include_once('./classes/database/' . $_type . '.php'); - $data = new $_type($_c->conn); - $data->platform = $_c->platform; - } - - fprintf(STDERR, "Connected to %s...\n", $server['desc']); - - 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. - **/ - foreach ($files as $testgroupfile) - require("{$test_src_dir}/{$testgroupfile}"); - } - - /* close the TestSuite.html file */ - $fd = fopen($testsuite_file, 'a'); - fprintf($fd, ""); - fclose($fd); - - /* Tests ready to be runned on all your configured servers !!!! */ -?> diff --git a/intro.php b/intro.php index c2b2969bd..7f5c03973 100755 --- a/intro.php +++ b/intro.php @@ -62,7 +62,7 @@
  • -
  • Selenium tests
  • +
  • Selenium tests
  • has*() ones, throught the $data variable like -in any other ppa script. -1. how build_tests is working and why -The build_tests.php script is processing the test-builders scripts from ./tests/selenium/src in alphanumeric order. That's why each +Normaly, the selenium's statis HTML tests files cannot behave differently in regard to the PG backend where the tests are run on. In order to address +this issue we are using PHP scripts that connect to each backends using the PPA database classes and allow you to use their methods, +and especialy the $data->has*() ones, throught the $data variable like in any other ppa script. + +TestSuite.php is the test suite script that build the list of tests groups (top left frame). + +1. how TestSuite.php is working and why +TestSuite.php script is processing the test-builders scripts from ./tests/selenium/src in alphanumeric order. That's why each test-builder's name should follow these rules: begin with 2numeric number, then -, then the script name (ex. 01-test1.php or 46-test46.php). It allows to enforce the order the scripts will be run during the testSuite. This way, column's tests could be run *after* the table's tests @@ -29,30 +27,21 @@ in the test suite and use the previous created tables. 2. how test-builder are working -These scripts are included and executed in the build_tests.php in alphanumeric order. -They should: -- begin with the declaration of the global values $testsuite_file and $test_static_dir which holds the paths to the TestSuite file -and the static folder where the HTML tests files are created +These scripts are included and executed in TestSuite.php in alphanumeric order. See comments in file ./tests/selenium/src/skeleton.php-dist +which is a template of test-builder. +When executed from TestSuite.php, test-builders should: - create a "TestBuilder" intance which gonna helps write HTML tests quickly. The constructor takes the following arguments: - - server's label (from your config.inc.php) - HTML title of the page - Test description (appears on top of the tests table) - $t = new TestBuilder($server['desc'], - 'Index tests', + $t = new TestBuilder('Index tests', 'Create/Drop an unique Index' ); - once the TestBuilder instance is created, you can use it to write our tests. - - In particular, you should use the login($username, $pass) and logout() methods to create appropriate steps to login/logout to the current + - You should use the login($username, $pass) and logout() methods to create appropriate steps to login/logout to the current server. - Each selenium actions are mapped (or should be) as methods. As instance, if you want to use the clickAndWait action, you should call the clickAndWait($locator) method. For the assertText, assertText($selector, $value), etc... - Use the addComment method to show comments anywhere in the tests page. Usefull to explain whatthe next tests are going to do. - -- finish whith calling the TestBuilder's "writeTests" method which will create the selenium HTML test file in the static dir and append this -new test file to the testSuite file. - - $t->writeTests("{$test_static_dir}/{$server['desc']}/view.html", $testsuite_file); - diff --git a/tests/selenium/TestSuite.php b/tests/selenium/TestSuite.php new file mode 100755 index 000000000..0943503b7 --- /dev/null +++ b/tests/selenium/TestSuite.php @@ -0,0 +1,52 @@ +
    {$errmsg}
    \n"; + exit; + } + + $_no_db_connection = true; /* load lib.inc.php without trying to connect */ + + require_once('./libraries/lib.inc.php'); + require('./tests/selenium/config.test.php'); + require_once('./classes/database/Connection.php'); + + $test_dir = './tests/selenium'; + $test_src_dir = "{$test_dir}/src"; + + echo " + + + \n"; + + $servers = $misc->getServers(); + + /* Loop on the servers given in the conf/config.inc.conf file */ + foreach ($servers as $server) { + // Is this server in our list of configured servers? + if (!in_array($server['desc'], $test_servers)) + continue; + + $fd = opendir($test_src_dir); + $files = array(); + while ($file = readdir($fd)) + if (preg_match('@[0-9]+.*\.php$@', $file)) + $files[] = $file; + closedir($fd); + sort($files); + /* include the tests creator scripts here + * in the order you want them executed. + * Each script append itself to the TestSuite.html file. + **/ + foreach ($files as $testgroupfile) { + require("{$test_src_dir}/{$testgroupfile}"); + echo "\n"; + } + } + echo "
    Test suite for PPA
    [{$server['desc']}] {$test_title}
    "; +?> diff --git a/tests/selenium/src/01-roles.php b/tests/selenium/src/01-roles.php index cb1bb10f1..e15f1897e 100644 --- a/tests/selenium/src/01-roles.php +++ b/tests/selenium/src/01-roles.php @@ -1,144 +1,145 @@ fail - * 3/ create admin_user - * 4/ logout & login as admin_user - * 5/ create user role/user with altered name, pass and props - * 6/ alter user back to the normal value - * NB: droping role tests are in the cleantests.php tests - */ - $t = new TestBuilder($server['desc'], - 'Roles, Users and Groups tests', - 'Create test admin role, test user role and tests Roles (or user/groups) features.' - ); + if (isset($_GET['run'])) { + global $lang; + require('../config.test.php'); + require('../testBuilder.class.php'); + /* + * 1/ login as superuser + * 2/ create admin_user role/user with wrong pass conf -> fail + * 3/ create admin_user + * 4/ logout & login as admin_user + * 5/ create user role/user with altered name, pass and props + * 6/ alter user back to the normal value + * NB: droping role tests are in the cleantests.php tests + */ + $t = new TestBuilder($test_title, + 'Create test admin role, test user role and tests Roles (or user/groups) features.' + ); - /* 1 */ - $t->addComment('1. login as superuser'); - $t->login($super_user[$server['desc']], $super_pass[$server['desc']]); + /* 1 */ + $t->addComment('1. login as superuser'); + $t->login($super_user[$t->server['desc']], $super_pass[$t->server['desc']]); - /* 2 */ - $t->addComment('2. create admin_user role/user with wrong pass conf -> fail'); - if ($data->hasRoles()) { - $t->clickAndWait("link={$lang['strroles']}"); - $t->clickAndWait("link={$lang['strcreaterole']}"); - $t->type('formRolename', $admin_user); - $t->click('formCreateRole'); - $t->click('formInherits'); - $t->click('formCanLogin'); - } else { - $t->clickAndWait("link={$lang['strusers']}"); - $t->clickAndWait("link={$lang['strcreateuser']}"); - $t->type('formUsername', $admin_user); - } - $t->type('formPassword', "{$admin_user_pass}bad"); - $t->type('formConfirm', $admin_user_pass); - $t->click('formSuper'); - $t->click('formCreateDB'); - $t->clickAndWait('create'); - $t->assertText("//p[@class='message']", $lang['strpasswordconfirm']); + /* 2 */ + $t->addComment('2. create admin_user role/user with wrong pass conf -> fail'); + if ($t->data->hasRoles()) { + $t->clickAndWait("link={$lang['strroles']}"); + $t->clickAndWait("link={$lang['strcreaterole']}"); + $t->type('formRolename', $admin_user); + $t->click('formCreateRole'); + $t->click('formInherits'); + $t->click('formCanLogin'); + } else { + $t->clickAndWait("link={$lang['strusers']}"); + $t->clickAndWait("link={$lang['strcreateuser']}"); + $t->type('formUsername', $admin_user); + } + $t->type('formPassword', "{$admin_user_pass}bad"); + $t->type('formConfirm', $admin_user_pass); + $t->click('formSuper'); + $t->click('formCreateDB'); + $t->clickAndWait('create'); + $t->assertText("//p[@class='message']", $lang['strpasswordconfirm']); - /* 3 */ - $t->addComment('3. create admin_user'); - $t->type('formPassword', $admin_user_pass); - $t->type('formConfirm', $admin_user_pass); - $t->clickAndWait('create'); - if ($data->hasRoles()) - $t->assertText("//p[@class='message']", $lang['strrolecreated']); - else - $t->assertText("//p[@class='message']", $lang['strusercreated']); + /* 3 */ + $t->addComment('3. create admin_user'); + $t->type('formPassword', $admin_user_pass); + $t->type('formConfirm', $admin_user_pass); + $t->clickAndWait('create'); + if ($t->data->hasRoles()) + $t->assertText("//p[@class='message']", $lang['strrolecreated']); + else + $t->assertText("//p[@class='message']", $lang['strusercreated']); - /* 4 */ - $t->addComment('4. logout & login as admin_user'); - $t->logout(); - $t->login($admin_user, $admin_user_pass); + /* 4 */ + $t->addComment('4. logout & login as admin_user'); + $t->logout(); + $t->login($admin_user, $admin_user_pass); - /* 5 */ - $current_user="{$user}toalter"; - $t->addComment('5. create user role/user with altered name, pass and props'); - if ($data->hasRoles()) { - $t->clickAndWait("link={$lang['strroles']}"); - $t->clickAndWait("link={$lang['strcreaterole']}"); - $t->type('formRolename', "{$user}toalter"); - $t->check('formCanLogin'); - $t->check('formCreateRole'); // will be revert - $t->check('formInherits'); // will be revert - } else { - $t->clickAndWait("link={$lang['strusers']}"); - $t->clickAndWait("link={$lang['strcreateuser']}"); - if ($data->hasUserRename()) - $t->type('formUsername', "{$user}toalter"); + /* 5 */ + $current_user="{$user}toalter"; + $t->addComment('5. create user role/user with altered name, pass and props'); + if ($t->data->hasRoles()) { + $t->clickAndWait("link={$lang['strroles']}"); + $t->clickAndWait("link={$lang['strcreaterole']}"); + $t->type('formRolename', "{$user}toalter"); + $t->check('formCanLogin'); + $t->check('formCreateRole'); // will be revert + $t->check('formInherits'); // will be revert + } else { + $t->clickAndWait("link={$lang['strusers']}"); + $t->clickAndWait("link={$lang['strcreateuser']}"); + if ($t->data->hasUserRename()) + $t->type('formUsername', "{$user}toalter"); + else { + $t->type('formUsername', $user); + $current_user=$user; + } + } + $t->check('formSuper'); // will be revert + $t->check('formCreateDB'); // will be revert + $t->type('formPassword', "{$user_pass}toalter"); + $t->type('formConfirm', "{$user_pass}toalter"); + $t->clickAndWait('create'); + if ($t->data->hasRoles()) { + $t->assertText("//p[@class='message']", $lang['strrolecreated']); + $t->assertText("//tr/td/a[text()='{$user}toalter']", "{$user}toalter"); + $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[2]", $lang['stryes']);//super user ? + $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[3]", $lang['stryes']);//create db ? + $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[4]", $lang['stryes']); //create role + $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[5]", $lang['stryes']); //inherit + $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[6]", $lang['stryes']); //can login + } else { - $t->type('formUsername', $user); - $current_user=$user; + $t->assertText("//p[@class='message']", $lang['strusercreated']); + $t->assertText("//tr/td[text()='{$current_user}']", $current_user); + $t->assertText("//tr/td[text()='{$current_user}']/../td[2]", $lang['stryes']);//super user ? + $t->assertText("//tr/td[text()='{$current_user}']/../td[3]", $lang['stryes']);//create db ? } - } - $t->check('formSuper'); // will be revert - $t->check('formCreateDB'); // will be revert - $t->type('formPassword', "{$user_pass}toalter"); - $t->type('formConfirm', "{$user_pass}toalter"); - $t->clickAndWait('create'); - if ($data->hasRoles()) { - $t->assertText("//p[@class='message']", $lang['strrolecreated']); - $t->assertText("//tr/td/a[text()='{$user}toalter']", "{$user}toalter"); - $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[2]", $lang['stryes']);//super user ? - $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[3]", $lang['stryes']);//create db ? - $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[4]", $lang['stryes']); //create role - $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[5]", $lang['stryes']); //inherit - $t->assertText("//tr/td/a[text()='{$user}toalter']/../../td[6]", $lang['stryes']); //can login - } - else { - $t->assertText("//p[@class='message']", $lang['strusercreated']); - $t->assertText("//tr/td[text()='{$current_user}']", $current_user); - $t->assertText("//tr/td[text()='{$current_user}']/../td[2]", $lang['stryes']);//super user ? - $t->assertText("//tr/td[text()='{$current_user}']/../td[3]", $lang['stryes']);//create db ? - } - /* 6 */ - $t->addComment('6. alter user back to the normal value'); - if ($data->hasRoles()) { - $t->clickAndWait("link={$lang['strroles']}"); - $t->clickAndWait("link={$user}toalter"); - $t->clickAndWait("link={$lang['stralter']}"); - $t->type('formNewRoleName', $user); - $t->uncheck('formCreateRole'); // revert - $t->uncheck('formInherits'); // revert - } else { - $t->clickAndWait("link={$lang['strusers']}"); - if ($data->hasUserRename()) { - $t->clickAndWait("//tr/td[text()='{$user}toalter']/../td/a[text()='{$lang['stralter']}']"); - $t->type('newname', $user); + /* 6 */ + $t->addComment('6. alter user back to the normal value'); + if ($t->data->hasRoles()) { + $t->clickAndWait("link={$lang['strroles']}"); + $t->clickAndWait("link={$user}toalter"); + $t->clickAndWait("link={$lang['stralter']}"); + $t->type('formNewRoleName', $user); + $t->uncheck('formCreateRole'); // revert + $t->uncheck('formInherits'); // revert + } else { + $t->clickAndWait("link={$lang['strusers']}"); + if ($t->data->hasUserRename()) { + $t->clickAndWait("//tr/td[text()='{$user}toalter']/../td/a[text()='{$lang['stralter']}']"); + $t->type('newname', $user); + } + else + $t->clickAndWait("//tr/td[text()='{$user}']/../td/a[text()='{$lang['stralter']}']"); + } + $t->uncheck('formSuper'); // revert + $t->uncheck('formCreateDB'); // revert + $t->type('formPassword', $user_pass); + $t->type('formConfirm', $user_pass); + $t->clickAndWait('alter'); + if ($t->data->hasRoles()) { + $t->assertText("//p[@class='message']", $lang['strrolealtered']); + $t->assertText("//tr/td/a[text()='{$user}']", $user); + $t->assertText("//tr/td/a[text()='{$user}']/../../td[2]", $lang['strno']);//super user ? + $t->assertText("//tr/td/a[text()='{$user}']/../../td[3]", $lang['strno']);//create db ? + $t->assertText("//tr/td/a[text()='{$user}']/../../td[4]", $lang['strno']); //create role + $t->assertText("//tr/td/a[text()='{$user}']/../../td[5]", $lang['strno']); //inherit + $t->assertText("//tr/td/a[text()='{$user}']/../../td[6]", $lang['stryes']); //can login + } + else { + $t->assertText("//p[@class='message']", $lang['struserupdated']); + $t->assertText("//tr/td[text()='{$user}']/../td[2]", $lang['strno']);//super user ? + $t->assertText("//tr/td[text()='{$user}']/../td[3]", $lang['strno']);//create db ? + $t->assertText("//p[@class='message']", $lang['struserupdated']); } - else - $t->clickAndWait("//tr/td[text()='{$user}']/../td/a[text()='{$lang['stralter']}']"); - } - $t->uncheck('formSuper'); // revert - $t->uncheck('formCreateDB'); // revert - $t->type('formPassword', $user_pass); - $t->type('formConfirm', $user_pass); - $t->clickAndWait('alter'); - if ($data->hasRoles()) { - $t->assertText("//p[@class='message']", $lang['strrolealtered']); - $t->assertText("//tr/td/a[text()='{$user}']", $user); - $t->assertText("//tr/td/a[text()='{$user}']/../../td[2]", $lang['strno']);//super user ? - $t->assertText("//tr/td/a[text()='{$user}']/../../td[3]", $lang['strno']);//create db ? - $t->assertText("//tr/td/a[text()='{$user}']/../../td[4]", $lang['strno']); //create role - $t->assertText("//tr/td/a[text()='{$user}']/../../td[5]", $lang['strno']); //inherit - $t->assertText("//tr/td/a[text()='{$user}']/../../td[6]", $lang['stryes']); //can login - } - else { - $t->assertText("//p[@class='message']", $lang['struserupdated']); - $t->assertText("//tr/td[text()='{$user}']/../td[2]", $lang['strno']);//super user ? - $t->assertText("//tr/td[text()='{$user}']/../td[3]", $lang['strno']);//create db ? - $t->assertText("//p[@class='message']", $lang['struserupdated']); - } - - $t->logout(); - - $t->writeTests("{$test_static_dir}/{$server['desc']}/roles.html", $testsuite_file); - unset($t); + $t->logout(); + unset($t); + } ?> diff --git a/tests/selenium/src/04-database.php b/tests/selenium/src/04-database.php index ad156bbc8..0b1fe8f33 100644 --- a/tests/selenium/src/04-database.php +++ b/tests/selenium/src/04-database.php @@ -1,72 +1,75 @@ login($admin_user, $admin_user_pass); + $t->login($admin_user, $admin_user_pass); -/** 1 **/ - $t->addComment('1. create test database with altered name and owner'); - $t->clickAndWait("link={$lang['strdatabases']}"); - $t->clickAndWait("link={$lang['strcreatedatabase']}"); + /** 1 **/ + $t->addComment('1. create test database with altered name and owner'); + $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); - /* template */ - $t->select('formTemplate', 'template0'); - /* 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']); + /* db name */ + if ($t->data->hasAlterDatabaseRename()) + $t->type('formName', "{$testdb}toalter"); + else $t->type('formName', $testdb); + /* template */ + $t->select('formTemplate', 'template0'); + /* encoding*/ + $t->select('formEncoding', 'SQL_ASCII'); + /* comment*/ + if ($t->data->hasSharedComments()) + $t->type('formComment', "database comment to alter"); + /* create */ + $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); + $t->assertText("//p[@class='message']", $lang['strdatabasecreated']); -/** 2 **/ - $t->addComment('2. alter DB\'s owner'); - 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']); - } + /** 2 **/ + $t->addComment('2. alter DB\'s owner'); + if ($t->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 ($t->data->hasAlterDatabaseOwner()) + $t->select('owner', $super_user[$t->server['desc']]); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strdatabasealtered']); + } -/** 3 **/ - $t->addComment('3. alter DB\'s name, owner and comment back to normal'); - 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']); - } + /** 3 **/ + $t->addComment('3. alter DB\'s name, owner and comment back to normal'); + if ($t->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 ($t->data->hasAlterDatabaseOwner()) + $t->select('owner', $admin_user); + /* comment */ + if ($t->data->hasSharedComments()) + $t->type('dbcomment', "database comment"); + /* alter */ + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strdatabasealtered']); + } - $t->logout(); - $t->writeTests("{$test_static_dir}/{$server['desc']}/database.html", $testsuite_file); - unset($t); + $t->logout(); + unset($t); + } ?> diff --git a/tests/selenium/src/06-schema.php b/tests/selenium/src/06-schema.php index c92fc848d..de1616253 100644 --- a/tests/selenium/src/06-schema.php +++ b/tests/selenium/src/06-schema.php @@ -1,52 +1,55 @@ login($admin_user, $admin_user_pass); + $t->login($admin_user, $admin_user_pass); -/** 1 **/ - $t->addComment('1. create test schema'); - $t->clickAndWait("link={$lang['strdatabases']}"); - $t->clickAndWait("link={$testdb}"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link={$lang['strcreateschema']}"); - if ($data->hasAlterSchema()) { - $t->type('formName', 'test_schema_toalter'); - if ($data->hasAlterSchemaOwner()) - $t->select('formAuth', $super_user[$server['desc']]); - else $t->select('formAuth', $admin_user); - $t->type('formComment', 'test schema comment to alter'); - } - else { - $t->type('formName', 'test_schema'); - $t->type('formComment', 'test schema comment'); - } - $t->clickAndWait('create'); - $t->assertText('//p[@class=\'message\']', $lang['strschemacreated']); - -/** 2 **/ - $t->addComment('2. alter schema\'s name, owner and comment'); - if ($data->hasAlterSchema()) { + /** 1 **/ + $t->addComment('1. create test schema'); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("//tr/td/a[text()='test_schema_toalter']/../../td/a[text()='{$lang['stralter']}']"); - $t->type('name', 'test_schema'); - if ($data->hasAlterSchemaOwner()) - $t->select('owner', $admin_user); - $t->type('comment', 'test schema'); - $t->clickAndWait('alter'); - $t->assertText('//p[@class=\'message\']', $lang['strschemaaltered']); + $t->clickAndWait("link={$lang['strcreateschema']}"); + if ($t->data->hasAlterSchema()) { + $t->type('formName', 'test_schema_toalter'); + if ($t->data->hasAlterSchemaOwner()) + $t->select('formAuth', $super_user[$t->server['desc']]); + else $t->select('formAuth', $admin_user); + $t->type('formComment', 'test schema comment to alter'); + } + else { + $t->type('formName', 'test_schema'); + $t->type('formComment', 'test schema comment'); + } + $t->clickAndWait('create'); + $t->assertText('//p[@class=\'message\']', $lang['strschemacreated']); + + /** 2 **/ + $t->addComment('2. alter schema\'s name, owner and comment'); + if ($t->data->hasAlterSchema()) { + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("//tr/td/a[text()='test_schema_toalter']/../../td/a[text()='{$lang['stralter']}']"); + $t->type('name', 'test_schema'); + if ($t->data->hasAlterSchemaOwner()) + $t->select('owner', $admin_user); + $t->type('comment', 'test schema'); + $t->clickAndWait('alter'); + $t->assertText('//p[@class=\'message\']', $lang['strschemaaltered']); + } + + $t->logout(); + unset($t); } - - $t->logout(); - $t->writeTests("{$test_static_dir}/{$server['desc']}/schema.html", $testsuite_file); - unset($t); ?> diff --git a/tests/selenium/src/08-domaine.php b/tests/selenium/src/08-domaine.php index 9f197abb6..5d9a65fed 100644 --- a/tests/selenium/src/08-domaine.php +++ b/tests/selenium/src/08-domaine.php @@ -1,118 +1,120 @@ login($admin_user, $admin_user_pass); + $t->login($admin_user, $admin_user_pass); -/** 1 **/ - $t->addComment('1. create domain'); - $t->clickAndWait("link={$lang['strdatabases']}"); - $t->clickAndWait("link={$testdb}"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=test_schema"); - $t->clickAndWait("link={$lang['strdomains']}"); - $t->clickAndWait("link={$lang['strcreatedomain']}"); - $t->type('domname', 'year'); - $t->select('domtype', 'label=integer'); - if ($data->hasAlterDomains()) { - $t->type('domdefault', '1900'); - $t->click('domnotnull'); - } - else - $t->type('domdefault', 'extract(year from current_date)'); - - if ($data->hasDomainConstraints()) - $t->type('domcheck', 'VALUE >= 1901 AND VALUE <= 2155'); - $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); - $t->assertText("//p[@class='message']", $lang['strdomaincreated']); - $t->assertText("//tr/td/a[text()='year']", 'year'); - $t->assertText("//tr/td/a[text()='year']/../../td[2]", 'integer'); - if ($data->hasAlterDomains()) { - $t->assertText("//tr/td/a[text()='year']/../../td[3]/div", 'NOT NULL'); - $t->assertText("//tr/td/a[text()='year']/../../td[4]", '1900'); - - } - /* we doesn't test default as Postgres change it with internal methods */ - //else - // $t->assertText("//tr/td/a[text()='year']/../../td[4]", 'extract(year from current_date)'); - $t->assertText("//tr/td/a[text()='year']/../../td[5]", $admin_user); - if ($data->hasDomainConstraints()) { - $t->clickAndWait("link=year"); - if ($data->major_version == '7.4') - $t->assertText("//tr/td[text()='$1']/../td[2]", 'CHECK (VALUE >= 1901 AND VALUE <= 2155)'); - else - $t->assertText("//tr/td[text()='year_check']/../td[2]", 'CHECK (VALUE >= 1901 AND VALUE <= 2155)'); - } - -/** 2 **/ - $t->addComment('2. add unwanted domain constraint'); - if ($data->hasDomainConstraints()) { - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); + /** 1 **/ + $t->addComment('1. create domain'); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("link=test_schema"); $t->clickAndWait("link={$lang['strdomains']}"); - $t->clickAndWait("link=year"); - $t->clickAndWait("//a[text()='{$lang['straddcheck']}']"); - $t->type('name', 'test_to_drop'); - $t->type('definition', 'VALUE > 1900'); - $t->clickAndWait('add'); - $t->assertText("//p[@class='message']", $lang['strcheckadded']); - $t->assertText("//tr/td[text()='test_to_drop']/../td[2]", 'CHECK (VALUE > 1900)'); - } - -/** 3 **/ - $t->addComment('3. drop unwanted check constraint on domain'); - if ($data->hasDomainConstraints()) { - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); - $t->clickAndWait("link={$lang['strdomains']}"); - $t->clickAndWait("link=year"); - $t->clickAndWait("//tr/td[text()='test_to_drop']/../td/a[text()='{$lang['strdrop']}']"); - $str = sprintf($lang['strconfdropconstraint'], 'test_to_drop', 'year'); - $t->assertText("//p[text()='$str']", sprintf($lang['strconfdropconstraint'], 'test_to_drop', 'year')); - $t->clickAndWait('drop'); - $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); - } + $t->clickAndWait("link={$lang['strcreatedomain']}"); + $t->type('domname', 'year'); + $t->select('domtype', 'label=integer'); + if ($t->data->hasAlterDomains()) { + $t->type('domdefault', '1900'); + $t->click('domnotnull'); + } + else + $t->type('domdefault', 'extract(year from current_date)'); -/** 4 **/ - $t->addComment('4. alter domain giving owner to super_user'); - if ($data->hasAlterDomains()) { - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); - $t->clickAndWait("link={$lang['strdomains']}"); - $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['stralter']}']"); - $t->click('domnotnull'); - $t->type('domdefault', 'extract(year from current_date)'); - $t->select('domowner', $super_user[$server['desc']]); - $t->clickAndWait('alter'); - $t->assertText("//p[@class='message']", $lang['strdomainaltered']); - $t->assertText("//tr/th[text()='{$lang['strnotnull']}']/../td", ''); + if ($t->data->hasDomainConstraints()) + $t->type('domcheck', 'VALUE >= 1901 AND VALUE <= 2155'); + $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); + $t->assertText("//p[@class='message']", $lang['strdomaincreated']); + $t->assertText("//tr/td/a[text()='year']", 'year'); + $t->assertText("//tr/td/a[text()='year']/../../td[2]", 'integer'); + if ($t->data->hasAlterDomains()) { + $t->assertText("//tr/td/a[text()='year']/../../td[3]/div", 'NOT NULL'); + $t->assertText("//tr/td/a[text()='year']/../../td[4]", '1900'); + } /* we doesn't test default as Postgres change it with internal methods */ - //$t->assertText("//tr/th[text()='{$lang['strdefault']}']/../td", 'extract(year from current_date)'); - $t->assertText("//tr/th[text()='{$lang['strowner']}']/../td", $super_user[$server['desc']]); - } + //else + // $t->assertText("//tr/td/a[text()='year']/../../td[4]", 'extract(year from current_date)'); + $t->assertText("//tr/td/a[text()='year']/../../td[5]", $admin_user); + if ($t->data->hasDomainConstraints()) { + $t->clickAndWait("link=year"); + if ($t->data->major_version == '7.4') + $t->assertText("//tr/td[text()='$1']/../td[2]", 'CHECK (VALUE >= 1901 AND VALUE <= 2155)'); + else + $t->assertText("//tr/td[text()='year_check']/../td[2]", 'CHECK (VALUE >= 1901 AND VALUE <= 2155)'); + } -/** 5 **/ - $t->addComment('5. alter back the owner to admin_user'); - if ($data->hasAlterDomains()) { - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); - $t->clickAndWait("link={$lang['strdomains']}"); - $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['stralter']}']"); - $t->select('domowner', $admin_user); - $t->clickAndWait('alter'); - $t->assertText("//p[@class='message']", $lang['strdomainaltered']); - $t->assertText("//tr/th[text()='{$lang['strowner']}']/../td", $admin_user); + /** 2 **/ + $t->addComment('2. add unwanted domain constraint'); + if ($t->data->hasDomainConstraints()) { + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); + $t->clickAndWait("link={$lang['strdomains']}"); + $t->clickAndWait("link=year"); + $t->clickAndWait("//a[text()='{$lang['straddcheck']}']"); + $t->type('name', 'test_to_drop'); + $t->type('definition', 'VALUE > 1900'); + $t->clickAndWait('add'); + $t->assertText("//p[@class='message']", $lang['strcheckadded']); + $t->assertText("//tr/td[text()='test_to_drop']/../td[2]", 'CHECK (VALUE > 1900)'); + } + + /** 3 **/ + $t->addComment('3. drop unwanted check constraint on domain'); + if ($t->data->hasDomainConstraints()) { + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); + $t->clickAndWait("link={$lang['strdomains']}"); + $t->clickAndWait("link=year"); + $t->clickAndWait("//tr/td[text()='test_to_drop']/../td/a[text()='{$lang['strdrop']}']"); + $str = sprintf($lang['strconfdropconstraint'], 'test_to_drop', 'year'); + $t->assertText("//p[text()='$str']", sprintf($lang['strconfdropconstraint'], 'test_to_drop', 'year')); + $t->clickAndWait('drop'); + $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); + } + + /** 4 **/ + $t->addComment('4. alter domain giving owner to super_user'); + if ($t->data->hasAlterDomains()) { + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); + $t->clickAndWait("link={$lang['strdomains']}"); + $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['stralter']}']"); + $t->click('domnotnull'); + $t->type('domdefault', 'extract(year from current_date)'); + $t->select('domowner', $super_user[$t->server['desc']]); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strdomainaltered']); + $t->assertText("//tr/th[text()='{$lang['strnotnull']}']/../td", ''); + /* we doesn't test default as Postgres change it with internal methods */ + //$t->assertText("//tr/th[text()='{$lang['strdefault']}']/../td", 'extract(year from current_date)'); + $t->assertText("//tr/th[text()='{$lang['strowner']}']/../td", $super_user[$t->server['desc']]); + } + + /** 5 **/ + $t->addComment('5. alter back the owner to admin_user'); + if ($t->data->hasAlterDomains()) { + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); + $t->clickAndWait("link={$lang['strdomains']}"); + $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['stralter']}']"); + $t->select('domowner', $admin_user); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strdomainaltered']); + $t->assertText("//tr/th[text()='{$lang['strowner']}']/../td", $admin_user); + } + + $t->logout(); + unset($t); } - - $t->logout(); - $t->writeTests("{$test_static_dir}/{$server['desc']}/domain.html", $testsuite_file); - unset($t); ?> diff --git a/tests/selenium/src/10-table.php b/tests/selenium/src/10-table.php index 37675bdb4..dc680bfc1 100644 --- a/tests/selenium/src/10-table.php +++ b/tests/selenium/src/10-table.php @@ -1,195 +1,198 @@ login($admin_user, $admin_user_pass); + $t->login($admin_user, $admin_user_pass); -/** 1 **/ - $t->addComment('1. create a table student in public'); - $t->clickAndWait("link={$lang['strdatabases']}"); - $t->clickAndWait("link={$testdb}"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=public"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("link={$lang['strcreatetable']}"); - $t->type('name','student'); - $t->type('fields', '5'); - $t->type('tblcomment', 'student table'); - $t->clickAndWait("//input[@value='{$lang['strnext']}']"); - $t->type('field[0]', 'id'); - $t->select('types0', 'label=SERIAL'); - $t->click('primarykey[0]'); - $t->type('field[1]', 'id_promo'); - $t->select('types1', 'label=integer'); - $t->type('field[2]', 'name'); - $t->select('types2', 'label=character varying'); - $t->type('lengths2', '20'); - $t->click('notnull[2]'); - $t->type('field[3]', 'birthday'); - $t->select('types3', 'label=date'); - $t->type('field[4]', 'resume'); - $t->select('types4', 'label=text'); - $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); - $t->assertText("//p[@class='message']", $lang['strtablecreated']); - -/** 2 **/ - $t->addComment('2. create table promo in test_schema'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=test_schema"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("link={$lang['strcreatetable']}"); - $t->type('name', 'promo'); - $t->type('fields', '3'); - $t->type('tblcomment', 'promotion\'s year & speciality'); - $t->clickAndWait("//input[@value='Next >']"); - $t->type('field[0]', 'id'); - $t->select('types0', 'label=SERIAL'); - $t->click('primarykey[0]'); - $t->type('field[1]', 'spe'); - $t->select('types1', 'label=character varying'); - $t->type('lengths1','20'); - $t->click('notnull[1]'); - $t->type('field[2]', 'year'); - $t->select('types2', "label=regexp:\"?year\"?"); // 8.3 does not quote domains - $t->click('notnull[2]'); - $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); - $t->assertText("//p[@class='message']", $lang['strtablecreated']); - -/** 3 **/ - $t->addComment('3. create table like student in test_schema'); - if ($data->hasCreateTableLike()) { - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); + /** 1 **/ + $t->addComment('1. create a table student in public'); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=test_schema"); + $t->clickAndWait("link=public"); $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("link={$lang['strcreatetablelike']}"); - $t->type('name', 'test_toalter'); - $t->select('like','label="public"."student"'); - $t->click('withdefaults'); - if ($data->hasCreateTableLikeWithConstraints()) - $t->click('withconstraints'); - if ($data->hasCreateTableLikeWithIndexes()) - $t->click('withindexes'); + $t->clickAndWait("link={$lang['strcreatetable']}"); + $t->type('name','student'); + $t->type('fields', '5'); + $t->type('tblcomment', 'student table'); + $t->clickAndWait("//input[@value='{$lang['strnext']}']"); + $t->type('field[0]', 'id'); + $t->select('types0', 'label=SERIAL'); + $t->click('primarykey[0]'); + $t->type('field[1]', 'id_promo'); + $t->select('types1', 'label=integer'); + $t->type('field[2]', 'name'); + $t->select('types2', 'label=character varying'); + $t->type('lengths2', '20'); + $t->click('notnull[2]'); + $t->type('field[3]', 'birthday'); + $t->select('types3', 'label=date'); + $t->type('field[4]', 'resume'); + $t->select('types4', 'label=text'); $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); $t->assertText("//p[@class='message']", $lang['strtablecreated']); - } - else { - /*no create like ? create it anyway for the next steps*/ + + /** 2 **/ + $t->addComment('2. create table promo in test_schema'); $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); $t->clickAndWait("link={$lang['strschemas']}"); $t->clickAndWait("link=test_schema"); $t->clickAndWait("link={$lang['strtables']}"); $t->clickAndWait("link={$lang['strcreatetable']}"); - $t->type('name','test_toalter'); - $t->type('fields', '1'); - $t->type('tblcomment', 'test table'); - $t->clickAndWait("//input[@value='{$lang['strnext']}']"); + $t->type('name', 'promo'); + $t->type('fields', '3'); + $t->type('tblcomment', 'promotion\'s year & speciality'); + $t->clickAndWait("//input[@value='Next >']"); $t->type('field[0]', 'id'); $t->select('types0', 'label=SERIAL'); $t->click('primarykey[0]'); + $t->type('field[1]', 'spe'); + $t->select('types1', 'label=character varying'); + $t->type('lengths1','20'); + $t->click('notnull[1]'); + $t->type('field[2]', 'year'); + $t->select('types2', "label=regexp:\"?year\"?"); // 8.3 does not quote domains + $t->click('notnull[2]'); $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); $t->assertText("//p[@class='message']", $lang['strtablecreated']); - } -/** 4 **/ - $t->addComment('4. alter each param one by one on test_toalter'); - /*table name*/ - $t->addComment('4.1. alter table name'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=test_schema"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("link=test_toalter"); - $t->clickAndWait("link={$lang['strcolumns']}"); /*alter using the link in the column page*/ - $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); - $t->type('name', 'test_renamed'); - $t->clickAndWait('alter'); - $t->assertText("//p[@class='message']", $lang['strtablealtered']); - $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label']", 'test_renamed'); + /** 3 **/ + $t->addComment('3. create table like student in test_schema'); + if ($t->data->hasCreateTableLike()) { + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("link=test_schema"); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait("link={$lang['strcreatetablelike']}"); + $t->type('name', 'test_toalter'); + $t->select('like','label="public"."student"'); + $t->click('withdefaults'); + if ($t->data->hasCreateTableLikeWithConstraints()) + $t->click('withconstraints'); + if ($t->data->hasCreateTableLikeWithIndexes()) + $t->click('withindexes'); + $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); + $t->assertText("//p[@class='message']", $lang['strtablecreated']); + } + else { + /*no create like ? create it anyway for the next steps*/ + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("link=test_schema"); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait("link={$lang['strcreatetable']}"); + $t->type('name','test_toalter'); + $t->type('fields', '1'); + $t->type('tblcomment', 'test table'); + $t->clickAndWait("//input[@value='{$lang['strnext']}']"); + $t->type('field[0]', 'id'); + $t->select('types0', 'label=SERIAL'); + $t->click('primarykey[0]'); + $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); + $t->assertText("//p[@class='message']", $lang['strtablecreated']); + } - /*table comment*/ - $t->addComment('4.2. alter table comment'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=test_schema"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("link=test_renamed"); - $t->clickAndWait("link={$lang['strcolumns']}"); /*alter using the link in the column page*/ - $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); - $t->type('comment', 'altered comment'); - $t->clickAndWait('alter'); - $t->assertText("//p[@class='message']", $lang['strtablealtered']); - $t->assertText("//p[@class='comment']", 'altered comment'); - - /*table owner*/ - $t->addComment('4.3. alter table owner'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=test_schema"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("//tr/td/a[text()='test_renamed']/../../td/a[text()='{$lang['stralter']}']"); /*alter using the link in the table list page*/ - $t->select('owner', "label={$user}"); - $t->clickAndWait('alter'); - $t->assertText("//p[@class='message']", $lang['strtablealtered']); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->assertText("//tr/td[2]/a[text()='test_renamed']/../../td[3]", $user); - - /*alter schema*/ - if ($data->hasAlterTableSchema()) { - $t->addComment('4.4. alter table schema'); + /** 4 **/ + $t->addComment('4. alter each param one by one on test_toalter'); + /*table name*/ + $t->addComment('4.1. alter table name'); $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); $t->clickAndWait("link={$lang['strschemas']}"); $t->clickAndWait("link=test_schema"); $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("//tr/td/a[text()='test_renamed']/../../td/a[text()='{$lang['stralter']}']"); /*alter using the link in the table list page*/ - $t->select('newschema', 'label=public'); + $t->clickAndWait("link=test_toalter"); + $t->clickAndWait("link={$lang['strcolumns']}"); /*alter using the link in the column page*/ + $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); + $t->type('name', 'test_renamed'); $t->clickAndWait('alter'); $t->assertText("//p[@class='message']", $lang['strtablealtered']); - $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'public'); - } + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label']", 'test_renamed'); -/** 5 **/ - $t->addComment('5. alter back test_toalter in one step'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); - $t->clickAndWait("link={$lang['strschemas']}"); - if ($data->hasAlterTableSchema()) - $t->clickAndWait("link=public"); - else + /*table comment*/ + $t->addComment('4.2. alter table comment'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); + $t->clickAndWait("link={$lang['strschemas']}"); $t->clickAndWait("link=test_schema"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("link=test_renamed"); - $t->clickAndWait("link={$lang['strcolumns']}"); - $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); - $t->type('name', 'test'); - - $t->type('comment', 'normal comment'); - if ($data->hasAlterTableSchema()) - $t->select('newschema', 'label=test_schema'); - $t->select('owner', "label={$admin_user}"); - $t->clickAndWait('alter'); - $t->assertText("//p[@class='message']", $lang['strtablealtered']); - $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label']", 'test'); - $t->assertText("//p[@class='comment']", 'normal comment'); - $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'test_schema'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->assertText("//tr/td[2]/a[text()='test']/../../td[3]", $admin_user); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait("link=test_renamed"); + $t->clickAndWait("link={$lang['strcolumns']}"); /*alter using the link in the column page*/ + $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); + $t->type('comment', 'altered comment'); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strtablealtered']); + $t->assertText("//p[@class='comment']", 'altered comment'); + + /*table owner*/ + $t->addComment('4.3. alter table owner'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("link=test_schema"); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait("//tr/td/a[text()='test_renamed']/../../td/a[text()='{$lang['stralter']}']"); /*alter using the link in the table list page*/ + $t->select('owner', "label={$user}"); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strtablealtered']); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); + $t->clickAndWait("link={$lang['strtables']}"); + $t->assertText("//tr/td[2]/a[text()='test_renamed']/../../td[3]", $user); - $t->logout(); - $t->writeTests("{$test_static_dir}/{$server['desc']}/table.html", $testsuite_file); - unset($t); + /*alter schema*/ + if ($t->data->hasAlterTableSchema()) { + $t->addComment('4.4. alter table schema'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("link=test_schema"); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait("//tr/td/a[text()='test_renamed']/../../td/a[text()='{$lang['stralter']}']"); /*alter using the link in the table list page*/ + $t->select('newschema', 'label=public'); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strtablealtered']); + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'public'); + } + + /** 5 **/ + $t->addComment('5. alter back test_toalter in one step'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); + $t->clickAndWait("link={$lang['strschemas']}"); + if ($t->data->hasAlterTableSchema()) + $t->clickAndWait("link=public"); + else + $t->clickAndWait("link=test_schema"); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait("link=test_renamed"); + $t->clickAndWait("link={$lang['strcolumns']}"); + $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); + $t->type('name', 'test'); + + $t->type('comment', 'normal comment'); + if ($t->data->hasAlterTableSchema()) + $t->select('newschema', 'label=test_schema'); + $t->select('owner', "label={$admin_user}"); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strtablealtered']); + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label']", 'test'); + $t->assertText("//p[@class='comment']", 'normal comment'); + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'test_schema'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); + $t->clickAndWait("link={$lang['strtables']}"); + $t->assertText("//tr/td[2]/a[text()='test']/../../td[3]", $admin_user); + + $t->logout(); + unset($t); + } ?> diff --git a/tests/selenium/src/15-sequence.php b/tests/selenium/src/15-sequence.php index 731bd21f7..63cf70b25 100644 --- a/tests/selenium/src/15-sequence.php +++ b/tests/selenium/src/15-sequence.php @@ -1,119 +1,122 @@ login($admin_user, $admin_user_pass); + $t->login($admin_user, $admin_user_pass); -/** 1 **/ - $t->addComment('1. Create a sequence'); - $t->clickAndWait("link={$lang['strdatabases']}"); - $t->clickAndWait("link={$testdb}"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait('link=public'); - $t->clickAndWait("link={$lang['strsequences']}"); - $t->clickAndWait("link={$lang['strcreatesequence']}"); - $t->type('formSequenceName', 'testcase_seq'); - $t->type('formIncrement', '2'); - $t->type('formMinValue', '1'); - $t->type('formMaxValue', '100'); - $t->type('formStartValue', '1'); - $t->type('formCacheValue', '1'); - $t->click('formCycledValue'); - $t->clickAndWait('create'); - $t->assertText("//p[@class='message']", $lang['strsequencecreated']); - $t->clickAndWait('link=testcase_seq'); - $t->assertText("//tr/th[text()='{$lang['strname']}' and @class='data']/../../tr/td[1]", 'testcase_seq'); - $i=2; - $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '1'); - if ($data->hasAlterSequenceStart()) + /** 1 **/ + $t->addComment('1. Create a sequence'); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait('link=public'); + $t->clickAndWait("link={$lang['strsequences']}"); + $t->clickAndWait("link={$lang['strcreatesequence']}"); + $t->type('formSequenceName', 'testcase_seq'); + $t->type('formIncrement', '2'); + $t->type('formMinValue', '1'); + $t->type('formMaxValue', '100'); + $t->type('formStartValue', '1'); + $t->type('formCacheValue', '1'); + $t->click('formCycledValue'); + $t->clickAndWait('create'); + $t->assertText("//p[@class='message']", $lang['strsequencecreated']); + $t->clickAndWait('link=testcase_seq'); + $t->assertText("//tr/th[text()='{$lang['strname']}' and @class='data']/../../tr/td[1]", 'testcase_seq'); + $i=2; $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '1'); - $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '2'); - $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '100'); - $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '1'); - $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '1'); - $i++; // we ignore log_count - $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i ."]", $lang['stryes']); + if ($t->data->hasAlterSequenceStart()) + $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '1'); + $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '2'); + $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '100'); + $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '1'); + $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i++ ."]", '1'); + $i++; // we ignore log_count + $t->assertText("//tr/td[text()='testcase_seq']/../td[". $i ."]", $lang['stryes']); -/** 2 **/ - $t->addComment('2. increment, reset sequence and set value'); - $t->clickAndWait("link={$lang['strsetval']}"); - $t->type('nextvalue', '2'); - $t->clickAndWait('setval'); - $t->assertText("//p[@class='message']", $lang['strsequencesetval']); - if ($data->hasAlterSequenceStart()) $i = 3; - else $i = 2; - $t->assertText("//tr/td[text()='testcase_seq']/../td[$i]", '2'); - $t->clickAndWait("link={$lang['strnextval']}"); - $t->assertText("//p[@class='message']", $lang['strsequencenextval']); - $t->assertText("//tr/td[text()='testcase_seq']/../td[$i]", '4'); - $t->clickAndWait("link={$lang['strreset']}"); - $t->assertText("//p[@class='message']", $lang['strsequencereset']); - $t->assertText("//tr/td[text()='testcase_seq']/../td[$i]", '1'); + /** 2 **/ + $t->addComment('2. increment, reset sequence and set value'); + $t->clickAndWait("link={$lang['strsetval']}"); + $t->type('nextvalue', '2'); + $t->clickAndWait('setval'); + $t->assertText("//p[@class='message']", $lang['strsequencesetval']); + if ($t->data->hasAlterSequenceStart()) $i = 3; + else $i = 2; + $t->assertText("//tr/td[text()='testcase_seq']/../td[$i]", '2'); + $t->clickAndWait("link={$lang['strnextval']}"); + $t->assertText("//p[@class='message']", $lang['strsequencenextval']); + $t->assertText("//tr/td[text()='testcase_seq']/../td[$i]", '4'); + $t->clickAndWait("link={$lang['strreset']}"); + $t->assertText("//p[@class='message']", $lang['strsequencereset']); + $t->assertText("//tr/td[text()='testcase_seq']/../td[$i]", '1'); -/** 3 **/ - $t->addComment('3. alter sequence'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait('link=public'); - $t->clickAndWait("link={$lang['strsequences']}"); - $t->clickAndWait('link=testcase_seq'); - $t->clickAndWait("link={$lang['stralter']}"); - $t->type('name', 'testcase_renamed_seq'); - $t->select('owner', "label={$user}"); - if ($data->hasAlterSequenceSchema()) - $t->select('newschema', 'label=test_schema'); - $t->type('comment', 'test comment on testcase_renamed_seq'); - if ($data->hasAlterSequenceStart()) - $t->type('formStartValue', 10); - $t->type('formRestartValue', 20); - $t->type('formIncrement', 3); - $t->type('formMaxValue', 104); - $t->type('formMinValue', 5); - $t->type('formCacheValue', 6); - $t->uncheck('formCycledValue'); - $t->clickAndWait('alter'); - $t->assertText("//p[@class='message']", $lang['strsequencealtered']); - if ($data->hasAlterSequenceSchema()) - $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'test_schema'); - $t->assertText("//p[@class='comment']", 'test comment on testcase_renamed_seq'); - $t->assertText("//tr/th[text()='{$lang['strname']}' and @class='data']/../../tr/td[1]", 'testcase_renamed_seq'); - $i = 2; - if ($data->hasAlterSequenceStart()) - $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '10'); - $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '20'); - $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '3'); - $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '104'); - $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '5'); - $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '6'); - $i++; // we ignore log_count - $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", $lang['strno']); + /** 3 **/ + $t->addComment('3. alter sequence'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait('link=public'); + $t->clickAndWait("link={$lang['strsequences']}"); + $t->clickAndWait('link=testcase_seq'); + $t->clickAndWait("link={$lang['stralter']}"); + $t->type('name', 'testcase_renamed_seq'); + $t->select('owner', "label={$user}"); + if ($t->data->hasAlterSequenceSchema()) + $t->select('newschema', 'label=test_schema'); + $t->type('comment', 'test comment on testcase_renamed_seq'); + if ($t->data->hasAlterSequenceStart()) + $t->type('formStartValue', 10); + $t->type('formRestartValue', 20); + $t->type('formIncrement', 3); + $t->type('formMaxValue', 104); + $t->type('formMinValue', 5); + $t->type('formCacheValue', 6); + $t->uncheck('formCycledValue'); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strsequencealtered']); + if ($t->data->hasAlterSequenceSchema()) + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'test_schema'); + $t->assertText("//p[@class='comment']", 'test comment on testcase_renamed_seq'); + $t->assertText("//tr/th[text()='{$lang['strname']}' and @class='data']/../../tr/td[1]", 'testcase_renamed_seq'); + $i = 2; + if ($t->data->hasAlterSequenceStart()) + $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '10'); + $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '20'); + $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '3'); + $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '104'); + $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '5'); + $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", '6'); + $i++; // we ignore log_count + $t->assertText("//tr/td[text()='testcase_renamed_seq']/../td[". $i++ ."]", $lang['strno']); - if ($data->hasAlterSequenceSchema()) - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); - else - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='public']"); - $t->clickAndWait("link={$lang['strsequences']}"); - $t->assertText("//tr/td[2]/a[text()='testcase_renamed_seq']/../../td[3]", $user); + if ($t->data->hasAlterSequenceSchema()) + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); + else + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='public']"); + $t->clickAndWait("link={$lang['strsequences']}"); + $t->assertText("//tr/td[2]/a[text()='testcase_renamed_seq']/../../td[3]", $user); -/** 4 **/ - $t->addComment('4. drop sequence'); - $t->clickAndWait("link={$lang['strsequences']}"); - $t->clickAndWait("//tr/td/a[text()='testcase_renamed_seq']/../../td/a[text()='{$lang['strdrop']}']"); - $t->click('cascade'); - $t->clickAndWait('drop'); - $t->assertText("//p[@class='message']", $lang['strsequencedropped']); + /** 4 **/ + $t->addComment('4. drop sequence'); + $t->clickAndWait("link={$lang['strsequences']}"); + $t->clickAndWait("//tr/td/a[text()='testcase_renamed_seq']/../../td/a[text()='{$lang['strdrop']}']"); + $t->click('cascade'); + $t->clickAndWait('drop'); + $t->assertText("//p[@class='message']", $lang['strsequencedropped']); - $t->logout(); - $t->writeTests("{$test_static_dir}/{$server['desc']}/sequence.html", $testsuite_file); - unset($t); + $t->logout(); + unset($t); + } ?> diff --git a/tests/selenium/src/20-constraint.php b/tests/selenium/src/20-constraint.php index f72225c69..8fded5b1b 100644 --- a/tests/selenium/src/20-constraint.php +++ b/tests/selenium/src/20-constraint.php @@ -1,112 +1,115 @@ login($admin_user, $admin_user_pass); + $t->login($admin_user, $admin_user_pass); - /** 1 **/ - $t->addComment('1. Add 2 Foreign Keys'); - $t->addComment('1.1. Add 1st Foreign Keys'); - $t->clickAndWait("link={$lang['strdatabases']}"); - $t->clickAndWait("link={$testdb}"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait('link=public'); - $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait('link=student'); - $t->clickAndWait("link={$lang['strconstraints']}"); - $t->clickAndWait("link={$lang['straddfk']}"); - $t->type('name', 'student_id_promo_fk'); - $t->addSelection('TableColumnList','label=id_promo'); - $t->click('add'); - $t->select('target', 'label=test_schema.promo'); - $t->clickAndWait("//input[@value='Add']"); - $t->addSelection('TableColumnList', 'label=id'); - $t->click('add'); - $t->select('upd_action', 'label=CASCADE'); - $t->select('del_action', 'label=RESTRICT'); - $t->clickAndWait("//input[@value='Add']"); - $t->assertText("//p[@class='message']", $lang['strfkadded']); + /** 1 **/ + $t->addComment('1. Add 2 Foreign Keys'); + $t->addComment('1.1. Add 1st Foreign Keys'); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait('link=public'); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait('link=student'); + $t->clickAndWait("link={$lang['strconstraints']}"); + $t->clickAndWait("link={$lang['straddfk']}"); + $t->type('name', 'student_id_promo_fk'); + $t->addSelection('TableColumnList','label=id_promo'); + $t->click('add'); + $t->select('target', 'label=test_schema.promo'); + $t->clickAndWait("//input[@value='Add']"); + $t->addSelection('TableColumnList', 'label=id'); + $t->click('add'); + $t->select('upd_action', 'label=CASCADE'); + $t->select('del_action', 'label=RESTRICT'); + $t->clickAndWait("//input[@value='Add']"); + $t->assertText("//p[@class='message']", $lang['strfkadded']); - /** 1' **/ - $t->addComment('1.2. Add 2nd Foreign Keys'); - $t->clickAndWait("link={$lang['straddfk']}"); - $t->type('name', 'fk_to_drop'); - $t->addSelection('TableColumnList', 'label=id_promo'); - $t->click('add'); - $t->select('target','label=test_schema.promo'); - $t->clickAndWait("//input[@value='Add']"); - $t->addSelection('TableColumnList', 'label=id'); - $t->click('add'); - $t->select('upd_action', 'label=CASCADE'); - $t->select('del_action', 'label=RESTRICT'); - $t->clickAndWait("//input[@value='Add']"); - $t->assertText("//p[@class='message']", $lang['strfkadded']); + /** 1' **/ + $t->addComment('1.2. Add 2nd Foreign Keys'); + $t->clickAndWait("link={$lang['straddfk']}"); + $t->type('name', 'fk_to_drop'); + $t->addSelection('TableColumnList', 'label=id_promo'); + $t->click('add'); + $t->select('target','label=test_schema.promo'); + $t->clickAndWait("//input[@value='Add']"); + $t->addSelection('TableColumnList', 'label=id'); + $t->click('add'); + $t->select('upd_action', 'label=CASCADE'); + $t->select('del_action', 'label=RESTRICT'); + $t->clickAndWait("//input[@value='Add']"); + $t->assertText("//p[@class='message']", $lang['strfkadded']); - /* 2 */ - $t->addComment('2. Add check constraint'); - $t->clickAndWait("link={$lang['straddcheck']}"); - $t->type('name', 'check_to_drop'); - $t->type('definition', 'extract(year from birthday) < 2000'); - $t->clickAndWait('ok'); - $t->assertText("//p[@class='message']", $lang['strcheckadded']); + /* 2 */ + $t->addComment('2. Add check constraint'); + $t->clickAndWait("link={$lang['straddcheck']}"); + $t->type('name', 'check_to_drop'); + $t->type('definition', 'extract(year from birthday) < 2000'); + $t->clickAndWait('ok'); + $t->assertText("//p[@class='message']", $lang['strcheckadded']); - /* 3 */ - $t->addComment('3. Add unique key'); - $t->clickAndWait("link={$lang['stradduniq']}"); - $t->type('name', 'unique_to_drop'); - $t->addSelection('TableColumnList', 'label=name'); - $t->click('add'); - $t->clickAndWait("//input[@value='{$lang['stradd']}']"); - $t->assertText("//p[@class='message']", $lang['struniqadded']); + /* 3 */ + $t->addComment('3. Add unique key'); + $t->clickAndWait("link={$lang['stradduniq']}"); + $t->type('name', 'unique_to_drop'); + $t->addSelection('TableColumnList', 'label=name'); + $t->click('add'); + $t->clickAndWait("//input[@value='{$lang['stradd']}']"); + $t->assertText("//p[@class='message']", $lang['struniqadded']); - /* 4 */ - $t->addComment('4. Drop PK before creating it again'); - $t->clickAndWait("//tr/td/pre[text()='PRIMARY KEY (id)']/../../td/a[text()='{$lang['strdrop']}']"); - $t->clickAndWait('drop'); - $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); + /* 4 */ + $t->addComment('4. Drop PK before creating it again'); + $t->clickAndWait("//tr/td/pre[text()='PRIMARY KEY (id)']/../../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); - /* 5 */ - $t->addComment('5. Add primary key'); - $t->clickAndWait("link={$lang['straddpk']}"); - $t->type('name', 'student_pk'); - $t->addSelection('TableColumnList', 'label=id'); - $t->click('add'); - $t->clickAndWait("//input[@value='Add']"); - $t->assertText("//p[@class='message']", $lang['strpkadded']); + /* 5 */ + $t->addComment('5. Add primary key'); + $t->clickAndWait("link={$lang['straddpk']}"); + $t->type('name', 'student_pk'); + $t->addSelection('TableColumnList', 'label=id'); + $t->click('add'); + $t->clickAndWait("//input[@value='Add']"); + $t->assertText("//p[@class='message']", $lang['strpkadded']); - /* 6 */ - $t->addComment('6. Drop FK'); - $t->clickAndWait("//tr/td[text()='fk_to_drop']/../td/a[text()='{$lang['strdrop']}']"); - $t->clickAndWait('drop'); - $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); + /* 6 */ + $t->addComment('6. Drop FK'); + $t->clickAndWait("//tr/td[text()='fk_to_drop']/../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); - /* 7 */ - $t->addComment('7. Drop unique'); - $t->clickAndWait("//tr/td[text()='unique_to_drop']/../td/a[text()='{$lang['strdrop']}']"); - $t->clickAndWait('drop'); - $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); + /* 7 */ + $t->addComment('7. Drop unique'); + $t->clickAndWait("//tr/td[text()='unique_to_drop']/../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); - /* 8 */ - $t->addComment('8. Drop check'); - $t->clickAndWait("//tr/td[text()='check_to_drop']/../td/a[text()='{$lang['strdrop']}']"); - $t->clickAndWait('drop'); - $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); + /* 8 */ + $t->addComment('8. Drop check'); + $t->clickAndWait("//tr/td[text()='check_to_drop']/../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText("//p[@class='message']", $lang['strconstraintdropped']); - $t->logout(); - $t->writeTests("{$test_static_dir}/{$server['desc']}/constraint.html", $testsuite_file); - unset($t); + $t->logout(); + unset($t); + } ?> \ No newline at end of file diff --git a/tests/selenium/src/25-column.php b/tests/selenium/src/25-column.php index 2896797bc..9db6f1b61 100644 --- a/tests/selenium/src/25-column.php +++ b/tests/selenium/src/25-column.php @@ -1,94 +1,97 @@ login($admin_user, $admin_user_pass); + $t->login($admin_user, $admin_user_pass); -/** 1 **/ -$t->addComment('1. add column'); -$t->clickAndWait("link={$lang['strdatabases']}"); -$t->clickAndWait("link={$testdb}"); -$t->clickAndWait("link={$lang['strschemas']}"); -$t->clickAndWait('link=public'); -$t->clickAndWait("link={$lang['strtables']}"); -$t->clickAndWait('link=student'); -$t->clickAndWait("link={$lang['strcolumns']}"); -$t->clickAndWait("link={$lang['straddcolumn']}"); -$t->type('field', 'new_col'); -$t->select('type', 'label=integer'); -$t->type('default', 0); -$t->type('comment', 'test col to drop'); -$t->clickAndWait("//input[@value='Add']"); -$t->assertText("//p[@class='message']", $lang['strcolumnadded']); -$t->assertText("//tr/td/a[text()='new_col']", 'new_col'); -$t->assertText("//tr/td/a[text()='new_col']/../../td[2]", 'integer'); -if ($data->hasCreateFieldWithConstraints()) { - $t->assertText("//tr/td/a[text()='new_col']/../../td[3]", ''); - $t->assertText("//tr/td/a[text()='new_col']/../../td[4]", '0'); -} -$t->assertText("//tr/td/a[text()='new_col']/../../td[10]", 'test col to drop'); + /** 1 **/ + $t->addComment('1. add column'); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait('link=public'); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait('link=student'); + $t->clickAndWait("link={$lang['strcolumns']}"); + $t->clickAndWait("link={$lang['straddcolumn']}"); + $t->type('field', 'new_col'); + $t->select('type', 'label=integer'); + $t->type('default', 0); + $t->type('comment', 'test col to drop'); + $t->clickAndWait("//input[@value='Add']"); + $t->assertText("//p[@class='message']", $lang['strcolumnadded']); + $t->assertText("//tr/td/a[text()='new_col']", 'new_col'); + $t->assertText("//tr/td/a[text()='new_col']/../../td[2]", 'integer'); + if ($t->data->hasCreateFieldWithConstraints()) { + $t->assertText("//tr/td/a[text()='new_col']/../../td[3]", ''); + $t->assertText("//tr/td/a[text()='new_col']/../../td[4]", '0'); + } + $t->assertText("//tr/td/a[text()='new_col']/../../td[10]", 'test col to drop'); -/** 2 **/ -$t->addComment('2. alter column'); -$t->clickAndWait("link={$lang['strcolumns']}"); -$t->clickAndWait('link=new_col'); -$t->clickAndWait("link={$lang['stralter']}"); -$t->type('field', 'altered_col'); -$current_type='integer'; -$current_default='1'; -if ($data->hasAlterColumnType()) { - $t->select('type', 'label=character'); - $t->type('length', 1); - $t->type('default', "'-'"); - $current_type='character(1)'; - $current_default="'-'"; -} -else { - $t->type('default', '2'); - $current_default='2'; -} -$t->check('notnull'); -$t->type('comment', 'altered col to drop'); -$t->clickAndWait("//input[@value='Alter']"); -$t->assertText("//p[@class='message']", $lang['strcolumnaltered']); -$t->assertText("//p[@class='comment']", 'altered col to drop'); -$t->assertText("//tr/th[text()='{$lang['strcolumn']}']/../../tr[2]/td[1]", 'altered_col'); -$t->assertText("//tr/td[1 and text()='altered_col']/../td[2]", $current_type); -$t->assertText("//tr/td[1 and text()='altered_col']/../td[3]", 'NOT NULL'); -$t->assertText("//tr/td[1 and text()='altered_col']/../td[4]", "{$current_default}*"); + /** 2 **/ + $t->addComment('2. alter column'); + $t->clickAndWait("link={$lang['strcolumns']}"); + $t->clickAndWait('link=new_col'); + $t->clickAndWait("link={$lang['stralter']}"); + $t->type('field', 'altered_col'); + $current_type='integer'; + $current_default='1'; + if ($t->data->hasAlterColumnType()) { + $t->select('type', 'label=character'); + $t->type('length', 1); + $t->type('default', "'-'"); + $current_type='character(1)'; + $current_default="'-'"; + } + else { + $t->type('default', '2'); + $current_default='2'; + } + $t->check('notnull'); + $t->type('comment', 'altered col to drop'); + $t->clickAndWait("//input[@value='Alter']"); + $t->assertText("//p[@class='message']", $lang['strcolumnaltered']); + $t->assertText("//p[@class='comment']", 'altered col to drop'); + $t->assertText("//tr/th[text()='{$lang['strcolumn']}']/../../tr[2]/td[1]", 'altered_col'); + $t->assertText("//tr/td[1 and text()='altered_col']/../td[2]", $current_type); + $t->assertText("//tr/td[1 and text()='altered_col']/../td[3]", 'NOT NULL'); + $t->assertText("//tr/td[1 and text()='altered_col']/../td[4]", "{$current_default}*"); -/** 3 **/ -$t->addComment('3. alter column fail'); -$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label' and text()='student']"); -$t->clickAndWait('link=name'); -$t->clickAndWait("link={$lang['stralter']}"); -$t->type('default', 'Bad default value'); -$t->clickAndWait("//input[@value='Alter']"); -$t->assertText("//p[@class='message']", $lang['strcolumnalteredbad']); -$t->clickAndWait('cancel'); + /** 3 **/ + $t->addComment('3. alter column fail'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label' and text()='student']"); + $t->clickAndWait('link=name'); + $t->clickAndWait("link={$lang['stralter']}"); + $t->type('default', 'Bad default value'); + $t->clickAndWait("//input[@value='Alter']"); + $t->assertText("//p[@class='message']", $lang['strcolumnalteredbad']); + $t->clickAndWait('cancel'); -/** 4 **/ -$t->addComment('4. drop column'); -$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label' and text()='student']"); -$t->clickAndWait('link=altered_col'); -$t->clickAndWait("link={$lang['strdrop']}"); -$t->click('cascade'); -$t->clickAndWait('drop'); -$t->assertText("//p[@class='message']", $lang['strcolumndropped']); -$t->assertErrorOnNext("Element //tr/td/a[text()='altered_col'] not found"); -$t->clickAndWait("//tr/td/a[text()='altered_col']"); //fail + /** 4 **/ + $t->addComment('4. drop column'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label' and text()='student']"); + $t->clickAndWait('link=altered_col'); + $t->clickAndWait("link={$lang['strdrop']}"); + $t->click('cascade'); + $t->clickAndWait('drop'); + $t->assertText("//p[@class='message']", $lang['strcolumndropped']); + $t->assertErrorOnNext("Element //tr/td/a[text()='altered_col'] not found"); + $t->clickAndWait("//tr/td/a[text()='altered_col']"); //fail -$t->logout(); -$t->writeTests("{$test_static_dir}/{$server['desc']}/column.html", $testsuite_file); -unset($t); + $t->logout(); + unset($t); + } ?> diff --git a/tests/selenium/src/30-view.php b/tests/selenium/src/30-view.php index b5ec22f45..d54706c29 100644 --- a/tests/selenium/src/30-view.php +++ b/tests/selenium/src/30-view.php @@ -1,103 +1,106 @@ login($admin_user, $admin_user_pass); + $t->login($admin_user, $admin_user_pass); -/** 1 **/ -$t->addComment('1. Create the view'); -$t->clickAndWait("link={$lang['strdatabases']}"); -$t->clickAndWait("link={$testdb}"); -$t->clickAndWait("link={$lang['strschemas']}"); -$t->clickAndWait('link=public'); -$t->clickAndWait("link={$lang['strviews']}"); -$t->clickAndWait("link={$lang['strcreateview']}"); -$t->type('formView', 'student_promo'); -$t->type('formDefinition', 'SELECT s.id, name, birthday, resume, spe, year - FROM student AS s - JOIN test_schema.promo AS p ON (s.id_promo=p.id)'); -$t->type('formComment', 'students and their promotion'); -$t->clickAndWait("//input[@value='Create']"); -$t->assertText("//p[@class='message']", "{$lang['strviewcreated']}"); -$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[2]", 'student_promo'); -$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[3]", $admin_user); -$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[8]", 'students and their promotion'); -$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'public'); + /** 1 **/ + $t->addComment('1. Create the view'); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait('link=public'); + $t->clickAndWait("link={$lang['strviews']}"); + $t->clickAndWait("link={$lang['strcreateview']}"); + $t->type('formView', 'student_promo'); + $t->type('formDefinition', 'SELECT s.id, name, birthday, resume, spe, year + FROM student AS s + JOIN test_schema.promo AS p ON (s.id_promo=p.id)'); + $t->type('formComment', 'students and their promotion'); + $t->clickAndWait("//input[@value='Create']"); + $t->assertText("//p[@class='message']", "{$lang['strviewcreated']}"); + $t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[2]", 'student_promo'); + $t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[3]", $admin_user); + $t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[8]", 'students and their promotion'); + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'public'); -/** 2 **/ -$t->addComment('2. Alter the view'); -$t->clickAndWait("link={$lang['strviews']}"); -$t->clickAndWait('link=student_promo'); -$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); -//Alter name -$t->addComment('2.1. Alter view\'s name'); -$t->type('name', 'student_promo_renamed'); -$t->clickAndWait('alter'); -$t->assertText("//p[@class='message']", $lang['strviewaltered']); -$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strview']}']/span[@class='label']", 'student_promo_renamed'); -//Alter comment -$t->addComment('2.2. Alter view\'s comment'); -$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); -$t->type('comment', 'students and their promotion (altered)'); -$t->clickAndWait('alter'); -$t->assertText("//p[@class='message']", $lang['strviewaltered']); -$t->assertText("//p[@class='comment']", 'students and their promotion (altered)'); -// Alter schema -$current_shema='public'; -if ($data->hasAlterTableSchema()) { - $t->addComment('2.3. Alter view\'s schema'); - $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); - $t->select('newschema', 'label=test_schema'); - $t->clickAndWait('alter'); - $t->assertText("//p[@class='message']", $lang['strviewaltered']); - $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'test_schema'); - $current_shema='test_schema'; -} -// Alter owner -$t->addComment('2.4. Alter view\'s owner'); -$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); -$t->select('owner', "label={$user}"); -$t->clickAndWait('alter'); -$t->assertText("//p[@class='message']", $lang['strviewaltered']); -$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='{$current_shema}']"); -$t->clickAndWait("link={$lang['strviews']}"); -$t->assertText("//tr/td[2]/a[text()='student_promo_renamed']/../../td[3]", $user); -// Alter back everything -$t->addComment('2.5. Alter back everything'); -$t->clickAndWait('link=student_promo_renamed'); -$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); -$t->select('owner', "label={$admin_user}"); -$t->type('name', 'student_promo'); -if ($data->hasAlterTableSchema()) { - $t->select('newschema', 'label=public'); -} -$t->type('comment', 'students and their promotion'); -$t->clickAndWait('alter'); -$t->assertText("//p[@class='message']", $lang['strviewaltered']); -$t->assertText("//p[@class='comment']", 'students and their promotion'); -$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strview']}']/span[@class='label']", 'student_promo'); -$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='public']"); -$t->clickAndWait("link={$lang['strviews']}"); -$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[3]", $admin_user); + /** 2 **/ + $t->addComment('2. Alter the view'); + $t->clickAndWait("link={$lang['strviews']}"); + $t->clickAndWait('link=student_promo'); + $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); + //Alter name + $t->addComment('2.1. Alter view\'s name'); + $t->type('name', 'student_promo_renamed'); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strviewaltered']); + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strview']}']/span[@class='label']", 'student_promo_renamed'); + //Alter comment + $t->addComment('2.2. Alter view\'s comment'); + $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); + $t->type('comment', 'students and their promotion (altered)'); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strviewaltered']); + $t->assertText("//p[@class='comment']", 'students and their promotion (altered)'); + // Alter schema + $current_shema='public'; + if ($t->data->hasAlterTableSchema()) { + $t->addComment('2.3. Alter view\'s schema'); + $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); + $t->select('newschema', 'label=test_schema'); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strviewaltered']); + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'test_schema'); + $current_shema='test_schema'; + } + // Alter owner + $t->addComment('2.4. Alter view\'s owner'); + $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); + $t->select('owner', "label={$user}"); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strviewaltered']); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='{$current_shema}']"); + $t->clickAndWait("link={$lang['strviews']}"); + $t->assertText("//tr/td[2]/a[text()='student_promo_renamed']/../../td[3]", $user); + // Alter back everything + $t->addComment('2.5. Alter back everything'); + $t->clickAndWait('link=student_promo_renamed'); + $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']"); + $t->select('owner', "label={$admin_user}"); + $t->type('name', 'student_promo'); + if ($t->data->hasAlterTableSchema()) { + $t->select('newschema', 'label=public'); + } + $t->type('comment', 'students and their promotion'); + $t->clickAndWait('alter'); + $t->assertText("//p[@class='message']", $lang['strviewaltered']); + $t->assertText("//p[@class='comment']", 'students and their promotion'); + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strview']}']/span[@class='label']", 'student_promo'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='public']"); + $t->clickAndWait("link={$lang['strviews']}"); + $t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[3]", $admin_user); -/** 3 **/ -$t->addComment('3. Drop the view'); -$t->clickAndWait("//tr/td/a[text()='student_promo']/../../td/a[text()='{$lang['strdrop']}']"); -$t->clickAndWait('drop'); -$t->assertText("//p[@class='message']", $lang['strviewdropped']); -$t->assertErrorOnNext("Element //tr/td/a[text()='student_promo'] not found"); -$t->clickAndWait("//tr/td/a[text()='student_promo']"); //fail + /** 3 **/ + $t->addComment('3. Drop the view'); + $t->clickAndWait("//tr/td/a[text()='student_promo']/../../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText("//p[@class='message']", $lang['strviewdropped']); + $t->assertErrorOnNext("Element //tr/td/a[text()='student_promo'] not found"); + $t->clickAndWait("//tr/td/a[text()='student_promo']"); //fail -$t->logout(); -$t->writeTests("{$test_static_dir}/{$server['desc']}/view.html", $testsuite_file); -unset($t); + $t->logout(); + unset($t); + } ?> \ No newline at end of file diff --git a/tests/selenium/src/35-index.php b/tests/selenium/src/35-index.php index d17568cae..bc2e6eda0 100644 --- a/tests/selenium/src/35-index.php +++ b/tests/selenium/src/35-index.php @@ -1,49 +1,52 @@ login($admin_user, $admin_user_pass); + $t->login($admin_user, $admin_user_pass); -/** 1 **/ -$t->addComment('1. Create the unique index'); -$t->clickAndWait("link={$lang['strdatabases']}"); -$t->clickAndWait("link={$testdb}"); -$t->clickAndWait("link={$lang['strschemas']}"); -$t->clickAndWait('link=public'); -$t->clickAndWait("link={$lang['strtables']}"); -$t->clickAndWait('link=student'); -$t->clickAndWait("link={$lang['strindexes']}"); -$t->clickAndWait("link={$lang['strcreateindex']}"); -$t->type('formIndexName', 'name_unique'); -$t->addSelection('TableColumnList', 'label=name'); -$t->click('add'); -$t->clickAndWait("//input[@value='{$lang['strcreate']}']"); -$t->assertText("//p[@class='message']", $lang['strindexcreated']); + /** 1 **/ + $t->addComment('1. Create the unique index'); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait('link=public'); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait('link=student'); + $t->clickAndWait("link={$lang['strindexes']}"); + $t->clickAndWait("link={$lang['strcreateindex']}"); + $t->type('formIndexName', 'name_unique'); + $t->addSelection('TableColumnList', 'label=name'); + $t->click('add'); + $t->clickAndWait("//input[@value='{$lang['strcreate']}']"); + $t->assertText("//p[@class='message']", $lang['strindexcreated']); -/** 2 **/ -$t->addComment('2. Cluster on the index'); -$t->clickAndWait("link={$lang['strindexes']}"); -$t->clickAndWait("//tr/td[text()='name_unique']/../td/a[text()='Cluster']"); -$t->clickAndWait('cluster'); -$t->assertText("//p[@class='message']", $lang['strclusteredgood'] . ' ' . $lang['stranalyzegood']); + /** 2 **/ + $t->addComment('2. Cluster on the index'); + $t->clickAndWait("link={$lang['strindexes']}"); + $t->clickAndWait("//tr/td[text()='name_unique']/../td/a[text()='Cluster']"); + $t->clickAndWait('cluster'); + $t->assertText("//p[@class='message']", $lang['strclusteredgood'] . ' ' . $lang['stranalyzegood']); -/** 3 **/ -$t->addComment('3. Drop the index'); -$t->clickAndWait("link={$lang['strindexes']}"); -$t->clickAndWait("//tr/td[text()='name_unique']/../td/a[text()='Drop']"); -$t->click('cascade'); -$t->clickAndWait('drop'); -$t->assertText("//p[@class='message']", $lang['strindexdropped']); + /** 3 **/ + $t->addComment('3. Drop the index'); + $t->clickAndWait("link={$lang['strindexes']}"); + $t->clickAndWait("//tr/td[text()='name_unique']/../td/a[text()='Drop']"); + $t->click('cascade'); + $t->clickAndWait('drop'); + $t->assertText("//p[@class='message']", $lang['strindexdropped']); -$t->logout(); -$t->writeTests("{$test_static_dir}/{$server['desc']}/index.html", $testsuite_file); -unset($t); + $t->logout(); + unset($t); + } ?> diff --git a/tests/selenium/src/99-cleantests.php b/tests/selenium/src/99-cleantests.php index aaa99b718..a23b5a427 100644 --- a/tests/selenium/src/99-cleantests.php +++ b/tests/selenium/src/99-cleantests.php @@ -1,142 +1,145 @@ fail - * 2/ logout / login as admin_user and drop user role/user - * 3/ try to drop himself -> fail - * 4/ drop domain -> fail table promo depend on it - * 5/ drop domain with cascade, test if promo.year disapeared - * 6/ drop table student with cascade using the action button - * 7/ drop table promo using the button from tblproperties - * 8/ drop test database - * 9/ logout & login as superuser and drop admin_user - */ - $t = new TestBuilder($server['desc'], - 'Cleaner tests', - 'Clean every created stuff for test.' - ); + if (isset($_GET['run'])) { + global $lang; + require('../config.test.php'); + require('../testBuilder.class.php'); + /* + * 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/ drop domain -> fail table promo depend on it + * 5/ drop domain with cascade, test if promo.year disapeared + * 6/ drop table student with cascade using the action button + * 7/ drop table promo using the button from tblproperties + * 8/ drop test database + * 9/ logout & login as superuser and drop admin_user + */ + $t = new TestBuilder($test_title, + 'Clean every created stuff for test.' + ); -/** 1 **/ - $t->addComment('1. login as user and try to drop database -> fail'); - $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 **/ - $t->addComment('2. logout / login as admin_user and drop user role/user'); - $t->logout(); - $t->login($admin_user, $admin_user_pass); - if ($data->hasRoles()) { - $t->clickAndWait("link={$lang['strroles']}"); - $t->clickAndWait("//tr/td/a[text()='{$user}']/../../td/a[text()='{$lang['strdrop']}']"); - $t->clickAndWait('drop'); - $t->assertText('//p[@class=\'message\']', $lang['strroledropped']); - } else { - $t->clickAndWait("link={$lang['strusers']}"); - $t->clickAndWait("//tr/td[text()='{$user}']/../td/a[text()='{$lang['strdrop']}']"); + /** 1 **/ + $t->addComment('1. login as user and try to drop database -> fail'); + $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['struserdropped']); - } + $t->assertText('//p[@class=\'message\']', $lang['strdatabasedroppedbad']); + + /** 2 **/ + $t->addComment('2. logout / login as admin_user and drop user role/user'); + $t->logout(); + $t->login($admin_user, $admin_user_pass); + if ($t->data->hasRoles()) { + $t->clickAndWait("link={$lang['strroles']}"); + $t->clickAndWait("//tr/td/a[text()='{$user}']/../../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText('//p[@class=\'message\']', $lang['strroledropped']); + } else { + $t->clickAndWait("link={$lang['strusers']}"); + $t->clickAndWait("//tr/td[text()='{$user}']/../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText('//p[@class=\'message\']', $lang['struserdropped']); + } -/** 3 **/ - $t->addComment('3. try to drop himself -> fail'); - if ($data->hasRoles()) { - $t->clickAndWait("link={$lang['strroles']}"); - $t->clickAndWait("link={$admin_user}"); - $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strrole']}']/span[@class='label']", $admin_user); - $t->clickAndWait("link={$lang['strdrop']}"); + /** 3 **/ + $t->addComment('3. try to drop himself -> fail'); + if ($t->data->hasRoles()) { + $t->clickAndWait("link={$lang['strroles']}"); + $t->clickAndWait("link={$admin_user}"); + $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strrole']}']/span[@class='label']", $admin_user); + $t->clickAndWait("link={$lang['strdrop']}"); + $t->clickAndWait('drop'); + $t->assertText('//p[@class=\'message\']', $lang['strroledroppedbad']); + } else { + $t->clickAndWait("link={$lang['strusers']}"); + $t->clickAndWait("//tr/td[text()='{$admin_user}']/../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText('//p[@class=\'message\']', $lang['struserdroppedbad']); + } + + /** 4 **/ + $t->addComment('4. drop domain -> fail table promo depend on it'); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("link=test_schema"); + $t->clickAndWait("link={$lang['strdomains']}"); + $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['strdrop']}']"); $t->clickAndWait('drop'); - $t->assertText('//p[@class=\'message\']', $lang['strroledroppedbad']); - } else { - $t->clickAndWait("link={$lang['strusers']}"); - $t->clickAndWait("//tr/td[text()='{$admin_user}']/../td/a[text()='{$lang['strdrop']}']"); + $t->assertText('//p[@class=\'message\']', $lang['strdomaindroppedbad']); + + /** 5 **/ + $t->addComment('5. drop domain with cascade, test if promo.year disapeared'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("link=test_schema"); + $t->clickAndWait("link={$lang['strdomains']}"); + $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['strdrop']}']"); + $t->check('cascade'); $t->clickAndWait('drop'); - $t->assertText('//p[@class=\'message\']', $lang['struserdroppedbad']); - } + $t->assertText('//p[@class=\'message\']', $lang['strdomaindropped']); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait("link=promo"); + $t->clickAndWait("link={$lang['strcolumns']}"); + $t->assertErrorOnNext('Element link=year not found'); + $t->clickAndWait("link=year"); -/** 4 **/ - $t->addComment('4. drop domain -> fail table promo depend on it'); - $t->clickAndWait("link={$lang['strdatabases']}"); - $t->clickAndWait("link={$testdb}"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=test_schema"); - $t->clickAndWait("link={$lang['strdomains']}"); - $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['strdrop']}']"); - $t->clickAndWait('drop'); - $t->assertText('//p[@class=\'message\']', $lang['strdomaindroppedbad']); + /** 6 **/ + $t->addComment('6. drop table student with cascade using the action button'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$t->server['desc']}']"); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("link=public"); + $t->clickAndWait("//tr/td/a[text()='student']/../../td/a[text()='{$lang['strdrop']}']"); + $t->check('cascade'); + $t->clickAndWait('drop'); + $t->assertText('//p[@class=\'message\']', $lang['strtabledropped']); -/** 5 **/ - $t->addComment('5. drop domain with cascade, test if promo.year disapeared'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=test_schema"); - $t->clickAndWait("link={$lang['strdomains']}"); - $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['strdrop']}']"); - $t->check('cascade'); - $t->clickAndWait('drop'); - $t->assertText('//p[@class=\'message\']', $lang['strdomaindropped']); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("link=promo"); - $t->clickAndWait("link={$lang['strcolumns']}"); - $t->assertErrorOnNext('Element link=year not found'); - $t->clickAndWait("link=year"); + /** 7 **/ + $t->addComment('7. drop table promo using the button from tblproperties'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$t->server['desc']}']"); + $t->clickAndWait("link={$lang['strdatabases']}"); + $t->clickAndWait("link={$testdb}"); + $t->clickAndWait("link={$lang['strschemas']}"); + $t->clickAndWait("link=test_schema"); + $t->clickAndWait("link={$lang['strtables']}"); + $t->clickAndWait("link=promo"); + $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText('//p[@class=\'message\']', $lang['strtabledropped']); -/** 6 **/ - $t->addComment('6. drop table student with cascade using the action button'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']"); - $t->clickAndWait("link={$lang['strdatabases']}"); - $t->clickAndWait("link={$testdb}"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=public"); - $t->clickAndWait("//tr/td/a[text()='student']/../../td/a[text()='{$lang['strdrop']}']"); - $t->check('cascade'); - $t->clickAndWait('drop'); - $t->assertText('//p[@class=\'message\']', $lang['strtabledropped']); + /** 8 **/ + $t->addComment('8. drop test database'); + $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$t->server['desc']}']"); + $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']); -/** 7 **/ - $t->addComment('7. drop table promo using the button from tblproperties'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']"); - $t->clickAndWait("link={$lang['strdatabases']}"); - $t->clickAndWait("link={$testdb}"); - $t->clickAndWait("link={$lang['strschemas']}"); - $t->clickAndWait("link=test_schema"); - $t->clickAndWait("link={$lang['strtables']}"); - $t->clickAndWait("link=promo"); - $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['strdrop']}']"); - $t->clickAndWait('drop'); - $t->assertText('//p[@class=\'message\']', $lang['strtabledropped']); - -/** 8 **/ - $t->addComment('8. drop test database'); - $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']"); - $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']); + /** 9 **/ + $t->addComment('9. logout & login as superuser and drop admin_user'); + $t->logout(); + $t->login($super_user[$t->server['desc']], $super_pass[$t->server['desc']]); -/** 9 **/ - $t->addComment('9. logout & login as superuser and drop admin_user'); - $t->logout(); - $t->login($super_user[$server['desc']], $super_pass[$server['desc']]); + if ($t->data->hasRoles()) { + /* drop adminuser */ + $t->clickAndWait("link={$lang['strroles']}"); + $t->clickAndWait("//tr/td/a[text()='{$admin_user}']/../../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText('//p[@class=\'message\']', $lang['strroledropped']); + } else { + $t->clickAndWait("link={$lang['strusers']}"); + $t->clickAndWait("//tr/td[text()='{$admin_user}']/../td/a[text()='{$lang['strdrop']}']"); + $t->clickAndWait('drop'); + $t->assertText('//p[@class=\'message\']', $lang['struserdropped']); + } - if ($data->hasRoles()) { - /* drop adminuser */ - $t->clickAndWait("link={$lang['strroles']}"); - $t->clickAndWait("//tr/td/a[text()='{$admin_user}']/../../td/a[text()='{$lang['strdrop']}']"); - $t->clickAndWait('drop'); - $t->assertText('//p[@class=\'message\']', $lang['strroledropped']); - } else { - $t->clickAndWait("link={$lang['strusers']}"); - $t->clickAndWait("//tr/td[text()='{$admin_user}']/../td/a[text()='{$lang['strdrop']}']"); - $t->clickAndWait('drop'); - $t->assertText('//p[@class=\'message\']', $lang['struserdropped']); + $t->logout(); + unset($t); } - - $t->logout(); - $t->writeTests("{$test_static_dir}/{$server['desc']}/cleantests.html", $testsuite_file); - unset($t); ?> diff --git a/tests/selenium/src/skeleton.php-dist b/tests/selenium/src/skeleton.php-dist new file mode 100644 index 000000000..7e3b43fa9 --- /dev/null +++ b/tests/selenium/src/skeleton.php-dist @@ -0,0 +1,48 @@ +addComment('this is a comment'); + + // login + $t->login($super_user[$t->server['desc']], $super_pass[$t->server['desc']]); + + // Testing backend capability + if ($t->data->hasXXXXX()) { + ... + } + + // Filling a field + $t->type('formFieldName', "a value"); + + // etc... + */ + + /** + * When finished, destry the class instance. + **/ + unset($t); + } +?> diff --git a/tests/selenium/testBuilder.class.php b/tests/selenium/testBuilder.class.php index 95402505e..b4c22f21d 100644 --- a/tests/selenium/testBuilder.class.php +++ b/tests/selenium/testBuilder.class.php @@ -1,33 +1,48 @@ {$errmsg}\n"; + exit; + } + + $_no_db_connection = true; /* load lib.inc.php without trying to connect */ + $_REQUEST['language'] = 'english'; + define('ADODB_ERROR_HANDLER','connection_failed'); + chdir(dirname(__FILE__). '/../..'); + require_once('./libraries/lib.inc.php'); + /* + * This class help building a selenium HTML test file for PPA. + **/ + class TestBuilder { /** * Constructor * @param $serverDesc The server['desc'] conf param to which we are writing this test file for. * @param $title The title of the HTML test page * @param $desc The top description on the HTML test page */ - public function __construct($serverDesc, $title, $desc) { + public function __construct($title, $desc) { + global $misc; $this->title = $title; - $this->servDesc = $serverDesc; - /*$this->fd = fopen($this->file, 'w'); + $serverid = $_GET['server']; - fprintf($this->fd, '%s', "\n - - $title - - - - - - " - );*/ - $this->code = "\n + require('./tests/selenium/config.test.php'); + require_once('./classes/database/Connection.php'); + + $this->webUrl = $webUrl; + $_REQUEST['server'] = $serverid; + + $server = $misc->getServerInfo($serverid); + $server['username'] = $super_user[$server['desc']]; + $server['password'] = $super_pass[$server['desc']]; + + $misc->setServerInfo(null, $server, $serverid); + + $this->server = $server; + + $this->data = $misc->getDatabaseAccessor($server['defaultdb']); + + echo "\n$title @@ -44,12 +59,9 @@ public function __construct($serverDesc, $title, $desc) { * @param $testfile The path to the test file to create * @param $testsuite_file The path to the TestSuite.html file */ - public function writeTests($testfile, $testsuite_file) { - file_put_contents($testfile, $this->code); - - $str = "\n\n\n"; - file_put_contents($testsuite_file, $str, FILE_APPEND); + public function writeTests() { //$testfile, $testsuite_file) { + //echo $this->code; + return; } /** @@ -59,11 +71,11 @@ public function writeTests($testfile, $testsuite_file) { * @param $value (optional) the expected (or not) value (third column) */ public function test($action, $selector, $value='') { - $this->code .= "\n\n\n\n\n"; + echo "\n\n\n\n\n"; } public function addComment($c) { - $this->code .= "\n\n\n"; + echo "\n\n\n"; } /** @@ -72,11 +84,10 @@ public function addComment($c) { * @param $p The password to use */ public function login($u, $p) { - global $webUrl, $data; - $this->addComment("Login as {$u}"); - $this->test('open', "{$webUrl}/intro.php"); + $this->addComment("Login as {$this->server['username']}"); + $this->test('open', "{$this->webUrl}/intro.php"); $this->select('language', 'English'); - $this->test('open', "{$webUrl}/login.php?server={$data->conn->host}&subject=server"); + $this->test('open', "{$this->webUrl}/login.php?server={$this->data->conn->host}&subject=server"); $this->test('type', "//input[@name='loginUsername']", $u); $this->test('type', "//input[@id='loginPassword']", $p); $this->test('clickAndWait', 'loginSubmit'); @@ -92,10 +103,10 @@ public function logout() { $this->addComment("Logout"); $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('clickAndWait', "//tr/td/a[text()='{$this->server['desc']}']/../../td/a[text()='{$lang['strlogout']}']"); $this->test('assertText', "//p[@class='message']", - sprintf($lang['strlogoutmsg'], $this->servDesc) + sprintf($lang['strlogoutmsg'], $this->server['desc']) ); }
    $desc
    servDesc}/". - basename($testfile) ."\">[{$this->servDesc}] {$this->title}
    $action$selector$value
    $action$selector$value
    {$c}
    {$c}