From 9e6fd99e862ab9e1b0a0d0f5ee67b1f309f7c9a8 Mon Sep 17 00:00:00 2001 From: ioguix Date: Tue, 4 Sep 2007 19:39:48 +0000 Subject: [PATCH] unit test refactoring + fix : some tests still need to be fixed. Read tests/README & tests/TODO for more infos. --- login.php | 6 +- sql.php | 5 +- tests/README | 45 ++- tests/testcase/Common/ExportTest.php | 112 ++++--- tests/testcase/Common/ImportTest.php | 39 ++- tests/testcase/Common/SecurityTest.php | 264 +++++++-------- tests/testcase/Databases/AdminTest.php | 316 +++++++++--------- tests/testcase/Databases/CastsTest.php | 147 ++++---- .../testcase/Databases/DatabaseGroupTest.php | 96 +++--- tests/testcase/Databases/DatabaseTest.php | 43 ++- tests/testcase/Databases/FindObjectsTest.php | 123 ++++--- tests/testcase/Databases/HelpTest.php | 34 +- tests/testcase/Databases/LanguageTest.php | 12 +- tests/testcase/Databases/ProcessesTest.php | 13 +- tests/testcase/Databases/SchemaBasicTest.php | 85 +++-- tests/testcase/Databases/SqlTest.php | 140 +++++--- tests/testcase/Databases/VariablesTest.php | 12 +- tests/testcase/Public/SetPrecondition.php | 80 +++-- tests/testcase/Schemas/AggregateTest.php | 59 ++-- tests/testcase/Schemas/ConversionTest.php | 26 +- tests/testcase/Schemas/DomainTest.php | 126 ++++--- tests/testcase/Schemas/FunctionTest.php | 62 ++-- tests/testcase/Schemas/OpClassTest.php | 12 +- tests/testcase/Schemas/OperatorTest.php | 34 +- tests/testcase/Schemas/SchemasGroupTest.php | 15 +- tests/testcase/Schemas/SequenceTest.php | 35 +- tests/testcase/Schemas/TableTest.php | 226 +++++++++---- tests/testcase/Schemas/TypeTest.php | 51 ++- tests/testcase/Schemas/ViewTest.php | 111 ++++-- tests/testcase/Server/GroupsTest.php | 57 ++-- tests/testcase/Server/ReportsTest.php | 61 ++-- tests/testcase/Server/TableSpacesTest.php | 89 +++-- tests/testcase/Server/UsersTest.php | 129 +++---- tests/testcase/Tables/ColumnTest.php | 149 ++++++--- tests/testcase/Tables/ConstraintsTest.php | 92 +++-- tests/testcase/Tables/DeadlockTest.php | 139 +++++--- tests/testcase/Tables/IndexesTest.php | 111 +++--- tests/testcase/Tables/InfoTest.php | 60 ++-- tests/testcase/Tables/RulesTest.php | 91 +++-- tests/testcase/Tables/TriggersTest.php | 90 +++-- tests/testcase/testphpPgAdminMain.php | 17 +- 41 files changed, 2067 insertions(+), 1347 deletions(-) diff --git a/login.php b/login.php index 9536c8cb..cdcf311e 100755 --- a/login.php +++ b/login.php @@ -3,7 +3,7 @@ /** * Login screen * - * $Id: login.php,v 1.37 2007/07/12 19:26:22 xzilla Exp $ + * $Id: login.php,v 1.38 2007/09/04 19:39:48 ioguix Exp $ */ global $conf; @@ -24,7 +24,7 @@ $md5_server = md5($_REQUEST['server']); ?> -
+ - + 1) : ?> diff --git a/sql.php b/sql.php index f24afa6f..53ee0902 100644 --- a/sql.php +++ b/sql.php @@ -6,7 +6,7 @@ * how many SQL statements have been strung together with semi-colons * @param $query The SQL query string to execute * - * $Id: sql.php,v 1.36 2007/05/28 17:30:32 ioguix Exp $ + * $Id: sql.php,v 1.37 2007/09/04 19:39:48 ioguix Exp $ */ // Prevent timeouts on large exports (non-safe mode only) @@ -153,7 +153,8 @@ elseif ($data->conn->Affected_Rows() > 0) { echo "

", $data->conn->Affected_Rows(), " {$lang['strrowsaff']}

\n"; } - // Otherwise output nothing... + // Otherwise nodata to print + else echo '

', $lang['strnodata'], "

\n"; } } diff --git a/tests/README b/tests/README index 337e9d45..246ca1ee 100644 --- a/tests/README +++ b/tests/README @@ -1,8 +1,43 @@ - - -README - - +Howto configure/run: + - download the latest simpletest code and untargz it where you want (http://prdownloads.sourceforge.net/simpletest/simpletest_1.0.1beta2.tar.gz) + - tests are connecting to the server given in conf['servers'][0] values from your config.inc.php + - cd to your ppa tests directory + - edit config.tests.php + - edit data/config.sql according to your config.tests.php + - install test database & users : + psql [...your options...] -f data/ppatests_install.sql + - point your browser to http://your_server/path_to_ppa/tests/tests.php + +Howto clean: + - remove test database & users : + psql [...your options...] -f data/ppatests_install.sql + + +General comments/tips for dev: + - using the web_tester, to click on a link with img + text, you have to $this->clickLink("[alt_txt] txt") where [alt_txt] is the alt text of the img tag. + see http://sourceforge.net/mailarchive/message.php?msg_id=41ACA535.1080406%40lastcraft.com + +Comments about tests: + Server tests : + TableSpacesTest.php : + - data/TableSpace must be empty and owned by your PgSQL admin user + ReportsTest.php: + - see comments in testrun() + Database tests: + DatabaseTest.php: + - cannot delete datbases. Error : "can't delete opened database" + HelpTest.php: + - last assert fail because of the pg version in the link + Schemas tests: + TableTest.php: + - cannot edit & delete rows on viewtest because this table hasn't indexes. + display.php gives edit/delete links in tables have some "key". + viewtest is created by method createTable in Public/SetPrecondition.php + + + + +OLD README PART Document History diff --git a/tests/testcase/Common/ExportTest.php b/tests/testcase/Common/ExportTest.php index 5901f927..32c8315f 100644 --- a/tests/testcase/Common/ExportTest.php +++ b/tests/testcase/Common/ExportTest.php @@ -19,16 +19,13 @@ if(is_dir('../Public')) */ class ExportTest extends PreconditionSet { - // Declare the member variable for database name. - private $_databaseName = 'test'; - function setUp() { global $webUrl; global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; - $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, "$webUrl/login.php"); return TRUE; } @@ -48,11 +45,13 @@ class ExportTest extends PreconditionSet */ function testServerDataCopyShow() { - global $webUrl; - global $lang; + global $webUrl, $lang, $SERVER, $DATABASE; // Turn to the export data page. - $this->assertTrue($this->get($webUrl . '/all_db.php?action=export')); + $this->assertTrue($this->get("$webUrl/all_db.php", array( + 'action' => 'export', + 'server' => $SERVER)) + ); // Enter information for exporting the data. $this->assertTrue($this->setField('what', 'dataonly')); @@ -61,7 +60,7 @@ class ExportTest extends PreconditionSet //Then submit and verify it. $this->assertTrue($this->clickSubmit($lang['strexport'])); - $this->assertWantedText('connect ' . $this->_databaseName); + $this->assertWantedText("connect $DATABASE"); return TRUE; } @@ -73,11 +72,13 @@ class ExportTest extends PreconditionSet */ function testServerStructureSQLDownload() { - global $webUrl; - global $lang; + global $webUrl, $lang, $SERVER, $DATABASE; // Turn to the export data page. - $this->assertTrue($this->get($webUrl . '/all_db.php?action=export')); + $this->assertTrue($this->get("$webUrl/all_db.php", array( + 'action' => 'export', + 'server' => $SERVER)) + ); // Enter information for exporting the data. $this->assertTrue($this->setField('what', 'structureonly')); @@ -86,7 +87,7 @@ class ExportTest extends PreconditionSet //Then submit and verify it. $this->assertTrue($this->clickSubmit($lang['strexport'])); - $this->assertWantedText('connect ' . $this->_databaseName); + $this->assertWantedText("connect $DATABASE"); return TRUE; } @@ -97,12 +98,15 @@ class ExportTest extends PreconditionSet */ function testDatabaseDataSQLShow() { - global $webUrl; - global $lang; + global $webUrl, $lang, $SERVER, $DATABASE; // Turn to the export data page. - $this->assertTrue($this->get($webUrl . '/database.php?database=' . - $this->_databaseName . '&subject=database&action=export')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'export')) + ); // Enter information for exporting the data. $this->assertTrue($this->setField('what', 'dataonly')); @@ -123,12 +127,15 @@ class ExportTest extends PreconditionSet */ function testDatabaseStructureCOPYDownload() { - global $webUrl; - global $lang; + global $webUrl, $lang, $SERVER, $DATABASE; // Turn to the export data page. - $this->assertTrue($this->get($webUrl . '/database.php?database=' . $this->_databaseName . - '&subject=database&action=export')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'export')) + ); // Enter information for exporting the data. $this->assertTrue($this->setField('what', 'structureonly')); @@ -151,12 +158,15 @@ class ExportTest extends PreconditionSet */ function testTableDataShow() { - global $webUrl; - global $lang; + global $webUrl, $lang, $SERVER, $DATABASE; // Turn to the "Insert row" interface. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confinsertrow' . - '&database=test&schema=public&table=student&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'action' => 'confinsertrow', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set the value of the fields. $this->assertTrue($this->setField('values[name]', 'testname')); @@ -169,8 +179,14 @@ class ExportTest extends PreconditionSet $this->assertTrue($this->assertWantedText($lang['strrowinserted'])); // Turn to the export data page. - $this->assertTrue($this->get($webUrl . '/tblproperties.php?database=' . $this->_databaseName . - '&schema=public&table=student&subject=table&action=export')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'subject' => 'table', + 'action' => 'export')) + ); // Enter information for export the data. $this->assertTrue($this->setField('what', 'dataonly')); $this->assertTrue($this->setField('d_format', 'XML')); @@ -182,8 +198,14 @@ class ExportTest extends PreconditionSet // Turn to the export data page. - $this->assertTrue($this->get($webUrl . '/tblproperties.php?database=' . $this->_databaseName . - '&schema=public&table=student&subject=table&action=export')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'subject' => 'table', + 'action' => 'export')) + ); // Enter information for exporting the data. $this->assertTrue($this->setField('what', 'dataonly')); @@ -195,8 +217,13 @@ class ExportTest extends PreconditionSet $this->assertWantedPattern('/testname/'); // Empty the data in the table. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_empty' . - '&database=test&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confirm_empty', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); $this->assertTrue($this->clickSubmit($lang['strempty'])); return TRUE; @@ -209,12 +236,17 @@ class ExportTest extends PreconditionSet */ function testTableStructureDataSQLDownload() { - global $webUrl; - global $lang; + global $webUrl, $lang, $SERVER, $DATABASE; // Turn to the export data page. - $this->assertTrue($this->get($webUrl . '/tblproperties.php?database=' . $this->_databaseName . - '&schema=public&table=student&subject=table&action=export')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'subject' => 'table', + 'action' => 'export')) + ); // Enter information for exporting the data. $this->assertTrue($this->setField('what', 'structureanddata')); @@ -234,12 +266,16 @@ class ExportTest extends PreconditionSet */ function testViewStructureShow() { - global $webUrl; - global $lang; + global $webUrl, $lang, $SERVER, $DATABASE; // Turn to the export data page. - $this->assertTrue($this->get($webUrl . '/viewproperties.php?database=' . $this->_databaseName . - '&schema=pg_catalog&view=pg_user&subject=view&action=export')); + $this->assertTrue($this->get("$webUrl/viewproperties.php", array( + 'database' => $DATABASE, + 'schema' => 'pg_catalog', + 'view' => 'pg_user', + 'subject' => 'view', + 'action' => 'export')) + ); // Enter information for exporting the data. $this->assertTrue($this->setField('s_clean', TRUE)); diff --git a/tests/testcase/Common/ImportTest.php b/tests/testcase/Common/ImportTest.php index 329b20a8..e467d53b 100644 --- a/tests/testcase/Common/ImportTest.php +++ b/tests/testcase/Common/ImportTest.php @@ -31,7 +31,7 @@ class ImportTest extends PreconditionSet global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; - $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, "$webUrl/login.php"); return TRUE; } @@ -56,14 +56,19 @@ class ImportTest extends PreconditionSet function testXMLData() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; $this->_dataFilePath = getcwd() . '/../data/'; // Turn to the import data page. - $this->assertTrue($this->get($webUrl . '/tblproperties.php?database=test' . - '&schema=public&table=' . $this->_tableName . - '&subject=table&action=import')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => $this->_tableName, + 'subject' => 'table', + 'action' => 'import')) + ); // Enter information for importing the data. $this->assertTrue($this->setField('format', 'XML')); @@ -86,13 +91,18 @@ class ImportTest extends PreconditionSet function testIncorectTxtData() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; $this->_dataFilePath = getcwd() . '/../data/'; // Turn to the import data page. - $this->assertTrue($this->get($webUrl . '/tblproperties.php?database=test' . - '&schema=public&table=' . $this->_tableName . - '&subject=table&action=import')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => $this->_tableName, + 'subject' => 'table', + 'action' => 'import')) + ); // Enter information for importing the data. $this->assertTrue($this->setField('format', $lang['strauto'])); @@ -112,10 +122,15 @@ class ImportTest extends PreconditionSet function emptyTable() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_empty' . - '&database=test&schema=public&table=' . $this->_tableName)); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confirm_empty', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => $this->_tableName)) + ); $this->assertTrue($this->clickSubmit($lang['strempty'])); return TRUE; diff --git a/tests/testcase/Common/SecurityTest.php b/tests/testcase/Common/SecurityTest.php index e3de41d4..034d1a87 100644 --- a/tests/testcase/Common/SecurityTest.php +++ b/tests/testcase/Common/SecurityTest.php @@ -1,132 +1,132 @@ -login('postgres', $this->_invalidPassword, $webUrl . '/index.php'); - - // Verify the error messages. - $this->assertWantedText($lang['strlogindisallowed']); - $this->assertWantedText($lang['strviewfaq']); - - // Login with special user name "postgres". - $this->login($NORMAL_USER_NAME, '', $webUrl . '/index.php'); - - // Verify the error messages. - $this->assertWantedText($lang['strlogindisallowed']); - $this->assertWantedText($lang['strviewfaq']); - - return TRUE; - } - - - /* - * TestCaseID: CSM02 - * Test to login with invalid user name or password. - */ - function testInvalidLogin() - { - global $webUrl; - global $SUPER_USER_NAME; - global $lang; - - // Login with invalid user name. - $this->login($this->_invalidUserName, $this->_invalidPassword, $webUrl . '/index.php'); - - // Verify the error messages. - $this->assertWantedText($lang['strloginfailed']); - - // Login with valid username and invalid password. - $this->login($SUPER_USER_NAME, $this->_invalidPassword, $webUrl . '/index.php'); - - // Verify the error messages. - $this->assertWantedText($lang['strloginfailed']); - - return TRUE; - } - - - /* - * TestCaseID: CSM03 - * Test to change the current user's password. - */ - function testAccount() - { - global $webUrl; - global $NORMAL_USER_NAME; - global $NORMAL_USER_PASSWORD; - global $lang; - $newpassword = 'newpassword'; - - $this->login($NORMAL_USER_NAME, $NORMAL_USER_PASSWORD, $webUrl . '/index.php'); - - // Turn to the account page and change the password page. - $this->assertTrue($this->get($webUrl . '/users.php?action=account')); - $this->assertTrue($this->clickLink($lang['strchangepassword'])); - - // Enter the new password and different confirm password. - $this->assertTrue($this->setField('password', $newpassword)); - $this->assertTrue($this->setField('confirm', $this->_invalidPassword)); - - // Then submit and verify the error messages. - $this->assertTrue($this->clickSubmit($lang['strok'])); - $this->assertWantedText($lang['strpasswordconfirm']); - - // Enter the new password and confirm password. - $this->assertTrue($this->setField('password', $NORMAL_USER_PASSWORD)); - $this->assertTrue($this->setField('confirm', $NORMAL_USER_PASSWORD)); - - // Then submit and verify the messages. - $this->assertTrue($this->clickSubmit($lang['strok'])); - $this->assertWantedText($lang['strpasswordchanged']); - - $this->logout(); - - return TRUE; - } - -} -?> +login('postgres', $this->_invalidPassword, "$webUrl/login.php"); + + // Verify the error messages. + $this->assertWantedText($lang['strlogindisallowed']); + $this->assertWantedText($lang['strviewfaq']); + + // Login with special user name "postgres". + $this->login($NORMAL_USER_NAME, '', "$webUrl/login.php"); + + // Verify the error messages. + $this->assertWantedText($lang['strlogindisallowed']); + $this->assertWantedText($lang['strviewfaq']); + + return TRUE; + } + + + /* + * TestCaseID: CSM02 + * Test to login with invalid user name or password. + */ + function testInvalidLogin() + { + global $webUrl; + global $SUPER_USER_NAME; + global $lang; + + // Login with invalid user name. + $this->login($this->_invalidUserName, $this->_invalidPassword, "$webUrl/login.php"); + + // Verify the error messages. + $this->assertWantedText($lang['strloginfailed']); + + // Login with valid username and invalid password. + $this->login($SUPER_USER_NAME, $this->_invalidPassword, "$webUrl/login.php"); + + // Verify the error messages. + $this->assertWantedText($lang['strloginfailed']); + + return TRUE; + } + + + /* + * TestCaseID: CSM03 + * Test to change the current user's password. + */ + function testAccount() + { + global $webUrl; + global $NORMAL_USER_NAME; + global $NORMAL_USER_PASSWORD; + global $lang, $SERVER; + $newpassword = 'newpassword'; + + $this->login($NORMAL_USER_NAME, $NORMAL_USER_PASSWORD, "$webUrl/login.php"); + + // Turn to the account page and change the password page. + $this->assertTrue($this->get("$webUrl/users.php", array('server' => $SERVER, 'action' => 'account'))); + $this->assertTrue($this->clickLink($lang['strchangepassword'])); + + // Enter the new password and different confirm password. + $this->assertTrue($this->setField('password', $newpassword)); + $this->assertTrue($this->setField('confirm', $this->_invalidPassword)); + + // Then submit and verify the error messages. + $this->assertTrue($this->clickSubmit($lang['strok'])); + $this->assertWantedText($lang['strpasswordconfirm']); + + // Enter the new password and confirm password. + $this->assertTrue($this->setField('password', $NORMAL_USER_PASSWORD)); + $this->assertTrue($this->setField('confirm', $NORMAL_USER_PASSWORD)); + + // Then submit and verify the messages. + $this->assertTrue($this->clickSubmit($lang['strok'])); + $this->assertWantedText($lang['strpasswordchanged']); + + $this->logout(); + + return TRUE; + } + +} +?> diff --git a/tests/testcase/Databases/AdminTest.php b/tests/testcase/Databases/AdminTest.php index f8218aa3..4b86bdac 100644 --- a/tests/testcase/Databases/AdminTest.php +++ b/tests/testcase/Databases/AdminTest.php @@ -1,153 +1,163 @@ -login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); - - return TRUE; - } - - - /** - * Release the relational resource. - */ - function tearDown() - { - // Logout this system. - $this->logout(); - - return TRUE; - } - - - /** - * TestCaseId: DAV001 - * This test is used to test the admin about Vacuum and full. - */ - function testAdminVacuumAna() - { - global $webUrl; - global $lang; - - // Locate the list page of admin. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test' . - '&subject=database' . '&action=admin')); - $this->assertTrue($this->setField('vacuum_analyze', TRUE)); - $this->assertTrue($this->setField('vacuum_full', TRUE)); - $this->assertTrue($this->clickSubmit($lang['strvacuum'])); - $this->assertWantedText($lang['strvacuumgood']); - - return TRUE; - } - - - /** - * TestCaseId: DCS002 - * This test is used to test the admin about freeze. - */ - function testAdminFreeze() - { - global $webUrl; - global $lang; - - // Locate the list page of admin. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test' . - '&subject=database&action=admin')); - $this->assertTrue($this->setField('vacuum_freeze', TRUE)); - $this->assertTrue($this->clickSubmit($lang['strvacuum'])); - $this->assertWantedText($lang['strvacuumgood']); - - return TRUE; - } - - - /** - * TestCaseId: DCS003 - * This test is used to test the admin about Analyze. - */ - function testAdminAnalyze() - { - global $webUrl; - global $lang; - - // Locate the list page of admin. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=admin')); - $this->assertTrue($this->clickSubmit($lang['stranalyze'])); - $this->assertWantedText($lang['stranalyzegood']); - - return TRUE; - } - - - /** - * TestCaseId: DCS004 - * This test is used to test the admin about Cluster. - */ - function testAdminCluster() - { - global $webUrl; - global $lang; - - // Locate the list page of admin. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=admin')); - $this->assertTrue($this->clickSubmit($lang['strcluster'])); - $this->assertWantedText($lang['strclusteredgood']); - - return TRUE; - } - - - /** - * TestCaseId: DCS005 - * This test is used to test the admin about Reindex. - */ - function testAdminReindex() - { - global $webUrl; - global $lang; - - // Locate the list page of admin. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=admin')); - $this->assertTrue($this->setField('reindex_force', TRUE)); - $this->assertTrue($this->clickSubmit($lang['strreindex'])); - $this->assertWantedText($lang['strreindexgood']); - - return TRUE; - } -} - -?> +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + "$webUrl/login.php"); + + return TRUE; + } + + + /** + * Release the relational resource. + */ + function tearDown() + { + // Logout this system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseId: DAV001 + * This test is used to test the admin about Vacuum and full. + */ + function testAdminVacuumAna() + { + global $webUrl, $lang, $SERVER, $DATABASE; + + // Locate the list page of admin. + $this->assertTrue($this->get("$webUrl/database.php", + array('database' => $DATABASE, + 'subject' => 'database', + 'action' => 'admin', + 'server' => $SERVER)) + ); + $this->assertTrue($this->setField('vacuum_analyze', TRUE)); + $this->assertTrue($this->setField('vacuum_full', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strvacuum'])); + $this->assertWantedText($lang['strvacuumgood']); + + return TRUE; + } + + + /** + * TestCaseId: DCS002 + * This test is used to test the admin about freeze. + */ + function testAdminFreeze() + { + global $webUrl, $lang, $SERVER, $DATABASE; + + // Locate the list page of admin. + $this->assertTrue($this->get("$webUrl/database.php", + array('database' => $DATABASE, + 'subject' => 'database', + 'action' => 'admin', + 'server' => $SERVER)) + ); + $this->assertTrue($this->setField('vacuum_freeze', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strvacuum'])); + $this->assertWantedText($lang['strvacuumgood']); + + return TRUE; + } + + + /** + * TestCaseId: DCS003 + * This test is used to test the admin about Analyze. + */ + function testAdminAnalyze() + { + global $webUrl, $lang, $SERVER, $DATABASE; + + // Locate the list page of admin. + $this->assertTrue($this->get("$webUrl/database.php", + array('database' => $DATABASE, + 'subject' => 'database', + 'action' => 'admin', + 'server' => $SERVER)) + ); + $this->assertTrue($this->clickSubmit($lang['stranalyze'])); + $this->assertWantedText($lang['stranalyzegood']); + + return TRUE; + } + + + /** + * TestCaseId: DCS004 + * This test is used to test the admin about Cluster. + */ + function testAdminCluster() + { + global $webUrl, $lang, $SERVER, $DATABASE; + + // Locate the list page of admin. + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'admin')) + ); + $this->assertTrue($this->clickSubmit($lang['strcluster'])); + $this->assertWantedText($lang['strclusteredgood']); + + return TRUE; + } + + + /** + * TestCaseId: DCS005 + * This test is used to test the admin about Reindex. + */ + function testAdminReindex() + { + global $webUrl, $lang, $SERVER, $DATABASE; + + // Locate the list page of admin. + $this->assertTrue($this->get("$webUrl/database.php", array( + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'admin', + 'server' => $SERVER)) + ); + $this->assertTrue($this->setField('reindex_force', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strreindex'])); + $this->assertWantedText($lang['strreindexgood']); + + return TRUE; + } +} + +?> diff --git a/tests/testcase/Databases/CastsTest.php b/tests/testcase/Databases/CastsTest.php index 1c8ea2ed..c07ccadd 100644 --- a/tests/testcase/Databases/CastsTest.php +++ b/tests/testcase/Databases/CastsTest.php @@ -1,72 +1,75 @@ -login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); - - return TRUE; - } - - - /** - * Release the relational resource. - */ - function tearDown() - { - // Logout this system. - $this->logout(); - - return TRUE; - } - - - /** - * TestCaseId: DLU001 - * This test is used to test Casts Displayed page. - * - * Note: It's strange here, because it only display one sentecse. - */ - function testLanguage() - { - global $webUrl; - global $lang; - - // Locate the list page of language. - $this->assertTrue($this->get($webUrl . '/casts.php?database=test' . - '&subject=database')); - - $this->assertWantedText($lang['strsourcetype']); - $this->assertWantedText($lang['strtargettype']); - $this->assertWantedText($lang['strimplicit']); - - - return TRUE; - } -} - -?> +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + "$webUrl/login.php"); + + return TRUE; + } + + + /** + * Release the relational resource. + */ + function tearDown() + { + // Logout this system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseId: DLU001 + * This test is used to test Casts Displayed page. + * + * Note: It's strange here, because it only display one sentecse. + */ + function testLanguage() + { + global $webUrl; + global $lang, $SERVER, $DATABASE; + + // Locate the list page of language. + $this->assertTrue($this->get("$webUrl/casts.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database')) + ); + + $this->assertWantedText($lang['strsourcetype']); + $this->assertWantedText($lang['strtargettype']); + $this->assertWantedText($lang['strimplicit']); + + + return TRUE; + } +} + +?> diff --git a/tests/testcase/Databases/DatabaseGroupTest.php b/tests/testcase/Databases/DatabaseGroupTest.php index 1d18ffc1..c0a013f4 100644 --- a/tests/testcase/Databases/DatabaseGroupTest.php +++ b/tests/testcase/Databases/DatabaseGroupTest.php @@ -1,48 +1,48 @@ -GroupTest('Database group test begins.'); - - /* - * Hides it temporary. - * $this->addTestClass(new TableTest()); - */ - $this->addTestClass(new SqlTest()); - $this->addTestClass(new DatabaseTest()); - $this->addTestClass(new FindObjectsTest()); - $this->addTestClass(new VariablesTest()); - $this->addTestClass(new SchemaBasicTest()); - $this->addTestClass(new AdminTest()); - $this->addTestClass(new ProcessesTest()); - $this->addTestClass(new LanguageTest()); - $this->addTestClass(new CastsTest()); - $this->addTestClass(new HelpTest()); - } - } - -?> +GroupTest('Database group test begins.'); + + /* + * Hides it temporary. + * $this->addTestClass(new TableTest()); + */ + $this->addTestClass(new SqlTest()); + $this->addTestClass(new DatabaseTest()); + $this->addTestClass(new FindObjectsTest()); + $this->addTestClass(new VariablesTest()); + $this->addTestClass(new SchemaBasicTest()); + $this->addTestClass(new AdminTest()); + $this->addTestClass(new ProcessesTest()); + $this->addTestClass(new LanguageTest()); + $this->addTestClass(new CastsTest()); + $this->addTestClass(new HelpTest()); + } + } + +?> diff --git a/tests/testcase/Databases/DatabaseTest.php b/tests/testcase/Databases/DatabaseTest.php index e25ca754..05150a47 100644 --- a/tests/testcase/Databases/DatabaseTest.php +++ b/tests/testcase/Databases/DatabaseTest.php @@ -28,7 +28,7 @@ class DatabaseTest extends PreconditionSet global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -58,13 +58,16 @@ class DatabaseTest extends PreconditionSet function testCreateLATIN1DBInSPT() { global $webUrl; - global $lang; + global $lang, $SERVER; // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/all_db.php')); + $this->assertTrue($this->get("$webUrl/all_db.php")); // Click the hyperlink of "Create Database". - $this->assertTrue($this->get($webUrl . '/all_db.php?action=create')); + $this->assertTrue($this->get("$webUrl/all_db.php", array( + 'server' => $SERVER, + 'action' => 'create')) + ); // Fill the form about creating database. $this->assertTrue($this->setfield('formName', 'spikesource1')); @@ -81,7 +84,8 @@ class DatabaseTest extends PreconditionSet $this->assertWantedText($lang['strdatabasecreated']); // Release the resource. - // In fact, this line doesnot work because of phpPgAdmin's bug. + // XXX In fact, this line doesnot work because of phpPgAdmin's bug. + // "cannot delete opened database" $this->dropDatabase('spikesource1'); return TRUE; @@ -100,19 +104,22 @@ class DatabaseTest extends PreconditionSet function testCreateUNICODEDBInTester() { global $webUrl; - global $lang; + global $lang, $SERVER; // Sleep for a while to wait for the template1 to be available sleep(20); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/all_db.php')); + $this->assertTrue($this->get("$webUrl/all_db.php")); // Click the hyperlink of "Create Database". - $this->assertTrue($this->get($webUrl . '/all_db.php?action=create')); + $this->assertTrue($this->get("$webUrl/all_db.php", array( + 'server' => $SERVER, + 'action' => 'create')) + ); // Fill the form about creating database. $this->assertTrue($this->setfield('formName', 'spikesource2')); - $this->assertTrue($this->setfield('formEncoding', 'UNICODE')); + $this->assertTrue($this->setfield('formEncoding', 'UTF8')); $this->assertTrue($this->setfield('formSpc', 'pg_default')); // Click the submit button. @@ -125,7 +132,8 @@ class DatabaseTest extends PreconditionSet $this->assertWantedText($lang['strdatabasecreated']); // Release the resource. - // In fact, this line doesnot work because of phpPgAdmin's bug. + // XXX In fact, this line doesnot work because of phpPgAdmin's bug (?) + // "cannot delete opened database" $this->dropDatabase('spikesource2'); return TRUE; @@ -142,12 +150,16 @@ class DatabaseTest extends PreconditionSet function testDropDatabase() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Click the hyperlink of "Create Database". - $this->assertTrue($this->get($webUrl . '/all_db.php' . - '?action=confirm_drop' . - '&subject=database&database=test&')); + $this->assertTrue($this->get("$webUrl/all_db.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'subject' => 'database', + 'database' => $DATABASE, + 'dropdatabase' => $DATABASE )) + ); // Click the submit button "Drop" next page. $this->assertTrue($this->clickSubmit($lang['strdrop'])); @@ -156,7 +168,7 @@ class DatabaseTest extends PreconditionSet // There is an issue about PostgreSQL. So let me difine the displayed text. $this->assertWantedText($lang['strdatabasedropped']); - // Release the resource. The lines below failed in deed. + // XXX Release the resource. The lines below failed in deed. (can't delete opened db) $this->dropDatabase('SpikeSource1'); $this->dropDatabase('SpikeSource2'); @@ -165,4 +177,3 @@ class DatabaseTest extends PreconditionSet } ?> - diff --git a/tests/testcase/Databases/FindObjectsTest.php b/tests/testcase/Databases/FindObjectsTest.php index 3c3207a5..dc06afb9 100644 --- a/tests/testcase/Databases/FindObjectsTest.php +++ b/tests/testcase/Databases/FindObjectsTest.php @@ -27,7 +27,7 @@ class FindObjectsTest extends PreconditionSet global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -51,12 +51,15 @@ class FindObjectsTest extends PreconditionSet function testSimpleFindObject() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'All objects')); @@ -72,102 +75,135 @@ class FindObjectsTest extends PreconditionSet function testFindObjsInSchemas() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Schemas')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Tables')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Views')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Sequences')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Columns')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Rules')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Indexes')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Triggers')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Constraints')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Functions')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=find')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'find')) + ); $this->assertTrue($this->setField('term', 'student')); $this->assertTrue($this->setField('filter', 'Domains')); @@ -184,12 +220,15 @@ class FindObjectsTest extends PreconditionSet function testFindTopObjects() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Locate the list page of databases. - $this->assertTrue($this->get($webUrl . '/sqledit.php?action=find&')); + $this->assertTrue($this->get("$webUrl/sqledit.php", array( + 'server' => $SERVER, + 'action' => 'find')) + ); - $this->assertTrue($this->setField('database', 'test')); + $this->assertTrue($this->setField('database', $DATABASE)); $this->assertTrue($this->setField('term', 'All objects')); $this->assertTrue($this->clickSubmit ($lang['strfind'])); return true; diff --git a/tests/testcase/Databases/HelpTest.php b/tests/testcase/Databases/HelpTest.php index 65717919..7392b3b8 100644 --- a/tests/testcase/Databases/HelpTest.php +++ b/tests/testcase/Databases/HelpTest.php @@ -29,7 +29,7 @@ class HelpTest extends PreconditionSet global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -57,16 +57,19 @@ class HelpTest extends PreconditionSet function testHelpWithInnerSchema() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Locate the list page of database. - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database')) + ); // Click the link about help. - $this->assertTrue($this->get($webUrl . '/help.php')); - $this->assertTrue($this->get($webUrl . '/help.php?help=pg.schema')); - $this->assertTrue($this->get($webUrl . '/help.php?help=pg.column.add')); + $this->assertTrue($this->get("$webUrl/help.php")); + $this->assertTrue($this->get("$webUrl/help.php?help=pg.schema")); + $this->assertTrue($this->get("$webUrl/help.php?help=pg.column.add")); // Comment this for avoiding error by Xdebug. // Becase we cannot assert something about the content of the page via @@ -83,14 +86,19 @@ class HelpTest extends PreconditionSet */ function testHelpWithInrClk() { - global $webUrl; + global $webUrl, $SERVER, $DATABASE; // Locate the list page of language. - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database')); - $this->assertTrue($this->get($webUrl . '/help.php')); - - $this->assertTrue($this->clickLink('http://www.postgresql.org/docs/8.0/' . + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database')) + ); + + $this->assertTrue($this->get("$webUrl/help.php", array('server' => $SERVER))); + + // XXX fail because of the version number in the URL + $this->assertTrue($this->clickLink(/*'http://www.postgresql.org/docs/8.0/' .*/ 'interactive/sql-expressions.html' . '#SQL-SYNTAX-TYPE-CASTS')); diff --git a/tests/testcase/Databases/LanguageTest.php b/tests/testcase/Databases/LanguageTest.php index 208727d9..8938df23 100644 --- a/tests/testcase/Databases/LanguageTest.php +++ b/tests/testcase/Databases/LanguageTest.php @@ -29,7 +29,7 @@ class LanguageTest extends PreconditionSet global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -53,10 +53,14 @@ class LanguageTest extends PreconditionSet */ function testLanguage() { - global $webUrl; + global $webUrl, $SERVER, $DATABASE; + // Locate the list page of language. - $this->assertTrue($this->get($webUrl . '/languages.php' . - '?database=test&subject=database')); + $this->assertTrue($this->get("$webUrl/languages.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database')) + ); $this->assertWantedPattern('/sql/'); diff --git a/tests/testcase/Databases/ProcessesTest.php b/tests/testcase/Databases/ProcessesTest.php index b8df5ffa..34007105 100644 --- a/tests/testcase/Databases/ProcessesTest.php +++ b/tests/testcase/Databases/ProcessesTest.php @@ -28,7 +28,7 @@ class ProcessesTest extends PreconditionSet global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -55,11 +55,14 @@ class ProcessesTest extends PreconditionSet function testProcesses() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/database.php' . - '?database=test&subject=database' . - '&action=processes')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'processes')) + ); $this->assertWantedText($lang['strnodata']); diff --git a/tests/testcase/Databases/SchemaBasicTest.php b/tests/testcase/Databases/SchemaBasicTest.php index 65f19180..73af3ef4 100644 --- a/tests/testcase/Databases/SchemaBasicTest.php +++ b/tests/testcase/Databases/SchemaBasicTest.php @@ -30,7 +30,7 @@ class SchemaBasicTest extends PreconditionSet global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -54,16 +54,22 @@ class SchemaBasicTest extends PreconditionSet */ function testCreateBasSchema() { - global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database')); - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&action=create')); + global $webUrl, $SUPER_USER_NAME; + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database')) + ); + $this->assertTrue($this->get("$webUrl/schemas.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'action' => 'create')) + ); $this->assertTrue($this->setField('formName', 'testSchemaName')); - $this->assertTrue($this->setField('formAuth', 'super')); + $this->assertTrue($this->setField('formAuth', $SUPER_USER_NAME)); $this->assertTrue($this->setField('formComment', 'Comment of test schema.')); @@ -82,17 +88,29 @@ class SchemaBasicTest extends PreconditionSet function testAlterBasSchema() { global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database')); - $this->assertTrue($this->get($webUrl . '/redirect.php?section=database' . - '&database=test&')); - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database')); - $this->assertTrue($this->get($webUrl . '/database.php' . - '?action=alter_schema' . - '&database=test&schema=testSchemaName&')); + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database')) + ); + $this->assertTrue($this->get("$webUrl/redirect.php", array( + 'server' => $SERVER, + 'section' => 'database', + 'database' => $DATABASE)) + ); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database')) + ); + $this->assertTrue($this->get("$webUrl/schemas.php", array( + 'server' => $SERVER, + 'action' => 'alter', + 'database' => $DATABASE, + 'schema' => 'testSchemaName')) + ); $this->assertTrue($this->setField('comment', 'The comment has been changed.')); @@ -111,15 +129,24 @@ class SchemaBasicTest extends PreconditionSet function testDropBasSchema() { global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database')); - $this->assertTrue($this->get($webUrl . '/redirect.php' . - '?section=database&database=test&')); - $this->assertTrue($this->get($webUrl . '/database.php' . - '?action=confirm_drop&database=test' . - '&schema=testSchemaName&')); + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database')) + ); + $this->assertTrue($this->get("$webUrl/redirect.php", array( + 'server' => $SERVER, + 'section' => 'database', + 'database' => $DATABASE)) + ); + $this->assertTrue($this->get("$webUrl/schemas.php", array( + 'server' => $SERVER, + 'action' => 'drop', + 'database' => $DATABASE, + 'schema' => 'testSchemaName')) + ); $this->assertTrue($this->setField('cascade', TRUE)); $this->assertTrue($this->clickSubmit($lang['strdrop'])); diff --git a/tests/testcase/Databases/SqlTest.php b/tests/testcase/Databases/SqlTest.php index 4750a3c7..c9930c28 100644 --- a/tests/testcase/Databases/SqlTest.php +++ b/tests/testcase/Databases/SqlTest.php @@ -27,7 +27,7 @@ class SqlTest extends PreconditionSet global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -53,13 +53,17 @@ class SqlTest extends PreconditionSet function testSimpleSelectSql() { global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=sql')); + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/database.php", + array('database' => $DATABASE, + 'subject' => 'database', + 'action' => 'sql', + 'server' => $SERVER)) + ); $this->assertTrue($this->setFieldById(0, "select id from student;")); - $this->assertTrue($this->clickSubmit($lang['strgo'])); + $this->assertTrue($this->clickSubmit($lang['strexecute'])); return TRUE; } @@ -73,13 +77,17 @@ class SqlTest extends PreconditionSet function testSimpleDeleteSql() { global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=sql')); + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'sql')) + ); $this->assertTrue($this->setField('query', 'delete from "student";')); - $this->assertTrue($this->clickSubmit($lang['strgo'])); + $this->assertTrue($this->clickSubmit($lang['strexecute'])); return TRUE; } @@ -92,16 +100,20 @@ class SqlTest extends PreconditionSet function testSimpleInsertSql() { global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=sql')); + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'sql')) + ); $this->assertTrue($this->setField('query', "insert into studen t values " . "(nextval('public.student_id_seq'::text)" . ", 'test2', now(), 'test2 is a student.');")); - $this->assertTrue($this->clickSubmit($lang['strgo'])); + $this->assertTrue($this->clickSubmit($lang['strexecute'])); return true; } @@ -115,15 +127,19 @@ class SqlTest extends PreconditionSet function testSimpleUpdateSql() { global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=sql')); + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/database.php", array( + 'database' => $DATABASE, + 'server' => $SERVER, + 'subject' => 'database', + 'action' => 'sql')) + ); $this->assertTrue($this->setField('query', 'update public."student" ' . 'set "birthday" = now();')); - $this->assertTrue($this->clickSubmit($lang['strgo'])); + $this->assertTrue($this->clickSubmit($lang['strexecute'])); return TRUE; } @@ -137,10 +153,14 @@ class SqlTest extends PreconditionSet function testExplain() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=sql')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'sql')) + ); $this->assertTrue($this->setField('query', 'select "id" from "student";')); @@ -165,10 +185,14 @@ class SqlTest extends PreconditionSet function testExplainAnalyze() { global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=sql')); + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/database.php", array( + 'database' => $DATABASE, + 'server' => $SERVER, + 'subject' => 'database', + 'action' => 'sql')) + ); $this->assertTrue($this->setField('query', 'select "id" from "student";')); @@ -176,12 +200,10 @@ class SqlTest extends PreconditionSet $this->assertTrue($this->clickSubmit($lang['strexplainanalyze'])); - // Here $lang['strsqlexecuted'] is not fit for this situation. Because the "%s" // make the assertion failed. $this->assertWantedText('Total runtime'); - return TRUE; } @@ -198,19 +220,22 @@ class SqlTest extends PreconditionSet { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/database.php?' . - 'database=test&subject=database' . - '&action=sql')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'sql')) + ); $webServerUrl = getcwd(); - $sqlScriptUrl = $webServerUrl . "/../data/select.sql"; + $sqlScriptUrl = getcwd() . "/data/select.sql"; $this->assertTrue ($this->setField('script', $sqlScriptUrl)); - // This should be failed. Because the SimpleText doesn't support - // upload yet. + $this->assertTrue($this->clickSubmit($lang['strexecute'])); + $this->assertWantedText($lang['strsqlexecuted']); return TRUE; @@ -225,14 +250,14 @@ class SqlTest extends PreconditionSet function testSelectTopSQL() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->get($webUrl . '/sqledit.php?action=sql&'); + $this->get("$webUrl/sqledit.php", array('action' => 'sql', 'server' => $SERVER)); - $this->assertTrue($this->setField('database', 'test')); + $this->assertTrue($this->setField('database', $DATABASE)); $this->assertTrue($this->setField('query', 'select * from student;')); - $this->assertTrue($this->clickSubmit($lang['strgo'])); + $this->assertTrue($this->clickSubmit($lang['strexecute'])); $this->assertWantedText($lang['strsqlexecuted']); @@ -248,14 +273,14 @@ class SqlTest extends PreconditionSet function testResultFromSelectTopSQL() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->get($webUrl . '/sqledit.php?action=sql&'); + $this->get("$webUrl/sqledit.php", array('action' => 'sql', 'server' => $SERVER)); - $this->assertTrue($this->setField('database', 'test')); + $this->assertTrue($this->setField('database', $DATABASE)); $this->assertTrue($this->setField('query', 'select * from student;')); $this->assertTrue($this->setField('paginate', TRUE)); - $this->assertTrue($this->clickSubmit($lang['strgo'])); + $this->assertTrue($this->clickSubmit($lang['strexecute'])); $this->assertTrue($this->clickLink($lang['strexpand'])); $this->assertWantedText($lang['strnodata']); @@ -277,14 +302,17 @@ class SqlTest extends PreconditionSet function testReportByTopSql() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . - '/reports.php?action=create&db_name=test' . - '&report_sql=select+id+from+student%3B')); + $this->assertTrue($this->get("$webUrl/reports.php", array( + 'action' => 'create', + 'server' => $SERVER, + 'db_name' => $DATABASE, + 'report_sql' => 'select id from student;') + )); - $this->assertTrue($this->setField('report_name', 'test')); - $this->assertTrue($this->setField('descr', 'test')); + $this->assertTrue($this->setField('report_name', 'ppasimpletestreport')); + $this->assertTrue($this->setField('descr', 'ppasimpletest tests')); $this->assertTrue($this->clickSubmit($lang['strsave'])); @@ -300,11 +328,13 @@ class SqlTest extends PreconditionSet function testDownloadTopSql() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . - '/dataexport.php?query=select+id+from+student%3B' . - '&database=test')); + $this->assertTrue($this->get("$webUrl/dataexport.php", array( + 'server' => $SERVER, + 'query' => 'select+id+from+student%3B', + 'database' => $DATABASE)) + ); $this->assertTrue($this->setField('d_format', 'XML')); $this->assertTrue($this->setField('output', 'show')); diff --git a/tests/testcase/Databases/VariablesTest.php b/tests/testcase/Databases/VariablesTest.php index 029fdfab..cb4ea7de 100644 --- a/tests/testcase/Databases/VariablesTest.php +++ b/tests/testcase/Databases/VariablesTest.php @@ -28,7 +28,7 @@ class VariablesTest extends PreconditionSet global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -53,10 +53,14 @@ class VariablesTest extends PreconditionSet function testVariablesList() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=variables')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'variables')) + ); $this->assertWantedText($lang['strname']); $this->assertWantedText($lang['strsetting']); diff --git a/tests/testcase/Public/SetPrecondition.php b/tests/testcase/Public/SetPrecondition.php index 9556f24d..a7477a9b 100644 --- a/tests/testcase/Public/SetPrecondition.php +++ b/tests/testcase/Public/SetPrecondition.php @@ -34,15 +34,14 @@ class PreconditionSet extends WebTestCase */ function login($userName, $password, $loginPageUrl) { - global $lang; - - $this->get($loginPageUrl); - $this->setField('formUsername', $userName); - $this->setField('formPassword', $password); - $this->setField('formLanguage', $lang['applang']); - $this->clickSubmit('Login'); - - return TRUE; + global $lang, $SERVER; + + $this->setCookie("PHPCOVERAGE_HOME", $PHP_SIMPLETEST_HOME); + $this->get($loginPageUrl, array('server' => $SERVER)); + $this->setField('loginUsername', $userName); + $this->setFieldById('loginPassword', $password); + $this->submitFormByid('login_form'); + return TRUE; } @@ -57,13 +56,13 @@ class PreconditionSet extends WebTestCase function createDatabase($databaseName, $enCoding) { global $webUrl; - global $lang; + global $lang, $SERVER; global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); - $this->get($webUrl . '/all_db.php'); + "$webUrl/login.php"); + $this->get("$webUrl/all_db.php", array('server' => $SERVER)); $this->clickLink('Create database'); $this->setField('formName', $databaseName); @@ -87,17 +86,22 @@ class PreconditionSet extends WebTestCase function dropDatabase($databaseName) { global $webUrl; - global $lang; + global $lang, $SERVER; global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); - $this->get($webUrl . '/all_db.php'); - $this->get($webUrl . '/all_db.php?action=confirm_drop' . - '&subject=database&database=' . $databaseName); - $this->clickSubmit($lang['strdrop']); + $this->get("$webUrl/all_db.php", array('server' => $SERVER)); + $this->get("$webUrl/all_db.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'subject' => 'database', + 'database' => $databaseName, + 'dropdatabase' => $databaseName) + ); + $this->clickSubmit($lang['strdrop']); return TRUE; } @@ -119,26 +123,30 @@ class PreconditionSet extends WebTestCase function createTable($databaseName, $schema, $tableName, $fieldNumber) { global $webUrl; - global $lang; + global $lang, $SERVER; global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); - $this->get($webUrl . '/tables.php?action=create&database=' . - $databaseName . '&schema=' .$schema); + $this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $databaseName, + 'schema' => $schema) + ); - $this->setField('name', $tableName); + $this->setField('name', $tableName); $this->setField('fields', $fieldNumber); $this->assertTrue($this->setField('spcname', 'pg_default')); $this->setField('tblcomment', 'Create auto!'); - - // Clicks the button "next >" for inputing the detail information. + + // Clicks the button "next >" for inputing the detail information. //$this->assertTrue($this->ClickSubmit($lang['strnext'])); // If we do not hardcoded it here, it will cause fail. Encoding issue. - $this->assertTrue($this->ClickSubmit('Next >')); - + $this->assertTrue($this->ClickSubmit('Next >')); + for($ii = 0 ; $ii < $fieldNumber; $ii++) { $field = 'field[' . $ii .']'; @@ -155,7 +163,7 @@ class PreconditionSet extends WebTestCase // Click the button "Create" for creating the // table use the specify conditions. $this->clickSubmit($lang['strcreate']); - + return TRUE; } @@ -173,18 +181,22 @@ class PreconditionSet extends WebTestCase { // Import the global variable. global $webUrl; - global $lang; + global $lang, $SERVER; global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; // Login and trun to the page which list all the // table in the database. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); - $this->get($webUrl . '/tables.php?action=confirm_drop&database=' . - $databaseName . '&schema=' . $schema . '&table=' . - $tableName . '&'); + $this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $databaseName, + 'schema' => $schema, + 'table' => $tableName ) + ); // Click the button "Drop" for dropping the table from the database. $this->clickSubmit($lang['strdrop']); @@ -200,7 +212,7 @@ class PreconditionSet extends WebTestCase { global $webUrl; global $lang; - $this->get($webUrl . '/index.php'); + $this->get("$webUrl/index.php"); // Select the frame and logout. $this->setFrameFocus('topbar'); diff --git a/tests/testcase/Schemas/AggregateTest.php b/tests/testcase/Schemas/AggregateTest.php index f58fcef2..c44070e1 100644 --- a/tests/testcase/Schemas/AggregateTest.php +++ b/tests/testcase/Schemas/AggregateTest.php @@ -29,12 +29,11 @@ class AggregateTest extends PreconditionSet // Login the system. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); - - return TRUE; - } - - + "$webUrl/login.php"); + + return TRUE; + } + /** * Clean up all the result. */ @@ -45,8 +44,7 @@ class AggregateTest extends PreconditionSet return TRUE; } - - + /** * TestCaseID: HCA01 * Creates a new aggregate. @@ -54,11 +52,15 @@ class AggregateTest extends PreconditionSet function testCreateAggregate() { global $webUrl; - global $lang; - + global $lang, $SERVER, $DATABASE; + // Turn to "sql" page. - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=sql')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'sql')) + ); // Enter the definition of the new aggregate. $this->assertTrue($this->setField('query', 'CREATE AGGREGATE ' . 'complex_sum(sfunc1 = box_intersect, basetype = box,' . @@ -80,17 +82,20 @@ class AggregateTest extends PreconditionSet function testBrowseAggregates() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to "Aggregates" page. - $this->assertTrue($this->get($webUrl . '/aggregates.php?database=' . - 'test&schema=public&subject=schema')); - + $this->assertTrue($this->get("$webUrl/aggregates.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema') + )); + // Verify whether the aggregates is displayed correctly. $this->assertTrue($this->assertWantedText('complex_sum')); - } - - + } + /** * TestCaseID: HDA01 * Drop a aggregate. @@ -98,15 +103,19 @@ class AggregateTest extends PreconditionSet function testDropAggregate() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to "sql" page. - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=sql')); - + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'sql')) + ); + $this->assertTrue($this->setField('query', 'DROP AGGREGATE' . ' complex_sum(box);')); - + // Click the button "Go" to drop the aggregate. $this->assertTrue($this->clickSubmit($lang['strgo'])); // Verify whether the aggregates is dropped correctly. @@ -115,6 +124,4 @@ class AggregateTest extends PreconditionSet return TRUE; } } - - ?> diff --git a/tests/testcase/Schemas/ConversionTest.php b/tests/testcase/Schemas/ConversionTest.php index 442c6c05..dd3fc506 100644 --- a/tests/testcase/Schemas/ConversionTest.php +++ b/tests/testcase/Schemas/ConversionTest.php @@ -29,12 +29,11 @@ class ConversionTest extends PreconditionSet // Login the system. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); - + "$webUrl/login.php"); + return TRUE; } - - + /** * Clean up all the result. */ @@ -46,7 +45,6 @@ class ConversionTest extends PreconditionSet return TRUE; } - /** * TestCaseID: HBC01 * Browse the conversions. @@ -54,19 +52,23 @@ class ConversionTest extends PreconditionSet function testBrowseConversion() { global $webUrl; - global $lang; - + global $lang, $SERVER; + // Turn to schema "pg_catalog" page. - $this->assertTrue($this->get($webUrl . '/redirect.php?section=schema' . - '&database=template1&schema=pg_catalog&')); + $this->assertTrue($this->get("$webUrl/redirect.php", array( + 'server' => $SERVER, + 'section' => 'schema', + 'database' => 'template1', + 'schema' => 'pg_catalog')) + ); // Click the "Conversions" hyper link. - $this->assertTrue($this->clickLink($lang['strconversions'])); - + $this->assertTrue($this->clickLink($lang['strconversions'])); + // Verify whether the conversions are displayed. // Normally, there should be conversions in this schema, but if there is no, // this assert will fail. Need to assert the normal case. $this->assertTrue($this->assertWantedText($lang['strsourceencoding'])); - + return TRUE; } } diff --git a/tests/testcase/Schemas/DomainTest.php b/tests/testcase/Schemas/DomainTest.php index 5fe99eb8..4fb1c2e5 100644 --- a/tests/testcase/Schemas/DomainTest.php +++ b/tests/testcase/Schemas/DomainTest.php @@ -26,15 +26,14 @@ class DomainTest extends PreconditionSet global $webUrl; global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; - + // Login the system. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); - + "$webUrl/login.php"); + return TRUE; - } - - + } + /** * Cleans up all the result. */ @@ -46,7 +45,6 @@ class DomainTest extends PreconditionSet return TRUE; } - /** * TestCaseID: HCD01 * Create a domain. @@ -54,11 +52,15 @@ class DomainTest extends PreconditionSet function testCreateDomain() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Create domain" page. - $this->assertTrue($this->get($webUrl . '/domains.php?action=create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/domains.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter the detail information of the new domain. $this->assertTrue($this->setField('domname', 'spikedomain')); @@ -75,7 +77,6 @@ class DomainTest extends PreconditionSet return TRUE; } - /** * TestCaseID: HAD01 * Alter the definition of a domain. @@ -83,24 +84,28 @@ class DomainTest extends PreconditionSet function testAlterDomain() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Display the domain which is to be altered. - $this->assertTrue($this->get($webUrl . '/domains.php?action=propert' . - 'ies&database=test&schema=public&domain=spikedomain&')); - + $this->assertTrue($this->get("$webUrl/domains.php", array( + 'server' => $SERVER, + 'action' => 'properties', + 'database' => $DATABASE, + 'schema' => 'public', + 'domain' => 'spikedomain')) + ); + $this->assertTrue($this->clickLink($lang['stralter'])); $this->assertTrue($this->setField('domowner', 'tester')); - + // Click the "Alter" button to alter the domain. $this->assertTrue($this->clickSubmit($lang['stralter'])); // Verify whether the domian is altered successfully. $this->assertTrue($this->assertWantedText($lang['strdomainaltered'])); - + return TRUE; } - - + /** * TestCaseID: HAC01 * Add check to an existing domain. @@ -108,29 +113,33 @@ class DomainTest extends PreconditionSet function testAddCheck() { global $webUrl; - global $lang; - + global $lang, $SERVER, $DATABASE; + // Display the domain to be be altered. - $this->assertTrue($this->get($webUrl . '/domains.php?action=properties&' . - 'database=test&schema=public&domain=spikedomain&')); + $this->assertTrue($this->get("$webUrl/domains.php", array( + 'server' => $SERVER, + 'action' => 'properties', + 'database' => $DATABASE, + 'schema' => 'public', + 'domain' => 'spikedomain')) + ); $this->assertTrue($this->clickLink($lang['straddcheck'])); - + // Enter the check's definition. $this->assertTrue($this->setField('name', 'newcheck')); $this->assertTrue($this->setField('definition', 'VALUE[0] > 3')); - + // Click the "Add" button add a new check. $this->assertTrue($this->clickSubmit($lang['stradd'])); - + // Verify whether the new check added. $this->assertTrue($this->assertWantedText($lang['strcheckadded'])); - + return TRUE; - } - - + } + /** * TestCaseID: HDC01 * Drops an existing constraint of a domain. @@ -138,31 +147,39 @@ class DomainTest extends PreconditionSet function testDropConstraint() { global $webUrl; - global $lang; - + global $lang, $SERVER, $DATABASE; + // Turn to the domains-display page. - $this->assertTrue($this->get($webUrl . '/domains.php?database=test&' . - 'schema=public&')); + $this->assertTrue($this->get("$webUrl/domains.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public&')) + ); // Display the specfied damain. $this->assertTrue($this->clickLink('spikedomain')); - + // Drop the constraint. - $this->assertTrue($this->get($webUrl . '/domains.php?action=confirm_drop_con&' . - 'database=test&schema=public&constraint=newcheck&' . - 'domain=spikedomain&type=c')); - + $this->assertTrue($this->get("$webUrl/domains.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop_con', + 'database' => $DATABASE, + 'schema' => 'public', + 'constraint' => 'newcheck', + 'domain' => 'spikedomain', + 'type' => 'c')) + ); + $this->assertTrue($this->setField('cascade', TRUE)); - + // Click the "Drop" button to drop the constraint. $this->assertTrue($this->clickSubmit($lang['strdrop'])); // Verify whether the constraint is dropped successfully. $this->assertTrue($this->assertWantedText($lang['strconstraintdropped'])); - + return TRUE; } - - + /** * TestCaseID: HDD01 * Drop an existing domain. @@ -170,14 +187,23 @@ class DomainTest extends PreconditionSet function testDropDomain() { global $webUrl; - global $lang; - + global $lang, $SERVER, $DATABASE; + // Turn to the "domains" page. - $this->assertTrue($this->get($webUrl . '/domains.php?database=test&' . - 'schema=public&subject=schema')); - - $this->assertTrue($this->get($webUrl . '/domains.php?action=confirm_drop&' . - 'database=test&schema=public&domain=spikedomain&')); + $this->assertTrue($this->get("$webUrl/domains.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); + + $this->assertTrue($this->get("$webUrl/domains.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'domain' => 'spikedomain')) + ); $this->assertTrue($this->setField('cascade', TRUE)); // Click the "Drop" button to drop the domain. diff --git a/tests/testcase/Schemas/FunctionTest.php b/tests/testcase/Schemas/FunctionTest.php index 8c86c86d..2cdc970c 100644 --- a/tests/testcase/Schemas/FunctionTest.php +++ b/tests/testcase/Schemas/FunctionTest.php @@ -29,8 +29,8 @@ class FunctionTest extends PreconditionSet // Login the system. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); - + "$webUrl/login.php"); + return TRUE; } @@ -54,11 +54,15 @@ class FunctionTest extends PreconditionSet function testCreatSqlFunction() { global $webUrl; - global $lang; - + global $lang, $DATABASE, $SERVER; + // Turn to the "Create SQL/PL function" page. - $this->assertTrue($this->get($webUrl . '/functions.php?action=create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/functions.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter the detail information of a SQL/PL function. $this->assertTrue($this->setField('formFunction', 'sqlplfunction')); @@ -81,7 +85,6 @@ class FunctionTest extends PreconditionSet return TRUE; } - /** * TestCaseID: HCF02 * Create a internal function. @@ -89,11 +92,16 @@ class FunctionTest extends PreconditionSet function testCreateInternalFunction() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Create internal function" page. - $this->assertTrue($this->get($webUrl . '/functions.php?action=create&' . - 'language=internal&database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/functions.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'language' => 'internal', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter the detail information of a SQL/PL function. $this->assertTrue($this->setField('formFunction', 'internalfunction')); @@ -114,8 +122,7 @@ class FunctionTest extends PreconditionSet return TRUE; } - - + /** * TestCaseID: HCF03 * Create a C function. @@ -123,10 +130,13 @@ class FunctionTest extends PreconditionSet function testCreateCFunction() { global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/functions.php?database=test' . - '&schema=public&')); + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/functions.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Turn to the C-function create page. $this->assertTrue($this->clickLink($lang['strcreatecfunction'])); @@ -157,11 +167,15 @@ class FunctionTest extends PreconditionSet function testAlterFunction() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the function-display page. - $this->assertTrue($this->get($webUrl . '/functions.php?database=test' . - '&schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/functions.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Alter the definiton of "cfunction". $this->assertTrue($this->clickLink('cfunction (text)')); @@ -188,11 +202,15 @@ class FunctionTest extends PreconditionSet function testDropFunction() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the function-display page. - $this->assertTrue($this->get($webUrl . '/functions.php?database=test' . - '&schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/functions.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Drop the fucntion "sqlplfunction". $this->assertTrue($this->clickLink('sqlplfunction (double precision[], double precision)')); diff --git a/tests/testcase/Schemas/OpClassTest.php b/tests/testcase/Schemas/OpClassTest.php index 09626667..f6b2a328 100644 --- a/tests/testcase/Schemas/OpClassTest.php +++ b/tests/testcase/Schemas/OpClassTest.php @@ -30,7 +30,7 @@ class OpClassTest extends PreconditionSet // Login the system. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -55,11 +55,15 @@ class OpClassTest extends PreconditionSet function testBrowseOpClass() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to schema "pg_catalog" page. - $this->assertTrue($this->get($webUrl . '/opclasses.php?database=' . - 'test&schema=pg_catalog&subject=schema')); + $this->assertTrue($this->get("$webUrl/opclasses.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'pg_catalog', + 'subject' => 'schema')) + ); // Verify whether all the op classes are displayed. $this->assertTrue($this->assertWantedText($lang['straccessmethod'])); diff --git a/tests/testcase/Schemas/OperatorTest.php b/tests/testcase/Schemas/OperatorTest.php index 9a678a84..01743491 100644 --- a/tests/testcase/Schemas/OperatorTest.php +++ b/tests/testcase/Schemas/OperatorTest.php @@ -29,8 +29,8 @@ class OperatorTest extends PreconditionSet // Login the system. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); - + "$webUrl/login.php"); + return TRUE; } @@ -54,11 +54,15 @@ class OperatorTest extends PreconditionSet function testCreateOperator() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to "sql" page. - $this->assertTrue($this->get($webUrl . '/database.php?database=test' . - '&subject=database&action=sql')); + $this->assertTrue($this->get("$webUrl/database.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'subject' => 'database', + 'action' => 'sql')) + ); // Enter the definition of the new operator. $this->assertTrue($this->setField('query', 'CREATE OPERATOR === (' . 'LEFTARG = box, RIGHTARG = box, PROCEDURE = box_above, ' . @@ -81,11 +85,15 @@ class OperatorTest extends PreconditionSet function testShowProperty() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to "Operators" page. - $this->assertTrue($this->get($webUrl . '/operators.php?' . - 'database=test&schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/operators.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Show the properties of the operator "===". $this->assertTrue($this->clickLink('===')); // Check the properties. @@ -102,11 +110,15 @@ class OperatorTest extends PreconditionSet function testDropOperator() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to "Operators" page. - $this->assertTrue($this->get($webUrl . '/operators.php?' . - 'database=test&schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/operators.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Drop the first operator. $this->assertTrue($this->clickLink($lang['strdrop'])); diff --git a/tests/testcase/Schemas/SchemasGroupTest.php b/tests/testcase/Schemas/SchemasGroupTest.php index b00bb298..648870d3 100644 --- a/tests/testcase/Schemas/SchemasGroupTest.php +++ b/tests/testcase/Schemas/SchemasGroupTest.php @@ -29,24 +29,15 @@ class SchemasGroupTest extends GroupTest $this->GroupTest('Schema management group test.'); $this->addTestClass(new TableTest()); - - $this->addTestClass(new ViewTest()); - + $this->addTestClass(new ViewTest()); $this->addTestClass(new SequenceTest()); - - $this->addTestClass(new FunctionTest()); - + $this->addTestClass(new FunctionTest()); $this->addTestClass(new TypeTest()); - $this->addTestClass(new DomainTest()); - $this->addTestClass(new AggregateTest()); - $this->addTestClass(new OperatorTest()); - $this->addTestClass(new OpClassTest()); - - $this->addTestClass(new ConversionTest()); + $this->addTestClass(new ConversionTest()); } } ?> diff --git a/tests/testcase/Schemas/SequenceTest.php b/tests/testcase/Schemas/SequenceTest.php index d8831ced..19cbcc36 100644 --- a/tests/testcase/Schemas/SequenceTest.php +++ b/tests/testcase/Schemas/SequenceTest.php @@ -30,7 +30,7 @@ class SequenceTest extends PreconditionSet // Login the system. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -55,11 +55,15 @@ class SequenceTest extends PreconditionSet function testCreateSequence() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Create sequence" page. - $this->assertTrue($this->get($webUrl . '/sequences.php?action=create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/sequences.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter the detail information of a sequence. $this->assertTrue($this->setField('formSequenceName', 'createsequence')); @@ -87,11 +91,15 @@ class SequenceTest extends PreconditionSet function testResetSequence() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the sequence-display page. - $this->assertTrue($this->get($webUrl . '/sequences.php?database=test&' . - 'schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/sequences.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Browse the specified sequence. $this->assertTrue($this->clickLink('createsequence')); // Reset the sequence. @@ -113,14 +121,19 @@ class SequenceTest extends PreconditionSet function testDropSequence() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/sequences.php?action=confirm_drop&' . - 'database=test&schema=public&sequence=createsequence&')); + $this->assertTrue($this->get("$webUrl/sequences.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'sequence' => 'createsequence')) + ); $this->assertTrue($this->setField('cascade', TRUE)); $this->assertTrue($this->clickSubmit($lang['strdrop'])); - + // Verify if the sequence dropped successful. $this->assertTrue($this->assertWantedText($lang['strsequencedropped'])); diff --git a/tests/testcase/Schemas/TableTest.php b/tests/testcase/Schemas/TableTest.php index 9f638503..7671779a 100644 --- a/tests/testcase/Schemas/TableTest.php +++ b/tests/testcase/Schemas/TableTest.php @@ -28,7 +28,7 @@ class TableTest extends PreconditionSet global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -53,11 +53,15 @@ class TableTest extends PreconditionSet function testCreateTable() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the create table page to create a table. - $this->assertTrue($this->get($webUrl . '/tables.php?action=create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter the table name and field number. $this->assertTrue($this->setField('name', 'newtable')); @@ -86,7 +90,7 @@ class TableTest extends PreconditionSet $this->assertTrue($this->assertWantedText($lang['strtablecreated'])); // Drop the table which is created in the testcase. - $this->dropTable('test', 'newtable', 'public'); + $this->dropTable($DATABASE, 'newtable', 'public'); return TRUE; } @@ -99,11 +103,15 @@ class TableTest extends PreconditionSet function testCreateTableWithBadFieldNumber() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the create table page to create a table. - $this->assertTrue($this->get($webUrl . '/tables.php?action=create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter no name. //$this->assertTrue($this->clickSubmit($lang['strnext'])); @@ -143,11 +151,15 @@ class TableTest extends PreconditionSet function testCreateTableWithBadFieldData() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the create table page to create a table. - $this->assertTrue($this->get($webUrl . '/tables.php?action=create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter the table name and field number. $this->assertTrue($this->setField('name', 'badfield')); @@ -188,14 +200,19 @@ class TableTest extends PreconditionSet function testInsertOneRow() { global $webUrl; - global $lang; + global $lang, $SERVER,$DATABASE; // Create a table. - $this->createTable('test', 'public', 'viewtest', '3'); + $this->createTable($DATABASE, 'public', 'viewtest', '3'); // Turn to the "Insert row" interface. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confinsertrow&' . - 'database=test&schema=public&table=viewtest&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confinsertrow', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'viewtest')) + ); // Set the value of the fields. $this->assertTrue($this->setField('values[field0]', 'row1column1')); @@ -218,11 +235,16 @@ class TableTest extends PreconditionSet function testInsertTwoRows() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Insert row" interface. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confinsertrow&' . - 'database=test&schema=public&table=viewtest&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confinsertrow', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'viewtest')) + ); // Set the value of the fields. $this->assertTrue($this->setField('values[field0]', 'row2column1')); @@ -257,12 +279,17 @@ class TableTest extends PreconditionSet function testInsertWithBadData() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Insert row" interface. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confinsertrow&' . - 'database=test&schema=public&table=viewtest&')); - + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confinsertrow', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'viewtest')) + ); + // Set the value of the fields. $this->assertTrue($this->setField('format[field0]', 'Expression')); $this->assertTrue($this->setField('format[field1]', 'Expression')); @@ -283,22 +310,28 @@ class TableTest extends PreconditionSet /** * TestCaseID: HER01 - * Edit a row. + * Edit a row. + * XXX Fail cause we have no index on viewtest, created by $this->createable + * see Public/SetPrecondition.php */ function testEditRow() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Tables" interface. - $this->assertTrue($this->get($webUrl . '/tables.php?database=test&schema=public&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Select the table "viewtest". - $this->assertTrue($this->clickLink('viewtest')); + $this->assertTrue($this->clickLink('viewtest')); // Browse the table. - $this->assertTrue($this->clickLink($lang['strbrowse'])); + $this->assertTrue($this->clickLink($lang['strbrowse'])); // Select a row. - $this->assertTrue($this->clickLink($lang['stredit'])); - + $this->assertTrue($this->clickLink($lang['stredit'])); + // Edit the row. $this->assertTrue($this->setField('values[field0]', 'updatecolumn0')); $this->assertTrue($this->setField('values[field1]', 'updatecolumn1')); @@ -308,22 +341,27 @@ class TableTest extends PreconditionSet $this->assertTrue($this->clickSubmit($lang['strsave'])); // Verify whether the edit is done successfully. $this->assertTrue($this->assertWantedText('updatecolumn0')); - + return TRUE; } /** * TestCaseID: HDR01 - * Delete a row. + * Delete a row. + * XXX Fail, see comment on testEditRow */ function testDeleteRow() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Tables" interface. - $this->assertTrue($this->get($webUrl . '/tables.php?database=test&schema=public&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Select the table "viewtest". $this->assertTrue($this->clickLink('viewtest')); // Browse the table. @@ -345,13 +383,18 @@ class TableTest extends PreconditionSet function testBrowseTable() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Browse table" interface. - $this->assertTrue($this->get($webUrl . '/display.php?database=test&' . - 'schema=public&subject=table&return_url=tables.php%3Fdatab' . - 'ase%3Dtest%26amp%3Bschema%3Dpublic&return_desc=Back&table=' . - 'viewtest&')); + $this->assertTrue($this->get("$webUrl/display.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'table', + 'return_url' => 'tables.php%3Fdatabase%3Dtest%26amp%3Bschema%3Dpublic', + 'return_desc' => 'Back', + 'table' => 'viewtest')) + ); // Verify whether the rows are displayed. $this->assertTrue($this->assertWantedText($lang['strrows'])); @@ -375,11 +418,15 @@ class TableTest extends PreconditionSet function testSelectAll() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "tables" page. - $this->assertTrue($this->get($webUrl . '/tables.php?database=test' . - '&schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); $this->assertTrue($this->clickLink('viewtest')); // Select all the rows. @@ -396,7 +443,6 @@ class TableTest extends PreconditionSet return TRUE; } - /** * TestCaseID: HST02 * Select rows according to the query conditions. @@ -404,11 +450,17 @@ class TableTest extends PreconditionSet function testSelectByConditions() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "tables" page. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confselectrows&' . - 'database=test&schema=public&table=viewtest&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confselectrows', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'viewtest')) + ); + // Display all columns. $this->assertTrue($this->setField('show[field0]', TRUE)); $this->assertTrue($this->setField('show[field1]', TRUE)); @@ -425,7 +477,6 @@ class TableTest extends PreconditionSet return TRUE; } - /** * TestCaseID: HST03 * Select data from an existing table with no row display. @@ -433,11 +484,16 @@ class TableTest extends PreconditionSet function testSelectTableNoRowDisplay() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "tables" page. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confselectrows&' . - 'database=test&schema=public&table=viewtest&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confselectrows', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'viewtest')) + ); // Enter the query conditions. $this->assertTrue($this->setField('values[field0]', 'row2column1')); @@ -460,11 +516,16 @@ class TableTest extends PreconditionSet function testVacuumUnchecked() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Vacuum" page. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_vacuum&' . - 'database=test&schema=public&table=viewtest&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confirm_vacuum', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'viewtest')) + ); // Click the "Vacuum" button. $this->assertTrue($this->clickSubmit($lang['strvacuum'])); @@ -482,11 +543,16 @@ class TableTest extends PreconditionSet function testVacuumChecked() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Vacuum" page. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_vacuum&' . - 'database=test&schema=public&table=viewtest&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confirm_vacuum', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'viewtest')) + ); // Make sure the check box "Full" and "Analyze" are checked $this->assertTrue($this->setField('vacuum_full', TRUE)); @@ -508,15 +574,24 @@ class TableTest extends PreconditionSet function testEmptyTable() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "tables" page. - $this->assertTrue($this->get($webUrl . '/tables.php?database=test&' . - 'schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Empty a table. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_empty&' . - 'database=test&schema=public&table=viewtest&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confirm_empty', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'viewtest')) + ); // Click the "Empty" button to clean the content of the table. $this->assertTrue($this->clickSubmit($lang['strempty'])); @@ -534,14 +609,23 @@ class TableTest extends PreconditionSet function testAlterTable() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Drop the table. - $this->assertTrue($this->get($webUrl . '/tables.php?database=test' . - '&schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Select the table. - $this->assertTrue($this->get($webUrl . '/tblproperties.php?action=confirm_alter&' . - 'database=test&schema=public&table=viewtest')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'confirm_alter', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'viewtest')) + ); $this->assertTrue($this->setField('name', 'testview')); $this->assertTrue($this->setField('owner', 'tester')); @@ -561,11 +645,17 @@ class TableTest extends PreconditionSet function testDropTable() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Drop the table. - $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_drop&' . - 'database=test&schema=public&table=testview&')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'testview')) + ); + $this->assertTrue($this->setField('cascade', TRUE)); // Click the "Drop" button to drop the table. $this->assertTrue($this->clickSubmit($lang['strdrop'])); diff --git a/tests/testcase/Schemas/TypeTest.php b/tests/testcase/Schemas/TypeTest.php index 27ba3b5f..acd68366 100644 --- a/tests/testcase/Schemas/TypeTest.php +++ b/tests/testcase/Schemas/TypeTest.php @@ -29,7 +29,7 @@ class TypeTest extends PreconditionSet // Login the system. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -54,11 +54,15 @@ class TypeTest extends PreconditionSet function testCreateType() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to "Types" page. - $this->assertTrue($this->get($webUrl . '/types.php?database=test&' . - 'schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/types.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); $this->assertTrue($this->clickLink($lang['strcreatetype'])); // Enter the definition of the type. @@ -81,11 +85,15 @@ class TypeTest extends PreconditionSet function testCreateCompositeType() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to "Types" page. - $this->assertTrue($this->get($webUrl . '/types.php?database=test&' . - 'schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/types.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); $this->assertTrue($this->clickLink($lang['strcreatecomptype'])); // Create without composite type name. @@ -135,11 +143,15 @@ class TypeTest extends PreconditionSet function testShowProperty() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to "Types" page. - $this->assertTrue($this->get($webUrl . '/types.php?database=test&' . - 'schema=pg_catalog&subject=schema')); + $this->assertTrue($this->get("$webUrl/types.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'pg_catalog', + 'subject' => 'schema')) + ); // Show the properties of general type. $this->assertTrue($this->clickLink('integer')); @@ -148,8 +160,12 @@ class TypeTest extends PreconditionSet // Turn to "Types" page. - $this->assertTrue($this->get($webUrl . '/types.php?database=test&' . - 'schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/types.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Show the properties of a composite type "compositetype". $this->assertTrue($this->clickLink('compositetype')); @@ -167,11 +183,16 @@ class TypeTest extends PreconditionSet function testDropType() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to type-dropped confirm page. - $this->assertTrue($this->get($webUrl . '/types.php?action=confirm_drop&' . - 'database=test&schema=public&type=compositetype&')); + $this->assertTrue($this->get("$webUrl/types.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'type' => 'compositetype')) + ); $this->assertTrue($this->setField('cascade', TRUE)); diff --git a/tests/testcase/Schemas/ViewTest.php b/tests/testcase/Schemas/ViewTest.php index 99f48f43..db1bf017 100644 --- a/tests/testcase/Schemas/ViewTest.php +++ b/tests/testcase/Schemas/ViewTest.php @@ -29,7 +29,7 @@ class ViewTest extends PreconditionSet // Login the system. $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -55,13 +55,17 @@ class ViewTest extends PreconditionSet { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->createTable('test', 'public', 'viewtest', '3'); - + $this->createTable($DATABASE, 'public', 'viewtest', '3'); + // Turn to the "Create view" page. - $this->assertTrue($this->get($webUrl . '/views.php?action=create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/views.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter the definition of the view. $this->assertTrue($this->setField('formView', 'createviewdirectly')); @@ -86,12 +90,16 @@ class ViewTest extends PreconditionSet function testCreateViewWithWizard() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Create view with wizard" page. - $this->assertTrue($this->get($webUrl . '/views.php?action=wiz_create&' . - 'database=test&schema=public')); - + $this->assertTrue($this->get("$webUrl/views.php", array( + 'server' => $SERVER, + 'action' => 'wiz_create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); + // Select the table. $this->assertTrue($this->setField('formTables[]', array('public.viewtest'))); @@ -118,11 +126,15 @@ class ViewTest extends PreconditionSet function testCreateViewDirectlyNegative() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Create view" page. - $this->assertTrue($this->get($webUrl . '/views.php?action=create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/views.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter the definition of the view. $this->assertTrue($this->setField('formView', 'createviewdirectly')); @@ -149,11 +161,15 @@ class ViewTest extends PreconditionSet function testCreateViewWithWizardNegation() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the "Create view with wizard" page. - $this->assertTrue($this->get($webUrl . '/views.php?action=wiz_create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/views.php", array( + 'server' => $SERVER, + 'action' => 'wiz_create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Select the table. $this->assertTrue($this->setField('formTables[]', array('public.viewtest'))); @@ -180,13 +196,18 @@ class ViewTest extends PreconditionSet function testBrowseView() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Browse the view "createviewdirectly" created just now. - $this->assertTrue($this->get($webUrl . '/display.php?database=test&' . - 'schema=public&subject=view&return_url=views.php%3Fdatabase%' . - '3Dtest%26amp%3Bschema%3Dpublic&return_desc=Back&view=' . - 'createviewdirectly&')); + $this->assertTrue($this->get("$webUrl/display.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'view', + 'return_url' => 'views.php%3Fdatabase%3Dtest%26amp%3Bschema%3Dpublic', + 'return_desc' => 'Back', + 'view' => 'createviewdirectly')) + ); // Click the links in the view-display page. $this->assertTrue($this->clickLink($lang['strexpand'])); @@ -205,10 +226,15 @@ class ViewTest extends PreconditionSet function testSelectView() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/views.php?action=confselectrows&' . - 'database=test&schema=public&view=createviewdirectly&')); + $this->assertTrue($this->get("$webUrl/views.php", array( + 'server' => $SERVER, + 'action' => 'confselectrows', + 'database' => $DATABASE, + 'schema' => 'public', + 'view' => 'createviewdirectly')) + ); // Enter the query conditions. $this->assertTrue($this->setField('show[field0]', TRUE)); @@ -230,11 +256,15 @@ class ViewTest extends PreconditionSet function testAlterView() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the view display page. - $this->assertTrue($this->get($webUrl . '/views.php?database=test&' . - 'schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/views.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Select a view. $this->assertTrue($this->clickLink('createviewdirectly')); // Select a column. @@ -259,15 +289,19 @@ class ViewTest extends PreconditionSet function testAlterDefinition() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Turn to the view display page. - $this->assertTrue($this->get($webUrl . '/views.php?database=test&' . - 'schema=public&subject=schema')); + $this->assertTrue($this->get("$webUrl/views.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'subject' => 'schema')) + ); // Select a view. $this->assertTrue($this->clickLink('createviewdirectly')); // Browse the definition of the view. - $this->assertTrue($this->clickLink($lang['strdefinition'])); + $this->assertTrue($this->clickLink("{$lang['strdefinition']} {$lang['strdefinition']}")); $this->assertTrue($this->clickLink($lang['stralter'])); // Alter the definition here. @@ -280,7 +314,7 @@ class ViewTest extends PreconditionSet $this->assertTrue($this->clickSubmit($lang['stralter'])); //Verify whether the definition is altered. $this->assertTrue($this->assertWantedText($lang['strviewupdated'])); - + return TRUE; } @@ -292,11 +326,16 @@ class ViewTest extends PreconditionSet function testDropView() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Drop the view which was created in the last case. - $this->assertTrue($this->get($webUrl . '/views.php?action=confirm_drop&' . - 'database=test&schema=public&view=createviewdirectly&')); + $this->assertTrue($this->get("$webUrl/views.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'view' => 'createviewdirectly')) + ); $this->assertTrue($this->setField('cascade', TRUE)); $this->assertTrue($this->clickSubmit($lang['strdrop'])); @@ -305,7 +344,7 @@ class ViewTest extends PreconditionSet $this->assertTrue($this->assertWantedText($lang['strviewdropped'])); // Drop the table which is created in setUp(). - $this->dropTable('test', 'viewtest', 'public'); + $this->dropTable($DATABASE, 'viewtest', 'public'); return TRUE; } diff --git a/tests/testcase/Server/GroupsTest.php b/tests/testcase/Server/GroupsTest.php index 2f9328a9..e03a897c 100644 --- a/tests/testcase/Server/GroupsTest.php +++ b/tests/testcase/Server/GroupsTest.php @@ -28,20 +28,18 @@ class GroupsTest extends PreconditionSet global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; - $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, "$webUrl/login.php"); return TRUE; } - - + function tearDown() { $this->logout(); - + return TRUE; } - - + /* * TestCaseID: SCG01 * Test to create group. @@ -51,16 +49,16 @@ class GroupsTest extends PreconditionSet global $webUrl; global $POWER_USER_NAME; global $NORMAL_USER_NAME; - global $lang; - + global $lang, $SERVER; + // Turn to create group page. - $this->assertTrue($this->get($webUrl . '/groups.php')); + $this->assertTrue($this->get("$webUrl/groups.php", array('server' => $SERVER))); $this->assertTrue($this->clickLink($lang['strcreategroup'])); - + // Enter the information for creating group. $this->assertTrue($this->setField('name', $this->_groupName)); $this->assertTrue($this->setField('members[]', array($POWER_USER_NAME, $NORMAL_USER_NAME))); - + // Then submit and verify it. $this->assertTrue($this->clickSubmit($lang['strcreate'])); $this->assertWantedText($lang['strgroupcreated']); @@ -68,8 +66,8 @@ class GroupsTest extends PreconditionSet return TRUE; } - - + + /* * TestCaseID: SAG01 * Test to add users to the gruop. @@ -80,12 +78,15 @@ class GroupsTest extends PreconditionSet global $SUPER_USER_NAME; global $POWER_USER_NAME; global $NORMAL_USER_NAME; - global $lang; + global $lang, $SERVER; // Turn to the gruop's properties page. - $this->assertTrue($this->get($webUrl . '/groups.php')); - $this->assertTrue($this->get($webUrl . '/groups.php?action=properties' . - '&group=' . $this->_groupName)); + $this->assertTrue($this->get("$webUrl/groups.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/groups.php", + array('action' => 'properties', + 'group' => $this->_groupName, + 'server' => $SERVER)) + ); // Select user and add it to the group. $this->assertTrue($this->setField('user', $SUPER_USER_NAME)); @@ -112,12 +113,15 @@ class GroupsTest extends PreconditionSet global $SUPER_USER_NAME; global $POWER_USER_NAME; global $NORMAL_USER_NAME; - global $lang; + global $lang, $SERVER; // Turn to the gruop properties page. - $this->assertTrue($this->get($webUrl . '/groups.php')); - $this->assertTrue($this->get($webUrl . '/groups.php?action=properties' . - '&group=' . $this->_groupName)); + $this->assertTrue($this->get("$webUrl/groups.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/groups.php", + array('action' => 'properties', + 'group' => $this->_groupName, + 'server' => $SERVER)) + ); // Drop users from the group and verify it. $this->assertTrue($this->clickLink($lang['strdrop'])); @@ -135,12 +139,15 @@ class GroupsTest extends PreconditionSet function testDrop() { global $webUrl; - global $lang; + global $lang, $SERVER; // Turn to the drop group page.. - $this->assertTrue($this->get($webUrl . '/groups.php')); - $this->assertTrue($this->get($webUrl . '/groups.php?action=confirm_drop' . - '&&group=' . $this->_groupName)); + $this->assertTrue($this->get("$webUrl/groups.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/groups.php", + array('server' => $SERVER, + 'action' => 'confirm_drop', + 'group' => $this->_groupName)) + ); // Confirm to drop the group and verify it. $this->assertTrue($this->clickSubmit($lang['strdrop'])); diff --git a/tests/testcase/Server/ReportsTest.php b/tests/testcase/Server/ReportsTest.php index aa821e1e..e1dca6e2 100644 --- a/tests/testcase/Server/ReportsTest.php +++ b/tests/testcase/Server/ReportsTest.php @@ -28,7 +28,7 @@ class ReportsTest extends PreconditionSet global $SUPER_USER_NAME; global $SUPER_USER_PASSWORD; - $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, "$webUrl/login.php"); return TRUE; } @@ -49,27 +49,27 @@ class ReportsTest extends PreconditionSet function testCreate() { global $webUrl; - global $lang; - + global $lang, $SERVER, $DATABASE; + // Turn to the create report page. - $this->assertTrue($this->get($webUrl . '/reports.php')); + $this->assertTrue($this->get("$webUrl/reports.php", array('server' => $SERVER))); $this->assertTrue($this->clickLink($lang['strcreatereport'])); - + // Enter information for creating a report. $this->assertTrue($this->setField('report_name', $this->_reportName)); - $this->assertTrue($this->setField('db_name', 'test')); + $this->assertTrue($this->setField('db_name', $DATABASE)); $this->assertTrue($this->setField('descr', 'comment')); $this->assertTrue($this->setField('report_sql', 'select * from student where 1=0')); - + //Then submit and verify it. $this->assertTrue($this->clickSubmit($lang['strsave'])); $this->assertWantedText($lang['strreportcreated']); $this->assertWantedText($this->_reportName); - + return TRUE; } - - + + /* * TestCaseID: SRR01 * Test to run existing report. @@ -77,27 +77,32 @@ class ReportsTest extends PreconditionSet function testRun() { global $webUrl; - global $lang; + global $lang, $SERVER; // Run the existing report and verify it. - $this->assertTrue($this->get($webUrl . '/reports.php')); - $this->assertTrue($this->clickLink($lang['strexecute'])); + $this->assertTrue($this->get("$webUrl/reports.php", array('server' => $SERVER))); + $this->assertTrue($this->clickLink($lang['strexecute'])); $this->assertWantedText($lang['strnodata']); - - $this->assertTrue($this->clickLink($lang['strrefresh'])); + +/* XXX there's no refresh link on report results page. see sql.php + $this->assertTrue($this->clickLink($lang['strrefresh'])); $this->assertWantedText($lang['strnodata']); - + */ +/* XXX there's no expand-collapse link on report results page. see sql.php $this->assertTrue($this->clickLink($lang['strexpand'])); $this->assertWantedText($lang['strnodata']); $this->assertWantedText($lang['strcollapse']); - + $this->assertTrue($this->clickLink($lang['strcollapse'])); $this->assertWantedText($lang['strnodata']); - $this->assertWantedText($lang['strexpand']); - + $this->assertWantedText($lang['strexpand']); +*/ + +/* XXX btw, there's a "create report" link in the report results page o_O */ + return TRUE; } - + /* * TestCaseID: SER01 @@ -106,16 +111,16 @@ class ReportsTest extends PreconditionSet function testEdit() { global $webUrl; - global $lang; - + global $lang, $SERVER, $DATABASE; + // Turn to the edit report page. - $this->assertTrue($this->get($webUrl . '/reports.php')); + $this->assertTrue($this->get("$webUrl/reports.php", array('server' => $SERVER))); $this->assertTrue($this->clickLink($this->_reportName)); $this->assertTrue($this->clickLink($lang['stredit'])); - + // Enter the information for altering the report's properties. $this->assertTrue($this->setField('report_name', $this->_reportName)); - $this->assertTrue($this->setField('db_name', 'test')); + $this->assertTrue($this->setField('db_name', $DATABASE)); $this->assertTrue($this->setField('descr', 'comment is changed')); $this->assertTrue($this->setField('report_sql', 'select * from student where 0=1')); @@ -135,10 +140,10 @@ class ReportsTest extends PreconditionSet function testDrop() { global $webUrl; - global $lang; - + global $lang, $SERVER; + // Turn to the drop report page. - $this->assertTrue($this->get($webUrl . '/reports.php')); + $this->assertTrue($this->get("$webUrl/reports.php", array('server' => $SERVER))); $this->assertTrue($this->clickLink($lang['strdrop'])); // Confirm to drop the report and verify it. diff --git a/tests/testcase/Server/TableSpacesTest.php b/tests/testcase/Server/TableSpacesTest.php index d8da4469..c22a3fea 100644 --- a/tests/testcase/Server/TableSpacesTest.php +++ b/tests/testcase/Server/TableSpacesTest.php @@ -31,7 +31,7 @@ class TableSpacesTest extends PreconditionSet global $SUPER_USER_PASSWORD; global $lang; - $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, "$webUrl/login.php"); return TRUE; } @@ -46,17 +46,18 @@ class TableSpacesTest extends PreconditionSet /* * TestCaseID: SCT01 - * Test to create tablespace. + * Test to create tablespace. + * XXX: Your PgSQL admin user must own data/TableSpace */ function testCreate() { global $webUrl; global $POWER_USER_NAME; - global $lang; - $this->_location = getcwd() . '/../data/TableSpace'; + global $lang, $SERVER; + $this->_location = getcwd() . '/data/TableSpace'; // Turn to the create tablespace page. - $this->assertTrue($this->get($webUrl . '/tablespaces.php')); + $this->assertTrue($this->get("$webUrl/tablespaces.php", array('server' => $SERVER))); $this->assertTrue($this->clickLink($lang['strcreatetablespace'])); // Enter information for creating a tablespace. @@ -65,8 +66,8 @@ class TableSpacesTest extends PreconditionSet $this->assertTrue($this->setField('formLoc', $this->_location)); // Then submit and verify it. - $this->assertTrue($this->clickSubmit($lang['strcreate'])); - $this->assertWantedText($this->_tableSpaceName); + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + $this->assertWantedText($lang['strtablespacecreated']); return TRUE; } @@ -80,21 +81,24 @@ class TableSpacesTest extends PreconditionSet { global $webUrl; global $NORMAL_USER_NAME; - global $lang; + global $lang, $SERVER; // Turn to the alter tablespace page. - $this->assertTrue($this->get($webUrl . '/tablespaces.php')); - $this->assertTrue($this->get($webUrl . '/tablespaces.php?action=edit' . - '&tablespace=' . $this->_tableSpaceName)); - + $this->assertTrue($this->get("$webUrl/tablespaces.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/tablespaces.php", array( + 'server' => $SERVER, + 'action' => 'edit', + 'tablespace' => $this->_tableSpaceName)) + ); + // Enter information for altering the tableSpace's properties. $this->assertTrue($this->setField('name', $this->_tableSpaceName)); $this->assertTrue($this->setField('owner', $NORMAL_USER_NAME)); - + // Then submit and verify it. $this->assertTrue($this->clickSubmit($lang['stralter'])); $this->assertWantedText($lang['strtablespacealtered']); - + return TRUE; } @@ -106,12 +110,15 @@ class TableSpacesTest extends PreconditionSet { global $webUrl; global $NORMAL_USER_NAME; - global $lang; + global $lang, $SERVER; // Turn to the privileges page. - $this->assertTrue($this->get($webUrl . '/privileges.php')); - $this->assertTrue($this->get($webUrl . '/privileges.php?subject=tablespace' . - '&tablespace=' . $this->_tableSpaceName)); + $this->assertTrue($this->get("$webUrl/privileges.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/privileges.php", array( + 'server' => $SERVER, + 'subject' => 'tablespace', + 'tablespace' => $this->_tableSpaceName)) + ); // Grant with no privileges selected. $this->assertTrue($this->clickLink($lang['strgrant'])); @@ -136,12 +143,15 @@ class TableSpacesTest extends PreconditionSet { global $webUrl; global $NORMAL_USER_NAME; - global $lang; + global $lang, $SERVER; // Turn to the privileges page. - $this->assertTrue($this->get($webUrl . '/privileges.php')); - $this->assertTrue($this->get($webUrl . '/privileges.php?subject=tablespace' . - '&tablespace=' . $this->_tableSpaceName)); + $this->assertTrue($this->get("$webUrl/privileges.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/privileges.php", array( + 'server' => $SERVER, + 'subject' => 'tablespace', + 'tablespace' => $this->_tableSpaceName)) + ); // Revoke with no users selected. $this->assertTrue($this->clickLink($lang['strrevoke'])); @@ -165,12 +175,15 @@ class TableSpacesTest extends PreconditionSet { global $webUrl; global $NORMAL_USER_NAME; - global $lang; + global $lang, $SERVER; // Turn to the privileges page. - $this->assertTrue($this->get($webUrl . '/privileges.php')); - $this->assertTrue($this->get($webUrl . '/privileges.php?subject=tablespace' . - '&tablespace=' . $this->_tableSpaceName)); + $this->assertTrue($this->get("$webUrl/privileges.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/privileges.php", array( + 'server' => $SERVER, + 'subject' => 'tablespace', + 'tablespace' => $this->_tableSpaceName)) + ); // Grant whit no privilege selected. $this->assertTrue($this->clickLink($lang['strgrant'])); @@ -191,12 +204,15 @@ class TableSpacesTest extends PreconditionSet { global $webUrl; global $NORMAL_USER_NAME; - global $lang; + global $lang, $SERVER; // Turn to the privileges page. - $this->assertTrue($this->get($webUrl . '/privileges.php')); - $this->assertTrue($this->get($webUrl . '/privileges.php?subject=tablespace' . - '&tablespace=' . $this->_tableSpaceName)); + $this->assertTrue($this->get("$webUrl/privileges.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/privileges.php", array( + 'server' => $SERVER, + 'subject' => 'tablespace', + 'tablespace' => $this->_tableSpaceName)) + ); // Revoke whit no users selected. $this->assertTrue($this->clickLink($lang['strrevoke'])); @@ -216,13 +232,16 @@ class TableSpacesTest extends PreconditionSet function testDrop() { global $webUrl; - global $lang; + global $lang, $SERVER; // Turn to the drop user page. - $this->assertTrue($this->get($webUrl . '/tablespaces.php')); - $this->assertTrue($this->get($webUrl . '/tablespaces.php?action=confirm_drop' . - '&tablespace=' . $this->_tableSpaceName)); - + $this->assertTrue($this->get("$webUrl/tablespaces.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/tablespaces.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'tablespace' => $this->_tableSpaceName)) + ); + // Confirm to drop the user and verify it. $this->assertTrue($this->clickSubmit($lang['strdrop'])); $this->assertWantedText($lang['strtablespacedropped']); diff --git a/tests/testcase/Server/UsersTest.php b/tests/testcase/Server/UsersTest.php index f4cd5977..159075f8 100644 --- a/tests/testcase/Server/UsersTest.php +++ b/tests/testcase/Server/UsersTest.php @@ -8,10 +8,7 @@ */ // Import the precondition class. -if(is_dir('../Public')) -{ - require_once('../Public/SetPrecondition.php'); -} +require_once('Public/SetPrecondition.php'); /** * This class is to test the user management. @@ -22,27 +19,23 @@ class UsersTest extends PreconditionSet // Declare the user names which are created, altered and dropped in the class. private $_superUserName = "superuser"; private $_powerUserName = "poweruser"; - + function setUp() { - global $webUrl; - global $SUPER_USER_NAME; - global $SUPER_USER_PASSWORD; - - $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); - + global $webUrl, $SUPER_USER_NAME, $SUPER_USER_PASSWORD, $SERVER; + + $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, "$webUrl/login.php"); + return TRUE; } - - + function tearDown() { $this->logout(); return TRUE; } - - + /* * TestCaseID: SCU01 * Test to create super user. @@ -50,12 +43,13 @@ class UsersTest extends PreconditionSet function testCreateSuper() { global $webUrl; - global $lang; - + global $lang, $SERVER; + // Turn to the "Create user" page. - $this->assertTrue($this->get($webUrl . '/users.php')); - $this->assertTrue($this->clickLink($lang['strcreateuser'])); - + $this->assertTrue($this->get("$webUrl/users.php", array('server' => $SERVER))); + + $this->assertTrue($this->clickLink($lang['strcreateuser'])); + // Enter information for creating a user. $this->assertTrue($this->setField('formUsername', $this->_superUserName)); $this->assertTrue($this->setField('formPassword', '123456')); @@ -77,22 +71,22 @@ class UsersTest extends PreconditionSet function testCreatePower() { global $webUrl; - global $lang; + global $lang, $SERVER; // Turn to the "Create user" page. - $this->assertTrue($this->get($webUrl . '/users.php')); + $this->assertTrue($this->get("$webUrl/users.php", array('server' => $SERVER))); $this->assertTrue($this->clickLink($lang['strcreateuser'])); - + // Enter information for creating a user. $this->assertTrue($this->setField('formUsername', $this->_powerUserName)); $this->assertTrue($this->setField('formPassword', '123456')); $this->assertTrue($this->setField('formConfirm', '123456')); $this->assertTrue($this->setField('formCreateDB', TRUE)); - + //Then submit and verify it. $this->assertTrue($this->clickSubmit($lang['strcreate'])); $this->assertWantedText($this->_powerUserName); - + return TRUE; } @@ -106,10 +100,10 @@ class UsersTest extends PreconditionSet global $SUPER_USER_NAME; global $POWER_USER_NAME; global $NORMAL_USER_NAME; - global $lang; + global $lang, $SERVER; // Get the users list page and verify it. - $this->assertTrue($this->get($webUrl . '/users.php')); + $this->assertTrue($this->get("$webUrl/users.php", array('server' => $SERVER))); $this->assertWantedText($SUPER_USER_NAME); $this->assertWantedText($POWER_USER_NAME); $this->assertWantedText($NORMAL_USER_NAME); @@ -125,28 +119,30 @@ class UsersTest extends PreconditionSet function testAlter() { global $webUrl; - global $lang; + global $lang, $SERVER; // Turn to the "alter user" page. - $this->assertTrue($this->get($webUrl . '/users.php')); - $this->assertTrue($this->get($webUrl . '/users.php?action=edit' . - '&&username=' . $this->_superUserName)); - + $this->assertTrue($this->get("$webUrl/users.php")); + $this->assertTrue($this->get("$webUrl/users.php", array( + 'action' => 'edit', + 'username' => $this->_superUserName, + 'server' => $SERVER)) + ); + // Enter the information for altering the user's properties. $this->assertTrue($this->setField('newname', $this->_superUserName)); $this->assertTrue($this->setField('formPassword', '56789')); $this->assertTrue($this->setField('formConfirm', '56789')); $this->assertTrue($this->setField('formSuper', TRUE)); $this->assertTrue($this->setField('formCreateDB', FALSE)); - + // Then submit and verify it. $this->assertTrue($this->clickSubmit($lang['stralter'])); $this->assertWantedText($this->_superUserName); - + return TRUE; - } - - + } + /* * TestCaseID: SDU01 * Test to drop existing user. @@ -154,20 +150,23 @@ class UsersTest extends PreconditionSet function testDrop() { global $webUrl; - global $lang; + global $lang, $SERVER; // Turn to the drop user page.. - $this->assertTrue($this->get($webUrl . '/users.php')); - $this->assertTrue($this->get($webUrl . '/users.php?action=confirm_drop' . - '&&username=' . $this->_superUserName)); - + $this->assertTrue($this->get("$webUrl/users.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/users.php", array( + 'action' => 'confirm_drop', + 'username' => $this->_superUserName, + 'server' => $SERVER)) + ); + // Confirm to drop the user and verify it. $this->assertTrue($this->clickSubmit($lang['strdrop'])); $this->assertNoUnWantedText($this->_superUserName); - + return TRUE; } - + /* * TestCaseID: SDU02 * Test to drop existing user when the user is login. @@ -175,34 +174,37 @@ class UsersTest extends PreconditionSet function testDropLogin() { global $webUrl; - global $lang; + global $lang, $SERVER; // Create a new browser to login the power user which we want to drop. $newBrowser = $this->createBrowser(); - $newBrowser->get($webUrl . '/index.php'); - $this->assertTrue($newBrowser->setField('formUsername', $this->_powerUserName)); - $this->assertTrue($newBrowser->setField('formPassword', '123456')); + $newBrowser->get("$webUrl/login.php", array('server' => $SERVER)); + $this->assertTrue($newBrowser->setField('loginUsername', $this->_powerUserName)); + $this->assertTrue($newBrowser->setFieldById('loginPassword', '123456')); $this->assertTrue($newBrowser->clickSubmit('Login')); - $this->assertTrue($newBrowser->get($webUrl . '/all_db.php')); - + $this->assertTrue($newBrowser->get("$webUrl/all_db.php", array('server' => $SERVER))); + // Turn to the old browser which we login with super user at very beginning. - $this->assertTrue($this->get($webUrl . '/users.php')); - $this->assertTrue($this->get($webUrl . '/users.php?action=confirm_drop' . - '&&username=' . $this->_powerUserName)); - + $this->assertTrue($this->get("$webUrl/users.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/users.php", array('action' => 'confirm_drop', + 'username' => $this->_powerUserName, + 'server' => $SERVER)) + ); + // Confirm to drop the user and verify it. $this->assertTrue($this->clickSubmit($lang['strdrop'])); $this->assertNoUnWantedText($this->_powerUserName); // Go back to the power user browser and try to create the database. // It will log out and $lang['strloginfailed'] will be displayed in the page. - $this->setBrowser($newBrowser); + $this->setBrowser($newBrowser); + $this->assertTrue($this->clickLink($lang['strcreatedatabase'])); $this->assertWantedText($lang['strloginfailed']); return TRUE; } - + /* * TestCaseID: SDU03 * Test to drop the user self. @@ -211,18 +213,21 @@ class UsersTest extends PreconditionSet { global $webUrl; global $SUPER_USER_NAME; - global $lang; + global $lang, $SERVER; // Turn to the drop user page.. - $this->assertTrue($this->get($webUrl . '/users.php')); - $this->assertTrue($this->get($webUrl . '/users.php?action=confirm_drop' . - '&&username=' . $SUPER_USER_NAME)); - + $this->assertTrue($this->get("$webUrl/users.php", array('server' => $SERVER))); + $this->assertTrue($this->get("$webUrl/users.php", array( + 'action' => 'confirm_drop', + 'username' => $SUPER_USER_NAME, + 'server' => $SERVER )) + ); + // Confirm to drop the user and verify it. $this->assertTrue($this->clickSubmit($lang['strdrop'])); $this->assertWantedText($SUPER_USER_NAME); $this->assertWantedText($lang['struserdroppedbad']); - + return TRUE; } } diff --git a/tests/testcase/Tables/ColumnTest.php b/tests/testcase/Tables/ColumnTest.php index 9f3f78be..946e8cc2 100644 --- a/tests/testcase/Tables/ColumnTest.php +++ b/tests/testcase/Tables/ColumnTest.php @@ -29,20 +29,20 @@ class ColumnTest extends PreconditionSet{ global $POWER_USER_PASSWORD; $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, - $webUrl . '/index.php'); - + "$webUrl/login.php"); + return TRUE; } - + /** * Clean up all the result. */ function tearDown(){ $this->logout(); - + return TRUE; } - + /** * TestCaseID: TNC01 * Add a column to the table @@ -50,11 +50,16 @@ class ColumnTest extends PreconditionSet{ function testAddColumn() { global $webUrl; - global $lang; + global $lang, $SERVER; // Go to the Columns page - $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . - 'action=add_column&database=test&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", + array('action' => 'add_column', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'server' => $SERVER)) + ); // Set properties for the new column $this->assertTrue($this->setField('field', 'sid')); @@ -75,23 +80,27 @@ class ColumnTest extends PreconditionSet{ function testAddColumnWithExistingName() { global $webUrl; - global $lang; - + global $lang, $SERVER, $DATABASE; + // Go to the Columns page - $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . - 'action=add_column&database=test&schema=public&table=student')); - + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'add_column', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); + // Set properties for the new column $this->assertTrue($this->setField('field', 'sid')); $this->assertTrue($this->setField('type', 'integer')); $this->assertTrue($this->clickSubmit($lang['stradd'])); - + // Make sure the operation failed $this->assertTrue($this->assertWantedText($lang['strcolumnaddedbad'])); - + return TRUE; - } - + } /** * TestCaseID: TNC03 @@ -100,11 +109,16 @@ class ColumnTest extends PreconditionSet{ function testCancelAddColumn() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Columns page - $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . - 'action=add_column&database=test&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'add_column', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new column $this->assertTrue($this->setField('field', 'sid')); @@ -122,12 +136,17 @@ class ColumnTest extends PreconditionSet{ function testAlterColumn() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Columns page - $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . - 'action=properties&database=test&schema=public&' . - 'table=student&column=sid')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'properties', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'column' => 'sid')) + ); // Set properties for the new column $this->assertTrue($this->setField('field', 'sid')); @@ -149,12 +168,17 @@ class ColumnTest extends PreconditionSet{ function testNegativeLengthColumn() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Columns page - $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . - 'action=properties&database=test&schema=public&' . - 'table=student&column=sid')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'properties', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'column' => 'sid')) + ); // Set properties for the new column $this->assertTrue($this->setField('field', 'sid')); @@ -176,12 +200,17 @@ class ColumnTest extends PreconditionSet{ function testCancelAlterColumn() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Columns page - $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . - 'action=properties&database=test&schema=public&' . - 'table=student&column=sid')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'properties', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'column' => 'sid')) + ); // Set properties for the new column $this->assertTrue($this->setField('field', 'sid')); @@ -200,12 +229,17 @@ class ColumnTest extends PreconditionSet{ function testCancelDropColumn() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Drop the column - $this->assertTrue($this->get($webUrl . '/tblproperties.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=student&column=sid')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'column' => 'sid')) + ); $this->assertTrue($this->clickSubmit($lang['strcancel'])); return TRUE; @@ -219,12 +253,17 @@ class ColumnTest extends PreconditionSet{ function testDropColumn() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Drop the column - $this->assertTrue($this->get($webUrl . '/tblproperties.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=student&column=sid')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'column' => 'sid')) + ); $this->assertTrue($this->clickSubmit($lang['strdrop'])); // Verify if the column is dropped correctly. $this->assertTrue($this->assertWantedText($lang['strcolumndropped'])); @@ -240,13 +279,18 @@ class ColumnTest extends PreconditionSet{ function testDropColumnWithCascade() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; global $POWER_USER_NAME; global $POWER_USER_PASSWORD; // Go to the Columns page - $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . - 'action=add_column&database=test&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'add_column', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new column $this->assertTrue($this->setField('field', 'sid')); @@ -258,13 +302,17 @@ class ColumnTest extends PreconditionSet{ $this->logout(); $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, - $webUrl . '/index.php'); - + "$webUrl/login.php"); // Drop the column with CASCADE checked - $this->assertTrue($this->get($webUrl . '/tblproperties.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=student&column=sid')); + $this->assertTrue($this->get("$webUrl/tblproperties.php" , array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'column' => 'sid')) + ); $this->assertTrue($this->setField('cascade', TRUE)); $this->assertTrue($this->clickSubmit($lang['strdrop'])); // Verify if the column is dropped correctly. @@ -273,7 +321,4 @@ class ColumnTest extends PreconditionSet{ return TRUE; } } - - - - +?> diff --git a/tests/testcase/Tables/ConstraintsTest.php b/tests/testcase/Tables/ConstraintsTest.php index 7eac3ceb..dc7c0058 100644 --- a/tests/testcase/Tables/ConstraintsTest.php +++ b/tests/testcase/Tables/ConstraintsTest.php @@ -29,7 +29,7 @@ class ConstraintsTest extends PreconditionSet{ global $SUPER_USER_PASSWORD; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -49,11 +49,16 @@ class ConstraintsTest extends PreconditionSet{ */ function testAddCheck(){ global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the constraints page - $this->assertTrue($this->get($webUrl . '/constraints.php?' . - 'action=add_check&database=test&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/constraints.php", array( + 'server' => $SERVER, + 'action' => 'add_check', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new constraint $this->assertTrue($this->setField('name', 'id_check')); @@ -75,11 +80,17 @@ class ConstraintsTest extends PreconditionSet{ function testDropCheckKey() { global $webUrl; - global $lang; - - $this->assertTrue($this->get($webUrl . '/constraints.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=student&constraint=id_check&type=c')); + global $lang, $SERVER, $DATABASE; + + $this->assertTrue($this->get("$webUrl/constraints.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'constraint' => 'id_check', + 'type' => 'c')) + ); $this->assertTrue($this->clickSubmit($lang['strdrop'])); // Verify if the constraint is dropped correctly. $this->assertTrue($this->assertWantedText($lang['strconstraintdropped'])); @@ -94,12 +105,16 @@ class ConstraintsTest extends PreconditionSet{ */ function testAddUniqueKey(){ global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the constraints page - $this->assertTrue($this->get($webUrl . '/constraints.php?' . - 'action=add_unique_key&database=test&' . - 'schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/constraints.php", array( + 'server' => $SERVER, + 'action' => 'add_unique_key', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new constraint $this->assertTrue($this->setField('name', 'unique_name')); @@ -122,11 +137,14 @@ class ConstraintsTest extends PreconditionSet{ function testDropUniqueKey() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/constraints.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=student&constraint=unique_name')); + $this->assertTrue($this->get("$webUrl/constraints.php", array( + 'server' => $SERVER, 'action' => 'confirm_drop', + 'database' => $DATABASE, 'schema' => 'public', + 'table' => 'student', 'constraint' => 'unique_name')) + ); + $this->assertTrue($this->clickSubmit($lang['strdrop'])); // Verify if the constraint is dropped correctly. $this->assertTrue($this->assertWantedText($lang['strconstraintdropped'])); @@ -141,12 +159,14 @@ class ConstraintsTest extends PreconditionSet{ */ function testAddPrimaryKey(){ global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the constraints page - $this->assertTrue($this->get($webUrl . '/constraints.php?' . - 'action=add_primary_key&database=test&schema=public&' . - 'table=college_student')); + $this->assertTrue($this->get("$webUrl/constraints.php", array( + 'server' => $SERVER, 'action' => 'add_primary_key', + 'database' => $DATABASE, 'schema' => 'public', + 'table' => 'college_student')) + ); // Set properties for the new constraint $this->assertTrue($this->setField('name', 'primary_id')); @@ -170,12 +190,14 @@ class ConstraintsTest extends PreconditionSet{ function testDropPrimaryKey() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Remove the primary key - $this->assertTrue($this->get($webUrl . '/constraints.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=college_student&constraint=primary_id&type=p')); + $this->assertTrue($this->get("$webUrl/constraints.php", array( + 'server' => $SERVER, 'action' => 'confirm_drop', 'database' => $DATABASE, + 'schema' => 'public', 'table' => 'college_student', 'constraint' => 'primary_id', + 'type' => 'p')) + ); $this->assertTrue($this->clickSubmit($lang['strdrop'])); $this->assertTrue($this->assertWantedText($lang['strconstraintdropped'])); @@ -189,12 +211,13 @@ class ConstraintsTest extends PreconditionSet{ */ function testAddForeignKey(){ global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the constraints page - $this->assertTrue($this->get($webUrl . '/constraints.php?' . - 'action=add_foreign_key&database=test&' . - 'schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/constraints.php", array( + 'server' => $SERVER, 'action' => 'add_foreign_key', 'database' => $DATABASE, + 'schema' => 'public', 'table' => 'student')) + ); // Set properties for the new constraint $this->assertTrue($this->setField('name', 'foreign_id')); @@ -225,15 +248,18 @@ class ConstraintsTest extends PreconditionSet{ function testDropForeignKey() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Remove the foreign key - $this->assertTrue($this->get($webUrl . '/constraints.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=student&constraint=foreign_id&type=f')); + $this->assertTrue($this->get("$webUrl/constraints.php", array( + 'server' => $SERVER, 'action' => 'confirm_drop', 'database' => $DATABASE, + 'schema' => 'public', 'table' => 'student', 'constraint' => 'foreign_id', + 'type' => 'f')) + ); $this->assertTrue($this->clickSubmit($lang['strdrop'])); $this->assertTrue($this->assertWantedText($lang['strconstraintdropped'])); return TRUE; } } +?> diff --git a/tests/testcase/Tables/DeadlockTest.php b/tests/testcase/Tables/DeadlockTest.php index 772b8e43..7a830b65 100644 --- a/tests/testcase/Tables/DeadlockTest.php +++ b/tests/testcase/Tables/DeadlockTest.php @@ -54,7 +54,7 @@ class DeadlockTest extends PreconditionSet{ function testAddCheckScenario() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; global $POWER_USER_PASSWORD; global $SUPER_USER_PASSWORD; global $SUPER_USER_NAME; @@ -62,12 +62,17 @@ class DeadlockTest extends PreconditionSet{ $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); // Try to add a check constraint to the table student // Go to the constraints page - $this->assertTrue($this->get($webUrl . '/constraints.php?' . - 'action=add_check&database=test&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/constraints.php", array( + 'server' => $SERVER, + 'action' => 'add_check', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new constraint $this->assertTrue($this->setField('name', 'id_check')); @@ -76,16 +81,19 @@ class DeadlockTest extends PreconditionSet{ // Open the second session, login as superuser $newBrowser = $this->createBrowser(); - $newBrowser->get($webUrl . '/index.php'); + $newBrowser->get("$webUrl/login.php"); $this->assertTrue($newBrowser->setField('formUsername', $SUPER_USER_NAME)); $this->assertTrue($newBrowser->setField('formPassword', $SUPER_USER_PASSWORD)); $this->assertTrue($newBrowser->setField('formLanguage', $lang['applang'])); $this->assertTrue($newBrowser->clickSubmit('Login')); // Alter the user's password - $this->assertTrue($newBrowser->get($webUrl . '/users.php')); - $this->assertTrue($newBrowser->get($webUrl . '/users.php?action=edit' . - '&&username=' . $POWER_USER_NAME)); + $this->assertTrue($newBrowser->get("$webUrl/users.php")); + $this->assertTrue($newBrowser->get("$webUrl/users.php", array( + 'server' => $SERVER, + 'action' => 'edit', + 'username' => $POWER_USER_NAME)) + ); // Enter the information for altering the user's properties. $this->assertTrue($newBrowser->setField('newname', $POWER_USER_NAME)); $this->assertTrue($newBrowser->setField('formPassword', '56789')); @@ -102,9 +110,12 @@ class DeadlockTest extends PreconditionSet{ // Rollback the changes to return to the original state - $this->assertTrue($newBrowser->get($webUrl . '/users.php')); - $this->assertTrue($newBrowser->get($webUrl . '/users.php?action=edit' . - '&&username=' . $POWER_USER_NAME)); + $this->assertTrue($newBrowser->get("$webUrl/users.php")); + $this->assertTrue($newBrowser->get("$webUrl/users.php", array( + 'server' => $SERVER, + 'action' => 'edit', + 'username' => $POWER_USER_NAME)) + ); // Change back the user's password $this->assertTrue($newBrowser->setField('newname', $POWER_USER_NAME)); @@ -135,34 +146,40 @@ class DeadlockTest extends PreconditionSet{ function testCreateDatabaseScenario() { global $webUrl; - global $lang; + global $lang, $SERVER; global $POWER_USER_PASSWORD; global $SUPER_USER_PASSWORD; global $SUPER_USER_NAME; global $POWER_USER_NAME; $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); // Try to create a database 'newdb', without commit the operation - $this->assertTrue ($this->get ($webUrl . '/all_db.php')); - $this->assertTrue ($this->get ($webUrl . '/all_db.php?action=create')); + $this->assertTrue ($this->get ("$webUrl/all_db.php")); + $this->assertTrue ($this->get ("$webUrl/all_db.php", array( + 'server' => $SERVER, + 'action' => 'create')) + ); $this->assertTrue ($this->setfield('formName', 'newdb')); $this->assertTrue ($this->setfield('formEncoding', 'UNICODE')); // Open another session, login as superuser $newBrowser = $this->createBrowser(); - $newBrowser->get($webUrl . '/index.php'); + $newBrowser->get("$webUrl/login.php"); $this->assertTrue($newBrowser->setField('formUsername', $SUPER_USER_NAME)); $this->assertTrue($newBrowser->setField('formPassword', $SUPER_USER_PASSWORD)); $this->assertTrue($newBrowser->setField('formLanguage', $lang['applang'])); $this->assertTrue($newBrowser->clickSubmit('Login')); // Revoke the user's createdb privilege - $this->assertTrue($newBrowser->get($webUrl . '/users.php')); - $this->assertTrue($newBrowser->get($webUrl . '/users.php?action=edit' . - '&&username=' . $POWER_USER_NAME)); + $this->assertTrue($newBrowser->get("$webUrl/users.php")); + $this->assertTrue($newBrowser->get("$webUrl/users.php", array( + 'server' => $SERVER, + 'action' => 'edit', + 'username' => $POWER_USER_NAME)) + ); $this->assertTrue($newBrowser->setField('newname', $POWER_USER_NAME)); $this->assertTrue($newBrowser->setField('formPassword', 'tester')); $this->assertTrue($newBrowser->setField('formConfirm', 'tester')); @@ -177,9 +194,13 @@ class DeadlockTest extends PreconditionSet{ $this->assertTrue ($this->assertWantedText($lang['strdatabasecreatedbad'])); // Rollback the changes to return to the original state - $this->assertTrue($newBrowser->get($webUrl . '/users.php')); - $this->assertTrue($newBrowser->get($webUrl . '/users.php?action=edit' . - '&&username=' . $POWER_USER_NAME)); + $this->assertTrue($newBrowser->get("$webUrl/users.php")); + $this->assertTrue($newBrowser->get("$webUrl/users.php", array( + 'server' => $SERVER, + 'action' => 'edit', + 'username' => $POWER_USER_NAME)) + ); + $this->assertTrue($newBrowser->setField('newname', $POWER_USER_NAME)); $this->assertTrue($newBrowser->setField('formPassword', $POWER_USER_PASSWORD)); $this->assertTrue($newBrowser->setField('formConfirm', $POWER_USER_PASSWORD)); @@ -190,7 +211,6 @@ class DeadlockTest extends PreconditionSet{ return TRUE; } - /** * TestCaseID: TET02 * @@ -205,18 +225,23 @@ class DeadlockTest extends PreconditionSet{ function testDropColumnScenario() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; global $POWER_USER_PASSWORD; global $SUPER_USER_PASSWORD; global $SUPER_USER_NAME; global $POWER_USER_NAME; $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); // Add a column "sid" - $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . - 'action=add_column&database=test&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'add_column', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new column $this->assertTrue($this->setField('field', 'sid')); $this->assertTrue($this->setField('type', 'integer')); @@ -226,9 +251,14 @@ class DeadlockTest extends PreconditionSet{ // Try to alter the column as "ssid" - $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . - 'action=properties&database=test&schema=public&' . - 'table=student&column=sid')); + $this->assertTrue($this->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'properties', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'column' => 'sid')) + ); // Set properties for the new column $this->assertTrue($this->setField('field', 'ssid')); $this->assertTrue($this->setField('type', 'character')); @@ -237,16 +267,21 @@ class DeadlockTest extends PreconditionSet{ // Open the second session, login as power user $newBrowser = $this->createBrowser(); - $newBrowser->get($webUrl . '/index.php'); + $newBrowser->get("$webUrl/login.php"); $this->assertTrue($newBrowser->setField('formUsername', $POWER_USER_NAME)); $this->assertTrue($newBrowser->setField('formPassword', $POWER_USER_PASSWORD)); $this->assertTrue($newBrowser->setField('formLanguage', $lang['applang'])); $this->assertTrue($newBrowser->clickSubmit('Login')); - + // Drop the column - $this->assertTrue($newBrowser->get($webUrl . '/tblproperties.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=student&column=sid')); + $this->assertTrue($newBrowser->get("$webUrl/tblproperties.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'column' => 'sid')) + ); $this->assertTrue($newBrowser->clickSubmit($lang['strdrop'])); @@ -273,17 +308,21 @@ class DeadlockTest extends PreconditionSet{ function testQueryDroppedTable() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; global $POWER_USER_PASSWORD; global $SUPER_USER_PASSWORD; global $SUPER_USER_NAME; global $POWER_USER_NAME; $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); // Create a table. - $this->assertTrue($this->get($webUrl . '/tables.php?action=create&' . - 'database=test&schema=public')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public')) + ); // Enter the table name and field number. $this->assertTrue($this->setField('name', 'newtable')); @@ -314,9 +353,13 @@ class DeadlockTest extends PreconditionSet{ // Issue a SELECT query // Turn to the "tables" page. - $this->assertTrue($this->get($webUrl . '/tables.php?&' . - 'action=confselectrows&database=test&' . - 'schema=public&table=newtable')); + $this->assertTrue($this->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confselectrows', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'newtable')) + ); // Select all the rows. $this->assertTrue($this->setField('show[firstfield]', TRUE)); @@ -325,15 +368,20 @@ class DeadlockTest extends PreconditionSet{ // Open another session, login as super user, drop the table "newtable" $newBrowser = $this->createBrowser(); - $newBrowser->get($webUrl . '/index.php'); + $newBrowser->get("$webUrl/login.php"); $this->assertTrue($newBrowser->setField('formUsername', $SUPER_USER_NAME)); $this->assertTrue($newBrowser->setField('formPassword', $SUPER_USER_PASSWORD)); $this->assertTrue($newBrowser->setField('formLanguage', $lang['applang'])); $this->assertTrue($newBrowser->clickSubmit('Login')); // Drop the table - $newBrowser->get($webUrl . '/tables.php?action=confirm_drop&' . - 'database=test&schema=public&table=newtable'); + $newBrowser->get("$webUrl/tables.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'newtable') + ); $this->assertTrue($newBrowser->clickSubmit($lang['strdrop'])); @@ -348,3 +396,4 @@ class DeadlockTest extends PreconditionSet{ return TRUE; } } +?> diff --git a/tests/testcase/Tables/IndexesTest.php b/tests/testcase/Tables/IndexesTest.php index 2584a9c2..d0b0c34d 100644 --- a/tests/testcase/Tables/IndexesTest.php +++ b/tests/testcase/Tables/IndexesTest.php @@ -29,7 +29,7 @@ class IndexesTest extends PreconditionSet{ global $SUPER_USER_NAME; $this->login($SUPER_USER_NAME, $SUPER_USER_NAME, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -49,12 +49,16 @@ class IndexesTest extends PreconditionSet{ */ function testCreateIndex(){ global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Indexes page - $this->assertTrue($this->get($webUrl . '/indexes.php?&' . - 'action=create_index&database=test&' . - 'schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/indexes.php", array( + 'server' => $SERVER, + 'action' => 'create_index', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new index $this->assertTrue($this->setField('formIndexName', 'stu_name_idx')); @@ -79,12 +83,16 @@ class IndexesTest extends PreconditionSet{ */ function testCancelCreateIndex(){ global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Indexes page - $this->assertTrue($this->get($webUrl . '/indexes.php?&' . - 'action=create_index&database=test' . - '&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/indexes.php", array( + 'server' => $SERVER, + 'action' => 'create_index', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new index $this->assertTrue($this->setField('formIndexName', 'stu_name_idx')); @@ -106,12 +114,17 @@ class IndexesTest extends PreconditionSet{ function testReindex() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Indexes page - $this->assertTrue($this->get($webUrl . '/indexes.php?action=reindex&' . - 'database=test&schema=public&table=student&' . - 'index=stu_name_idx')); + $this->assertTrue($this->get("$webUrl/indexes.php", array( + 'server' => $SERVER, + 'action' => 'reindex', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'index' => 'stu_name_idx')) + ); // Verify if the index is reindexed correctly. $this->assertTrue($this->assertWantedText($lang['strreindexgood'])); @@ -127,11 +140,16 @@ class IndexesTest extends PreconditionSet{ function testClusterPrimaryKeyWithAnalyze() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/indexes.php?' . - 'action=confirm_cluster_index&database=test&schema=public&' . - 'table=student&index=student_pkey')); + $this->assertTrue($this->get("$webUrl/indexes.php", array( + 'server' => $SERVER, + 'action' => 'confirm_cluster_index', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'index' => 'student_pkey')) + ); $this->assertTrue($this->setField('analyze', TRUE)); $this->assertTrue($this->clickSubmit($lang['strcluster'])); // Verify if the key is clustered correctly. @@ -149,11 +167,16 @@ class IndexesTest extends PreconditionSet{ function testClusterPrimaryKeyWithoutAnalyze() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/indexes.php?' . - 'action=confirm_cluster_index&database=test&schema=public&' . - 'table=student&index=student_pkey')); + $this->assertTrue($this->get("$webUrl/indexes.php", array( + 'server' => $SERVER, + 'action' => 'confirm_cluster_index', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'index' => 'student_pkey')) + ); $this->assertTrue($this->setField('analyze', FALSE)); $this->assertTrue($this->clickSubmit($lang['strcluster'])); // Verify if the key is clustered correctly. @@ -170,19 +193,22 @@ class IndexesTest extends PreconditionSet{ function testCancelCluster() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/indexes.php?' . - 'action=confirm_cluster_index&database=test&schema=public&' . - 'table=student&constraint=student_pkey')); + $this->assertTrue($this->get("$webUrl/indexes.php", array( + 'server' => $SERVER, + 'action' => 'confirm_cluster_index', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'constraint' => 'student_pkey')) + ); $this->assertTrue($this->setField('analyze', TRUE)); $this->assertTrue($this->clickSubmit($lang['strcancel'])); return TRUE; } - - - + /** * TestCaseID: TDI02 * Cancel dropping an index in a table @@ -190,18 +216,22 @@ class IndexesTest extends PreconditionSet{ function testCancelDropIndex() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/indexes.php?' . - 'action=confirm_drop_index&database=test&schema=public&' . - 'table=student&index=stu_name_idx')); + $this->assertTrue($this->get("$webUrl/indexes.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop_index', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'index' => 'stu_name_idx')) + ); $this->assertField($this->setField('cascade', FALSE)); $this->assertTrue($this->clickSubmit($lang['strcancel'])); return TRUE; } - - + /** * TestCaseID: TDI01 * Test dropping an index in a table @@ -209,11 +239,16 @@ class IndexesTest extends PreconditionSet{ function testDropIndex() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; - $this->assertTrue($this->get($webUrl . '/indexes.php?' . - 'action=confirm_drop_index&database=test&schema=public&' . - 'table=student&index=stu_name_idx')); + $this->assertTrue($this->get("$webUrl/indexes.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop_index', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'index' => 'stu_name_idx')) + ); $this->assertField($this->setField('cascade', TRUE)); $this->assertTrue($this->clickSubmit($lang['strdrop'])); // Verify if the index is dropped correctly. diff --git a/tests/testcase/Tables/InfoTest.php b/tests/testcase/Tables/InfoTest.php index f85261f4..936b8881 100644 --- a/tests/testcase/Tables/InfoTest.php +++ b/tests/testcase/Tables/InfoTest.php @@ -29,7 +29,7 @@ class InfoTest extends PreconditionSet{ global $POWER_USER_PASSWORD; $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -50,11 +50,16 @@ class InfoTest extends PreconditionSet{ function testListParentTableInfo() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Rules page - $this->assertTrue($this->get($webUrl . '/info.php?&' . - 'database=test&schema=public&table=student&subject=table')); + $this->assertTrue($this->get("$webUrl/info.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'subject' => 'table')) + ); return TRUE; } @@ -67,11 +72,16 @@ class InfoTest extends PreconditionSet{ function testListChildrenTableInfo() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Rules page - $this->assertTrue($this->get($webUrl . '/info.php?&database=test&' . - 'schema=public&table=college_student&subject=table')); + $this->assertTrue($this->get("$webUrl/info.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'college_student', + 'subject' => 'table')) + ); return TRUE; } @@ -84,17 +94,20 @@ class InfoTest extends PreconditionSet{ function testListForeignTableInfo() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Rules page - $this->assertTrue($this->get($webUrl . '/info.php?&' . - 'database=test&schema=public&' . - 'table=department&subject=table')); + $this->assertTrue($this->get("$webUrl/info.php", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'department', + 'subject' => 'table')) + ); - return TRUE; - } - - + return TRUE; + } + /** * TestCaseID: TSP01 * Show the properties of the foreign key constraint @@ -102,12 +115,16 @@ class InfoTest extends PreconditionSet{ function testShowForeignKeyProperties() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Rules page - $this->assertTrue($this->get($webUrl . '/info.php?&' . - 'database=test&schema=public&' . - 'table=department&subject=table')); + $this->assertTrue($this->get("$webUrl/info.php?", array( + 'server' => $SERVER, + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'department', + 'subject' => 'table')) + ); $this->assertTrue($this->clickLink($lang['strproperties'])); $this->assertWantedText('FOREIGN KEY (dep_id) REFERENCES department(id) ' . @@ -116,7 +133,4 @@ class InfoTest extends PreconditionSet{ return TRUE; } } - - - - +?> diff --git a/tests/testcase/Tables/RulesTest.php b/tests/testcase/Tables/RulesTest.php index aeff6bdc..57330599 100644 --- a/tests/testcase/Tables/RulesTest.php +++ b/tests/testcase/Tables/RulesTest.php @@ -28,7 +28,7 @@ class RulesTest extends PreconditionSet{ global $POWER_USER_PASSWORD; $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -49,12 +49,17 @@ class RulesTest extends PreconditionSet{ function testCreateRule() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Rules page - $this->assertTrue($this->get($webUrl . '/rules.php?&' . - 'action=create_rule&database=test&schema=public&' . - 'table=student&subject=table')); + $this->assertTrue($this->get("$webUrl/rules.php", array( + 'server' => $SERVER, + 'action' => 'create_rule', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'subject' => 'table')) + ); // Set properties for the new rule $this->assertTrue($this->setField('name', 'insert_stu_rule')); @@ -77,12 +82,17 @@ class RulesTest extends PreconditionSet{ function testCancelCreateRule() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Rules page - $this->assertTrue($this->get($webUrl . '/rules.php?&' . - 'action=create_rule&database=test&schema=public&' . - 'table=student&subject=table')); + $this->assertTrue($this->get("$webUrl/rules.php", array( + 'server' => $SERVER, + 'action' => 'create_rule', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'subject' => 'table')) + ); // Set properties for the new rule $this->assertTrue($this->setField('name', 'insert_stu_rule')); @@ -102,12 +112,19 @@ class RulesTest extends PreconditionSet{ function testCancelDropRule() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Drop the rule - $this->assertTrue($this->get($webUrl . '/rules.php?' . - 'action=confirm_drop&database=test&schema=public&reltype=table&' . - 'table=student&subject=rule&rule=insert_stu_rule')); + $this->assertTrue($this->get("$webUrl/rules.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'reltype' => 'table', + 'table' => 'student', + 'subject' => 'rule', + 'rule' => 'insert_stu_rule')) + ); $this->assertTrue($this->clickSubmit($lang['strno'])); return TRUE; @@ -120,12 +137,19 @@ class RulesTest extends PreconditionSet{ function testDropRule() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Drop the rule - $this->assertTrue($this->get($webUrl . '/rules.php?' . - 'action=confirm_drop&database=test&schema=public&reltype=table' . - '&table=student&subject=rule&rule=insert_stu_rule')); + $this->assertTrue($this->get("$webUrl/rules.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'reltype' => 'table', + 'table' => 'student', + 'subject' => 'rule', + 'rule' => 'insert_stu_rule')) + ); $this->assertTrue($this->clickSubmit($lang['stryes'])); // Verify if the rule is dropped correctly. $this->assertTrue($this->assertWantedText($lang['strruledropped'])); @@ -141,14 +165,19 @@ class RulesTest extends PreconditionSet{ function testDropRuleWithCascade() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; global $POWER_USER_NAME; global $POWER_USER_PASSWORD; // Go to the Rules page - $this->assertTrue($this->get($webUrl . '/rules.php?&' . - 'action=create_rule&database=test&schema=public&' . - 'table=student&subject=table')); + $this->assertTrue($this->get("$webUrl/rules.php", array( + 'server' => $SERVER, + 'action' => 'create_rule', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'subject' => 'table')) + ); // Set properties for the new rule $this->assertTrue($this->setField('name', 'insert_stu_rule')); @@ -162,12 +191,19 @@ class RulesTest extends PreconditionSet{ $this->logout(); $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); // Drop the rule - $this->assertTrue($this->get($webUrl . '/rules.php?' . - 'action=confirm_drop&database=test&schema=public&reltype=table&' . - 'table=student&subject=rule&rule=insert_stu_rule')); + $this->assertTrue($this->get("$webUrl/rules.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'reltype' => 'table', + 'table' => 'student', + 'subject' => 'rule', + 'rule' => 'insert_stu_rule')) + ); $this->assertTrue($this->setField('cascade', TRUE)); $this->assertTrue($this->clickSubmit($lang['stryes'])); // Verify if the rule is dropped correctly. @@ -176,7 +212,4 @@ class RulesTest extends PreconditionSet{ return TRUE; } } - - - - +?> diff --git a/tests/testcase/Tables/TriggersTest.php b/tests/testcase/Tables/TriggersTest.php index fbc18e67..5576d9b3 100644 --- a/tests/testcase/Tables/TriggersTest.php +++ b/tests/testcase/Tables/TriggersTest.php @@ -11,8 +11,6 @@ if(is_dir('../Public')) { require_once('../Public/SetPrecondition.php'); } -//require_once('english.php'); -//require_once('../lang/english.php'); /** * A test case suite for testing TRIGGER feature in phpPgAdmin, including cases @@ -31,7 +29,7 @@ class TriggersTest extends PreconditionSet{ global $POWER_USER_PASSWORD; $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, - $webUrl . '/index.php'); + "$webUrl/login.php"); return TRUE; } @@ -52,11 +50,16 @@ class TriggersTest extends PreconditionSet{ function testAddTrigger() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Triggers page - $this->assertTrue($this->get($webUrl . '/triggers.php?action=create&' . - 'database=test&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/triggers.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new trigger $this->assertTrue($this->setField('formTriggerName', @@ -82,11 +85,16 @@ class TriggersTest extends PreconditionSet{ function testCancelAddTrigger() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Go to the Triggers page - $this->assertTrue($this->get($webUrl . '/triggers.php?action=create&' . - 'database=test&schema=public&table=student')); + $this->assertTrue($this->get("$webUrl/triggers.php", array( + 'server' => $SERVER, + 'action' => 'create', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student')) + ); // Set properties for the new trigger $this->assertTrue($this->setField('formTriggerName', @@ -109,12 +117,17 @@ class TriggersTest extends PreconditionSet{ function testAlterTrigger() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Alter the trigger - $this->assertTrue($this->get($webUrl . '/triggers.php?&' . - 'action=confirm_alter&database=test&schema=public&' . - 'table=student&trigger=insert_stu_trigger')); + $this->assertTrue($this->get("$webUrl/triggers.php" , array( + 'server' => $SERVER, + 'action' => 'confirm_alter', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'trigger' => 'insert_stu_trigger')) + ); $this->assertTrue($this->setField('name', 'changed_trigger')); $this->assertTrue($this->clickSubmit($lang['strok'])); // Verify if the trigger is altered correctly. @@ -131,19 +144,23 @@ class TriggersTest extends PreconditionSet{ function testCancelAlterTrigger() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Alter the trigger - $this->assertTrue($this->get($webUrl . '/triggers.php?&' . - 'action=confirm_alter&database=test&schema=public&' . - 'table=student&trigger=changed_trigger')); + $this->assertTrue($this->get("$webUrl/triggers.php", array( + 'server' => $SERVER, + 'action' => 'confirm_alter', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'trigger' => 'changed_trigger')) + ); $this->assertTrue($this->setField('name', 'changed_trigger_changed')); $this->assertTrue($this->clickSubmit($lang['strcancel'])); - + return TRUE; - } - - + } + /** * TestCaseID: TDT01 * Cancel dropping a trigger from the table @@ -151,12 +168,17 @@ class TriggersTest extends PreconditionSet{ function testCancelDropTrigger() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Drop the trigger - $this->assertTrue($this->get($webUrl . '/triggers.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=student&trigger=changed_trigger')); + $this->assertTrue($this->get("$webUrl/triggers.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'trigger' => 'changed_trigger')) + ); $this->assertTrue($this->clickSubmit($lang['strno'])); return TRUE; @@ -170,12 +192,17 @@ class TriggersTest extends PreconditionSet{ function testDropTrigger() { global $webUrl; - global $lang; + global $lang, $SERVER, $DATABASE; // Drop the trigger - $this->assertTrue($this->get($webUrl . '/triggers.php?' . - 'action=confirm_drop&database=test&schema=public&' . - 'table=student&trigger=changed_trigger')); + $this->assertTrue($this->get("$webUrl/triggers.php", array( + 'server' => $SERVER, + 'action' => 'confirm_drop', + 'database' => $DATABASE, + 'schema' => 'public', + 'table' => 'student', + 'trigger' => 'changed_trigger')) + ); $this->assertTrue($this->setField('cascade', TRUE)); $this->assertTrue($this->clickSubmit($lang['stryes'])); // Verify if the trigger is dropped correctly. @@ -184,7 +211,4 @@ class TriggersTest extends PreconditionSet{ return TRUE; } } - - - - +?> diff --git a/tests/testcase/testphpPgAdminMain.php b/tests/testcase/testphpPgAdminMain.php index 9018ad62..3166bf07 100644 --- a/tests/testcase/testphpPgAdminMain.php +++ b/tests/testcase/testphpPgAdminMain.php @@ -8,15 +8,10 @@ // Import necessary library files to setup the testcase. // And for web testcase, the library web_tester.php shoule be included. -require_once 'simpletest.inc.php'; -require_once 'simpletest/web_tester.php'; -require_once 'simpletest/reporter.php'; -require_once 'simpletest/reporter/DetailedHtmlReporter.php'; -// Import the language file for phpPgAdmi to avoid hard code. -require_once('lang/recoded/english.php'); +require_once("$PHP_SIMPLETEST_HOME/web_tester.php"); +require_once("$PHP_SIMPLETEST_HOME/reporter.php"); -require_once('Public/common.php'); require_once('Public/SetPrecondition.php'); require_once('Server/ServerGroupTest.php'); @@ -33,16 +28,18 @@ class phpPgAdminGroupTest extends GroupTest { function phpPgAdminGroupTest() { - $this->GroupTest('phpPgAdmin automation test.'); + $this->GroupTest('phpPgAdmin automation test.'); $this->addTestClass(new ServerGroupTest()); $this->addTestClass(new DatabaseGroupTest()); $this->addTestClass(new SchemasGroupTest()); $this->addTestClass(new TableGroupTest()); - $this->addTestClass(new CommonGroupTest()); + $this->addTestClass(new CommonGroupTest()); + } } $phpPgAdminTest = &new phpPgAdminGroupTest(); -$phpPgAdminTest->run(new DetailedHtmlReporter()); + +$phpPgAdminTest->run(new HtmlReporter()); ?> -- 2.39.5