From 20a4aebb13f73d26d664e4fb36c28c3221dabe35 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 12 Jan 2006 22:49:38 +0000 Subject: [PATCH] first round at fixing tests to work with new session system --- t/FormGetName.t | 22 +++++++++++----------- t/FormListEquiv.t | 22 +++++++++++----------- t/Id.t | 27 +++++++++++++-------------- t/Macro.t | 22 +++++++++++----------- t/POD.t | 22 +++++++++++----------- t/SQL.t | 24 ++++++++++++------------ t/User.t | 22 +++++++++++----------- t/Utility.t | 13 ++++++------- t/_test.skeleton | 12 ++++++------ t/help_compiled.t | 22 +++++++++++----------- t/help_related.t | 23 ++++++++++++----------- t/help_toc.t | 22 +++++++++++----------- t/i18n.t | 22 +++++++++++----------- t/mandatory_template_vars.t | 24 ++++++++++++------------ t/syntaxCheck.t | 22 +++++++++++----------- 15 files changed, 160 insertions(+), 161 deletions(-) diff --git a/t/FormGetName.t b/t/FormGetName.t index f0159afc8..b343ef3d6 100644 --- a/t/FormGetName.t +++ b/t/FormGetName.t @@ -12,7 +12,6 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use WebGUI::Form::FieldType; use WebGUI::Form::DynamicField; # ---- END DO NOT EDIT ---- @@ -27,7 +26,7 @@ use Test::More; # increment this value for each test you create my $numTests = 0; -initialize(); # this line is required +my $session = initialize(); # this line is required # put your tests here @@ -57,21 +56,22 @@ my $name = WebGUI::Form::DynamicField->getName(); ok($name, 'did not inherit default form name'); -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/FormListEquiv.t b/t/FormListEquiv.t index 346eda40e..5e09c3c45 100644 --- a/t/FormListEquiv.t +++ b/t/FormListEquiv.t @@ -12,7 +12,6 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use WebGUI::Form::DynamicField; use WebGUI::Form::SelectList; use Data::Dumper; @@ -33,7 +32,7 @@ use Test::More; # increment this value for each test you create # compare output of toHtmlWithWrapper from both objects my $numTests = 8*14; -initialize(); # this line is required +my $session = initialize(); # this line is required # put your tests here @@ -409,21 +408,22 @@ is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching DatabaseLink out -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/Id.t b/t/Id.t index b30c9ec6c..e4ae4d8f7 100644 --- a/t/Id.t +++ b/t/Id.t @@ -12,45 +12,44 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; # ---- END DO NOT EDIT ---- use Test::More tests => 2; # increment this value for each test you create -use WebGUI::Id; use WebGUI::Utility; -initialize(); # this line is required +my $session = initialize(); # this line is required # generate -my $generateId = WebGUI::Id::generate(); +my $generateId = $session->id->generate(); is(length($generateId), 22, "generate() - length of 22 characters"); my @uniqueIds; my $isUnique = 1; for (1..2000) { last unless $isUnique; - my $id = WebGUI::Id::generate(); + my $id = $session->id->generate(); $isUnique = !isIn($id,@uniqueIds); push(@uniqueIds,$id); } ok($isUnique, "generate() - unique"); -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/Macro.t b/t/Macro.t index 6a27948e2..00cce0c01 100644 --- a/t/Macro.t +++ b/t/Macro.t @@ -12,13 +12,12 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use WebGUI::Macro; use WebGUI::SQL; use Data::Dumper; # ---- END DO NOT EDIT ---- -initialize(); # this line is required +my $session = initialize(); # this line is required #This test is to verify bugs with respect to Macros: # - [ 1364838 ] ^GroupText Macro cannot execute other macros @@ -103,21 +102,22 @@ foreach my $macro ( @settingMacros ) { $sth->finish(); -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/POD.t b/t/POD.t index de52b6ce1..cf7be69a7 100644 --- a/t/POD.t +++ b/t/POD.t @@ -14,13 +14,12 @@ use lib '../lib'; use Getopt::Long; use Pod::Coverage; use File::Find; -use WebGUI::Session; # ---- END DO NOT EDIT ---- use Test::More; -initialize(); # this line is required +my $session = initialize(); # this line is required my @modules = (); find(\&countModules, "../lib/WebGUI"); @@ -32,7 +31,7 @@ foreach my $package (sort @modules) { ok($pc->coverage, $package); } -cleanup(); # this line is required +cleanup($session); # this line is required sub countModules { my $filename = $File::Find::dir."/".$_; @@ -50,16 +49,17 @@ sub countModules { # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/SQL.t b/t/SQL.t index fd9077203..60ed61743 100644 --- a/t/SQL.t +++ b/t/SQL.t @@ -12,7 +12,6 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use Data::Dumper; # ---- END DO NOT EDIT ---- @@ -20,7 +19,7 @@ use Data::Dumper; use Test::More tests => 33; # increment this value for each test you create use WebGUI::SQL; -initialize(); # this line is required +my $session = initialize(); # this line is required # read ok(my $sth = WebGUI::SQL->read("select * from settings"), "read()"); @@ -149,22 +148,23 @@ is($getRow->{nextValue}, 47, "getRow()"); WebGUI::SQL->write("delete from incrementer where incrementerId=".quote($setRowId)); -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- -sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); +nitialize { + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/User.t b/t/User.t index 6d61748d4..ee549841d 100644 --- a/t/User.t +++ b/t/User.t @@ -12,7 +12,6 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use WebGUI::Utility; # ---- END DO NOT EDIT ---- @@ -20,7 +19,7 @@ use WebGUI::User; use WebGUI::SQL; use Test::More tests => 33; # increment this value for each test you create -initialize(); # this line is required +my $session = initialize(); # this line is required # put your tests here my $user; @@ -152,22 +151,23 @@ SKIP: { ok(undef, "uncache"); } -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/Utility.t b/t/Utility.t index 754a51a7b..38837daec 100644 --- a/t/Utility.t +++ b/t/Utility.t @@ -13,12 +13,11 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; # ---- END DO NOT EDIT ---- use Test::More tests => 21; # increment this value for each test you create -initialize(); # this line is required +my $session = initialize(); # this line is required # commify @@ -88,23 +87,23 @@ SKIP: { } -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering + $|=1; # disable output buffering my $configFile; GetOptions( 'configFile=s'=>\$configFile ); exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } - diff --git a/t/_test.skeleton b/t/_test.skeleton index 2e4ef2b7b..e8b68eaf7 100644 --- a/t/_test.skeleton +++ b/t/_test.skeleton @@ -1,5 +1,5 @@ #------------------------------------------------------------------- -# WebGUI is Copyright 2001-2005 Plain Black Corporation. +# WebGUI is Copyright 2001-2006 Plain Black Corporation. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using @@ -12,17 +12,16 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; # ---- END DO NOT EDIT ---- use Test::More tests => 1; # increment this value for each test you create -initialize(); # this line is required +my $session = initialize(); # this line is required # put your tests here -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- @@ -34,10 +33,11 @@ sub initialize { 'configFile=s'=>\$configFile ); exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/help_compiled.t b/t/help_compiled.t index c37b44034..13ee2094d 100644 --- a/t/help_compiled.t +++ b/t/help_compiled.t @@ -12,7 +12,6 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use WebGUI::Operation::Help; # ---- END DO NOT EDIT ---- @@ -24,7 +23,7 @@ use WebGUI::Operation::Help; use Test::More; my $numTests = 0; -initialize(); # this line is required +my $session = initialize(); # this line is required my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList(); @@ -42,22 +41,23 @@ foreach my $helpSet (@helpFileSet) { # put your tests here -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/help_related.t b/t/help_related.t index 09fe69f86..71add664e 100644 --- a/t/help_related.t +++ b/t/help_related.t @@ -12,7 +12,6 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use WebGUI::Operation::Help; # ---- END DO NOT EDIT ---- @@ -24,7 +23,7 @@ use WebGUI::Operation::Help; use Test::More; my $numTests = 0; -initialize(); # this line is required +my $session = initialize(); # this line is required my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList(); @@ -64,22 +63,24 @@ foreach my $related (@relatedHelp) { # put your tests here -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } + diff --git a/t/help_toc.t b/t/help_toc.t index dfa969dfe..347bfe2c3 100644 --- a/t/help_toc.t +++ b/t/help_toc.t @@ -12,7 +12,6 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use WebGUI::Operation::Help; use WebGUI::International; use Data::Dumper; @@ -25,7 +24,7 @@ use File::Find; use Test::More; # increment this value for each test you create my $numTests = 0; -initialize(); # this line is required +my $session = initialize(); # this line is required my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList(); @@ -42,21 +41,22 @@ foreach my $fileSet (@helpFileSet) { ok(WebGUI::Operation::Help::_getHelpName($file), "Missing label for $file"); } -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/i18n.t b/t/i18n.t index 61fe915f4..7132e5b1b 100644 --- a/t/i18n.t +++ b/t/i18n.t @@ -13,7 +13,6 @@ use strict; use lib '../lib'; use Text::Balanced qw(extract_codeblock); use Getopt::Long; -use WebGUI::Session; use WebGUI::Operation::Help; use WebGUI::International; use Data::Dumper; @@ -26,7 +25,7 @@ use File::Find; use Test::More; # increment this value for each test you create my $numTests = 0; -initialize(); # this line is required +my $session = initialize(); # this line is required # put your tests here @@ -118,7 +117,7 @@ foreach my $i18n ( @objLabels ) { sprintf "label: %s->%s inside %s", @{ $i18n }{'namespace', 'label', 'file', }); } -cleanup(); # this line is required +cleanup($session); # this line is required sub label_finder_pm { next unless /\.pm$/; @@ -228,16 +227,17 @@ sub getSQLLabels { # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/mandatory_template_vars.t b/t/mandatory_template_vars.t index df1a34bcc..ce76440f4 100644 --- a/t/mandatory_template_vars.t +++ b/t/mandatory_template_vars.t @@ -12,7 +12,6 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use WebGUI::Asset; use File::Find; # ---- END DO NOT EDIT ---- @@ -178,7 +177,7 @@ my @tmplVarTable = ( use Test::More; # increment this value for each test you create my $numTests = 0; -initialize(); # this line is required +my $session = initialize(); # this line is required my @varTypes = qw( var loop if ); @@ -213,21 +212,22 @@ foreach my $tmpl ( @tmplVarTable ) { } } -cleanup(); # this line is required +cleanup($session); # this line is required # ---- DO NOT EDIT BELOW THIS LINE ----- -sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); +nitialize { + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); } diff --git a/t/syntaxCheck.t b/t/syntaxCheck.t index 353c0a1a0..6f3a57353 100644 --- a/t/syntaxCheck.t +++ b/t/syntaxCheck.t @@ -12,7 +12,6 @@ use strict; use lib '../lib'; use Getopt::Long; -use WebGUI::Session; use File::Find; # ---- END DO NOT EDIT ---- @@ -34,11 +33,11 @@ foreach my $package (@modules) { is($returnVal, 0, "syntax check for $package"); } -initialize(); # this line is required +my $session = initialize(); # this line is required # put your tests here -cleanup(); # this line is required +cleanup($session); # this line is required #---------------------------------------- sub getWebGUIModules { @@ -49,16 +48,17 @@ sub getWebGUIModules { # ---- DO NOT EDIT BELOW THIS LINE ----- sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - WebGUI::Session::open("..",$configFile); + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + my $session = WebGUI::Session->open("..",$configFile); } sub cleanup { - WebGUI::Session::close(); + my $session = shift; + $session->close(); }