diff --git a/tests/README b/tests/README new file mode 100644 index 000000000..337e9d45d --- /dev/null +++ b/tests/README @@ -0,0 +1,149 @@ + + +README + + + + +Document History +Version +Date +Author +Comments +0.1 +06/07/05 +Augmentum SpikeSource Team +Initial Draft +1.0 +06/10/05 +Augmentum SpikeSource Team +Promote to release + + + + + + + + + + + + + + + + + + + + + + + + + +Summary: + +This test archive contains the automated test suite for phpPgAdmin, a web-based database management tool for PostgreSQL. The package also contains the related documents, including the test plan, test setup documents, as well as the test case specification and issue reports. + + +Folder Structure: + + ----build + | + ------data + | + ------testcase + | + -------Public + | + -------Common + | + -------Server + | + -------Databases + | + -------Schemas + | + -------Tables + | + -------Lang + +1. The "data" folder contains the resources needed in the testing cases + +2. The testing work is divided into 5 parts according to the function areas of phpPgAdmin + a. "Public" sets the global env for the testing + b. "Common" tests the common functionalities of phpPgAdmin + c. "Server" tests the server level functionalities + d. "Database" tests the database level functionalities + e. "Schema" tests the schema level functionalities + f. "Table" tests the table level functionalities + g. �Lang� contains the phpPgAdmin language package + +The test suite is implemented based on the SimpleTest Framework (v1.0). The phpPgAdmin (3.5.3) application is tested using Apache2 application server and PostgreSQL 8.0.3 database server. The code coverage is measured using spikePhpCoverage (0.6.2). + + +Run the Test: + +To run the test suite, measure code coverage using spikephpcoverage: + +To run the test suite, run the following commands assuming that the PHP command line executable is in your path. The following alose assumes that your web server deploy directory is "/usr/local/apache2/htdocs" (Linux), �C:\apache2\htdocs�, simpletest deploy directory is +"/usr/local/apache2/htdocs/simpletest" (Linux), �C:\apache2\htdocs\simpletest� + +Linux: + # Depoly application + $ export PHPCOVERAGE_HOME=/usr/local/apache2/htdocs/phpcoverage/src + $ cp -rp TestphpPgAdmin /usr/local/apache2/htdocs + # Instrument + $ php ${PHPCOVERAGE_HOME}/cli/instrument.php -b + /usr/local/apache2/htdocs/TestphpPgAdmin/phpPgAdmin/ + /usr/local/apache2/htdocs/TestphpPgAdmin/phpPgAdmin/ + # Execute + $ php coveragephpPgAdminMain.php + PHPCOVERAGE_APPBASE_PATH=/usr/local/apache2/htdocs/TestphpPgAdmin/phpPgAdmin/ + PHP_SIMPLETEST_HOME=/usr/local/apache2/htdocs/ + +Windows: + Open a command window, issue the following commands: + C:\> set PHPCOVERAGE_HOME= C:\apache2\htdocs\phpcoverage\src + # Instrument + C:\> php ${PHPCOVERAGE_HOME}\cli\instrument.php -b C:\apache2\htdocs\phpPgAdmin\ + C:\apache2\htdocs\phpPgAdmin\ + # Execute + C:\> php coveragephpPgAdminMain.php PHPCOVERAGE_APPBASE_PATH=C:\apache2\htdocs\phpPgAdmin\ + PHP_SIMPLETEST_HOME=C:\apache2\htdocs\ + + +Test Results Summary and Analysis: + + Test Summary: + There are a total of 1166 assertions in this test suite, 1162 passes, 4 fails and 6 exceptions. + + Fails Analysis: + 1. One failed case is related to the dropping of databases + For detailed information, refer to "phpPgAdmin Issue Report" + 2. Three failed cases are related to upload files (import data and run sql script file). + Currently, SimpleTest1.0 does not support upload files. + For detailed information, refer to "SimpleTest Issue Report". + + Exception Analysis: + 1. All six exceptions are related to the Tables module. SimpleTest1.0 cannot handle non- + submit button. For detailed information, refer to "SimpleTest Issue Report". + + Other issues: + 1. It is possible that one test case may fail in the Schema/ConversionTest. + Typically there should be conversions in the schema pg_catalog in template1, but if + there are no conversions, the assertion in our test will fail. We implemented our test + based on the normal case. + 2. Occasionally, if the web server is overloaded, there may be latency, which could cause + some assertions to fail + 3. In addition, PostgreSQL has some limitations. For example, if you already have a psql + session running, you cannot create database in another session. If you try, you will get + the following message: + "ERROR: source database "template1" is being accessed by other users" + 4. It is possible that one test case may fail in the Database/ProcessesTest. + Typically there should be no processes in the process list page, but if there are many + database accesses, there will be processes in the list. The assertion in our test will + fail. We implemented our test based on the normal case. + diff --git a/tests/build.xml b/tests/build.xml new file mode 100644 index 000000000..204f186ed --- /dev/null +++ b/tests/build.xml @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + SpikeSource Core Stack 1.4 + + + + 1.0 + + + + + + + + + + + + + + + + + + + + + + + + Replace spike_bin_dir in /conf/config.inc.php with '${spike.bin.dir}' + + + + + Do nothing + + + + + + + + + + + + + + + + + + + + -------------------------------------------------------------- + Starting phpPgAdmin SimpleTest Tests + -------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + "Do nothing" + + + + + Do nothing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -------------------------------------------------------------- + Starting Coverage + -------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + "Do nothing" + + + diff --git a/tests/data/CFunction/euc_jp_and_sjis.so b/tests/data/CFunction/euc_jp_and_sjis.so new file mode 100644 index 000000000..65ceb2a75 Binary files /dev/null and b/tests/data/CFunction/euc_jp_and_sjis.so differ diff --git a/tests/data/TableSpace/.cvsignore b/tests/data/TableSpace/.cvsignore new file mode 100644 index 000000000..72e8ffc0d --- /dev/null +++ b/tests/data/TableSpace/.cvsignore @@ -0,0 +1 @@ +* diff --git a/tests/data/select.sql b/tests/data/select.sql new file mode 100644 index 000000000..6ff707712 --- /dev/null +++ b/tests/data/select.sql @@ -0,0 +1 @@ +select Id from student; \ No newline at end of file diff --git a/tests/data/student.csv b/tests/data/student.csv new file mode 100644 index 000000000..d0d69fe84 --- /dev/null +++ b/tests/data/student.csv @@ -0,0 +1,2 @@ +"id","name","birthday","resume" +"2","testname","2005-05-31","test resume." diff --git a/tests/data/student.txt b/tests/data/student.txt new file mode 100644 index 000000000..ef4e406f5 --- /dev/null +++ b/tests/data/student.txt @@ -0,0 +1,2 @@ +"id" "name" "birthday" "resume" +"2" "testname" "2005-05-31" "test resume." diff --git a/tests/data/student.xml b/tests/data/student.xml new file mode 100644 index 000000000..82164a8b2 --- /dev/null +++ b/tests/data/student.xml @@ -0,0 +1,17 @@ + + +
+ + + + +
+ + + 2 + testname + 2005-05-31 + test resume. + + +
diff --git a/tests/testcase/Common/CommonGroupTest.php b/tests/testcase/Common/CommonGroupTest.php new file mode 100644 index 000000000..d68f24530 --- /dev/null +++ b/tests/testcase/Common/CommonGroupTest.php @@ -0,0 +1,28 @@ +GroupTest('Common manipulation group test.'); + $this->addTestClass(new SecurityTest()); + $this->addTestClass(new ExportTest()); + $this->addTestClass(new ImportTest()); + } +} +?> diff --git a/tests/testcase/Common/ExportTest.php b/tests/testcase/Common/ExportTest.php new file mode 100644 index 000000000..5901f927e --- /dev/null +++ b/tests/testcase/Common/ExportTest.php @@ -0,0 +1,256 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + + return TRUE; + } + + + function tearDown() + { + $this->logout(); + + return TRUE; + } + + + /* + * TestCaseID: CED01 + * Test to export server data with "COPY" format. + */ + function testServerDataCopyShow() + { + global $webUrl; + global $lang; + + // Turn to the export data page. + $this->assertTrue($this->get($webUrl . '/all_db.php?action=export')); + + // Enter information for exporting the data. + $this->assertTrue($this->setField('what', 'dataonly')); + $this->assertTrue($this->setField('d_format', 'COPY')); + $this->assertTrue($this->setField('output', 'show')); + + //Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strexport'])); + $this->assertWantedText('connect ' . $this->_databaseName); + + return TRUE; + } + + + /* + * TestCaseID: CED02 + * Test to export server structure with "SQL" format. + */ + function testServerStructureSQLDownload() + { + global $webUrl; + global $lang; + + // Turn to the export data page. + $this->assertTrue($this->get($webUrl . '/all_db.php?action=export')); + + // Enter information for exporting the data. + $this->assertTrue($this->setField('what', 'structureonly')); + $this->assertTrue($this->setField('d_format', 'SQL')); + $this->assertTrue($this->setField('output', 'download')); + + //Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strexport'])); + $this->assertWantedText('connect ' . $this->_databaseName); + + return TRUE; + } + + /* + * TestCaseID: CED03 + * Test to export database data with "SQL" format. + */ + function testDatabaseDataSQLShow() + { + global $webUrl; + global $lang; + + // Turn to the export data page. + $this->assertTrue($this->get($webUrl . '/database.php?database=' . + $this->_databaseName . '&subject=database&action=export')); + + // Enter information for exporting the data. + $this->assertTrue($this->setField('what', 'dataonly')); + $this->assertTrue($this->setField('d_format', 'SQL')); + $this->assertTrue($this->setField('output', 'show')); + + //Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strexport'])); + $this->assertWantedText('Data for Name: student'); + + return TRUE; + } + + + /* + * TestCaseID: CED04 + * Test to export database structure with "COPY" format. + */ + function testDatabaseStructureCOPYDownload() + { + global $webUrl; + global $lang; + + // Turn to the export data page. + $this->assertTrue($this->get($webUrl . '/database.php?database=' . $this->_databaseName . + '&subject=database&action=export')); + + // Enter information for exporting the data. + $this->assertTrue($this->setField('what', 'structureonly')); + $this->assertTrue($this->setField('d_format', 'COPY')); + $this->assertTrue($this->setField('output', 'download')); + + //Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strexport'])); + $this->assertWantedText('CREATE TABLE student'); + + return TRUE; + } + + /* + * TestCaseID: CED05 + * Test to export table data with "XML" format. + * + * This test case need insert one row data firstly. + * And the data will be removed in the end of the test case. + */ + function testTableDataShow() + { + global $webUrl; + global $lang; + + // Turn to the "Insert row" interface. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confinsertrow' . + '&database=test&schema=public&table=student&')); + + // Set the value of the fields. + $this->assertTrue($this->setField('values[name]', 'testname')); + $this->assertTrue($this->setField('values[birthday]', '2005-05-31')); + $this->assertTrue($this->setField('values[resume]', 'test resume')); + + // Click the "Insert" button insert a row. + $this->assertTrue($this->clickSubmit($lang['strinsert'])); + // Verify if the row insert successful. + $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')); + // Enter information for export the data. + $this->assertTrue($this->setField('what', 'dataonly')); + $this->assertTrue($this->setField('d_format', 'XML')); + $this->assertTrue($this->setField('output', 'show')); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strexport'])); + $this->assertWantedPattern("/xml version/"); + + + // Turn to the export data page. + $this->assertTrue($this->get($webUrl . '/tblproperties.php?database=' . $this->_databaseName . + '&schema=public&table=student&subject=table&action=export')); + + // Enter information for exporting the data. + $this->assertTrue($this->setField('what', 'dataonly')); + $this->assertTrue($this->setField('d_format', 'XHTML')); + $this->assertTrue($this->setField('output', 'show')); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strexport'])); + $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->clickSubmit($lang['strempty'])); + + return TRUE; + } + + + /* + * TestCaseID: CED06 + * Test to export database structure and data with "SQL" format. + */ + function testTableStructureDataSQLDownload() + { + global $webUrl; + global $lang; + + // Turn to the export data page. + $this->assertTrue($this->get($webUrl . '/tblproperties.php?database=' . $this->_databaseName . + '&schema=public&table=student&subject=table&action=export')); + + // Enter information for exporting the data. + $this->assertTrue($this->setField('what', 'structureanddata')); + $this->assertTrue($this->setField('sd_format', 'COPY')); + $this->assertTrue($this->setField('output', 'download')); + + //Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strexport'])); + $this->assertWantedText('CREATE TABLE student'); + + return TRUE; + } + + /* + * TestCaseID: CED07 + * Test to export view structure. + */ + function testViewStructureShow() + { + global $webUrl; + global $lang; + + // 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')); + + // Enter information for exporting the data. + $this->assertTrue($this->setField('s_clean', TRUE)); + $this->assertTrue($this->setField('output', 'show')); + + //Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strexport'])); + $this->assertWantedText('CREATE VIEW pg_user'); + + return TRUE; + } + +} +?> diff --git a/tests/testcase/Common/ImportTest.php b/tests/testcase/Common/ImportTest.php new file mode 100644 index 000000000..329b20a8e --- /dev/null +++ b/tests/testcase/Common/ImportTest.php @@ -0,0 +1,125 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + + return TRUE; + } + + + function tearDown() + { + // Clear the data and logout. + $this->emptyTable(); + $this->logout(); + + return TRUE; + } + + + /* + * TestCaseID: CID01 + * Test to import XML format data into the table. + * + * This test case will failed because SimpleTest1.0 doesn't support upload file. + */ + function testXMLData() + { + global $webUrl; + global $lang; + + $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')); + + // Enter information for importing the data. + $this->assertTrue($this->setField('format', 'XML')); + $this->assertTrue($this->setField('source', $this->_dataFilePath . $this->_tableName . '.xml')); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strimport'])); + // This assert will failed because SimpleTest1.0 doesn't support upload file. + $this->assertWantedText($lang['strfileimported']); + + return TRUE; + } + + /* + * TestCaseID: CID02 + * Test to import incorect text format data into the table. + * + * This test case will failed because SimpleTest1.0 doesn't support upload file. + */ + function testIncorectTxtData() + { + global $webUrl; + global $lang; + + $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')); + + // Enter information for importing the data. + $this->assertTrue($this->setField('format', $lang['strauto'])); + $this->assertTrue($this->setField('source', $this->_dataFilePath . $this->_tableName . '.txt')); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strimport'])); + // This assert will failed because SimpleTest1.0 doesn't support upload file. + $this->assertWantedText(sprintf($lang['strimporterrorline'], 1)); + + return TRUE; + } + + /* + * Help to empty the table's data. + */ + function emptyTable() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_empty' . + '&database=test&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 new file mode 100644 index 000000000..e3de41d4c --- /dev/null +++ b/tests/testcase/Common/SecurityTest.php @@ -0,0 +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; + } + +} +?> diff --git a/tests/testcase/Databases/AdminTest.php b/tests/testcase/Databases/AdminTest.php new file mode 100644 index 000000000..f8218aa31 --- /dev/null +++ b/tests/testcase/Databases/AdminTest.php @@ -0,0 +1,153 @@ +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; + } +} + +?> diff --git a/tests/testcase/Databases/CastsTest.php b/tests/testcase/Databases/CastsTest.php new file mode 100644 index 000000000..1c8ea2ede --- /dev/null +++ b/tests/testcase/Databases/CastsTest.php @@ -0,0 +1,72 @@ +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; + } +} + +?> diff --git a/tests/testcase/Databases/DatabaseGroupTest.php b/tests/testcase/Databases/DatabaseGroupTest.php new file mode 100644 index 000000000..1d18ffc16 --- /dev/null +++ b/tests/testcase/Databases/DatabaseGroupTest.php @@ -0,0 +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()); + } + } + +?> diff --git a/tests/testcase/Databases/DatabaseTest.php b/tests/testcase/Databases/DatabaseTest.php new file mode 100644 index 000000000..e25ca754a --- /dev/null +++ b/tests/testcase/Databases/DatabaseTest.php @@ -0,0 +1,168 @@ +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: DCD001 + * This test is used to create a default database with + * "LATIN1" character set. + * + * Note: The open database cannot delete by phpPgAdmin, so this case + * can be run only one time. It needs to change name of database for + * next time. + */ + function testCreateLATIN1DBInSPT() + { + global $webUrl; + global $lang; + + // Locate the list page of databases. + $this->assertTrue($this->get($webUrl . '/all_db.php')); + + // Click the hyperlink of "Create Database". + $this->assertTrue($this->get($webUrl . '/all_db.php?action=create')); + + // Fill the form about creating database. + $this->assertTrue($this->setfield('formName', 'spikesource1')); + $this->assertTrue($this->setfield('formEncoding', 'LATIN1')); + $this->assertTrue($this->setfield('formSpc', 'pg_default')); + + // Click the submit button. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify weather the database has been created. + // Because the phpPgAdmin cannot drop the currently open database. + // this test case may be failed + // when runing the testcase second time without removing the databases. + $this->assertWantedText($lang['strdatabasecreated']); + + // Release the resource. + // In fact, this line doesnot work because of phpPgAdmin's bug. + $this->dropDatabase('spikesource1'); + + return TRUE; + } + + + /** + * TestCaseId: DCD002 + * This test is used to create a defined database with other + * character set "UNICODE". + * + * Note: The open database cannot delete by phpPgAdmin, so this case + * can be run only one time. It needs to change name of database for + * next time. + */ + function testCreateUNICODEDBInTester() + { + global $webUrl; + global $lang; + + // 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')); + + // Click the hyperlink of "Create Database". + $this->assertTrue($this->get($webUrl . '/all_db.php?action=create')); + + // Fill the form about creating database. + $this->assertTrue($this->setfield('formName', 'spikesource2')); + $this->assertTrue($this->setfield('formEncoding', 'UNICODE')); + $this->assertTrue($this->setfield('formSpc', 'pg_default')); + + // Click the submit button. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify weather the database has been created. + // Because the phpPgAdmin cannot drop the currently open database, + // this test case may be failed + // when runing the testcase second time without removing the databases. + $this->assertWantedText($lang['strdatabasecreated']); + + // Release the resource. + // In fact, this line doesnot work because of phpPgAdmin's bug. + $this->dropDatabase('spikesource2'); + + return TRUE; + } + + + /** + * TestCaseId: DDD001 + * This test is used to drop a defined database. + * + * This test is faild, because the PostgreSQL cannot support deleteing + * an open database currently. + */ + function testDropDatabase() + { + global $webUrl; + global $lang; + + // Click the hyperlink of "Create Database". + $this->assertTrue($this->get($webUrl . '/all_db.php' . + '?action=confirm_drop' . + '&subject=database&database=test&')); + + // Click the submit button "Drop" next page. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + + // Verify weather the database has been droped. + // 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. + $this->dropDatabase('SpikeSource1'); + $this->dropDatabase('SpikeSource2'); + + return TRUE; + } +} + +?> + diff --git a/tests/testcase/Databases/FindObjectsTest.php b/tests/testcase/Databases/FindObjectsTest.php new file mode 100644 index 000000000..3c3207a5c --- /dev/null +++ b/tests/testcase/Databases/FindObjectsTest.php @@ -0,0 +1,199 @@ +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: DFO001 + * This test is used to find objects in the search component. + */ + function testSimpleFindObject() + { + global $webUrl; + global $lang; + + // Locate the list page of databases. + $this->assertTrue($this->get($webUrl . '/database.php' . + '?database=test&subject=database' . + '&action=find')); + + $this->assertTrue($this->setField('term', 'student')); + $this->assertTrue($this->setField('filter', 'All objects')); + $this->assertTrue($this->clickSubmit ($lang['strfind'])); + return true; + } + + + /** + * TestCaseId: DFO002 + * This test is used to find objects in the search component. + */ + function testFindObjsInSchemas() + { + global $webUrl; + global $lang; + + // Locate the list page of databases. + $this->assertTrue($this->get($webUrl . '/database.php' . + '?database=test&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->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->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->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->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->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->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->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->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->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->setField('term', 'student')); + $this->assertTrue($this->setField('filter', 'Domains')); + $this->assertTrue($this->clickSubmit ($lang['strfind'])); + + return true; + } + + + /** + * TestCaseId: DFO003 + * This test is used to find objects in the search component in top bar. + */ + function testFindTopObjects() + { + global $webUrl; + global $lang; + + // Locate the list page of databases. + $this->assertTrue($this->get($webUrl . '/sqledit.php?action=find&')); + + $this->assertTrue($this->setField('database', 'test')); + $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 new file mode 100644 index 000000000..65717919e --- /dev/null +++ b/tests/testcase/Databases/HelpTest.php @@ -0,0 +1,101 @@ +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:DCD001; + * This test is used to test help links. + * + * Note: It's strange here, because all the links are outside. + * So the Pattern cannot be invoked directly. + */ + function testHelpWithInnerSchema() + { + global $webUrl; + global $lang; + + // Locate the list page of database. + $this->assertTrue($this->get($webUrl . '/database.php' . + '?database=test&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')); + + // Comment this for avoiding error by Xdebug. + // Becase we cannot assert something about the content of the page via + // hyperlink outside + // $this->assertWantedPattern('/"Schemas"/'); + + return TRUE; + } + + + /** + * TestCaseId:DCD002; + * This test is used to test help links from the index links. + */ + function testHelpWithInrClk() + { + global $webUrl; + + // 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/' . + 'interactive/sql-expressions.html' . + '#SQL-SYNTAX-TYPE-CASTS')); + + return TRUE; + } +} + +?> diff --git a/tests/testcase/Databases/LanguageTest.php b/tests/testcase/Databases/LanguageTest.php new file mode 100644 index 000000000..208727d94 --- /dev/null +++ b/tests/testcase/Databases/LanguageTest.php @@ -0,0 +1,67 @@ +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: DLD001 + * This test is used to test Language Displayed page. + */ + function testLanguage() + { + global $webUrl; + // Locate the list page of language. + $this->assertTrue($this->get($webUrl . '/languages.php' . + '?database=test&subject=database')); + + $this->assertWantedPattern('/sql/'); + + return TRUE; + } +} + +?> diff --git a/tests/testcase/Databases/ProcessesTest.php b/tests/testcase/Databases/ProcessesTest.php new file mode 100644 index 000000000..b8df5ffa2 --- /dev/null +++ b/tests/testcase/Databases/ProcessesTest.php @@ -0,0 +1,70 @@ +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: DPS001 + * This test is used to test Processes. + * + * Note: This sub function is dynamic during the run time. + */ + function testProcesses() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/database.php' . + '?database=test&subject=database' . + '&action=processes')); + + $this->assertWantedText($lang['strnodata']); + + return TRUE; + } +} + +?> diff --git a/tests/testcase/Databases/SchemaBasicTest.php b/tests/testcase/Databases/SchemaBasicTest.php new file mode 100644 index 000000000..65f191808 --- /dev/null +++ b/tests/testcase/Databases/SchemaBasicTest.php @@ -0,0 +1,133 @@ +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: DCS001 + * This test is used to create one new schema for super user. + */ + 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')); + + $this->assertTrue($this->setField('formName', 'testSchemaName')); + $this->assertTrue($this->setField('formAuth', 'super')); + $this->assertTrue($this->setField('formComment', + 'Comment of test schema.')); + + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + $this->assertWantedText($lang['strschemacreated']); + + return TRUE; + } + + + /** + * TestCaseId: DAS001 + * This test is used to modify one existent schema for super user. + */ + 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&')); + + $this->assertTrue($this->setField('comment', + 'The comment has been changed.')); + $this->assertTrue($this->clickSubmit('Alter')); + + $this->assertWantedText($lang['strschemaaltered']); + + return TRUE; + } + + + /** + * TestCaseId: DDS001 + * This test is used to drop one existent schema for super user. + */ + 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&')); + + $this->assertTrue($this->setField('cascade', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + + $this->assertWantedText($lang['strschemadropped']); + + return TRUE; + } +} + +?> diff --git a/tests/testcase/Databases/SqlTest.php b/tests/testcase/Databases/SqlTest.php new file mode 100644 index 000000000..4750a3c7a --- /dev/null +++ b/tests/testcase/Databases/SqlTest.php @@ -0,0 +1,319 @@ +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: DES001 + * This test is used to send the "select" sql script to phpPgAdmin for + * implementation. + */ + function testSimpleSelectSql() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&subject=database&action=sql')); + $this->assertTrue($this->setFieldById(0, "select id from student;")); + + $this->assertTrue($this->clickSubmit($lang['strgo'])); + + return TRUE; + } + + + /** + * TestCaseId: DES003 + * This test is used to send the "delete" sql script to phpPgAdmin for + * implementation. + */ + function testSimpleDeleteSql() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&subject=database&action=sql')); + $this->assertTrue($this->setField('query', 'delete from "student";')); + + $this->assertTrue($this->clickSubmit($lang['strgo'])); + + return TRUE; + } + + + /** + * TestCaseId: DES002 + * This test is used to send the "insert" sql script to phpPgAdmin for implement. + */ + function testSimpleInsertSql() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&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'])); + + return true; + } + + + /** + * TestCaseId: DES004 + * This test is used to send the "update" sql script to phpPgAdmin + * for implementation. + */ + function testSimpleUpdateSql() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&subject=database&action=sql')); + $this->assertTrue($this->setField('query', + 'update public."student" ' . + 'set "birthday" = now();')); + + $this->assertTrue($this->clickSubmit($lang['strgo'])); + + return TRUE; + } + + + /** + * TestCaseId: DES005 + * This test is used to send the "select"" sql script to PostgreSQL + * for implementation about "Explain". + */ + function testExplain() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&subject=database&action=sql')); + + $this->assertTrue($this->setField('query', + 'select "id" from "student";')); + + $this->assertTrue($this->setField('paginate', TRUE)); + + $this->assertTrue($this->clickSubmit($lang['strexplain'])); + + // Here $lang['strsqlexecuted'] is not fit for this situation. Because the "%s" + // make the assertion failed. + $this->assertWantedText('Total runtime'); + + return TRUE; + } + + + /** + * TestCaseId: DES006 + * This test is used to send the "select" sql script to phpPgAdmin + * for implementation about "Explain Analyze". + */ + function testExplainAnalyze() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&subject=database&action=sql')); + $this->assertTrue($this->setField('query', + 'select "id" from "student";')); + + $this->assertTrue($this->setField('paginate', TRUE)); + + $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; + } + + + /** + * TestCaseId: DES007 + * This test is used to send the "select" sql script file to phpPgAdmin + * for implementation about "upload" sql script. + * + * Note: The SimpleTest doesn't support this yet currently. + * So this failed. + */ + function testUploadSQLFile() + { + + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/database.php?' . + 'database=test&subject=database' . + '&action=sql')); + + $webServerUrl = getcwd(); + $sqlScriptUrl = $webServerUrl . "/../data/select.sql"; + + $this->assertTrue ($this->setField('script', $sqlScriptUrl)); + + // This should be failed. Because the SimpleText doesn't support + // upload yet. + $this->assertWantedText($lang['strsqlexecuted']); + + return TRUE; + } + + + /** + * TestCaseId: DES009 + * This test is used to send the "select" sql script to the topbar link + * in phpPgAdmin for implementation. + */ + function testSelectTopSQL() + { + global $webUrl; + global $lang; + + $this->get($webUrl . '/sqledit.php?action=sql&'); + + $this->assertTrue($this->setField('database', 'test')); + $this->assertTrue($this->setField('query', 'select * from student;')); + + $this->assertTrue($this->clickSubmit($lang['strgo'])); + + $this->assertWantedText($lang['strsqlexecuted']); + + return true; + } + + + /** + * TestCaseId: DES010; + * This test is used to send the "select" sql script to the topbar link + * in phpPgAdmin for implementation. + */ + function testResultFromSelectTopSQL() + { + global $webUrl; + global $lang; + + $this->get($webUrl . '/sqledit.php?action=sql&'); + + $this->assertTrue($this->setField('database', 'test')); + $this->assertTrue($this->setField('query', 'select * from student;')); + $this->assertTrue($this->setField('paginate', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strgo'])); + + $this->assertTrue($this->clickLink($lang['strexpand'])); + $this->assertWantedText($lang['strnodata']); + + $this->assertTrue($this->clickLink($lang['strcollapse'])); + $this->assertWantedText($lang['strnodata']); + + $this->assertTrue($this->clickLink($lang['strrefresh'])); + + return TRUE; + } + + + /** + * TestCaseId: DES011 + * This test is used to generate the report by the sql in topbar + * in phpPgAdmin for implementation. + */ + function testReportByTopSql() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . + '/reports.php?action=create&db_name=test' . + '&report_sql=select+id+from+student%3B')); + + $this->assertTrue($this->setField('report_name', 'test')); + $this->assertTrue($this->setField('descr', 'test')); + + $this->assertTrue($this->clickSubmit($lang['strsave'])); + + $this->assertWantedText($lang['strreportcreated']); + } + + + /** + * TestCaseId: DES012 + * This test is used to download the specified format of + * report by the sql in topbar in phpPgAdmin for implementation. + */ + function testDownloadTopSql() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . + '/dataexport.php?query=select+id+from+student%3B' . + '&database=test')); + + $this->assertTrue($this->setField('d_format', 'XML')); + $this->assertTrue($this->setField('output', 'show')); + + $this->assertTrue($this->clickSubmit($lang['strexport'])); + + // Here anything about xml cannot be found in English.php so hard code. + $this->assertWantedPattern('/ diff --git a/tests/testcase/Databases/VariablesTest.php b/tests/testcase/Databases/VariablesTest.php new file mode 100644 index 000000000..029fdfab3 --- /dev/null +++ b/tests/testcase/Databases/VariablesTest.php @@ -0,0 +1,68 @@ +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: DVA001 + * This test is used to display the list of Prcesses. + */ + function testVariablesList() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&subject=database&action=variables')); + + $this->assertWantedText($lang['strname']); + $this->assertWantedText($lang['strsetting']); + + return TRUE; + } +} + +?> diff --git a/tests/testcase/Public/SetPrecondition.php b/tests/testcase/Public/SetPrecondition.php new file mode 100644 index 000000000..9556f24d8 --- /dev/null +++ b/tests/testcase/Public/SetPrecondition.php @@ -0,0 +1,212 @@ +get($loginPageUrl); + $this->setField('formUsername', $userName); + $this->setField('formPassword', $password); + $this->setField('formLanguage', $lang['applang']); + $this->clickSubmit('Login'); + + return TRUE; + } + + + /** + * Create a new database by the giving database name and encoding. + * + * @param string $databaseName The name of the new database. + * @param string $enCoding The encoding mode. + * + * @access public + */ + function createDatabase($databaseName, $enCoding) + { + global $webUrl; + global $lang; + 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'); + $this->clickLink('Create database'); + + $this->setField('formName', $databaseName); + $this->setField('formEncoding', $enCoding); + + // Click the button "Create" for creating a database + // use the specifid name. + $this->clickSubmit($lang['strcreate']); + + return TRUE; + } + + + /** + * Drop a exist database by the specify database name. + * + * @param string $databaseName The specify database name which be droped. + * + * @access public + */ + function dropDatabase($databaseName) + { + global $webUrl; + global $lang; + 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'); + $this->get($webUrl . '/all_db.php?action=confirm_drop' . + '&subject=database&database=' . $databaseName); + $this->clickSubmit($lang['strdrop']); + + return TRUE; + } + + + /** + * Create a new table by the specified conditions. + * + * Notice: + * If the value of $fieldNumber equals 3, it would be create a + * table with 3 field like(field name, field type):(field0, text), + * (field1, text), (field2, text). + * + * @param string $databaseName Owner of the new table. paramname. + * @param string $schema the Schema which the new table belong to. + * @param string $tablename The name of the new table. + * @param string $fieldNumber The field number of the new table. + */ + function createTable($databaseName, $schema, $tableName, $fieldNumber) + { + global $webUrl; + global $lang; + global $SUPER_USER_NAME; + global $SUPER_USER_PASSWORD; + + $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + $this->get($webUrl . '/tables.php?action=create&database=' . + $databaseName . '&schema=' .$schema); + + $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. + //$this->assertTrue($this->ClickSubmit($lang['strnext'])); + // If we do not hardcoded it here, it will cause fail. Encoding issue. + $this->assertTrue($this->ClickSubmit('Next >')); + + for($ii = 0 ; $ii < $fieldNumber; $ii++) + { + $field = 'field[' . $ii .']'; + $type = 'type[' . $ii . ']'; + $array = 'array[' . $ii . ']'; + $fieldName = 'field' . $ii; + + // Enter the detail information of the table. + $this->setField($field, $fieldName); + $this->setField($type, 'text'); + $this->setField($array, ''); + } + + // Click the button "Create" for creating the + // table use the specify conditions. + $this->clickSubmit($lang['strcreate']); + + return TRUE; + } + + + /** + * Drop a exist table by the specified table name in a database. + * + * @param string $databaseName the database which the table content. + * @param string $tableName the table name which wants to delete. + * @param string $schema the schema the table belong. + * + * @access public + */ + function dropTable($databaseName, $tableName, $schema) + { + // Import the global variable. + global $webUrl; + global $lang; + 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'); + + $this->get($webUrl . '/tables.php?action=confirm_drop&database=' . + $databaseName . '&schema=' . $schema . '&table=' . + $tableName . '&'); + + // Click the button "Drop" for dropping the table from the database. + $this->clickSubmit($lang['strdrop']); + + return TRUE; + } + + + /** + * Logout the system. + */ + function logout() + { + global $webUrl; + global $lang; + $this->get($webUrl . '/index.php'); + + // Select the frame and logout. + $this->setFrameFocus('topbar'); + $this->clickLink($lang['strlogout']); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Public/common.php b/tests/testcase/Public/common.php new file mode 100644 index 000000000..b6f61be0d --- /dev/null +++ b/tests/testcase/Public/common.php @@ -0,0 +1,35 @@ + diff --git a/tests/testcase/Schemas/AggregateTest.php b/tests/testcase/Schemas/AggregateTest.php new file mode 100644 index 000000000..f58fcef2f --- /dev/null +++ b/tests/testcase/Schemas/AggregateTest.php @@ -0,0 +1,120 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Clean up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HCA01 + * Creates a new aggregate. + */ + function testCreateAggregate() + { + global $webUrl; + global $lang; + + // Turn to "sql" page. + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&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,' . + ' stype1 = box, initcond1 = \'(0,0)\');')); + + // Click the button "Go" to create a new aggregate. + $this->assertTrue($this->clickSubmit($lang['strgo'])); + // Verify whether the aggregates is created correctly. + $this->assertTrue($this->assertWantedText($lang['strsqlexecuted'])); + + return TRUE; + } + + + /** + * TestCaseID: HBA01 + * Displays all the aggregates. + */ + function testBrowseAggregates() + { + global $webUrl; + global $lang; + + // Turn to "Aggregates" page. + $this->assertTrue($this->get($webUrl . '/aggregates.php?database=' . + 'test&schema=public&subject=schema')); + + // Verify whether the aggregates is displayed correctly. + $this->assertTrue($this->assertWantedText('complex_sum')); + } + + + /** + * TestCaseID: HDA01 + * Drop a aggregate. + */ + function testDropAggregate() + { + global $webUrl; + global $lang; + + // Turn to "sql" page. + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&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. + $this->assertTrue($this->assertWantedText($lang['strsqlexecuted'])); + + return TRUE; + } +} + + +?> diff --git a/tests/testcase/Schemas/ConversionTest.php b/tests/testcase/Schemas/ConversionTest.php new file mode 100644 index 000000000..442c6c052 --- /dev/null +++ b/tests/testcase/Schemas/ConversionTest.php @@ -0,0 +1,74 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Clean up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HBC01 + * Browse the conversions. + */ + function testBrowseConversion() + { + global $webUrl; + global $lang; + + // Turn to schema "pg_catalog" page. + $this->assertTrue($this->get($webUrl . '/redirect.php?section=schema' . + '&database=template1&schema=pg_catalog&')); + // Click the "Conversions" hyper link. + $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 new file mode 100644 index 000000000..5fe99eb82 --- /dev/null +++ b/tests/testcase/Schemas/DomainTest.php @@ -0,0 +1,191 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Cleans up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HCD01 + * Create a domain. + */ + function testCreateDomain() + { + global $webUrl; + global $lang; + + // Turn to the "Create domain" page. + $this->assertTrue($this->get($webUrl . '/domains.php?action=create&' . + 'database=test&schema=public')); + + // Enter the detail information of the new domain. + $this->assertTrue($this->setField('domname', 'spikedomain')); + $this->assertTrue($this->setField('domtype', 'bigint')); + $this->assertTrue($this->setField('domarray', '[ ]')); + $this->assertTrue($this->setField('domnotnull', TRUE)); + + // Click the "Create" button to create the domain. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify whether the domain is created successfully. + $this->assertTrue($this->assertWantedText($lang['strdomaincreated'])); + + return TRUE; + } + + + /** + * TestCaseID: HAD01 + * Alter the definition of a domain. + */ + function testAlterDomain() + { + global $webUrl; + global $lang; + + // 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->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. + */ + function testAddCheck() + { + global $webUrl; + global $lang; + + // 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->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. + */ + function testDropConstraint() + { + global $webUrl; + global $lang; + + // Turn to the domains-display page. + $this->assertTrue($this->get($webUrl . '/domains.php?database=test&' . + '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->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. + */ + function testDropDomain() + { + global $webUrl; + global $lang; + + // 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->setField('cascade', TRUE)); + + // Click the "Drop" button to drop the domain. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify whether the domain is droped successfully. + $this->assertTrue($this->assertWantedText($lang['strdomaindropped'])); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Schemas/FunctionTest.php b/tests/testcase/Schemas/FunctionTest.php new file mode 100644 index 000000000..8c86c86d4 --- /dev/null +++ b/tests/testcase/Schemas/FunctionTest.php @@ -0,0 +1,230 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Clean up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HCF01 + * Create a SQL/PL function. + */ + function testCreatSqlFunction() + { + global $webUrl; + global $lang; + + // Turn to the "Create SQL/PL function" page. + $this->assertTrue($this->get($webUrl . '/functions.php?action=create&' . + 'database=test&schema=public')); + + // Enter the detail information of a SQL/PL function. + $this->assertTrue($this->setField('formFunction', 'sqlplfunction')); + $this->assertTrue($this->setField('formArguments', 'double precision[], double precision')); + $this->assertTrue($this->setField('formSetOf', 'SETOF')); + $this->assertTrue($this->setField('formReturns', 'double precision')); + $this->assertTrue($this->setField('formArray', '[ ]')); + $this->assertTrue($this->setField('formLanguage', 'sql')); + $this->assertTrue($this->setField('formDefinition', 'select $1')); + $this->assertTrue($this->setField('formProperties[0]', 'VOLATILE')); + $this->assertTrue($this->setField('formProperties[1]', 'RETURNS NULL ON NULL INPUT')); + $this->assertTrue($this->setField('formProperties[2]', 'SECURITY INVOKER')); + + // Click the "Create" button to create a function. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify whether the function is created successfully. + $this->assertTrue($this->assertWantedText($lang['strfunctioncreated'])); + + return TRUE; + } + + + /** + * TestCaseID: HCF02 + * Create a internal function. + */ + function testCreateInternalFunction() + { + global $webUrl; + global $lang; + + // Turn to the "Create internal function" page. + $this->assertTrue($this->get($webUrl . '/functions.php?action=create&' . + 'language=internal&database=test&schema=public')); + + // Enter the detail information of a SQL/PL function. + $this->assertTrue($this->setField('formFunction', 'internalfunction')); + $this->assertTrue($this->setField('formArguments', 'boolean')); + $this->assertTrue($this->setField('formSetOf', 'SETOF')); + $this->assertTrue($this->setField('formReturns', 'name')); + $this->assertTrue($this->setField('formArray', '[ ]')); + $this->assertTrue($this->setField('formLinkSymbol', 'current_schemas')); + $this->assertTrue($this->setField('formProperties[0]', 'VOLATILE')); + $this->assertTrue($this->setField('formProperties[1]', 'RETURNS NULL ON NULL INPUT')); + $this->assertTrue($this->setField('formProperties[2]', 'SECURITY INVOKER')); + + // Click the "Create" button to create a function. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify whether the function is created successfully. + $this->assertTrue($this->assertWantedText($lang['strfunctioncreated'])); + + return TRUE; + } + + + /** + * TestCaseID: HCF03 + * Create a C function. + */ + function testCreateCFunction() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/functions.php?database=test' . + '&schema=public&')); + // Turn to the C-function create page. + $this->assertTrue($this->clickLink($lang['strcreatecfunction'])); + + // Enter the definition of the C function. + $this->assertTrue($this->setField('formFunction', 'cfunction')); + $this->assertTrue($this->setField('formArguments', 'text')); + $this->assertTrue($this->setField('formReturns', 'boolean')); + $cFunLocation = getcwd() . '/../data/CFunction/euc_jp_and_sjis'; + $this->assertTrue($this->setField('formObjectFile', $cFunLocation)); + $this->assertTrue($this->setField('formLinkSymbol', 'mic_to_sjis')); + $this->assertTrue($this->setField('formProperties[0]', 'VOLATILE')); + $this->assertTrue($this->setField('formProperties[1]', 'RETURNS NULL ON NULL INPUT')); + $this->assertTrue($this->setField('formProperties[2]', 'SECURITY DEFINER')); + + // Click the "Create" button to create the C fucntion. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + // Verify whether the function is created successfully. + $this->assertTrue($this->assertWantedText($lang['strfunctioncreated'])); + + return TRUE; + } + + + /** + * TestCaseID: HAF01 + * Alter the definition of an existing function. + */ + function testAlterFunction() + { + global $webUrl; + global $lang; + + // Turn to the function-display page. + $this->assertTrue($this->get($webUrl . '/functions.php?database=test' . + '&schema=public&subject=schema')); + + // Alter the definiton of "cfunction". + $this->assertTrue($this->clickLink('cfunction (text)')); + $this->assertTrue($this->clickLink($lang['stralter'])); + + // Alter the definition of the function. + $this->assertTrue($this->setField('formProperties[0]', 'IMMUTABLE')); + $this->assertTrue($this->setField('formProperties[1]', 'CALLED ON NULL INPUT')); + $this->assertTrue($this->setField('formProperties[2]', 'SECURITY INVOKER')); + + // Click the "Create" button to alter the fucntion. + $this->assertTrue($this->clickSubmit($lang['stralter'])); + // Verify whether the function is updated successfully. + $this->assertTrue($this->assertWantedText($lang['strfunctionupdated'])); + + return TRUE; + } + + + /** + * TestCaseID: HDF01 + * Drop an existing function. + */ + function testDropFunction() + { + global $webUrl; + global $lang; + + // Turn to the function-display page. + $this->assertTrue($this->get($webUrl . '/functions.php?database=test' . + '&schema=public&subject=schema')); + + // Drop the fucntion "sqlplfunction". + $this->assertTrue($this->clickLink('sqlplfunction (double precision[], double precision)')); + $this->assertTrue($this->clickLink($lang['strdrop'])); + $this->assertTrue($this->setField('cascade', TRUE)); + + // Click the "Drop" button to dorp the function. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify whether the function is dropped successfully. + $this->assertTrue($this->assertWantedText($lang['strfunctiondropped'])); + + // Drop the fucntion "cfunction". + $this->assertTrue($this->clickLink('cfunction (text)')); + $this->assertTrue($this->clickLink($lang['strdrop'])); + $this->assertTrue($this->setField('cascade', TRUE)); + + // Click the "Drop" button to drop the function. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify whether the function is dropped successfully. + $this->assertTrue($this->assertWantedText($lang['strfunctiondropped'])); + + // Drop the function "internalfunction". + $this->assertTrue($this->clickLink('internalfunction (boolean)')); + $this->assertTrue($this->clickLink($lang['strdrop'])); + $this->assertTrue($this->setField('cascade', TRUE)); + + // Click the "Drop" button to drop the function. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify whether the function is dropped successfully. + $this->assertTrue($this->assertWantedText($lang['strfunctiondropped'])); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Schemas/OpClassTest.php b/tests/testcase/Schemas/OpClassTest.php new file mode 100644 index 000000000..096266678 --- /dev/null +++ b/tests/testcase/Schemas/OpClassTest.php @@ -0,0 +1,71 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Clean up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HBC01 + * Browse all the op classes. + */ + function testBrowseOpClass() + { + global $webUrl; + global $lang; + + // Turn to schema "pg_catalog" page. + $this->assertTrue($this->get($webUrl . '/opclasses.php?database=' . + 'test&schema=pg_catalog&subject=schema')); + + // Verify whether all the op classes are displayed. + $this->assertTrue($this->assertWantedText($lang['straccessmethod'])); + + return TRUE; + } +} + +?> diff --git a/tests/testcase/Schemas/OperatorTest.php b/tests/testcase/Schemas/OperatorTest.php new file mode 100644 index 000000000..9a678a843 --- /dev/null +++ b/tests/testcase/Schemas/OperatorTest.php @@ -0,0 +1,136 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Clean up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HCO01 + * Create a operator. + */ + function testCreateOperator() + { + global $webUrl; + global $lang; + + // Turn to "sql" page. + $this->assertTrue($this->get($webUrl . '/database.php?database=test' . + '&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, ' . + 'COMMUTATOR = ==, NEGATOR = !==, RESTRICT = areasel, JOIN ' . + '= areajoinsel);')); + + // Click the button "Go" to create a new operator. + $this->assertTrue($this->clickSubmit($lang['strgo'])); + // Verify if the operator is created correctly. + $this->assertTrue($this->assertWantedText($lang['strsqlexecuted'])); + + return TRUE; + } + + + /** + * TestCaseID: HSP01 + * Show the properties of the specified operator. + */ + function testShowProperty() + { + global $webUrl; + global $lang; + + // Turn to "Operators" page. + $this->assertTrue($this->get($webUrl . '/operators.php?' . + 'database=test&schema=public&subject=schema')); + // Show the properties of the operator "===". + $this->assertTrue($this->clickLink('===')); + // Check the properties. + $this->assertTrue($this->assertWantedText('areasel')); + + return TRUE; + } + + + /** + * TestCaseID: HDO01 + * Drop the operators. + */ + function testDropOperator() + { + global $webUrl; + global $lang; + + // Turn to "Operators" page. + $this->assertTrue($this->get($webUrl . '/operators.php?' . + 'database=test&schema=public&subject=schema')); + + // Drop the first operator. + $this->assertTrue($this->clickLink($lang['strdrop'])); + $this->assertTrue($this->setField('cascade', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify whether the operator is dropped correctly. + $this->assertTrue($this->assertWantedText($lang['stroperatordropped'])); + + // Drop the second operator. + $this->assertTrue($this->clickLink($lang['strdrop'])); + $this->assertTrue($this->setField('cascade', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify whether the operator is dropped correctly. + $this->assertTrue($this->assertWantedText($lang['stroperatordropped'])); + + // Drop the third operator. + $this->assertTrue($this->clickLink($lang['strdrop'])); + $this->assertTrue($this->setField('cascade', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify whether the operator is dropped completely. + $this->assertTrue($this->assertWantedText($lang['strnooperators'])); + + return TRUE; + } +} + +?> diff --git a/tests/testcase/Schemas/SchemasGroupTest.php b/tests/testcase/Schemas/SchemasGroupTest.php new file mode 100644 index 000000000..b00bb298a --- /dev/null +++ b/tests/testcase/Schemas/SchemasGroupTest.php @@ -0,0 +1,52 @@ +GroupTest('Schema management group test.'); + + $this->addTestClass(new TableTest()); + + $this->addTestClass(new ViewTest()); + + $this->addTestClass(new SequenceTest()); + + $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()); + } +} +?> diff --git a/tests/testcase/Schemas/SequenceTest.php b/tests/testcase/Schemas/SequenceTest.php new file mode 100644 index 000000000..d8831ced3 --- /dev/null +++ b/tests/testcase/Schemas/SequenceTest.php @@ -0,0 +1,130 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Clean up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HCS01 + * Create a sequence. + */ + function testCreateSequence() + { + global $webUrl; + global $lang; + + // Turn to the "Create sequence" page. + $this->assertTrue($this->get($webUrl . '/sequences.php?action=create&' . + 'database=test&schema=public')); + + // Enter the detail information of a sequence. + $this->assertTrue($this->setField('formSequenceName', 'createsequence')); + $this->assertTrue($this->setField('formIncrement', '1')); + $this->assertTrue($this->setField('formMinValue', '1000')); + $this->assertTrue($this->setField('formMaxValue', '10000')); + $this->assertTrue($this->setField('formStartValue', '1000')); + $this->assertTrue($this->setField('formCacheValue', '5')); + $this->assertTrue($this->setField('formCycledValue', TRUE)); + + // Click the "Create" button to create a sequence. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify whether the sequence is created successfully. + $this->assertTrue($this->assertWantedText($lang['strsequencecreated'])); + + return TRUE; + } + + + /** + * TestCaseID: HRS01 + * Reset an existing sequence. + */ + function testResetSequence() + { + global $webUrl; + global $lang; + + // Turn to the sequence-display page. + $this->assertTrue($this->get($webUrl . '/sequences.php?database=test&' . + 'schema=public&subject=schema')); + // Browse the specified sequence. + $this->assertTrue($this->clickLink('createsequence')); + // Reset the sequence. + $this->assertTrue($this->clickLink($lang['strreset'])); + + // Verify whether the sequence is reset successfully. + $this->assertTrue($this->assertWantedText($lang['strsequencereset'])); + // Display all the sequence. + $this->assertTrue($this->clickLink($lang['strshowallsequences'])); + + return TRUE; + } + + + /** + * TestCaseID: HDS01 + * Drop a sequence. + */ + function testDropSequence() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/sequences.php?action=confirm_drop&' . + 'database=test&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'])); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Schemas/TableTest.php b/tests/testcase/Schemas/TableTest.php new file mode 100644 index 000000000..9f6385034 --- /dev/null +++ b/tests/testcase/Schemas/TableTest.php @@ -0,0 +1,579 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Clean up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HCT01 + * This testcase is used to create a table in an existing database. + */ + function testCreateTable() + { + global $webUrl; + global $lang; + + // Turn to the create table page to create a table. + $this->assertTrue($this->get($webUrl . '/tables.php?action=create&' . + 'database=test&schema=public')); + + // Enter the table name and field number. + $this->assertTrue($this->setField('name', 'newtable')); + $this->assertTrue($this->setField('fields', '2')); + $this->assertTrue($this->setField('spcname', 'pg_default')); + $this->assertTrue($this->setField('tblcomment', 'Create from SimpleTest!')); + + // Click the button "next >" for entering 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 >')); + + // Enter the detail information of the table. + $this->assertTrue($this->setField('field[0]', 'firstfield')); + $this->assertTrue($this->setField('type[0]', 'text')); + $this->assertTrue($this->setField('array[0]', '')); + + $this->assertTrue($this->setField('field[1]', 'secondfield')); + $this->assertTrue($this->setField('type[1]', 'text')); + $this->assertTrue($this->setField('array[1]', '')); + + // Click the button "Create" for creating the table + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify whether the table is created correctly. + $this->assertTrue($this->assertWantedText($lang['strtablecreated'])); + + // Drop the table which is created in the testcase. + $this->dropTable('test', 'newtable', 'public'); + + return TRUE; + } + + + /** + * TestCaseID: HCT02 + * Create a table with the wrong field number. + */ + function testCreateTableWithBadFieldNumber() + { + global $webUrl; + global $lang; + + // Turn to the create table page to create a table. + $this->assertTrue($this->get($webUrl . '/tables.php?action=create&' . + 'database=test&schema=public')); + + // Enter no name. + //$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->assertWantedText($lang['strtableneedsname'])); + + // Enter the table name and field number. + $this->assertTrue($this->setField('name', 'badtable')); + + // Enter no name. + //$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->assertWantedText($lang['strtableneedscols'])); + + // Enter illegal field number. + $this->assertTrue($this->setField('fields', 'illegalnumber')); + $this->assertTrue($this->setField('tblcomment', 'Wrong field number.')); + + // Click the button "next >" for entering 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 >')); + + //Verify whether the table creation fialed. + $this->assertTrue($this->assertWantedText($lang['strtableneedscols'])); + + return TRUE; + } + + + /** + * TestCaseID: HCT03 + * Create a table with the wrong field information. + */ + function testCreateTableWithBadFieldData() + { + global $webUrl; + global $lang; + + // Turn to the create table page to create a table. + $this->assertTrue($this->get($webUrl . '/tables.php?action=create&' . + 'database=test&schema=public')); + + // Enter the table name and field number. + $this->assertTrue($this->setField('name', 'badfield')); + $this->assertTrue($this->setField('fields', '2')); + $this->assertTrue($this->setField('spcname', 'pg_default')); + $this->assertTrue($this->setField('tblcomment', 'With illegal field information!')); + + // Click the button "next >" for entering 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 >')); + + // Enter the detail information of the table. + $this->assertTrue($this->setField('field[0]', 'field1')); + $this->assertTrue($this->setField('type[0]', 'integer')); + $this->assertTrue($this->setField('array[0]', '[ ]')); + $this->assertTrue($this->setField('default[0]', '100')); + + $this->assertTrue($this->setField('field[1]', 'field2')); + $this->assertTrue($this->setField('type[1]', 'integer')); + $this->assertTrue($this->setField('array[1]', '[ ]')); + $this->assertTrue($this->setField('default[0]', 'testcase')); + + // Click the button "Create" for creating the table + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + //Verify whether the table creation failed. + $this->assertTrue($this->assertWantedText($lang['strtableneedsfield'])); + + return TRUE; + } + + + /** + * TestCaseID: HIT01 + * Insert a row into an existing table + */ + function testInsertOneRow() + { + global $webUrl; + global $lang; + + // Create a table. + $this->createTable('test', 'public', 'viewtest', '3'); + + // Turn to the "Insert row" interface. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confinsertrow&' . + 'database=test&schema=public&table=viewtest&')); + + // Set the value of the fields. + $this->assertTrue($this->setField('values[field0]', 'row1column1')); + $this->assertTrue($this->setField('values[field1]', 'row1column2')); + $this->assertTrue($this->setField('values[field2]', 'row1column3')); + + // Click the "Insert" button to insert a row. + $this->assertTrue($this->clickSubmit($lang['strinsert'])); + // Verify whether the row is inserted successfully. + $this->assertTrue($this->assertWantedText($lang['strrowinserted'])); + + return TRUE; + } + + + /** + * TestCaseID: HIT02 + * Insert two rows into an existing table + */ + function testInsertTwoRows() + { + global $webUrl; + global $lang; + + // Turn to the "Insert row" interface. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confinsertrow&' . + 'database=test&schema=public&table=viewtest&')); + + // Set the value of the fields. + $this->assertTrue($this->setField('values[field0]', 'row2column1')); + $this->assertTrue($this->setField('values[field1]', 'row2column2')); + $this->assertTrue($this->setField('values[field2]', 'row2column3')); + + // Click the "Insert & Repeat" button to insert a row. + //$this->assertTrue($this->clickSubmit($lang['strinsertandrepeat'])); + // If we do not hardcoded it here, it will cause fail. Encoding issue. + $this->assertTrue($this->clickSubmit('Insert & Repeat')); + // Verify whether the row is inserted successfully. + $this->assertTrue($this->assertWantedText($lang['strrowinserted'])); + + // Set the value of the fields again. + $this->assertTrue($this->setField('values[field0]', 'row3column1')); + $this->assertTrue($this->setField('values[field1]', 'row3column2')); + $this->assertTrue($this->setField('values[field2]', 'row3column3')); + + // Click the "Insert" button to insert a row. + $this->assertTrue($this->clickSubmit($lang['strinsert'])); + // Verify whether the row is inserted successfully. + $this->assertTrue($this->assertWantedText($lang['strrowinserted'])); + + return TRUE; + } + + + /** + * TestCaseID: HIT03 + * Insert one row with illegal data type into an existing table. + */ + function testInsertWithBadData() + { + global $webUrl; + global $lang; + + // Turn to the "Insert row" interface. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confinsertrow&' . + 'database=test&schema=public&table=viewtest&')); + + // Set the value of the fields. + $this->assertTrue($this->setField('format[field0]', 'Expression')); + $this->assertTrue($this->setField('format[field1]', 'Expression')); + $this->assertTrue($this->setField('format[field2]', 'Expression')); + + $this->assertTrue($this->setField('values[field0]', 'row0column1')); + $this->assertTrue($this->setField('values[field1]', 'row0column2')); + $this->assertTrue($this->setField('values[field2]', 'row0column3')); + + // Click the "Insert" button to insert a row. + $this->assertTrue($this->clickSubmit($lang['strinsert'])); + // Verify whether the row insertion failed. + $this->assertTrue($this->assertWantedText($lang['strrowinsertedbad'])); + + return TRUE; + } + + + /** + * TestCaseID: HER01 + * Edit a row. + */ + function testEditRow() + { + global $webUrl; + global $lang; + + // Turn to the "Tables" interface. + $this->assertTrue($this->get($webUrl . '/tables.php?database=test&schema=public&')); + // Select the table "viewtest". + $this->assertTrue($this->clickLink('viewtest')); + // Browse the table. + $this->assertTrue($this->clickLink($lang['strbrowse'])); + // Select a row. + $this->assertTrue($this->clickLink($lang['stredit'])); + + // Edit the row. + $this->assertTrue($this->setField('values[field0]', 'updatecolumn0')); + $this->assertTrue($this->setField('values[field1]', 'updatecolumn1')); + $this->assertTrue($this->setField('values[field2]', 'updatecolumn2')); + + // Click the "Save" button and save the edits. + $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. + */ + function testDeleteRow() + { + global $webUrl; + global $lang; + + // Turn to the "Tables" interface. + $this->assertTrue($this->get($webUrl . '/tables.php?database=test&schema=public&')); + // Select the table "viewtest". + $this->assertTrue($this->clickLink('viewtest')); + // Browse the table. + $this->assertTrue($this->clickLink($lang['strbrowse'])); + // Delete a row. + $this->assertTrue($this->clickLink($lang['strdelete'])); + + // Click the "Yes" button and delete the edits. + $this->assertTrue($this->clickSubmit($lang['stryes'])); + + return TRUE; + } + + + /** + * TestCaseID: HBT01 + * Browse an existing table. + */ + function testBrowseTable() + { + global $webUrl; + global $lang; + + // 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&')); + + // Verify whether the rows are displayed. + $this->assertTrue($this->assertWantedText($lang['strrows'])); + + // Click the links in the display page. + $this->assertTrue($this->clickLink('field0')); + $this->assertTrue($this->clickLink('field1')); + $this->assertTrue($this->clickLink($lang['strexpand'])); + $this->assertTrue($this->clickLink($lang['strcollapse'])); + $this->assertTrue($this->clickLink($lang['strrefresh'])); + $this->assertTrue($this->clickLink($lang['strback'])); + + return TRUE; + } + + + /** + * TestCaseID: HST01 + * Select all the rows of the table. + */ + function testSelectAll() + { + global $webUrl; + global $lang; + + // Turn to the "tables" page. + $this->assertTrue($this->get($webUrl . '/tables.php?database=test' . + '&schema=public&subject=schema')); + $this->assertTrue($this->clickLink('viewtest')); + + // Select all the rows. + $this->assertTrue($this->clickLink($lang['strselect'])); + $this->assertTrue($this->setField('show[field0]', TRUE)); + $this->assertTrue($this->setField('show[field1]', TRUE)); + $this->assertTrue($this->setField('show[field2]', TRUE)); + + // Display all the rows. + $this->assertTrue($this->clickSubmit($lang['strselect'])); + // Verify whether select successful. + $this->assertTrue($this->assertWantedText('row')); + + return TRUE; + } + + + /** + * TestCaseID: HST02 + * Select rows according to the query conditions. + */ + function testSelectByConditions() + { + global $webUrl; + global $lang; + + // Turn to the "tables" page. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confselectrows&' . + 'database=test&schema=public&table=viewtest&')); + // Display all columns. + $this->assertTrue($this->setField('show[field0]', TRUE)); + $this->assertTrue($this->setField('show[field1]', TRUE)); + $this->assertTrue($this->setField('show[field2]', TRUE)); + // Enter the query conditions. + $this->assertTrue($this->setField('values[field0]', 'row2column1')); + $this->assertTrue($this->setField('values[field1]', 'row2column2')); + $this->assertTrue($this->setField('values[field2]', 'row2column3')); + + // Click the "Select" button. + $this->assertTrue($this->clickSubmit($lang['strselect'])); + // Verify whether select successful. + $this->assertTrue($this->assertWantedText('row')); + return TRUE; + } + + + /** + * TestCaseID: HST03 + * Select data from an existing table with no row display. + */ + function testSelectTableNoRowDisplay() + { + global $webUrl; + global $lang; + + // Turn to the "tables" page. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confselectrows&' . + 'database=test&schema=public&table=viewtest&')); + + // Enter the query conditions. + $this->assertTrue($this->setField('values[field0]', 'row2column1')); + $this->assertTrue($this->setField('values[field1]', 'row2column2')); + $this->assertTrue($this->setField('values[field2]', 'row2column3')); + + // Click the "Select" button. + $this->assertTrue($this->clickSubmit($lang['strselect'])); + // Verify whether select successful. + $this->assertTrue($this->assertWantedText($lang['strselectneedscol'])); + + return TRUE; + } + + + /** + * TestCaseID: HVT01 + * Vacuum an existing table with the check box "Full" and "Analyze" unchecked. + */ + function testVacuumUnchecked() + { + global $webUrl; + global $lang; + + // Turn to the "Vacuum" page. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_vacuum&' . + 'database=test&schema=public&table=viewtest&')); + + // Click the "Vacuum" button. + $this->assertTrue($this->clickSubmit($lang['strvacuum'])); + // Verify whether vacuum successfully. + $this->assertTrue($this->assertWantedText($lang['strvacuumgood'])); + + return TRUE; + } + + + /** + * TestCaseID: HVT02 + * Vacuum an existing table with the check box "Full" and "Analyze" checked. + */ + function testVacuumChecked() + { + global $webUrl; + global $lang; + + // Turn to the "Vacuum" page. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_vacuum&' . + 'database=test&schema=public&table=viewtest&')); + + // Make sure the check box "Full" and "Analyze" are checked + $this->assertTrue($this->setField('vacuum_full', TRUE)); + $this->assertTrue($this->setField('vacuum_analyze', TRUE)); + + // Click the "Vacuum" button. + $this->assertTrue($this->clickSubmit($lang['strvacuum'])); + // Verify whether vacuum successfully. + $this->assertTrue($this->assertWantedText($lang['strvacuumgood'])); + + return TRUE; + } + + + /** + * TestCaseID: HET01 + * Empty an existing table. + */ + function testEmptyTable() + { + global $webUrl; + global $lang; + + // Turn to the "tables" page. + $this->assertTrue($this->get($webUrl . '/tables.php?database=test&' . + 'schema=public&subject=schema')); + + // Empty a table. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_empty&' . + 'database=test&schema=public&table=viewtest&')); + // Click the "Empty" button to clean the content of the table. + $this->assertTrue($this->clickSubmit($lang['strempty'])); + + // Verify whether the table is emptied successfully. + $this->assertTrue($this->assertWantedText($lang['strtableemptied'])); + + return TRUE; + } + + + /** + * TestCaseID: HAT01 + * Alter the properties of an existing table. + */ + function testAlterTable() + { + global $webUrl; + global $lang; + + // Drop the table. + $this->assertTrue($this->get($webUrl . '/tables.php?database=test' . + '&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->setField('name', 'testview')); + $this->assertTrue($this->setField('owner', 'tester')); + $this->assertTrue($this->setField('tablespace', 'pg_default')); + + $this->assertTrue($this->clickSubmit($lang['stralter'])); + $this->assertTrue($this->assertWantedText($lang['strtablealtered'])); + + return TRUE; + } + + + /** + * TestCaseID: HDT01 + * Drop an existing table. + */ + function testDropTable() + { + global $webUrl; + global $lang; + + // Drop the table. + $this->assertTrue($this->get($webUrl . '/tables.php?action=confirm_drop&' . + 'database=test&schema=public&table=testview&')); + $this->assertTrue($this->setField('cascade', TRUE)); + // Click the "Drop" button to drop the table. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + + // Verify whether the table is dropped successfully. + $this->assertTrue($this->assertWantedText($lang['strtabledropped'])); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Schemas/TypeTest.php b/tests/testcase/Schemas/TypeTest.php new file mode 100644 index 000000000..27ba3b5fd --- /dev/null +++ b/tests/testcase/Schemas/TypeTest.php @@ -0,0 +1,186 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Clean up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HCT01 + * Create a type. + */ + function testCreateType() + { + global $webUrl; + global $lang; + + // Turn to "Types" page. + $this->assertTrue($this->get($webUrl . '/types.php?database=test&' . + 'schema=public&subject=schema')); + $this->assertTrue($this->clickLink($lang['strcreatetype'])); + + // Enter the definition of the type. + $this->assertTrue($this->setField('typname', 'complex')); + $this->assertTrue($this->setField('typin', 'abs')); + $this->assertTrue($this->setField('typout', 'abs')); + $this->assertTrue($this->setField('typlen', '2')); + + // Click the "Create" button to create a type. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + return TRUE; + } + + + /** + * TestCaseID: HCT02 + * Create a composite type. + */ + function testCreateCompositeType() + { + global $webUrl; + global $lang; + + // Turn to "Types" page. + $this->assertTrue($this->get($webUrl . '/types.php?database=test&' . + 'schema=public&subject=schema')); + $this->assertTrue($this->clickLink($lang['strcreatecomptype'])); + + // Create without composite type name. + //$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->assertWantedText($lang['strtypeneedsname'])); + + // Enter the name of the new composite type. + $this->assertTrue($this->setField('name', 'compositetype')); + + // Create without composite type field. + //$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->assertWantedText($lang['strtypeneedscols'])); + + $this->assertTrue($this->setField('fields', '2')); + $this->assertTrue($this->setField('typcomment', 'Create in testcase')); + $this->assertTrue($this->clickSubmit('Next >')); + // If we do not hardcoded it here, it will cause fail. Encoding issue. + //$this->assertTrue($this->clickSubmit('Next >')); + + // Create the composite type without the definition of fields. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + $this->assertTrue($this->assertWantedText($lang['strtypeneedsfield'])); + + // Enter the fields information. + $this->assertTrue($this->setField('field[0]', 'firstfield')); + $this->assertTrue($this->setField('type[0]', 'bigint')); + $this->assertTrue($this->setField('field[1]', 'secondfield')); + $this->assertTrue($this->setField('type[1]', 'bigint')); + + // Click the "Create" button to create the composite type. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + // Verify if the type create correctly. + $this->assertTrue($this->assertWantedText($lang['strtypecreated'])); + + return TRUE; + } + + + /** + * TestCaseID: HTP01 + * Show the properties of the specified type. + */ + function testShowProperty() + { + global $webUrl; + global $lang; + + // Turn to "Types" page. + $this->assertTrue($this->get($webUrl . '/types.php?database=test&' . + 'schema=pg_catalog&subject=schema')); + + // Show the properties of general type. + $this->assertTrue($this->clickLink('integer')); + // Verify whether the properties are displayed correctly. + $this->assertTrue($this->assertWantedText('int4')); + + + // Turn to "Types" page. + $this->assertTrue($this->get($webUrl . '/types.php?database=test&' . + 'schema=public&subject=schema')); + + // Show the properties of a composite type "compositetype". + $this->assertTrue($this->clickLink('compositetype')); + // Verify whether the properties are displayed correctly. + $this->assertTrue($this->assertWantedText('firstfield')); + + return TRUE; + } + + + /** + * TestCaseID: HDT01 + * Drop the type. + */ + function testDropType() + { + global $webUrl; + global $lang; + + // 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->setField('cascade', TRUE)); + + // Click the "Drop" button to drop the type. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify whether the type is dropped correctly. + $this->assertTrue($this->assertWantedText($lang['strtypedropped'])); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Schemas/ViewTest.php b/tests/testcase/Schemas/ViewTest.php new file mode 100644 index 000000000..99f48f43c --- /dev/null +++ b/tests/testcase/Schemas/ViewTest.php @@ -0,0 +1,313 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + + /** + * Clean up all the result. + */ + function tearDown() + { + // Logout from the system. + $this->logout(); + + return TRUE; + } + + + /** + * TestCaseID: HCV01 + * Test creating a view in an existing table directly. + */ + function testCreateViewDirectly() + { + + global $webUrl; + global $lang; + + $this->createTable('test', 'public', 'viewtest', '3'); + + // Turn to the "Create view" page. + $this->assertTrue($this->get($webUrl . '/views.php?action=create&' . + 'database=test&schema=public')); + + // Enter the definition of the view. + $this->assertTrue($this->setField('formView', 'createviewdirectly')); + $this->assertTrue($this->setField('formDefinition', + 'select field0, field1 from viewtest')); + $this->assertTrue($this->setField('formComment', 'Create View Directly.')); + + // Click "Create" button to create the view. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify whether the view is created correctly. + $this->assertTrue($this->assertWantedText($lang['strviewcreated'])); + + return TRUE; + } + + + /** + * TestCaseID: HCV02 + * This test case test for creating a view in an existing table with wizard. + */ + function testCreateViewWithWizard() + { + global $webUrl; + global $lang; + + // Turn to the "Create view with wizard" page. + $this->assertTrue($this->get($webUrl . '/views.php?action=wiz_create&' . + 'database=test&schema=public')); + + // Select the table. + $this->assertTrue($this->setField('formTables[]', array('public.viewtest'))); + + //$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->setField('formView', 'createwitwizard')); + $this->assertTrue($this->setField('formComment', + 'Create the view with wizard.')); + + // Click "Create" button for creating the view. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + return TRUE; + } + + + /** + * TestCaseID: HCV03 + * Test creating a view in an existing table directly. + * But in this test case, some illegal data will be input. + */ + function testCreateViewDirectlyNegative() + { + global $webUrl; + global $lang; + + // Turn to the "Create view" page. + $this->assertTrue($this->get($webUrl . '/views.php?action=create&' . + 'database=test&schema=public')); + + // Enter the definition of the view. + $this->assertTrue($this->setField('formView', 'createviewdirectly')); + $this->assertTrue($this->setField('formDefinition', + 'select firstfield, secondfield from noexisttable')); + $this->assertTrue($this->setField('formComment', + 'Create view directly use illegal definition.')); + + // Click "Create" button to create the view. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify whether the view is created correctly. + $this->assertTrue($this->assertWantedText($lang['strviewcreatedbad'])); + + return TRUE; + } + + + /** + * TestCaseID: HCV04 + * Test creating a view in an existing table with wizard. + * But in this test case, some illegal data will be input. + */ + function testCreateViewWithWizardNegation() + { + global $webUrl; + global $lang; + + // Turn to the "Create view with wizard" page. + $this->assertTrue($this->get($webUrl . '/views.php?action=wiz_create&' . + 'database=test&schema=public')); + + // Select the table. + $this->assertTrue($this->setField('formTables[]', array('public.viewtest'))); + //$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->setField('formView', 'createwitwizard')); + $this->assertTrue($this->setField('formComment', + 'Create the view do not select any field with wizard.')); + + // Click "Create" button for creating the view. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + $this->assertTrue($this->assertWantedText($lang['strviewneedsfields'])); + + return TRUE; + } + + + /** + * TestCaseID: HBV01 + * Test browsing an existing view with illegal data. + */ + function testBrowseView() + { + global $webUrl; + global $lang; + + // 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&')); + + // Click the links in the view-display page. + $this->assertTrue($this->clickLink($lang['strexpand'])); + $this->assertTrue($this->clickLink($lang['strcollapse'])); + $this->assertTrue($this->clickLink($lang['strrefresh'])); + $this->assertTrue($this->clickLink($lang['strback'])); + + return TRUE; + } + + + /** + * TestCaseID: HSV01 + * Test selecting rows from an existing view. + */ + function testSelectView() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/views.php?action=confselectrows&' . + 'database=test&schema=public&view=createviewdirectly&')); + + // Enter the query conditions. + $this->assertTrue($this->setField('show[field0]', TRUE)); + $this->assertTrue($this->setField('show[field1]', TRUE)); + $this->assertTrue($this->setField('values[field0]', 'yes')); + $this->assertTrue($this->setField('values[field1]', 'no')); + + $this->assertTrue($this->clickSubmit($lang['strselect'])); + $this->assertTrue($this->assertWantedText($lang['strnodata'])); + + return TRUE; + } + + + /** + * TestCaseID: HAV01 + * Alter the properties of an existing view. + */ + function testAlterView() + { + global $webUrl; + global $lang; + + // Turn to the view display page. + $this->assertTrue($this->get($webUrl . '/views.php?database=test&' . + 'schema=public&subject=schema')); + // Select a view. + $this->assertTrue($this->clickLink('createviewdirectly')); + // Select a column. + $this->assertTrue($this->clickLink($lang['stralter'])); + // Alter the properties of the view. + $this->assertTrue($this->setField('field', 'newfield')); + $this->assertTrue($this->setField('comment', 'alterintestcase')); + + // Click the "Alter" button to alter the properties. + $this->assertTrue($this->clickSubmit($lang['stralter'])); + // Verify whether the properties are altered. + $this->assertTrue($this->assertWantedText($lang['strcolumnaltered'])); + + return TRUE; + } + + + /** + * TestCaseID: HAD01 + * Alter the definiton of an existing view. + */ + function testAlterDefinition() + { + global $webUrl; + global $lang; + + // Turn to the view display page. + $this->assertTrue($this->get($webUrl . '/views.php?database=test&' . + '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['stralter'])); + + // Alter the definition here. + $this->assertTrue($this->setField('formDefinition', + 'SELECT viewtest.field0 AS newfield, ' . + 'viewtest.field2 AS field1 FROM viewtest;')); + $this->assertTrue($this->setField('formComment', 'The definition be altered.')); + + // Click the "Alter" button. + $this->assertTrue($this->clickSubmit($lang['stralter'])); + //Verify whether the definition is altered. + $this->assertTrue($this->assertWantedText($lang['strviewupdated'])); + + return TRUE; + } + + + /** + * TestCaseID: HDV01 + * Test dropping a view. + */ + function testDropView() + { + global $webUrl; + global $lang; + + // 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->setField('cascade', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + + // Verify whether the view is dropped successfully. + $this->assertTrue($this->assertWantedText($lang['strviewdropped'])); + + // Drop the table which is created in setUp(). + $this->dropTable('test', 'viewtest', 'public'); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Server/GroupsTest.php b/tests/testcase/Server/GroupsTest.php new file mode 100644 index 000000000..2f9328a9a --- /dev/null +++ b/tests/testcase/Server/GroupsTest.php @@ -0,0 +1,153 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + + return TRUE; + } + + + function tearDown() + { + $this->logout(); + + return TRUE; + } + + + /* + * TestCaseID: SCG01 + * Test to create group. + */ + function testCreate() + { + global $webUrl; + global $POWER_USER_NAME; + global $NORMAL_USER_NAME; + global $lang; + + // Turn to create group page. + $this->assertTrue($this->get($webUrl . '/groups.php')); + $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']); + $this->assertWantedText($this->_groupName); + + return TRUE; + } + + + /* + * TestCaseID: SAG01 + * Test to add users to the gruop. + */ + function testAddUser() + { + global $webUrl; + global $SUPER_USER_NAME; + global $POWER_USER_NAME; + global $NORMAL_USER_NAME; + global $lang; + + // 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)); + + // Select user and add it to the group. + $this->assertTrue($this->setField('user', $SUPER_USER_NAME)); + $this->assertTrue($this->clickSubmit($lang['straddmember'])); + $this->assertTrue($this->setField('user', $POWER_USER_NAME)); + $this->assertTrue($this->clickSubmit($lang['straddmember'])); + + // Verify the group's memebers. + $this->assertWantedText($SUPER_USER_NAME); + $this->assertWantedText($POWER_USER_NAME); + $this->assertWantedText($NORMAL_USER_NAME); + + return TRUE; + } + + + /* + * TestCaseID: SRG01 + * Test to Remove users from the group. + */ + function testRemoveUser() + { + global $webUrl; + global $SUPER_USER_NAME; + global $POWER_USER_NAME; + global $NORMAL_USER_NAME; + global $lang; + + // 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)); + + // Drop users from the group and verify it. + $this->assertTrue($this->clickLink($lang['strdrop'])); + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + $this->assertWantedText($lang['strmemberdropped']); + + return TRUE; + } + + + /* + * TestCaseID: SDG01 + * Test to drop the group. + */ + function testDrop() + { + global $webUrl; + global $lang; + + // 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)); + + // Confirm to drop the group and verify it. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + $this->assertWantedText($lang['strgroupdropped']); + $this->assertNoUnWantedText($this->_groupName); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Server/ReportsTest.php b/tests/testcase/Server/ReportsTest.php new file mode 100644 index 000000000..373fef9b4 --- /dev/null +++ b/tests/testcase/Server/ReportsTest.php @@ -0,0 +1,151 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + + return TRUE; + } + + + function tearDown() + { + $this->logout(); + + return TRUE; + } + + + /* + * TestCaseID: SCR01 + * Test to create report. + */ + function testCreate() + { + global $webUrl; + global $lang; + + // Turn to the create report page. + $this->assertTrue($this->get($webUrl . '/reports.php')); + $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('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. + */ + function testRun() + { + global $webUrl; + global $lang; + + // Run the existing report and verify it. + $this->assertTrue($this->get($webUrl . '/reports.php')); + $this->assertTrue($this->clickLink($lang['strrun'])); + $this->assertWantedText($lang['strnodata']); + + $this->assertTrue($this->clickLink($lang['strrefresh'])); + $this->assertWantedText($lang['strnodata']); + + $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']); + + return TRUE; + } + + + /* + * TestCaseID: SER01 + * Test to edit existing report. + */ + function testEdit() + { + global $webUrl; + global $lang; + + // Turn to the edit report page. + $this->assertTrue($this->get($webUrl . '/reports.php')); + $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('descr', 'comment is changed')); + $this->assertTrue($this->setField('report_sql', 'select * from student where 0=1')); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strsave'])); + $this->assertWantedText($lang['strreportcreated']); + $this->assertWantedText($this->_reportName); + + return TRUE; + } + + + /* + * TestCaseID: SDR01 + * Test to drop existing report. + */ + function testDrop() + { + global $webUrl; + global $lang; + + // Turn to the drop report page. + $this->assertTrue($this->get($webUrl . '/reports.php')); + $this->assertTrue($this->clickLink($lang['strdrop'])); + + // Confirm to drop the report and verify it. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + $this->assertWantedText($lang['strreportdropped']); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Server/ServerGroupTest.php b/tests/testcase/Server/ServerGroupTest.php new file mode 100644 index 000000000..6c9641298 --- /dev/null +++ b/tests/testcase/Server/ServerGroupTest.php @@ -0,0 +1,31 @@ +GroupTest('Server management group test.'); + $this->addTestClass(new UsersTest()); + $this->addTestClass(new GroupsTest()); + $this->addTestClass(new ReportsTest()); + $this->addTestClass(new TableSpacesTest()); + + } +} +?> diff --git a/tests/testcase/Server/TableSpacesTest.php b/tests/testcase/Server/TableSpacesTest.php new file mode 100644 index 000000000..d8da4469b --- /dev/null +++ b/tests/testcase/Server/TableSpacesTest.php @@ -0,0 +1,234 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + + return TRUE; + } + + function tearDown() + { + $this->logout(); + + return TRUE; + } + + + /* + * TestCaseID: SCT01 + * Test to create tablespace. + */ + function testCreate() + { + global $webUrl; + global $POWER_USER_NAME; + global $lang; + $this->_location = getcwd() . '/../data/TableSpace'; + + // Turn to the create tablespace page. + $this->assertTrue($this->get($webUrl . '/tablespaces.php')); + $this->assertTrue($this->clickLink($lang['strcreatetablespace'])); + + // Enter information for creating a tablespace. + $this->assertTrue($this->setField('formSpcname', $this->_tableSpaceName)); + $this->assertTrue($this->setField('formOwner', $POWER_USER_NAME)); + $this->assertTrue($this->setField('formLoc', $this->_location)); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + $this->assertWantedText($this->_tableSpaceName); + + return TRUE; + } + + + /* + * TestCaseID: SAT01 + * Test to alter existing tablespace's properties. + */ + function testAlter() + { + global $webUrl; + global $NORMAL_USER_NAME; + global $lang; + + // 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)); + + // 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; + } + + /* + * TestCaseID: SPT01 + * Test to grant privileges for tablespace. + */ + function testGrantPrivilege() + { + global $webUrl; + global $NORMAL_USER_NAME; + global $lang; + + // Turn to the privileges page. + $this->assertTrue($this->get($webUrl . '/privileges.php')); + $this->assertTrue($this->get($webUrl . '/privileges.php?subject=tablespace' . + '&tablespace=' . $this->_tableSpaceName)); + + // Grant with no privileges selected. + $this->assertTrue($this->clickLink($lang['strgrant'])); + $this->assertTrue($this->setField('username[]', array($NORMAL_USER_NAME))); + $this->assertTrue($this->setField('privilege[CREATE]', TRUE)); + $this->assertTrue($this->setField('privilege[ALL PRIVILEGES]', TRUE)); + $this->assertTrue($this->setField('grantoption', TRUE)); + + // Then submit and verifiy it. + $this->assertTrue($this->clickSubmit($lang['strgrant'])); + $this->assertWantedText($lang['strgranted']); + $this->assertWantedText($NORMAL_USER_NAME); + + return TRUE; + } + + /* + * TestCaseID: SPT02 + * Test to revoke privileges for tablespace. + */ + function testRevokePrivilege() + { + global $webUrl; + global $NORMAL_USER_NAME; + global $lang; + + // Turn to the privileges page. + $this->assertTrue($this->get($webUrl . '/privileges.php')); + $this->assertTrue($this->get($webUrl . '/privileges.php?subject=tablespace' . + '&tablespace=' . $this->_tableSpaceName)); + + // Revoke with no users selected. + $this->assertTrue($this->clickLink($lang['strrevoke'])); + $this->assertTrue($this->setField('username[]', array($NORMAL_USER_NAME))); + $this->assertTrue($this->setField('privilege[ALL PRIVILEGES]', TRUE)); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strrevoke'])); + $this->assertWantedText($lang['strgranted']); + $this->assertNoUnWantedText($NORMAL_USER_NAME); + + return TRUE; + } + + + /* + * TestCaseID: SPT03 + * Test to grant privilege with no privilege selected for tablespace. + */ + function testGrantNoPrivilege() + { + global $webUrl; + global $NORMAL_USER_NAME; + global $lang; + + // Turn to the privileges page. + $this->assertTrue($this->get($webUrl . '/privileges.php')); + $this->assertTrue($this->get($webUrl . '/privileges.php?subject=tablespace' . + '&tablespace=' . $this->_tableSpaceName)); + + // Grant whit no privilege selected. + $this->assertTrue($this->clickLink($lang['strgrant'])); + $this->assertTrue($this->setField('username[]', array($NORMAL_USER_NAME))); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strgrant'])); + $this->assertWantedText($lang['strgrantbad']); + + return TRUE; + } + + /* + * TestCaseID: SPT04 + * Test to revoke privileges with no user selected for tablespace. + */ + function testRevokeNoUser() + { + global $webUrl; + global $NORMAL_USER_NAME; + global $lang; + + // Turn to the privileges page. + $this->assertTrue($this->get($webUrl . '/privileges.php')); + $this->assertTrue($this->get($webUrl . '/privileges.php?subject=tablespace' . + '&tablespace=' . $this->_tableSpaceName)); + + // Revoke whit no users selected. + $this->assertTrue($this->clickLink($lang['strrevoke'])); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strrevoke'])); + $this->assertWantedText($lang['strgrantbad']); + + return TRUE; + } + + + /* + * TestCaseID: SDT01 + * Test to drop existing tablespace. + */ + function testDrop() + { + global $webUrl; + global $lang; + + // 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)); + + // Confirm to drop the user and verify it. + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + $this->assertWantedText($lang['strtablespacedropped']); + $this->assertNoUnWantedText($this->_tableSpaceName); + + return TRUE; + } +} +?> diff --git a/tests/testcase/Server/UsersTest.php b/tests/testcase/Server/UsersTest.php new file mode 100644 index 000000000..f4cd59771 --- /dev/null +++ b/tests/testcase/Server/UsersTest.php @@ -0,0 +1,229 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, $webUrl . '/index.php'); + + return TRUE; + } + + + function tearDown() + { + $this->logout(); + + return TRUE; + } + + + /* + * TestCaseID: SCU01 + * Test to create super user. + */ + function testCreateSuper() + { + global $webUrl; + global $lang; + + // Turn to the "Create user" page. + $this->assertTrue($this->get($webUrl . '/users.php')); + $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')); + $this->assertTrue($this->setField('formConfirm', '123456')); + $this->assertTrue($this->setField('formSuper', TRUE)); + $this->assertTrue($this->setField('formCreateDB', TRUE)); + + // Then submit and verify it. + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + $this->assertWantedText($this->_superUserName); + + return TRUE; + } + + /* + * TestCaseID: SCU02 + * Test to create power user. + */ + function testCreatePower() + { + global $webUrl; + global $lang; + + // Turn to the "Create user" page. + $this->assertTrue($this->get($webUrl . '/users.php')); + $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; + } + + /* + * TestCaseID: SLU01 + * Test to list all the users. + */ + function testListUsers() + { + global $webUrl; + global $SUPER_USER_NAME; + global $POWER_USER_NAME; + global $NORMAL_USER_NAME; + global $lang; + + // Get the users list page and verify it. + $this->assertTrue($this->get($webUrl . '/users.php')); + $this->assertWantedText($SUPER_USER_NAME); + $this->assertWantedText($POWER_USER_NAME); + $this->assertWantedText($NORMAL_USER_NAME); + + return TRUE; + } + + + /* + * TestCaseID: SAU01 + * Test to alter existing user's properties. + */ + function testAlter() + { + global $webUrl; + global $lang; + + // 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)); + + // 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. + */ + function testDrop() + { + global $webUrl; + global $lang; + + // 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)); + + // 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. + */ + function testDropLogin() + { + global $webUrl; + global $lang; + + // 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')); + $this->assertTrue($newBrowser->clickSubmit('Login')); + $this->assertTrue($newBrowser->get($webUrl . '/all_db.php')); + + // 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)); + + // 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->assertTrue($this->clickLink($lang['strcreatedatabase'])); + $this->assertWantedText($lang['strloginfailed']); + + return TRUE; + } + + /* + * TestCaseID: SDU03 + * Test to drop the user self. + */ + function testDropSelf() + { + global $webUrl; + global $SUPER_USER_NAME; + global $lang; + + // 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)); + + // 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 new file mode 100644 index 000000000..9f3f78be8 --- /dev/null +++ b/tests/testcase/Tables/ColumnTest.php @@ -0,0 +1,279 @@ +login($POWER_USER_NAME, $POWER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + /** + * Clean up all the result. + */ + function tearDown(){ + $this->logout(); + + return TRUE; + } + + /** + * TestCaseID: TNC01 + * Add a column to the table + */ + function testAddColumn() + { + global $webUrl; + global $lang; + + // Go to the Columns page + $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . + 'action=add_column&database=test&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'])); + + // Verify if the column is created correctly. + $this->assertTrue($this->assertWantedText($lang['strcolumnadded'])); + + return TRUE; + } + + + /** + * TestCaseID: TNC02 + * Add a column with the same name as the existing one + */ + function testAddColumnWithExistingName() + { + global $webUrl; + global $lang; + + // Go to the Columns page + $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . + 'action=add_column&database=test&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 + * Cancel the add column operation + */ + function testCancelAddColumn() + { + global $webUrl; + global $lang; + + // Go to the Columns page + $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . + 'action=add_column&database=test&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['strcancel'])); + + return TRUE; + } + + + /** + * TestCaseID: TAC01 + * Alter a column of the table + */ + function testAlterColumn() + { + global $webUrl; + global $lang; + + // Go to the Columns page + $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . + 'action=properties&database=test&schema=public&' . + 'table=student&column=sid')); + + // Set properties for the new column + $this->assertTrue($this->setField('field', 'sid')); + $this->assertTrue($this->setField('type', 'character')); + $this->assertTrue($this->setField('length', '18')); + $this->assertTrue($this->clickSubmit($lang['stralter'])); + + // Verify if the column is altered correctly. + $this->assertTrue($this->assertWantedText($lang['strcolumnaltered'])); + + return TRUE; + } + + + /** + * TestCaseID: TAC02 + * Alter a column to be of negative length + */ + function testNegativeLengthColumn() + { + global $webUrl; + global $lang; + + // Go to the Columns page + $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . + 'action=properties&database=test&schema=public&' . + 'table=student&column=sid')); + + // Set properties for the new column + $this->assertTrue($this->setField('field', 'sid')); + $this->assertTrue($this->setField('type', 'character')); + $this->assertTrue($this->setField('length', '-2')); + $this->assertTrue($this->clickSubmit($lang['stralter'])); + + // Make sure the alteration failed. + $this->assertTrue($this->assertWantedText($lang['strcolumnalteredbad'])); + + return TRUE; + } + + + /** + * TestCaseID: TAC03 + * Cancel the alter column operation + */ + function testCancelAlterColumn() + { + global $webUrl; + global $lang; + + // Go to the Columns page + $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . + 'action=properties&database=test&schema=public&' . + 'table=student&column=sid')); + + // Set properties for the new column + $this->assertTrue($this->setField('field', 'sid')); + $this->assertTrue($this->setField('type', 'character')); + $this->assertTrue($this->setField('length', '18')); + $this->assertTrue($this->clickSubmit($lang['strcancel'])); + + return TRUE; + } + + + /** + * TestCaseID: TDC03 + * Cancel the drop column operation + */ + function testCancelDropColumn() + { + global $webUrl; + global $lang; + + // Drop the column + $this->assertTrue($this->get($webUrl . '/tblproperties.php?' . + 'action=confirm_drop&database=test&schema=public&' . + 'table=student&column=sid')); + $this->assertTrue($this->clickSubmit($lang['strcancel'])); + + return TRUE; + } + + + /** + * TestCaseID: TDC01 + * Drop a column from the table + */ + function testDropColumn() + { + global $webUrl; + global $lang; + + // Drop the column + $this->assertTrue($this->get($webUrl . '/tblproperties.php?' . + 'action=confirm_drop&database=test&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'])); + + return TRUE; + } + + + /** + * TestCaseID: TDC02 + * Drop a column wich "CASCADE" checked + */ + function testDropColumnWithCascade() + { + global $webUrl; + global $lang; + 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')); + + // Set properties for the new column + $this->assertTrue($this->setField('field', 'sid')); + $this->assertTrue($this->setField('type', 'integer')); + $this->assertTrue($this->clickSubmit($lang['stradd'])); + + // Verify if the column is created correctly. + $this->assertTrue($this->assertWantedText($lang['strcolumnadded'])); + + $this->logout(); + $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, + $webUrl . '/index.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->setField('cascade', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify if the column is dropped correctly. + $this->assertTrue($this->assertWantedText($lang['strcolumndropped'])); + + return TRUE; + } +} + + + + diff --git a/tests/testcase/Tables/ConstraintsTest.php b/tests/testcase/Tables/ConstraintsTest.php new file mode 100644 index 000000000..7eac3cebb --- /dev/null +++ b/tests/testcase/Tables/ConstraintsTest.php @@ -0,0 +1,239 @@ +login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + /** + * Clean up all the result. + */ + function tearDown(){ + $this->logout(); + + return TRUE; + } + + /** + * TestCaseID: TAC01 + * Test creating a check constraint in a table + */ + function testAddCheck(){ + global $webUrl; + global $lang; + + // Go to the constraints page + $this->assertTrue($this->get($webUrl . '/constraints.php?' . + 'action=add_check&database=test&schema=public&table=student')); + + // Set properties for the new constraint + $this->assertTrue($this->setField('name', 'id_check')); + $this->assertTrue($this->setField('definition', 'id > 0')); + + $this->assertTrue($this->clickSubmit($lang['stradd'])); + + // Verify if the constraint is created correctly. + $this->assertTrue($this->assertWantedText($lang['strcheckadded'])); + + return TRUE; + } + + + /** + * TestCaseID: TDC02 + * Test dropping a check constraint in a table + */ + 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')); + $this->assertTrue($this->clickSubmit($lang['strdrop'])); + // Verify if the constraint is dropped correctly. + $this->assertTrue($this->assertWantedText($lang['strconstraintdropped'])); + + return TRUE; + } + + + /** + * TestCaseID: TAC02 + * Test adding a unique key to a table + */ + function testAddUniqueKey(){ + global $webUrl; + global $lang; + + // Go to the constraints page + $this->assertTrue($this->get($webUrl . '/constraints.php?' . + 'action=add_unique_key&database=test&' . + 'schema=public&table=student')); + + // Set properties for the new constraint + $this->assertTrue($this->setField('name', 'unique_name')); + $this->assertTrue($this->setField('TableColumnList', array('name'))); + $this->assertTrue($this->setField('tablespace', 'pg_default')); + $this->assertTrue($this->setField('IndexColumnList[]', 'name')); + + $this->assertTrue($this->clickSubmit($lang['stradd'])); + // Verify if the constraint is created correctly. + $this->assertTrue($this->assertWantedText($lang['struniqadded'])); + + return TRUE; + } + + + /** + * TestCaseID: TDC01 + * Test dropping a unique constraint in a table + */ + function testDropUniqueKey() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/constraints.php?' . + 'action=confirm_drop&database=test&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'])); + + return TRUE; + } + + + /** + * TestCaseID: TAC03 + * Test adding a primary key to a table + */ + function testAddPrimaryKey(){ + global $webUrl; + global $lang; + + // Go to the constraints page + $this->assertTrue($this->get($webUrl . '/constraints.php?' . + 'action=add_primary_key&database=test&schema=public&' . + 'table=college_student')); + + // Set properties for the new constraint + $this->assertTrue($this->setField('name', 'primary_id')); + $this->assertTrue($this->setField('TableColumnList', array('id'))); + $this->assertTrue($this->setField('tablespace', 'pg_default')); + $this->assertTrue($this->setField('IndexColumnList[]', 'id')); + + $this->assertTrue($this->clickSubmit($lang['stradd'])); + + // Verify if the constraint is created correctly. + $this->assertTrue($this->assertWantedText($lang['strpkadded'])); + + return TRUE; + } + + + /** + * TestCaseID: TDC03 + * Test dropping a primary key constraint in a table + */ + function testDropPrimaryKey() + { + global $webUrl; + global $lang; + + // 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->clickSubmit($lang['strdrop'])); + $this->assertTrue($this->assertWantedText($lang['strconstraintdropped'])); + + return TRUE; + } + + + /** + * TestCaseID: TAC03 + * Test adding a foreign key to a table + */ + function testAddForeignKey(){ + global $webUrl; + global $lang; + + // Go to the constraints page + $this->assertTrue($this->get($webUrl . '/constraints.php?' . + 'action=add_foreign_key&database=test&' . + 'schema=public&table=student')); + + // Set properties for the new constraint + $this->assertTrue($this->setField('name', 'foreign_id')); + $this->assertTrue($this->setField('TableColumnList', array('id'))); + $this->assertTrue($this->setField('IndexColumnList[]', 'id')); + $this->assertTrue($this->setField('target', 'department')); + + $this->assertTrue($this->clickSubmit($lang['stradd'])); + + $this->assertTrue($this->setField('TableColumnList', array('id'))); + + $this->assertTrue($this->setFieldById('IndexColumnList', 'id')); + $this->assertTrue($this->setField('upd_action', 'RESTRICT')); + $this->assertTrue($this->setField('del_action', 'RESTRICT')); + $this->assertTrue($this->clickSubmit($lang['stradd'])); + + // Verify if the constraint is created correctly. + $this->assertTrue($this->assertWantedText($lang['strfkadded'])); + + return TRUE; + } + + + /** + * TestCaseID: TDC04 + * Test dropping a foreign key constraint in a table + */ + function testDropForeignKey() + { + global $webUrl; + global $lang; + + // 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->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 new file mode 100644 index 000000000..772b8e43c --- /dev/null +++ b/tests/testcase/Tables/DeadlockTest.php @@ -0,0 +1,350 @@ +logout(); + + return TRUE; + } + + + /** + * TestCaseID: TET03 + * + * Scenario: + * 1. Open the first session, login as power user. Try to add a check + * constraint: id_check (id > 0), without commit + * 2. Open the second session, login as super user. Change the password + * of the power user and commit the alteration. + * 3. Turn to the first session and commit the add check operation. + * 4. Rollback the changes, that's, change back the password for the + * power user. + * + * Expected result: Login failed. + */ + function testAddCheckScenario() + { + global $webUrl; + global $lang; + 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'); + + // 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')); + + // Set properties for the new constraint + $this->assertTrue($this->setField('name', 'id_check')); + $this->assertTrue($this->setField('definition', 'id > 0')); + + + // Open the second session, login as superuser + $newBrowser = $this->createBrowser(); + $newBrowser->get($webUrl . '/index.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)); + // Enter the information for altering the user's properties. + $this->assertTrue($newBrowser->setField('newname', $POWER_USER_NAME)); + $this->assertTrue($newBrowser->setField('formPassword', '56789')); + $this->assertTrue($newBrowser->setField('formConfirm', '56789')); + $this->assertTrue($newBrowser->setField('formSuper', FALSE)); + $this->assertTrue($newBrowser->setField('formCreateDB', TRUE)); + $this->assertTrue($newBrowser->clickSubmit($lang['stralter'])); + + + // Now turn to the first session, submit the "add check" operation + $this->assertTrue($this->clickSubmit($lang['stradd'])); + // Verify if the constraint is created correctly. + $this->assertTrue($this->assertWantedText($lang['strloginfailed'])); + + + // 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)); + + // Change back the user's password + $this->assertTrue($newBrowser->setField('newname', $POWER_USER_NAME)); + $this->assertTrue($newBrowser->setField('formPassword', $POWER_USER_PASSWORD)); + $this->assertTrue($newBrowser->setField('formConfirm', $POWER_USER_PASSWORD)); + $this->assertTrue($newBrowser->setField('formSuper', FALSE)); + $this->assertTrue($newBrowser->setField('formCreateDB', TRUE)); + $this->assertTrue($newBrowser->clickSubmit($lang['stralter'])); + + return TRUE; + } + + + /** + * TestCaseID: TET01 + * + * Scenario: + * 1. Open the first session, login as power user. Try to create a + * database, don't commit; + * 2. Open the second session, login as super user. Revoke the power + * user's createdb privilege + * 3. Turn to the first session and commit the create database operation. + * 4. Rollback the changes, that's, grant the createdb privilege to the + * power user. + * + * Expected result: Failed to add database. Permission denied. + */ + function testCreateDatabaseScenario() + { + global $webUrl; + global $lang; + 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'); + + // 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->setfield('formName', 'newdb')); + $this->assertTrue ($this->setfield('formEncoding', 'UNICODE')); + + + // Open another session, login as superuser + $newBrowser = $this->createBrowser(); + $newBrowser->get($webUrl . '/index.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->setField('newname', $POWER_USER_NAME)); + $this->assertTrue($newBrowser->setField('formPassword', 'tester')); + $this->assertTrue($newBrowser->setField('formConfirm', 'tester')); + $this->assertTrue($newBrowser->setField('formSuper', FALSE)); + $this->assertTrue($newBrowser->setField('formCreateDB', FALSE)); + $this->assertTrue($newBrowser->clickSubmit($lang['stralter'])); + + + // Now turn to the first session, submit the "create DB" operation + $this->assertTrue ($this->clickSubmit($lang['strcreate'])); + // Verify weather the database has been created. + $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->setField('newname', $POWER_USER_NAME)); + $this->assertTrue($newBrowser->setField('formPassword', $POWER_USER_PASSWORD)); + $this->assertTrue($newBrowser->setField('formConfirm', $POWER_USER_PASSWORD)); + $this->assertTrue($newBrowser->setField('formSuper', FALSE)); + $this->assertTrue($newBrowser->setField('formCreateDB', TRUE)); + $this->assertTrue($newBrowser->clickSubmit($lang['stralter'])); + + return TRUE; + } + + + /** + * TestCaseID: TET02 + * + * Scenario: + * 1. Open the first session, login as power user. Create a column named + * "sid". Then try to rename it as "ssid", don't commit; + * 2. Open the second session, login as power user. Drop the column "sid"; + * 3. Turn to the first session and commit the alter column operation. + * + * Expected result: Failed to alter the column. + */ + function testDropColumnScenario() + { + global $webUrl; + global $lang; + 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'); + + // Add a column "sid" + $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . + 'action=add_column&database=test&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'])); + // Verify if the column is created correctly. + $this->assertTrue($this->assertWantedText($lang['strcolumnadded'])); + + + // Try to alter the column as "ssid" + $this->assertTrue($this->get($webUrl . '/tblproperties.php?&' . + 'action=properties&database=test&schema=public&' . + 'table=student&column=sid')); + // Set properties for the new column + $this->assertTrue($this->setField('field', 'ssid')); + $this->assertTrue($this->setField('type', 'character')); + $this->assertTrue($this->setField('length', '18')); + + + // Open the second session, login as power user + $newBrowser = $this->createBrowser(); + $newBrowser->get($webUrl . '/index.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->clickSubmit($lang['strdrop'])); + + + // Now turn to the first session, submit the "create DB" operation + $this->assertTrue($this->clickSubmit($lang['stralter'])); + // Verify if the column is altered correctly. + $this->assertTrue($this->assertWantedText($lang['strcolumnalteredbad'])); + + return TRUE; + } + + + /** + * TestCaseID: TET05 + * + * Scenario: + * 1. Open the first session, login as power user. Create a table + * named "newtable". Then issue a SELECT query without commit. + * 2. Open another session, login as power user. Drop the table "newtable"; + * 3. Turn to the first session and commit the SELECT query. + * + * Expected result: ERROR: relation "public.newtable" does not exist. + */ + function testQueryDroppedTable() + { + global $webUrl; + global $lang; + 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'); + // Create a table. + $this->assertTrue($this->get($webUrl . '/tables.php?action=create&' . + 'database=test&schema=public')); + + // Enter the table name and field number. + $this->assertTrue($this->setField('name', 'newtable')); + $this->assertTrue($this->setField('fields', '2')); + $this->assertTrue($this->setField('spcname', 'pg_default')); + $this->assertTrue($this->setField('tblcomment', 'Create from SimpleTest!')); + + // Click 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 >')); + + // Enter the detail information of the table. + $this->assertTrue($this->setField('field[0]', 'firstfield')); + $this->assertTrue($this->setField('type[0]', 'text')); + $this->assertTrue($this->setField('array[0]', '')); + + $this->assertTrue($this->setField('field[1]', 'secondfield')); + $this->assertTrue($this->setField('type[1]', 'text')); + $this->assertTrue($this->setField('array[1]', '')); + + // Click the button "Create" to create the table + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + // Verify if the table create correctly. + $this->assertTrue($this->assertWantedText($lang['strtablecreated'])); + + + // Issue a SELECT query + + // Turn to the "tables" page. + $this->assertTrue($this->get($webUrl . '/tables.php?&' . + 'action=confselectrows&database=test&' . + 'schema=public&table=newtable')); + + // Select all the rows. + $this->assertTrue($this->setField('show[firstfield]', TRUE)); + $this->assertTrue($this->setField('show[secondfield]', TRUE)); + + + // Open another session, login as super user, drop the table "newtable" + $newBrowser = $this->createBrowser(); + $newBrowser->get($webUrl . '/index.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'); + $this->assertTrue($newBrowser->clickSubmit($lang['strdrop'])); + + + // Now turn to the first session, submit the SELECT query + // Display all the rows. + $this->assertTrue($this->clickSubmit($lang['strselect'])); + // Verify whether select successful. + $this->assertTrue($this->assertWantedText($lang['strsqlerror'])); + $this->assertTrue($this->assertWantedText('public.newtable')); + $this->assertTrue($this->assertWantedText('does not exist')); + + return TRUE; + } +} diff --git a/tests/testcase/Tables/IndexesTest.php b/tests/testcase/Tables/IndexesTest.php new file mode 100644 index 000000000..2584a9c2b --- /dev/null +++ b/tests/testcase/Tables/IndexesTest.php @@ -0,0 +1,224 @@ +login($SUPER_USER_NAME, $SUPER_USER_NAME, + $webUrl . '/index.php'); + + return TRUE; + } + + /** + * Clean up all the result. + */ + function tearDown(){ + $this->logout(); + + return TRUE; + } + + /** + * TestCaseID: TCI01 + * Test creating indexes in a table + */ + function testCreateIndex(){ + global $webUrl; + global $lang; + + // Go to the Indexes page + $this->assertTrue($this->get($webUrl . '/indexes.php?&' . + 'action=create_index&database=test&' . + 'schema=public&table=student')); + + // Set properties for the new index + $this->assertTrue($this->setField('formIndexName', 'stu_name_idx')); + $this->assertTrue($this->setField('TableColumnList', array('name'))); + $this->assertTrue($this->setField('IndexColumnList[]', 'name')); + $this->assertTrue($this->setField('formIndexType', 'BTREE')); + $this->assertTrue($this->setField('formUnique', FALSE)); + $this->assertTrue($this->setField('formSpc', 'pg_default')); + + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify if the index is created correctly. + $this->assertTrue($this->assertWantedText($lang['strindexcreated'])); + + return TRUE; + } + + + /** + * TestCaseID: TCI02 + * Cancel creating index + */ + function testCancelCreateIndex(){ + global $webUrl; + global $lang; + + // Go to the Indexes page + $this->assertTrue($this->get($webUrl . '/indexes.php?&' . + 'action=create_index&database=test' . + '&schema=public&table=student')); + + // Set properties for the new index + $this->assertTrue($this->setField('formIndexName', 'stu_name_idx')); + $this->assertTrue($this->setField('TableColumnList', array('name'))); + $this->assertTrue($this->setField('IndexColumnList[]', 'name')); + $this->assertTrue($this->setField('formIndexType', 'BTREE')); + $this->assertTrue($this->setField('formUnique', TRUE)); + $this->assertTrue($this->setField('formSpc', 'pg_default')); + + $this->assertTrue($this->clickSubmit($lang['strcancel'])); + + return TRUE; + } + + /** + * TestCaseID: TRI01 + * Test reindexing an index in a table + */ + function testReindex() + { + global $webUrl; + global $lang; + + // Go to the Indexes page + $this->assertTrue($this->get($webUrl . '/indexes.php?action=reindex&' . + 'database=test&schema=public&table=student&' . + 'index=stu_name_idx')); + + // Verify if the index is reindexed correctly. + $this->assertTrue($this->assertWantedText($lang['strreindexgood'])); + + return TRUE; + } + + + /** + * TestCaseID: TCP01 + * Test clustering and analyzing the primary key in a table + */ + function testClusterPrimaryKeyWithAnalyze() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/indexes.php?' . + 'action=confirm_cluster_index&database=test&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. + $this->assertTrue($this->assertWantedText($lang['strclusteredgood'])); + $this->assertTrue($this->assertWantedText($lang['stranalyzegood'])); + + return TRUE; + } + + + /** + * TestCaseID: TCP02 + * Test clustering the primary key without analyzing in a table + */ + function testClusterPrimaryKeyWithoutAnalyze() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/indexes.php?' . + 'action=confirm_cluster_index&database=test&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. + $this->assertTrue($this->assertWantedText($lang['strclusteredgood'])); + + return TRUE; + } + + + /** + * TestCaseID: TCP03 + * Test cancelling clustering the primary key in a table + */ + function testCancelCluster() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/indexes.php?' . + 'action=confirm_cluster_index&database=test&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 + */ + function testCancelDropIndex() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/indexes.php?' . + 'action=confirm_drop_index&database=test&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 + */ + function testDropIndex() + { + global $webUrl; + global $lang; + + $this->assertTrue($this->get($webUrl . '/indexes.php?' . + 'action=confirm_drop_index&database=test&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. + $this->assertTrue($this->assertWantedText($lang['strindexdropped'])); + + return TRUE; + } +} diff --git a/tests/testcase/Tables/InfoTest.php b/tests/testcase/Tables/InfoTest.php new file mode 100644 index 000000000..f85261f41 --- /dev/null +++ b/tests/testcase/Tables/InfoTest.php @@ -0,0 +1,122 @@ +login($POWER_USER_NAME, $POWER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + /** + * Clean up all the result. + */ + function tearDown(){ + $this->logout(); + + return TRUE; + } + + /** + * TestCaseID: TSI01 + * List the performance info of the parent table -- student + */ + function testListParentTableInfo() + { + global $webUrl; + global $lang; + + // Go to the Rules page + $this->assertTrue($this->get($webUrl . '/info.php?&' . + 'database=test&schema=public&table=student&subject=table')); + + return TRUE; + } + + + /** + * TestCaseID: TSI02 + * List the performance info of the children table -- college_student + */ + function testListChildrenTableInfo() + { + global $webUrl; + global $lang; + + // Go to the Rules page + $this->assertTrue($this->get($webUrl . '/info.php?&database=test&' . + 'schema=public&table=college_student&subject=table')); + + return TRUE; + } + + + /** + * TestCaseID: TSI03 + * List the performance info of the foreign table -- department + */ + function testListForeignTableInfo() + { + global $webUrl; + global $lang; + + // Go to the Rules page + $this->assertTrue($this->get($webUrl . '/info.php?&' . + 'database=test&schema=public&' . + 'table=department&subject=table')); + + return TRUE; + } + + + /** + * TestCaseID: TSP01 + * Show the properties of the foreign key constraint + */ + function testShowForeignKeyProperties() + { + global $webUrl; + global $lang; + + // Go to the Rules page + $this->assertTrue($this->get($webUrl . '/info.php?&' . + 'database=test&schema=public&' . + 'table=department&subject=table')); + + $this->assertTrue($this->clickLink($lang['strproperties'])); + $this->assertWantedText('FOREIGN KEY (dep_id) REFERENCES department(id) ' . + 'ON UPDATE RESTRICT ON DELETE RESTRICT'); + + return TRUE; + } +} + + + + diff --git a/tests/testcase/Tables/RulesTest.php b/tests/testcase/Tables/RulesTest.php new file mode 100644 index 000000000..aeff6bdcf --- /dev/null +++ b/tests/testcase/Tables/RulesTest.php @@ -0,0 +1,182 @@ +login($POWER_USER_NAME, $POWER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + /** + * Clean up all the result. + */ + function tearDown(){ + $this->logout(); + + return TRUE; + } + + /** + * TestCaseID: TCR01 + * Create a rule for a table + */ + function testCreateRule() + { + global $webUrl; + global $lang; + + // Go to the Rules page + $this->assertTrue($this->get($webUrl . '/rules.php?&' . + 'action=create_rule&database=test&schema=public&' . + 'table=student&subject=table')); + + // Set properties for the new rule + $this->assertTrue($this->setField('name', 'insert_stu_rule')); + $this->assertTrue($this->setField('event', 'INSERT')); + $this->assertTrue($this->setField('where', '')); + $this->assertTrue($this->setField('type', 'NOTHING')); + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify if the rule is created correctly. + $this->assertTrue($this->assertWantedText($lang['strrulecreated'])); + + return TRUE; + } + + + /** + * TestCaseID: TCR02 + * Cancel creating a rule for a table + */ + function testCancelCreateRule() + { + global $webUrl; + global $lang; + + // Go to the Rules page + $this->assertTrue($this->get($webUrl . '/rules.php?&' . + 'action=create_rule&database=test&schema=public&' . + 'table=student&subject=table')); + + // Set properties for the new rule + $this->assertTrue($this->setField('name', 'insert_stu_rule')); + $this->assertTrue($this->setField('event', 'INSERT')); + $this->assertTrue($this->setField('where', '')); + $this->assertTrue($this->setField('instead', TRUE)); + $this->assertTrue($this->clickSubmit($lang['strcancel'])); + + return TRUE; + } + + + /** + * TestCaseID: TDR03 + * Cancel the drop rule operation + */ + function testCancelDropRule() + { + global $webUrl; + global $lang; + + // 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->clickSubmit($lang['strno'])); + + return TRUE; + } + + /** + * TestCaseID: TDR01 + * Drop a rule from the table + */ + function testDropRule() + { + global $webUrl; + global $lang; + + // 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->clickSubmit($lang['stryes'])); + // Verify if the rule is dropped correctly. + $this->assertTrue($this->assertWantedText($lang['strruledropped'])); + + return TRUE; + } + + + /** + * TestCaseID: TDR02 + * Drop a rule from the table witch CASCADE checked + */ + function testDropRuleWithCascade() + { + global $webUrl; + global $lang; + 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')); + + // Set properties for the new rule + $this->assertTrue($this->setField('name', 'insert_stu_rule')); + $this->assertTrue($this->setField('event', 'INSERT')); + $this->assertTrue($this->setField('where', '')); + $this->assertTrue($this->setField('type', 'SOMETHING')); + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + + // Verify if the rule is created correctly. + $this->assertTrue($this->assertWantedText($lang['strrulecreated'])); + + $this->logout(); + $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, + $webUrl . '/index.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->setField('cascade', TRUE)); + $this->assertTrue($this->clickSubmit($lang['stryes'])); + // Verify if the rule is dropped correctly. + $this->assertTrue($this->assertWantedText($lang['strruledropped'])); + + return TRUE; + } +} + + + + diff --git a/tests/testcase/Tables/TableGroupTest.php b/tests/testcase/Tables/TableGroupTest.php new file mode 100644 index 000000000..541875eaa --- /dev/null +++ b/tests/testcase/Tables/TableGroupTest.php @@ -0,0 +1,32 @@ +GroupTest('Table management group test.'); + $this->addTestClass(new ColumnTest()); + $this->addTestClass(new TriggersTest()); + $this->addTestClass(new RulesTest()); + $this->addTestClass(new IndexesTest()); + $this->addTestClass(new InfoTest()); + $this->addTestClass(new ConstraintsTest()); + $this->addTestClass(new DeadlockTest()); + } +} +?> diff --git a/tests/testcase/Tables/TriggersTest.php b/tests/testcase/Tables/TriggersTest.php new file mode 100644 index 000000000..fbc18e674 --- /dev/null +++ b/tests/testcase/Tables/TriggersTest.php @@ -0,0 +1,190 @@ +login($POWER_USER_NAME, $POWER_USER_PASSWORD, + $webUrl . '/index.php'); + + return TRUE; + } + + /** + * Clean up all the result. + */ + function tearDown(){ + $this->logout(); + + return TRUE; + } + + /** + * TestCaseID: TCT01 + * Add a trigger to the table + */ + function testAddTrigger() + { + global $webUrl; + global $lang; + + // Go to the Triggers page + $this->assertTrue($this->get($webUrl . '/triggers.php?action=create&' . + 'database=test&schema=public&table=student')); + + // Set properties for the new trigger + $this->assertTrue($this->setField('formTriggerName', + 'insert_stu_trigger')); + $this->assertTrue($this->setField('formExecTime', 'AFTER')); + $this->assertTrue($this->setField('formEvent', 'INSERT')); + $this->assertTrue($this->setField('formFunction', + 'RI_FKey_check_ins')); + $this->assertTrue($this->setField('formTriggerArgs', '')); + + $this->assertTrue($this->clickSubmit($lang['strcreate'])); + // Verify if the trigger is created correctly. + $this->assertTrue($this->assertWantedText($lang['strtriggercreated'])); + + return TRUE; + } + + + /** + * TestCaseID: TCT02 + * Cancel adding a trigger to the table + */ + function testCancelAddTrigger() + { + global $webUrl; + global $lang; + + // Go to the Triggers page + $this->assertTrue($this->get($webUrl . '/triggers.php?action=create&' . + 'database=test&schema=public&table=student')); + + // Set properties for the new trigger + $this->assertTrue($this->setField('formTriggerName', + 'insert_stu_trigger')); + $this->assertTrue($this->setField('formExecTime', 'AFTER')); + $this->assertTrue($this->setField('formEvent', 'INSERT')); + $this->assertTrue($this->setField('formFunction', + 'RI_FKey_check_ins')); + $this->assertTrue($this->setField('formTriggerArgs', '')); + $this->assertTrue($this->clickSubmit($lang['strcancel'])); + + return TRUE; + } + + + /** + * TestCaseID: TAT02 + * Alter a trigger of the table + */ + function testAlterTrigger() + { + global $webUrl; + global $lang; + + // 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->setField('name', 'changed_trigger')); + $this->assertTrue($this->clickSubmit($lang['strok'])); + // Verify if the trigger is altered correctly. + $this->assertTrue($this->assertWantedText($lang['strtriggeraltered'])); + + return TRUE; + } + + + /** + * TestCaseID: TAT01 + * Cancel altering a trigger of the table + */ + function testCancelAlterTrigger() + { + global $webUrl; + global $lang; + + // 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->setField('name', 'changed_trigger_changed')); + $this->assertTrue($this->clickSubmit($lang['strcancel'])); + + return TRUE; + } + + + /** + * TestCaseID: TDT01 + * Cancel dropping a trigger from the table + */ + function testCancelDropTrigger() + { + global $webUrl; + global $lang; + + // 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->clickSubmit($lang['strno'])); + + return TRUE; + } + + + /** + * TestCaseID: TDT02 + * Drop a trigger from the table + */ + function testDropTrigger() + { + global $webUrl; + global $lang; + + // 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->setField('cascade', TRUE)); + $this->assertTrue($this->clickSubmit($lang['stryes'])); + // Verify if the trigger is dropped correctly. + $this->assertTrue($this->assertWantedText($lang['strtriggerdropped'])); + + return TRUE; + } +} + + + + diff --git a/tests/testcase/coveragephpPgAdminMain.php b/tests/testcase/coveragephpPgAdminMain.php new file mode 100644 index 000000000..576631c90 --- /dev/null +++ b/tests/testcase/coveragephpPgAdminMain.php @@ -0,0 +1,70 @@ +run(new TextReporter()); +$testDatabase->run(new TextReporter()); +$testSchema->run(new TextReporter()); +$testTable->run(new TextReporter()); +$testCommon->run(new TextReporter()); + +// Get the coverage data xml +$xml = file_get_contents($cov_weburl . "?phpcoverage-action=get-coverage-xml"); + +// Cleanup the recording +file_get_contents($cov_weburl . "?phpcoverage-action=cleanup"); + +$reporter = new HtmlCoverageReporter("phpPgAdmin Code coverage report","","$PHPCOVERAGE_REPORT_DIR"); + +// Sets the directories or file paths to be included in the code coverage recording. +$includePaths = array(realpath($PHPCOVERAGE_APPBASE_PATH)); +$excludePaths = array(realpath($PHPCOVERAGE_APPBASE_PATH)."/lang", realpath($PHPCOVERAGE_APPBASE_PATH)."/libraries/adodb/drivers"); +$cov = new RemoteCoverageRecorder($includePaths, $excludePaths, $reporter); + +// Generate the code coverage report +$cov->generateReport($xml); + +$reporter->printTextSummary(); + +?> diff --git a/tests/testcase/phpcoverage.inc.php b/tests/testcase/phpcoverage.inc.php new file mode 100644 index 000000000..7eb3c0d58 --- /dev/null +++ b/tests/testcase/phpcoverage.inc.php @@ -0,0 +1,59 @@ + + PHPCOVERAGE_HOME=/path/to/coverage/home'\n"; + die($msg); + } + + // Fallback + if(!defined("PHPCOVERAGE_HOME")) { + $include_path = get_include_path(); + set_include_path($PHPCOVERAGE_HOME. ":" . $include_path); + define('PHPCOVERAGE_HOME', $PHPCOVERAGE_HOME); + } + + error_log("[phpcoverage.inc.php] PHPCOVERAGE_HOME=" . $PHPCOVERAGE_HOME); + error_log("[phpcoverage.inc.php] PHPCOVERAGE_REPORT_DIR=" . $PHPCOVERAGE_REPORT_DIR); + error_log("[phpcoverage.inc.php] PHPCOVERAGE_APPBASE_PATH=" . $PHPCOVERAGE_APPBASE_PATH); + +?> diff --git a/tests/testcase/simpletest.inc.php b/tests/testcase/simpletest.inc.php new file mode 100644 index 000000000..4d4f943d2 --- /dev/null +++ b/tests/testcase/simpletest.inc.php @@ -0,0 +1,41 @@ + + PHP_SIMPLETEST_HOME=/path/to/simpletest/home'\n"; + die($msg); + } + + error_log("PHP_SIMPLETEST_HOME=" . $PHP_SIMPLETEST_HOME); + $include_path = get_include_path(); + set_include_path($PHP_SIMPLETEST_HOME. ":" . $include_path); + define('__PHP_SIMPLETEST_HOME', $PHP_SIMPLETEST_HOME); + echo $PHP_SIMPLETEST_REPORT_PATH; + echo $PHP_SIMPLETEST_HOME; + +?> diff --git a/tests/testcase/testphpPgAdminMain.php b/tests/testcase/testphpPgAdminMain.php new file mode 100644 index 000000000..9018ad621 --- /dev/null +++ b/tests/testcase/testphpPgAdminMain.php @@ -0,0 +1,48 @@ +GroupTest('phpPgAdmin automation test.'); + $this->addTestClass(new ServerGroupTest()); + $this->addTestClass(new DatabaseGroupTest()); + $this->addTestClass(new SchemasGroupTest()); + $this->addTestClass(new TableGroupTest()); + $this->addTestClass(new CommonGroupTest()); + } +} + +$phpPgAdminTest = &new phpPgAdminGroupTest(); +$phpPgAdminTest->run(new DetailedHtmlReporter()); + +?>