From 831f5a36e1783d2b122143ec827b950caa687ce4 Mon Sep 17 00:00:00 2001 From: Christian Hansen Date: Tue, 17 Jan 2006 21:22:11 +0000 Subject: [PATCH] ported t/A-M to use WebGUI::Test --- t/Asset/Template.t | 28 +++++----------------------- t/Config.t | 4 +--- t/Form/GetName.t | 30 +++++------------------------- t/Form/ListEquiv.t | 31 +++++-------------------------- t/Help/compiled.t | 33 +++++---------------------------- t/Help/related.t | 34 +++++----------------------------- t/Help/toc.t | 30 +++++------------------------- t/Macro.t | 31 ++++++------------------------- t/Macro/AdminText.t | 12 +++++------- t/Macro/At_username.t | 30 +++++------------------------- t/Macro/GroupText.t | 30 +++++------------------------- t/Macro/SettingMacros.t | 30 +++++------------------------- t/_test.skeleton | 27 ++++----------------------- t/i18n/label.t | 32 ++++++-------------------------- 14 files changed, 67 insertions(+), 315 deletions(-) diff --git a/t/Asset/Template.t b/t/Asset/Template.t index 3d7cb31b1..939b58017 100644 --- a/t/Asset/Template.t +++ b/t/Asset/Template.t @@ -8,14 +8,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Session; use WebGUI::Asset::Template; use Test::More tests => 8; # increment this value for each test you create -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; my $list = WebGUI::Asset::Template->getList($session); ok(defined $list, "getList()"); @@ -37,23 +39,3 @@ ok($output =~ m/AAAAA/, "process() - variables"); ok($output =~ m/true/, "process() - conditionals"); ok($output =~ m/XYXYXYXYXY/, "process() - loops"); $template->purge; - -cleanup($session); # this line is required - - - -sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - my $session = WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/Config.t b/t/Config.t index b3a7cabab..321615b8c 100644 --- a/t/Config.t +++ b/t/Config.t @@ -8,10 +8,8 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- - -use strict; - use FindBin; +use strict; use lib "$FindBin::Bin/lib"; use WebGUI::Test; diff --git a/t/Form/GetName.t b/t/Form/GetName.t index 986fe2279..0b3e7d46c 100644 --- a/t/Form/GetName.t +++ b/t/Form/GetName.t @@ -8,15 +8,15 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Form::FieldType; use WebGUI::Form::DynamicField; use WebGUI::Session; use Data::Dumper; -# ---- END DO NOT EDIT ---- #The goal of this test is to verify that getName works with all Form types. #getName is now inherited by all Forms and pulls the internationalized ID @@ -28,7 +28,7 @@ use Test::More; # increment this value for each test you create my $numTests = 0; -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; # put your tests here @@ -55,23 +55,3 @@ foreach my $formType (@formTypes) { my $name = WebGUI::Form::DynamicField->getName($session); ok($name, 'did not inherit default form name'); - -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); - my $session = WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/Form/ListEquiv.t b/t/Form/ListEquiv.t index 86fb7a0c5..e5dc56b1b 100644 --- a/t/Form/ListEquiv.t +++ b/t/Form/ListEquiv.t @@ -8,15 +8,15 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Form::DynamicField; use WebGUI::Form::SelectList; use WebGUI::Session; use Data::Dumper; -# ---- END DO NOT EDIT ---- #The goal of this test is to verify that all SelectList type Forms #can be generated directly and via DynamicField @@ -33,7 +33,7 @@ use Test::More; # increment this value for each test you create # compare output of toHtmlWithWrapper from both objects my $numTests = 8*14; -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; my $i18n = WebGUI::International->new($session); @@ -422,24 +422,3 @@ is($direct->get('sortByValue'), 1, 'direct DatabaseLink was assigned sortByValue is($dynamic->toHtml, $direct->toHtml, "matching DatabaseLink output, toHtml"); is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching DatabaseLink output, toHtmlWithWrapper"); is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching DatabaseLink output, toHtmlAsHidden"); - - -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); - my $session = WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/Help/compiled.t b/t/Help/compiled.t index 9fd8148b4..b263a8ffc 100644 --- a/t/Help/compiled.t +++ b/t/Help/compiled.t @@ -8,13 +8,13 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Session; use WebGUI::Operation::Help; -# ---- END DO NOT EDIT ---- #The goal of this test is to verify that all entries in the lib/WebGUI/Help #directory compile. This test is necessary because WebGUI::Operation::Help @@ -24,7 +24,7 @@ use WebGUI::Operation::Help; use Test::More; my $numTests = 0; -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session); @@ -39,26 +39,3 @@ foreach my $helpSet (@helpFileSet) { my $help = WebGUI::Operation::Help::_load($session, $helpName); ok(keys %{ $help }, "$helpName compiled"); } - -# put your tests here - -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); - return WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/Help/related.t b/t/Help/related.t index e0181f009..22b1f5f8b 100644 --- a/t/Help/related.t +++ b/t/Help/related.t @@ -8,13 +8,13 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Session; use WebGUI::Operation::Help; -# ---- END DO NOT EDIT ---- #The goal of this test is to verify that all entries in the lib/WebGUI/Help #directory correctly resolve to other Help entries. The total number of @@ -24,7 +24,7 @@ use WebGUI::Operation::Help; use Test::More; my $numTests = 0; -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session); @@ -61,27 +61,3 @@ foreach my $related (@relatedHelp) { my ($topic, $entry, $parentTopic, $parentEntry) = @{ $related }{'namespace', 'tag', 'parentTopic', 'parentEntry'}; ok( exists $helpTable{$topic}{$entry}, "Help entry: $topic -> $entry from $parentTopic -> $parentEntry"); } - -# put your tests here - -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); - return WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - - diff --git a/t/Help/toc.t b/t/Help/toc.t index 333aa08c9..ce2011a47 100644 --- a/t/Help/toc.t +++ b/t/Help/toc.t @@ -8,15 +8,15 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Session; use WebGUI::Operation::Help; use WebGUI::International; use Data::Dumper; -# ---- END DO NOT EDIT ---- #The goal of this test is to make sure that all required labels #for the help system exist. @@ -24,7 +24,7 @@ use Data::Dumper; use Test::More; # increment this value for each test you create my $numTests = 0; -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session); @@ -40,23 +40,3 @@ foreach my $fileSet (@helpFileSet) { my $file = $fileSet->[1]; ok(WebGUI::Operation::Help::_getHelpName($session, $file), "Missing label for $file"); } - -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); - return WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/Macro.t b/t/Macro.t index 124bf1463..491dc9472 100644 --- a/t/Macro.t +++ b/t/Macro.t @@ -8,16 +8,17 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- use strict; -use lib '../lib'; -use Getopt::Long; + +use FindBin; +use lib "$FindBin::Bin/lib"; + +use WebGUI::Test; use WebGUI::Macro; use WebGUI::Session; use Data::Dumper; -# ---- END DO NOT EDIT ---- -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; #This test is to verify bugs with respect to Macros: # - [ 1364838 ] ^GroupText Macro cannot execute other macros @@ -113,23 +114,3 @@ foreach my $macro ( @settingMacros ) { is($value, $macroVal, sprintf "Testing %s", $macro->{macro}); } } - -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); - my $session = WebGUI::Session->open("..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/Macro/AdminText.t b/t/Macro/AdminText.t index c5b3c3863..5bce780e2 100644 --- a/t/Macro/AdminText.t +++ b/t/Macro/AdminText.t @@ -8,17 +8,15 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Macro; use WebGUI::Session; -use Data::Dumper; -# ---- END DO NOT EDIT ---- - -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; use Test::More; # increment this value for each test you create diff --git a/t/Macro/At_username.t b/t/Macro/At_username.t index 1a9e8a6aa..01ab9ad0b 100644 --- a/t/Macro/At_username.t +++ b/t/Macro/At_username.t @@ -8,16 +8,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Macro; use WebGUI::Session; use Data::Dumper; -# ---- END DO NOT EDIT ---- -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; use Test::More; # increment this value for each test you create @@ -38,23 +38,3 @@ $output = $macroText; $session->user({userId => 3}); WebGUI::Macro::process($session, \$output); is($output, 'Admin', 'username = Admin'); - -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); - my $session = WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/Macro/GroupText.t b/t/Macro/GroupText.t index fef493a8e..f7adc68db 100644 --- a/t/Macro/GroupText.t +++ b/t/Macro/GroupText.t @@ -8,16 +8,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Macro; use WebGUI::Session; use Data::Dumper; -# ---- END DO NOT EDIT ---- -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; use Test::More; # increment this value for each test you create @@ -38,23 +38,3 @@ $output = $macroText; $session->user({userId => 3}); WebGUI::Macro::process($session, \$output); is($output, 'local', 'GroupText, user in group'); - -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); - my $session = WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/Macro/SettingMacros.t b/t/Macro/SettingMacros.t index 9dae57657..d7c2c7f0a 100644 --- a/t/Macro/SettingMacros.t +++ b/t/Macro/SettingMacros.t @@ -8,16 +8,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Macro; use WebGUI::Session; use Data::Dumper; -# ---- END DO NOT EDIT ---- -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; #This test is to verify bugs with respect to Macros: # - [ 1364838 ] ^GroupText Macro cannot execute other macros @@ -77,23 +77,3 @@ foreach my $macro ( @settingMacros ) { is($value, $macroVal, sprintf "Testing %s", $macro->{macro}); } } - -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); - my $session = WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/_test.skeleton b/t/_test.skeleton index d3b7a7b99..654a5b027 100644 --- a/t/_test.skeleton +++ b/t/_test.skeleton @@ -8,32 +8,13 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- +use FindBin; use strict; -use lib '../lib'; -use Getopt::Long; +use lib "$FindBin::Bin/lib"; + use WebGUI::Session; use Test::More tests => 1; # increment this value for each test you create -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; # put your tests here - -cleanup($session); # this line is required - - - -sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - my $session = WebGUI::Session->open("..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} - diff --git a/t/i18n/label.t b/t/i18n/label.t index e9e7491ae..2dddcfcd0 100644 --- a/t/i18n/label.t +++ b/t/i18n/label.t @@ -8,17 +8,17 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -# ---- BEGIN DO NOT EDIT ---- +use FindBin; use strict; -use lib '../../lib'; -use Text::Balanced qw(extract_codeblock); -use Getopt::Long; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; use WebGUI::Operation::Help; use WebGUI::International; use WebGUI::Session; +use Text::Balanced qw(extract_codeblock); use Data::Dumper; use File::Find; -# ---- END DO NOT EDIT ---- #The goal of this test is to locate all of the international labels that it #can and verify that they exist in all loaded language models @@ -26,7 +26,7 @@ use File::Find; use Test::More; # increment this value for each test you create my $numTests = 0; -my $session = initialize(); # this line is required +my $session = WebGUI::Test->session; # put your tests here @@ -126,8 +126,6 @@ foreach my $label ( @objLabels ) { sprintf "label: %s->%s inside %s", @{ $label }{'namespace', 'label', 'file', }); } -cleanup($session); # this line is required - sub label_finder_pm { next unless /\.pm$/; open my $pmf, $_ @@ -233,21 +231,3 @@ sub getSQLLabels { } return @sqlLabels; } - -# ---- DO NOT EDIT BELOW THIS LINE ----- - -sub initialize { - $|=1; # disable output buffering - my $configFile; - GetOptions( - 'configFile=s'=>\$configFile - ); - exit 1 unless ($configFile); - return WebGUI::Session->open("../..",$configFile); -} - -sub cleanup { - my $session = shift; - $session->close(); -} -