some more unit tests fix (see tests/TODO) : "34/34 test cases complete: 969 passes...
authorioguix <ioguix>
Fri, 7 Sep 2007 22:37:54 +0000 (22:37 +0000)
committerioguix <ioguix>
Fri, 7 Sep 2007 22:37:54 +0000 (22:37 +0000)
12 files changed:
tests/TODO [new file with mode: 0644]
tests/config.tests.php [new file with mode: 0644]
tests/data/.cvsignore [new file with mode: 0644]
tests/data/config.sql [new file with mode: 0644]
tests/data/ppatests_install.sql [new file with mode: 0644]
tests/data/ppatests_remove.sql [new file with mode: 0644]
tests/testcase/Common/ExportTest.php
tests/testcase/Common/ImportTest.php
tests/testcase/Common/SecurityTest.php
tests/testcase/Tables/ColumnTest.php
tests/testcase/testphpPgAdminMain.php
tests/tests.php [new file with mode: 0644]

diff --git a/tests/TODO b/tests/TODO
new file mode 100644 (file)
index 0000000..2ccf68c
--- /dev/null
@@ -0,0 +1,28 @@
+- fix code coverage: currently, only unit tests has been refactored/fix.
+- automatic {create|drop} needed test database, roles & objects {before|after} tests (we could use a Makefile, but what about windows users ? a full php solution seems better)
+- add new tests
+- file to check / fix :
+       * Schemas:
+               AggregateTest.php
+               ConversionTest.php
+               DomainTest.php
+               FunctionTest.php
+               OpClassTest.php
+               OperatorTest.php
+               TypeTest.php
+       * Tables:
+               ConstraintsTest.php
+               DeadlockTest.php
+               IndexesTest.php
+               InfoTest.php
+               RulesTest.php
+               TriggersTest.php
+       * Common:
+               SecurityTest.php
+
+Optionals:
+- ability to run only wanted test groups (we could use directly a get param or a small form)
+- putting every config var in one place (if possible, instead of config.tests.php & data/config.sql)
+- add a custom html report given more details on errors ( collapse/expend $this->showRequest() & $this->showSource() infos as instance )
+- do not auto-detect webUrl global param (in config.tests.php) because of PHP_SELF ?
+- add server infos in config.tests.php instead of getting them from conf['servers'][0] ?
diff --git a/tests/config.tests.php b/tests/config.tests.php
new file mode 100644 (file)
index 0000000..8877435
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+global $webUrl,
+               $SERVER,
+               $SUPER_USER_NAME,
+               $SUPER_USER_PASSWORD,
+               $POWER_USER_NAME,
+               $POWER_USER_PASSWORD,
+               $NORMAL_USER_NAME,
+               $NORMAL_USER_PASSWORD;
+
+$webUrl = "http://{$_SERVER['SERVER_NAME']}/" . dirname($_SERVER['PHP_SELF']) . "/../";
+$SERVER="{$conf['servers'][0]['host']}:{$conf['servers'][0]['port']}:{$conf['servers'][0]['sslmode']}";
+$DATABASE="ppatests";
+$PHP_SIMPLETEST_HOME='/home/ioguix/public_html/ppa/simpletest';
+
+$SUPER_USER_NAME = 'ppatests_super';
+$SUPER_USER_PASSWORD = 'super';
+
+$POWER_USER_NAME = 'ppatests_power';
+$POWER_USER_PASSWORD = 'power';
+
+$NORMAL_USER_NAME = 'ppatests_guest';
+$NORMAL_USER_PASSWORD = 'guest';
+?>
diff --git a/tests/data/.cvsignore b/tests/data/.cvsignore
new file mode 100644 (file)
index 0000000..ff1a7a3
--- /dev/null
@@ -0,0 +1 @@
+TableSpace
diff --git a/tests/data/config.sql b/tests/data/config.sql
new file mode 100644 (file)
index 0000000..633e586
--- /dev/null
@@ -0,0 +1,4 @@
+\set dbname ppatests
+\set superuser ppatests_super
+\set poweruser ppatests_power
+\set guestuser ppatests_guest
diff --git a/tests/data/ppatests_install.sql b/tests/data/ppatests_install.sql
new file mode 100644 (file)
index 0000000..e075c73
--- /dev/null
@@ -0,0 +1,53 @@
+\i data/config.sql
+\connect postgres
+
+CREATE ROLE :guestuser;
+ALTER ROLE :guestuser WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN ENCRYPTED PASSWORD 'guest' VALID UNTIL 'infinity';
+CREATE ROLE :poweruser;
+ALTER ROLE :poweruser WITH NOSUPERUSER INHERIT NOCREATEROLE CREATEDB LOGIN ENCRYPTED PASSWORD 'power' VALID UNTIL 'infinity';
+CREATE ROLE :superuser;
+ALTER ROLE :superuser WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN ENCRYPTED PASSWORD 'super' VALID UNTIL 'infinity';
+
+CREATE DATABASE :dbname WITH TEMPLATE = template0 OWNER = :poweruser ENCODING = 'UTF8';
+
+\connect :dbname
+
+COMMENT ON DATABASE :dbname IS 'Tests database for PhpPgAdmin';
+
+
+COMMENT ON SCHEMA public IS 'Standard public schema';
+
+
+SET search_path = public, pg_catalog;
+
+SET default_tablespace = '';
+
+SET default_with_oids = false;
+
+CREATE SEQUENCE student_id_seq;
+
+CREATE TABLE student (
+    id integer NOT NULL DEFAULT nextval('student_id_seq'),
+    name character varying,
+    birthday date,
+    resume text
+);
+
+
+ALTER TABLE public.student OWNER TO :poweruser;
+
+COPY student (id, name, birthday, resume) FROM stdin;
+2      testname        2007-08-04      test resume.
+\.
+
+SELECT setval('student_id_seq', 2);
+
+ALTER TABLE ONLY student
+    ADD CONSTRAINT student_pkey PRIMARY KEY (id);
+
+
+REVOKE ALL ON SCHEMA public FROM PUBLIC;
+REVOKE ALL ON SCHEMA public FROM :poweruser;
+GRANT ALL ON SCHEMA public TO :poweruser;
+GRANT ALL ON SCHEMA public TO PUBLIC;
+
diff --git a/tests/data/ppatests_remove.sql b/tests/data/ppatests_remove.sql
new file mode 100644 (file)
index 0000000..dd2347c
--- /dev/null
@@ -0,0 +1,10 @@
+\connect postgres
+\i data/config.sql
+
+DROP DATABASE :dbname;
+DROP DATABASE spikesource1;
+DROP DATABASE spikesource2;
+
+DROP ROLE :superuser;
+DROP ROLE :poweruser;
+DROP ROLE :guestuser;
index 32c8315f8297d58ba2d9400a11fd025b3f126094..4e20679a582b67c828506ae23f4ff1d540e56f39 100644 (file)
@@ -162,19 +162,20 @@ class ExportTest extends PreconditionSet
         
         // Turn to the "Insert row" interface.
                $this->assertTrue($this->get("$webUrl/tables.php", array(
+                       'server' => $SERVER,
                        'action' => 'confinsertrow',
                        'database' => $DATABASE,
                        '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']));
+               $this->assertTrue($this->clickSubmit($lang['strinsert']));
+
         // Verify if the row insert successful.
         $this->assertTrue($this->assertWantedText($lang['strrowinserted']));
         
@@ -269,7 +270,8 @@ class ExportTest extends PreconditionSet
         global $webUrl, $lang, $SERVER, $DATABASE;
         
         // Turn to the export data page.
-        $this->assertTrue($this->get("$webUrl/viewproperties.php", array(
+               $this->assertTrue($this->get("$webUrl/viewproperties.php", array(
+                       'server' => $SERVER,
                        'database' => $DATABASE,
                        'schema' => 'pg_catalog',
                        'view' => 'pg_user',
index e467d53b5b1c87e00a32970d50e274e0eec1c87d..c3a6fbcc7f3ea6ed7468cceb6df5e6b0f742389b 100644 (file)
@@ -58,7 +58,7 @@ class ImportTest extends PreconditionSet
         global $webUrl;
         global $lang, $SERVER, $DATABASE;
         
-        $this->_dataFilePath = getcwd() . '/../data/';
+        $this->_dataFilePath = getcwd() . '/./data/';
         
         // Turn to the import data page.
                $this->assertTrue($this->get("$webUrl/tblproperties.php", array(
@@ -69,7 +69,7 @@ class ImportTest extends PreconditionSet
                        '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'));
@@ -93,7 +93,7 @@ class ImportTest extends PreconditionSet
         global $webUrl;
         global $lang, $SERVER, $DATABASE;
         
-        $this->_dataFilePath = getcwd() . '/../data/';
+        $this->_dataFilePath = getcwd() . '/./data/';
         // Turn to the import data page.
                $this->assertTrue($this->get("$webUrl/tblproperties.php", array(
                                    'server' => $SERVER,
@@ -111,7 +111,7 @@ class ImportTest extends PreconditionSet
         // 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));
+        $this->assertWantedText(sprintf($lang['strimporterrorline'], 2));
         
         return TRUE;
     }
index 034d1a877d144c76856bfc0eb1fdc269e0933f99..8536eb4aac09d44e9298667b0d004d7dc33b3d61 100644 (file)
@@ -50,8 +50,7 @@ class SecurityTest extends PreconditionSet
         
         // Verify the error messages.
         $this->assertWantedText($lang['strlogindisallowed']);
-        $this->assertWantedText($lang['strviewfaq']);
-
+               $this->assertWantedText($lang['strviewfaq']);
         // Login with special user name "postgres".
         $this->login($NORMAL_USER_NAME, '', "$webUrl/login.php");
         
index 946e8cc225f9db8e6ad63b7a1694f0fc6780064b..b71e5370c43ae90c1ceff1bbc8b9fc68322db057 100644 (file)
@@ -50,7 +50,7 @@ class ColumnTest extends PreconditionSet{
     function testAddColumn()\r
     {\r
         global $webUrl;\r
-        global $lang, $SERVER;\r
+        global $lang, $SERVER, $DATABASE;\r
         \r
         // Go to the Columns page\r
                $this->assertTrue($this->get("$webUrl/tblproperties.php",\r
@@ -67,7 +67,7 @@ class ColumnTest extends PreconditionSet{
         $this->assertTrue($this->clickSubmit($lang['stradd']));\r
         \r
         // Verify if the column is created correctly.\r
-        $this->assertTrue($this->assertWantedText($lang['strcolumnadded'])); \r
+               $this->assertTrue($this->assertWantedText($lang['strcolumnadded'])); \r
         \r
         return TRUE;             \r
     }\r
@@ -139,7 +139,7 @@ class ColumnTest extends PreconditionSet{
         global $lang, $SERVER, $DATABASE;\r
         \r
         // Go to the Columns page\r
-               $this->assertTrue($this->get("$webUrl/tblproperties.php", array(\r
+               $this->assertTrue($this->get("$webUrl/colproperties.php", array(\r
                        'server' => $SERVER,\r
                        'action' => 'properties',\r
                        'database' => $DATABASE,\r
@@ -171,7 +171,7 @@ class ColumnTest extends PreconditionSet{
         global $lang, $SERVER, $DATABASE;\r
         \r
         // Go to the Columns page\r
-               $this->assertTrue($this->get("$webUrl/tblproperties.php", array(\r
+               $this->assertTrue($this->get("$webUrl/colproperties.php", array(\r
                        'server' => $SERVER,\r
                        'action' => 'properties',\r
                        'database' => $DATABASE,\r
@@ -203,7 +203,7 @@ class ColumnTest extends PreconditionSet{
         global $lang, $SERVER, $DATABASE;\r
         \r
         // Go to the Columns page\r
-               $this->assertTrue($this->get("$webUrl/tblproperties.php", array(\r
+               $this->assertTrue($this->get("$webUrl/colproperties.php", array(\r
                        'server' => $SERVER,\r
                        'action' => 'properties',\r
                        'database' => $DATABASE,\r
index 3166bf071dddb2e81c331455bcf64c3d9af5abf4..49988799488ea829d8eeb329a1acb4057862328e 100644 (file)
@@ -29,10 +29,10 @@ class phpPgAdminGroupTest extends GroupTest
     function phpPgAdminGroupTest() \r
     {\r
                $this->GroupTest('phpPgAdmin automation test.');\r
-        $this->addTestClass(new ServerGroupTest());\r
-        $this->addTestClass(new DatabaseGroupTest());\r
-        $this->addTestClass(new SchemasGroupTest());\r
-        $this->addTestClass(new TableGroupTest());\r
+               $this->addTestClass(new ServerGroupTest());\r
+               $this->addTestClass(new DatabaseGroupTest());\r
+               $this->addTestClass(new SchemasGroupTest());\r
+               $this->addTestClass(new TableGroupTest());\r
                $this->addTestClass(new CommonGroupTest());\r
 \r
     }\r
diff --git a/tests/tests.php b/tests/tests.php
new file mode 100644 (file)
index 0000000..9ad7422
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/php5
+<?php
+require_once('../conf/config.inc.php');
+require_once('../lang/recoded/english.php');
+
+require_once('config.tests.php');
+
+set_include_path($PHP_SIMPLETEST_HOME . ':' . './testcase' . ':' . get_include_path());
+
+require_once('testcase/testphpPgAdminMain.php');
+
+?>