Code cleaning of the selenium new archi and add some new tests on domaine and table
authorGuillaume (ioguix) de Rorthais <ioguix@free.fr>
Wed, 5 Nov 2008 06:31:43 +0000 (01:31 -0500)
committerGuillaume (ioguix) de Rorthais <ioguix@free.fr>
Wed, 5 Nov 2008 06:31:43 +0000 (01:31 -0500)
tests/selenium/src/01-roles.php
tests/selenium/src/04-database.php
tests/selenium/src/06-schema.php
tests/selenium/src/08-domaine.php [new file with mode: 0644]
tests/selenium/src/10-table.php [new file with mode: 0644]
tests/selenium/src/99-cleantests.php
tests/selenium/testBuilder.class.php

index 6d43a8fb8b8f07696778cf8ee1500ad909b1908e..b319b1808980d97f395f6bd074141d2653ebdbd2 100644 (file)
@@ -10,7 +10,7 @@
         * 6/ alter user back to the normal value
         * NB: droping role tests are in the cleantests.php tests
         */
-       $t = new TestBuilder("{$test_static_dir}/{$server['desc']}/roles.html", $server['desc'],
+       $t = new TestBuilder($server['desc'],
                'Roles, Users and Groups tests',
                'Create test admin role, test user role and tests Roles (or user/groups) features.'
        );
                $t->assertText("//p[@class='message']", $lang['struserupdated']);
 
        $t->logout();
-       $t->writeTests($testsuite_file);
+       
+       $t->writeTests("{$test_static_dir}/{$server['desc']}/roles.html", $testsuite_file);
+
        unset($t);
 ?>
index 47313961632663da2fb945b8b123cf21c249074b..fd740972eff072e60a9866ca2a16620b22be55ef 100644 (file)
@@ -7,7 +7,7 @@
         * 3/ alter its name, owner and comment back to normal
         * NB: droping database is in the cleantests.php tests
         */
-       $t = new TestBuilder("{$test_static_dir}/{$server['desc']}/database.html", $server['desc'],
+       $t = new TestBuilder($server['desc'],
                'Database tests',
                'Create and Alter database.'
        );
@@ -62,6 +62,6 @@
        }
 
        $t->logout();
-       $t->writeTests($testsuite_file);
+       $t->writeTests("{$test_static_dir}/{$server['desc']}/database.html", $testsuite_file);
        unset($t);
 ?>
index ea6041825c1c202709afd19c743e73729c79808a..8d4c6b675df656944181c44eb5f9fbd3fe268822 100644 (file)
@@ -6,7 +6,7 @@
         * 2/ alter its name, owner and comment
         * NB: droping the schema is in the cleantests.php tests
         */
-       $t = new TestBuilder("{$test_static_dir}/{$server['desc']}/schema.html", $server['desc'],
+       $t = new TestBuilder($server['desc'],
                'Schema tests',
                'Create and Alter schema.'
        );
@@ -45,6 +45,6 @@
        }
        
        $t->logout();
-       $t->writeTests($testsuite_file);
+       $t->writeTests("{$test_static_dir}/{$server['desc']}/schema.html", $testsuite_file);
        unset($t);
 ?>
diff --git a/tests/selenium/src/08-domaine.php b/tests/selenium/src/08-domaine.php
new file mode 100644 (file)
index 0000000..e40c49a
--- /dev/null
@@ -0,0 +1,113 @@
+<?php
+       global $testsuite_file, $test_static_dir;
+
+       /*
+        * 1/ create domain
+        * 2/ add unwanted domain constraint
+        * 3/ drop unwanted check constraint on domain
+        * 4/ alter domain giving owner to super_user
+        * 5/ alter back the owner to admin_user
+        * NB: droping domain is in the cleantests.php tests
+        */
+       $t = new TestBuilder($server['desc'],
+               'Domain tests',
+               'Create and Alter a domain.'
+       );
+
+       $t->login($admin_user, $admin_user_pass);
+
+/** 1 **/
+       $t->clickAndWait("link={$lang['strdatabases']}");
+       $t->clickAndWait("link={$testdb}");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait("link=test_schema");
+       $t->clickAndWait("link={$lang['strdomains']}");
+       $t->clickAndWait("link={$lang['strcreatedomain']}");
+       $t->type('domname', 'year');
+       $t->select('domtype', 'label=integer');
+       if ($data->hasAlterDomains()) {
+               $t->type('domdefault', '1900');
+               $t->click('domnotnull');
+       }
+       else
+               $t->type('domdefault', 'extract(year from current_date)');
+       
+       if ($data->hasDomainConstraints()) 
+               $t->type('domcheck', 'VALUE &gt;= 1901 AND VALUE &lt;= 2155');
+       $t->clickAndWait("//input[@value='{$lang['strcreate']}']");
+       $t->assertText("//p[@class='message']", $lang['strdomaincreated']);
+       $t->assertText("//tr/td/a[text()='year']", 'year');
+       $t->assertText("//tr/td/a[text()='year']/../../td[2]", 'integer');
+       if ($data->hasAlterDomains()) {
+               $t->assertText("//tr/td/a[text()='year']/../../td[3]/div", 'NOT NULL');
+               $t->assertText("//tr/td/a[text()='year']/../../td[4]", '1900');
+               
+       }
+       /* we doesn't test default as Postgres change it with internal methods */
+       //else
+       //      $t->assertText("//tr/td/a[text()='year']/../../td[4]", 'extract(year from current_date)');
+       $t->assertText("//tr/td/a[text()='year']/../../td[5]", $admin_user);
+       if ($data->hasDomainConstraints()) {
+               $t->clickAndWait("link=year");
+               if ($data->major_version == '7.4')
+                       $t->assertText("//tr/td[text()='$1']/../td[2]", 'CHECK (VALUE >= 1901 AND VALUE <= 2155)');
+               else
+                       $t->assertText("//tr/td[text()='year_check']/../td[2]", 'CHECK (VALUE >= 1901 AND VALUE <= 2155)');
+       }
+       
+/** 2 **/
+       if ($data->hasDomainConstraints()) {
+               $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
+               $t->clickAndWait("link={$lang['strdomains']}");
+               $t->clickAndWait("link=year");
+               $t->clickAndWait("//a[text()='{$lang['straddcheck']}']");
+               $t->type('name', 'test_to_drop');
+               $t->type('definition', 'VALUE > 1900');
+               $t->clickAndWait('add');
+               $t->assertText("//p[@class='message']", $lang['strcheckadded']);
+               $t->assertText("//tr/td[text()='test_to_drop']/../td[2]", 'CHECK (VALUE > 1900)');
+       }
+
+/** 3 **/
+       if ($data->hasDomainConstraints()) {
+               $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
+               $t->clickAndWait("link={$lang['strdomains']}");
+               $t->clickAndWait("link=year");
+               $t->clickAndWait("//tr/td[text()='test_to_drop']/../td/a[text()='{$lang['strdrop']}']");
+               $str = sprintf($lang['strconfdropconstraint'], 'test_to_drop', 'year');
+               $t->assertText("//p[text()='$str']", sprintf($lang['strconfdropconstraint'], 'test_to_drop', 'year'));
+               $t->clickAndWait('drop');
+               $t->assertText("//p[@class='message']", $lang['strconstraintdropped']);
+       }
+
+/** 4 **/
+       if ($data->hasAlterDomains()) {
+               $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
+               $t->clickAndWait("link={$lang['strdomains']}");
+               $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['stralter']}']");
+               $t->click('domnotnull');
+               $t->type('domdefault', 'extract(year from current_date)');
+               $t->select('domowner', $super_user[$server['desc']]);
+               $t->clickAndWait('alter');
+               $t->assertText("//p[@class='message']", $lang['strdomainaltered']);
+               $t->assertText("//tr/th[text()='{$lang['strnotnull']}']/../td", '');
+               /* we doesn't test default as Postgres change it with internal methods */
+               //$t->assertText("//tr/th[text()='{$lang['strdefault']}']/../td", 'extract(year from current_date)');
+               $t->assertText("//tr/th[text()='{$lang['strowner']}']/../td", $super_user[$server['desc']]);
+       }
+
+/** 5 **/
+       if ($data->hasAlterDomains()) {
+               $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
+               $t->clickAndWait("link={$lang['strdomains']}");
+               $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['stralter']}']");
+               $t->select('domowner', $admin_user);
+               $t->clickAndWait('alter');
+               $t->assertText("//p[@class='message']", $lang['strdomainaltered']);
+               $t->assertText("//tr/th[text()='{$lang['strowner']}']/../td", $admin_user);
+       }
+               
+       $t->logout();
+       $t->writeTests("{$test_static_dir}/{$server['desc']}/domain.html", $testsuite_file);
+       unset($t);
+?>
diff --git a/tests/selenium/src/10-table.php b/tests/selenium/src/10-table.php
new file mode 100644 (file)
index 0000000..d6102ef
--- /dev/null
@@ -0,0 +1,190 @@
+<?php
+       global $testsuite_file, $test_static_dir;
+
+       /*
+        * 1/ create a table student in public
+        * 2/ create table promo in test_schema
+        * 3/ create table like student in test_schema
+        * 4/ alter each param one by one on test_toalter
+        * 5/ alter back test_toalter in one step
+        * NB: droping a table is in the cleantests.php tests
+        */
+       $t = new TestBuilder($server['desc'],
+               'Table tests',
+               'Create tables, make some alterations...'
+       );
+
+       $t->login($admin_user, $admin_user_pass);
+
+/** 1 **/
+       $t->clickAndWait("link={$lang['strdatabases']}");
+       $t->clickAndWait("link={$testdb}");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait("link=public");
+       $t->clickAndWait("link={$lang['strtables']}");
+       $t->clickAndWait("link={$lang['strcreatetable']}");
+       $t->type('name','student');
+       $t->type('fields', '5');
+       $t->type('tblcomment', 'student table');
+       $t->clickAndWait("//input[@value='{$lang['strnext']}']");
+       $t->type('field[0]', 'id');
+       $t->select('types0', 'label=SERIAL');
+       $t->click('primarykey[0]');
+       $t->type('field[1]', 'id_promo');
+       $t->select('types1', 'label=integer');
+       $t->type('field[2]', 'name');
+       $t->select('types2', 'label=character varying');
+       $t->type('lengths2', '20');
+       $t->click('notnull[2]');
+       $t->type('field[3]', 'birthday');
+       $t->select('types3', 'label=date');
+       $t->type('field[4]', 'resume');
+       $t->select('types4', 'label=text');
+       $t->clickAndWait("//input[@value='{$lang['strcreate']}']");
+       $t->assertText("//p[@class='message']", $lang['strtablecreated']);
+
+/** 2 **/
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait("link=test_schema");
+       $t->clickAndWait("link={$lang['strtables']}");
+       $t->clickAndWait("link={$lang['strcreatetable']}");
+       $t->type('name', 'promo');
+       $t->type('fields', '3');
+       $t->type('tblcomment', 'promotion\'s year & speciality');
+       $t->clickAndWait("//input[@value='Next &gt;']");
+       $t->type('field[0]', 'id');
+       $t->select('types0', 'label=SERIAL');
+       $t->click('primarykey[0]');
+       $t->type('field[1]', 'spe');
+       $t->select('types1', 'label=character varying');
+       $t->type('lengths1','20');
+       $t->click('notnull[1]');
+       $t->type('field[2]', 'year');
+       $t->select('types2', "label=regexp:\"?year\"?"); // 8.3 does not quote domains
+       $t->click('notnull[2]');
+       $t->clickAndWait("//input[@value='{$lang['strcreate']}']");
+       $t->assertText("//p[@class='message']", $lang['strtablecreated']);
+
+/** 3 **/
+       if ($data->hasCreateTableLike()) {
+               $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
+               $t->clickAndWait("link={$lang['strschemas']}");
+               $t->clickAndWait("link=test_schema");
+               $t->clickAndWait("link={$lang['strtables']}");
+               $t->clickAndWait("link={$lang['strcreatetablelike']}");
+               $t->type('name', 'test_toalter');
+               $t->select('like','label="public"."student"');
+               $t->click('withdefaults');
+               if ($data->hasCreateTableLikeWithConstraints())
+                       $t->click('withconstraints');
+               if ($data->hasCreateTableLikeWithIndexes())
+                       $t->click('withindexes');
+               $t->clickAndWait("//input[@value='{$lang['strcreate']}']");
+               $t->assertText("//p[@class='message']", $lang['strtablecreated']);
+       }
+       else {
+               /*no create like ? create it anyway for the next steps*/
+               $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
+               $t->clickAndWait("link={$lang['strschemas']}");
+               $t->clickAndWait("link=test_schema");
+               $t->clickAndWait("link={$lang['strtables']}");
+               $t->clickAndWait("link={$lang['strcreatetable']}");
+               $t->type('name','test_toalter');
+               $t->type('fields', '1');
+               $t->type('tblcomment', 'test table');
+               $t->clickAndWait("//input[@value='{$lang['strnext']}']");
+               $t->type('field[0]', 'id');
+               $t->select('types0', 'label=SERIAL');
+               $t->click('primarykey[0]');
+               $t->clickAndWait("//input[@value='{$lang['strcreate']}']");
+               $t->assertText("//p[@class='message']", $lang['strtablecreated']);
+       }
+
+/** 4 **/
+       /*table name*/
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait("link=test_schema");
+       $t->clickAndWait("link={$lang['strtables']}");
+       $t->clickAndWait("link=test_toalter");
+       $t->clickAndWait("link={$lang['strcolumns']}"); /*alter using the link in the column page*/
+       $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
+       $t->type('name', 'test_renamed');
+       $t->clickAndWait('alter');
+       $t->assertText("//p[@class='message']", $lang['strtablealtered']);
+       $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label']", 'test_renamed');
+
+       /*table comment*/
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait("link=test_schema");
+       $t->clickAndWait("link={$lang['strtables']}");
+       $t->clickAndWait("link=test_renamed");
+       $t->clickAndWait("link={$lang['strcolumns']}"); /*alter using the link in the column page*/
+       $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
+       $t->type('comment', 'altered comment');
+       $t->clickAndWait('alter');
+       $t->assertText("//p[@class='message']", $lang['strtablealtered']);
+       $t->assertText("//p[@class='comment']", 'altered comment');
+       
+       /*table owner*/
+       if ($data->hasAlterTableOwner()) {
+               $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
+               $t->clickAndWait("link={$lang['strschemas']}");
+               $t->clickAndWait("link=test_schema");
+               $t->clickAndWait("link={$lang['strtables']}");
+               $t->clickAndWait("//tr/td/a[text()='test_renamed']/../../td/a[text()='{$lang['stralter']}']"); /*alter using the link in the table list page*/
+               $t->select('owner', "label={$user}");
+               $t->clickAndWait('alter');
+               $t->assertText("//p[@class='message']", $lang['strtablealtered']);
+               $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
+               $t->clickAndWait("link={$lang['strtables']}");
+               $t->assertText("//tr/td[2]/a[text()='test_renamed']/../../td[3]", $user);
+       }
+       
+       /*alter schema*/
+       if ($data->hasAlterTableSchema()) {
+               $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
+               $t->clickAndWait("link={$lang['strschemas']}");
+               $t->clickAndWait("link=test_schema");
+               $t->clickAndWait("link={$lang['strtables']}");
+               $t->clickAndWait("//tr/td/a[text()='test_renamed']/../../td/a[text()='{$lang['stralter']}']"); /*alter using the link in the table list page*/
+               $t->select('newschema', 'label=public');
+               $t->clickAndWait('alter');
+               $t->assertText("//p[@class='message']", $lang['strtablealtered']);
+               $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'public');
+       }
+
+/** 5 **/
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       if ($data->hasAlterTableSchema())
+               $t->clickAndWait("link=public");
+       else
+               $t->clickAndWait("link=test_schema");
+       $t->clickAndWait("link={$lang['strtables']}");
+       $t->clickAndWait("link=test_renamed");
+       $t->clickAndWait("link={$lang['strcolumns']}");
+       $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
+       $t->type('name', 'test');
+       
+       $t->type('comment', 'normal comment');
+       if ($data->hasAlterTableSchema())
+               $t->select('newschema', 'label=test_schema');
+       if ($data->hasAlterTableOwner())
+               $t->select('owner', "label={$admin_user}");
+       $t->clickAndWait('alter');
+       $t->assertText("//p[@class='message']", $lang['strtablealtered']);
+       $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label']", 'test');
+       $t->assertText("//p[@class='comment']", 'normal comment');
+       $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'test_schema');
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
+       $t->clickAndWait("link={$lang['strtables']}");
+       if ($data->hasAlterTableOwner())
+               $t->assertText("//tr/td[2]/a[text()='test']/../../td[3]", $admin_user);
+
+       $t->logout();
+       $t->writeTests("{$test_static_dir}/{$server['desc']}/table.html", $testsuite_file);
+       unset($t);
+?>
index 15d61934c7ca3be2496a8ec87a18d75890bedc61..ecb47d16e8bae9a70b70f6d0caf5c322368add41 100644 (file)
@@ -5,10 +5,14 @@
         * 1/ login as user and try to drop database -> fail
         * 2/ logout / login as admin_user and drop user role/user
         * 3/ try to drop himself -> fail
-        * 4/ drop test database
-        * 5/ logout & login as superuser and drop admin_user
+        * 4/ drop domain -> fail table promo depend on it
+        * 5/ drop domain with cascade, test if promo.year disapeared
+        * 6/ drop table student with cascade using the action button
+        * 7/ drop table promo using the button from tblproperties
+        * 8/ drop test database
+        * 9/ logout & login as superuser and drop admin_user
         */
-       $t = new TestBuilder("{$test_static_dir}/{$server['desc']}/cleantests.html", $server['desc'],
+       $t = new TestBuilder($server['desc'],
                'Cleaner tests',
                'Clean every created stuff for test.'
        );
        }
 
 /** 4 **/
+       $t->clickAndWait("link={$lang['strdatabases']}");
+       $t->clickAndWait("link={$testdb}");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait("link=test_schema");
+       $t->clickAndWait("link={$lang['strdomains']}");
+       $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['strdrop']}']");
+       $t->clickAndWait('drop');
+       $t->assertText('//p[@class=\'message\']', $lang['strdomaindroppedbad']);
+
+/** 5 **/
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait("link=test_schema");
+       $t->clickAndWait("link={$lang['strdomains']}");
+       $t->clickAndWait("//tr/td/a[text()='year']/../../td/a[text()='{$lang['strdrop']}']");
+       $t->check('cascade');
+       $t->clickAndWait('drop');
+       $t->assertText('//p[@class=\'message\']', $lang['strdomaindropped']);
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
+       $t->clickAndWait("link={$lang['strtables']}");
+       $t->clickAndWait("link=promo");
+       $t->clickAndWait("link={$lang['strcolumns']}");
+       $t->assertErrorOnNext('Element link=year not found');
+       $t->clickAndWait("link=year");
+
+/** 6 **/
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']");
+       $t->clickAndWait("link={$lang['strdatabases']}");
+       $t->clickAndWait("link={$testdb}");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait("link=public");
+       $t->clickAndWait("//tr/td/a[text()='student']/../../td/a[text()='{$lang['strdrop']}']");
+       $t->check('cascade');
+       $t->clickAndWait('drop');
+       $t->assertText('//p[@class=\'message\']', $lang['strtabledropped']);
+
+/** 7 **/
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']");
+       $t->clickAndWait("link={$lang['strdatabases']}");
+       $t->clickAndWait("link={$testdb}");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait("link=test_schema");
+       $t->clickAndWait("link={$lang['strtables']}");
+       $t->clickAndWait("link=promo");
+       $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['strdrop']}']");
+       $t->clickAndWait('drop');
+       $t->assertText('//p[@class=\'message\']', $lang['strtabledropped']);
+       
+/** 8 **/
+       $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']");
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("//tr/td/a[text()='{$testdb}']/../../td/a[text()='{$lang['strdrop']}']");
        $t->clickAndWait('drop');
        $t->assertText('//p[@class=\'message\']', $lang['strdatabasedropped']);
 
-/** 5 **/
+/** 9 **/
        $t->logout();
        $t->login($super_user[$server['desc']], $super_pass[$server['desc']]);
 
        }
 
        $t->logout();
-       $t->writeTests($testsuite_file);
+       $t->writeTests("{$test_static_dir}/{$server['desc']}/cleantests.html", $testsuite_file);
     unset($t);
 ?>
index 7a695e5cabbed3403c14546bfdd8e7f4fa16a68c..564163a3caf0e70c1511b830b306da438600073f 100644 (file)
@@ -3,22 +3,19 @@
  * This class help building a selenium HTML test file for PPA.
 **/
        class TestBuilder {
-               private $fd; /* the file descriptor to the test file to write */
-               private $file; /* the test file name where the tests will be written*/
+               private $code;
 
                /**
                 * Constructor
-                * @param $file The file name that will be created
                 * @param $serverDesc The server['desc'] conf param to which we are writing this test file for.
                 * @param $title The title of the HTML test page
                 * @param $desc The top description on the HTML test page
                 */
-               public function __construct($file, $serverDesc, $title, $desc) {
-                       $this->file = $file;
+               public function __construct($serverDesc, $title, $desc) {
                        $this->title = $title;
                        $this->servDesc = $serverDesc;
 
-                       $this->fd = fopen($this->file, 'w');
+                       /*$this->fd = fopen($this->file, 'w');
 
                        fprintf($this->fd, '%s', "<html>\n<head>
                                <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
                                <thead>
                                <tr><td rowspan=\"1\" colspan=\"3\">$desc</td></tr>
                                </thead><tbody>"
-                       );
+                       );*/
+                       $this->code =  "<html>\n<head>
+                               <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
+                               <title>$title</title>
+                               </head>
+                               <body>
+                               <table cellpadding=\"1\" cellspacing=\"1\" border=\"1\">
+                               <thead>
+                               <tr><td rowspan=\"1\" colspan=\"3\">$desc</td></tr>
+                               </thead><tbody>";
+               }
+               
+               /**
+                * Write the test file, close it,
+                * append the test file to the TestSuite.html file and destroy itself
+                * @param $testfile The path to the test file to create
+                * @param $testsuite_file The path to the TestSuite.html file
+                */
+               public function writeTests($testfile, $testsuite_file) {
+                       file_put_contents($testfile, $this->code);
+
+                       $str = "<tr>\n<td><a href=\"{$this->servDesc}/".
+                               basename($testfile) ."\">[{$this->servDesc}] {$this->title}</a></td>\n</tr>\n";
+                       file_put_contents($testsuite_file, $str, FILE_APPEND);
+               }
+               
+               /**
+                * Add a selenium test to the file
+                * @param $action the selenium action (first column)
+                * @param $selector the selector to select the object to work on (second column)
+                * @param $value (optional) the expected (or not) value (third column)
+                */
+               public function test($action, $selector, $value='') {
+                       $this->code .= "<tr>\n<td>$action</td>\n<td>$selector</td>\n<td>$value</td>\n</tr>\n";
                }
 
                /**
@@ -38,9 +68,8 @@
                 * @param $p The password to use
                 */
                public function login($u, $p) {
-                       global $webUrl;
-                       $this->test('open', "$webUrl/servers.php");
-                       $this->test('clickAndWait', "link={$this->servDesc}");
+                       global $webUrl, $data;
+                       $this->test('open', "{$webUrl}/login.php?server={$data->conn->host}&subject=server");
                        $this->test('type', "//input[@name='loginUsername']", $u);
                        $this->test('type', "//input[@id='loginPassword']", $p);
                        $this->test('clickAndWait', 'loginSubmit');
                        );
                }
 
-               /**
-                * Write the test file, close it,
-                * append the test file to the TestSuite.html file and destroy itself
-                */
-               public function writeTests($testsuite_file) {
-                       fprintf($this->fd, '%s', "\n</tbody></table></body></html>");
-                       fclose($this->fd);
-
-                       $fd = fopen($testsuite_file, 'a');
-                       fprintf($fd, "<tr>\n<td><a href=\"%s/%s\">[%s] %s</a></td>\n</tr>\n", $this->servDesc, basename($this->file), $this->servDesc, $this->title);
-                       fclose($fd);
-               }
-
-               /**
-                * Add a selenium test to the file
-                * @param $action the selenium action (first column)
-                * @param $selector the selector to select the object to work on (second column)
-                * @param $value (optional) the expected (or not) value (third column)
-                */
-               public function test($action, $selector, $value='') {
-                       fprintf($this->fd, '%s',
-                               "<tr>\n<td>$action</td>\n<td>$selector</td>\n<td>$value</td>\n</tr>\n"
-                       );
-               }
-
                /**
                 * Add a selenium type test to the file
                 * @param $selector the selector to select the object to work on (second column)
                public function click($selector) {
                        $this->test('click', $selector);
                }
+               
+               /**
+                * Add a selenium check test to the file
+                * @param $selector the selector to select the object to work on (second column)
+                */
+               public function check($selector) {
+                       $this->test('check', $selector);
+               }
+               
+               /**
+                * Add a selenium uncheck test to the file
+                * @param $selector the selector to select the object to work on (second column)
+                */
+               public function uncheck($selector) {
+                       $this->test('uncheck', $selector);
+               }
 
                /**
                 * Add a selenium clickAndWait est to the file
                public function assertText($selector, $value) {
                        $this->test('assertText', $selector, $value);
                }
+               
+               /**
+                * Add a selenium assertErrorOnNext test to the file
+                * @param $msg the selenium error message expected
+                */
+               public function assertErrorOnNext($msg) {
+                       $this->test('assertErrorOnNext', $msg);
+               }
+               
        }
 ?>