Ported all tests

This commit is contained in:
Christian Hansen 2006-01-17 22:06:21 +00:00
parent 734484f48e
commit 83d59837fd
15 changed files with 84 additions and 318 deletions

View file

@ -8,9 +8,8 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
use strict;
use FindBin; use FindBin;
use strict;
use lib "$FindBin::Bin/lib"; use lib "$FindBin::Bin/lib";
use WebGUI::Test; use WebGUI::Test;

17
t/POD.t
View file

@ -8,20 +8,21 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../lib'; use lib "$FindBin::Bin/lib";
use Getopt::Long;
use WebGUI::Test;
use Test::More;
use Pod::Coverage; use Pod::Coverage;
use File::Find; use File::Find;
# ---- END DO NOT EDIT ---- use File::Spec;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
use Test::More;
my @modules = (); my @modules = ();
find(\&countModules, "../lib/WebGUI"); find(\&countModules, File::Spec->catdir( WebGUI::Test->lib, 'WebGUI' ) );
my $moduleCount = scalar(@modules); my $moduleCount = scalar(@modules);
diag("Planning on running $moduleCount tests\n"); diag("Planning on running $moduleCount tests\n");
plan tests => $moduleCount; plan tests => $moduleCount;
@ -37,7 +38,7 @@ sub countModules {
return if $filename =~ m/WebGUI\/i18n/; return if $filename =~ m/WebGUI\/i18n/;
return if $filename =~ m/WebGUI\/Help/; return if $filename =~ m/WebGUI\/Help/;
my $package = $filename; my $package = $filename;
$package =~ s/^\.\.\/lib\/(.*)\.pm$/$1/; $package =~ s/^.*(WebGUI.*)\.pm$/$1/;
$package =~ s/\//::/g; $package =~ s/\//::/g;
push(@modules,$package); push(@modules,$package);
} }

32
t/SQL.t
View file

@ -8,17 +8,17 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../lib'; use lib "$FindBin::Bin/lib";
use Getopt::Long;
use WebGUI::Test;
use WebGUI::Session; use WebGUI::Session;
use Data::Dumper; use Data::Dumper;
# ---- END DO NOT EDIT ----
use Test::More tests => 33; # increment this value for each test you create use Test::More tests => 33; # increment this value for each test you create
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
# read # read
ok(my $sth = $session->db->read("select * from settings"), "read()"); ok(my $sth = $session->db->read("select * from settings"), "read()");
@ -145,25 +145,3 @@ is($setRowResult, 47, "setRow() - set data");
my $getRow = $session->db->getRow("incrementer","incrementerId",$setRowId); my $getRow = $session->db->getRow("incrementer","incrementerId",$setRowId);
is($getRow->{nextValue}, 47, "getRow()"); is($getRow->{nextValue}, 47, "getRow()");
$session->db->write("delete from incrementer where incrementerId=".$session->db->quote($setRowId)); $session->db->write("delete from incrementer where incrementerId=".$session->db->quote($setRowId));
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();
}

View file

@ -8,15 +8,16 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../../lib'; use lib "$FindBin::Bin/../lib";
use Getopt::Long;
use WebGUI::Test;
use WebGUI::Session; use WebGUI::Session;
# ---- END DO NOT EDIT ----
use Test::More tests => 22; # increment this value for each test you create use Test::More tests => 22; # increment this value for each test you create
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
my $wgbday = 997966800; my $wgbday = 997966800;
ok($session->datetime->addToDate($wgbday,1,2,3) >= $wgbday+1*60*60*24*365+2*60*60*24*28+3*60*60*24, "addToDate()"); ok($session->datetime->addToDate($wgbday,1,2,3) >= $wgbday+1*60*60*24*365+2*60*60*24*28+3*60*60*24, "addToDate()");
@ -46,20 +47,3 @@ is($session->datetime->secondsToTime(60*60*8),"08:00:00", "secondsToTime()");
is($session->datetime->setToEpoch("2001-08-16 08:00:00"), $wgbday, "setToEpoch()"); is($session->datetime->setToEpoch("2001-08-16 08:00:00"), $wgbday, "setToEpoch()");
ok($session->datetime->time() > $wgbday,"time()"); ok($session->datetime->time() > $wgbday,"time()");
is($session->datetime->timeToSeconds("08:00:00"), 60*60*8, "timeToSeconds()"); is($session->datetime->timeToSeconds("08:00:00"), 60*60*8, "timeToSeconds()");
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();
}

View file

@ -8,37 +8,15 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../../lib'; use lib "$FindBin::Bin/../lib";
use Getopt::Long;
use WebGUI::Session;
# ---- END DO NOT EDIT ----
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 1; # increment this value for each test you create 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;
ok($session->env->get("PATH") ne "", "get()"); ok($session->env->get("PATH") ne "", "get()");
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();
}

View file

@ -8,18 +8,17 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../../lib'; use lib "$FindBin::Bin/../lib";
use Getopt::Long;
use WebGUI::Session;
# ---- END DO NOT EDIT ----
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 2; # increment this value for each test you create use Test::More tests => 2; # increment this value for each test you create
use WebGUI::Utility; use WebGUI::Utility;
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
# generate # generate
my $generateId = $session->id->generate(); my $generateId = $session->id->generate();
@ -33,24 +32,3 @@ for (1..2000) {
push(@uniqueIds,$id); push(@uniqueIds,$id);
} }
ok($isUnique, "generate() - unique"); ok($isUnique, "generate() - unique");
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();
}

View file

@ -8,38 +8,16 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../../lib'; use lib "$FindBin::Bin/../lib";
use Getopt::Long;
use WebGUI::Session;
# ---- END DO NOT EDIT ----
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 2; # increment this value for each test you create use Test::More tests => 2; # increment this value for each test you create
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
ok($session->os->get("name") ne "", "get(name)"); ok($session->os->get("name") ne "", "get(name)");
ok($session->os->get("type") eq "Windowsish" || $session->os->get("type") eq "Linuxish", "get(type)"); ok($session->os->get("type") eq "Windowsish" || $session->os->get("type") eq "Linuxish", "get(type)");
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();
}

View file

@ -8,15 +8,16 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../../lib'; use lib "$FindBin::Bin/../lib";
use Getopt::Long;
use WebGUI::Test;
use WebGUI::Session; use WebGUI::Session;
# ---- END DO NOT EDIT ----
use Test::More tests => 4; # increment this value for each test you create use Test::More tests => 4; # increment this value for each test you create
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
$session->setting->add("test","XXX"); $session->setting->add("test","XXX");
my ($value) = $session->db->quickArray("select value from settings where name='test'"); my ($value) = $session->db->quickArray("select value from settings where name='test'");
@ -28,20 +29,3 @@ is($value, 'YYY', "set()");
$session->setting->remove("test"); $session->setting->remove("test");
my ($value) = $session->db->quickArray("select value from settings where name='test'"); my ($value) = $session->db->quickArray("select value from settings where name='test'");
is($value, undef, "delete()"); is($value, undef, "delete()");
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();
}

View file

@ -8,15 +8,16 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../../lib'; use lib "$FindBin::Bin/../lib";
use Getopt::Long;
use WebGUI::Test;
use WebGUI::Session; use WebGUI::Session;
# ---- END DO NOT EDIT ----
use Test::More tests => 22; # increment this value for each test you create use Test::More tests => 22; # increment this value for each test you create
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
# put your tests here # put your tests here
@ -36,20 +37,3 @@ $stow->delete("Test1");
is($stow->get("Test1"), undef, "delete()"); is($stow->get("Test1"), undef, "delete()");
$stow->deleteAll; $stow->deleteAll;
is($stow->get("Test2"), undef, "deleteAll()"); is($stow->get("Test2"), undef, "deleteAll()");
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();
}

View file

@ -8,15 +8,16 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../../lib'; use lib "$FindBin::Bin/../lib";
use Getopt::Long;
use WebGUI::Test;
use WebGUI::Session; use WebGUI::Session;
# ---- END DO NOT EDIT ----
use Test::More tests => 6; # increment this value for each test you create use Test::More tests => 6; # increment this value for each test you create
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
ok($session->var->getId ne "", "getId()"); ok($session->var->getId ne "", "getId()");
@ -30,21 +31,3 @@ my $id = $session->var->getId;
$session->var->end; $session->var->end;
my ($count) = $session->db->quickArray("select count(*) from userSession where sessionId=".$session->db->quote($id)); my ($count) = $session->db->quickArray("select count(*) from userSession where sessionId=".$session->db->quote($id));
ok($count == 0,"end()"); ok($count == 0,"end()");
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();
}

View file

@ -8,17 +8,18 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../lib'; use lib "$FindBin::Bin/lib";
use Getopt::Long;
use WebGUI::Test;
use WebGUI::Session; use WebGUI::Session;
use WebGUI::Utility; use WebGUI::Utility;
# ---- END DO NOT EDIT ----
use WebGUI::User; use WebGUI::User;
use Test::More tests => 33; # increment this value for each test you create use Test::More tests => 33; # increment this value for each test you create
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
my $user; my $user;
my $lastUpdate; my $lastUpdate;
@ -148,24 +149,3 @@ SKIP: {
skip("uncache() -- Don't know how to test uncache()",1); skip("uncache() -- Don't know how to test uncache()",1);
ok(undef, "uncache"); ok(undef, "uncache");
} }
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();
}

View file

@ -9,17 +9,16 @@
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../lib'; use lib "$FindBin::Bin/lib";
use Getopt::Long;
use WebGUI::Test;
use WebGUI::Session; use WebGUI::Session;
# ---- END DO NOT EDIT ----
use Test::More tests => 21; # increment this value for each test you create use Test::More tests => 21; # increment this value for each test you create
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
# commify # commify
is(WebGUI::Utility::commify(10), "10", 'commify() - no comma needed'); is(WebGUI::Utility::commify(10), "10", 'commify() - no comma needed');
@ -86,25 +85,3 @@ SKIP: {
skip("Don't know how to test sortHashDescending.",1); skip("Don't know how to test sortHashDescending.",1);
ok(undef, 'sortHashDescending()'); ok(undef, 'sortHashDescending()');
} }
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();
}

View file

@ -69,6 +69,10 @@ sub config {
return $SESSION->config; return $SESSION->config;
} }
sub lib {
return $WEBGUI_LIB;
}
sub session { sub session {
return $SESSION; return $SESSION;
} }

View file

@ -8,14 +8,14 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../lib'; use lib "$FindBin::Bin/lib";
use Getopt::Long;
use WebGUI::Test;
use WebGUI::Asset; use WebGUI::Asset;
use WebGUI::Session; use WebGUI::Session;
use File::Find; use File::Find;
# ---- END DO NOT EDIT ----
#The goal of this test is to check that mandatory template #The goal of this test is to check that mandatory template
#variables exist in their templates. #variables exist in their templates.
@ -178,7 +178,7 @@ my @tmplVarTable = (
use Test::More; # increment this value for each test you create use Test::More; # increment this value for each test you create
my $numTests = 0; my $numTests = 0;
my $session = initialize(); # this line is required my $session = WebGUI::Test->session;
my @varTypes = qw( var loop if ); my @varTypes = qw( var loop if );
@ -213,22 +213,4 @@ foreach my $tmpl ( @tmplVarTable ) {
} }
} }
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();
}

View file

@ -8,20 +8,21 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ---- use FindBin;
use strict; use strict;
use lib '../lib'; use lib "$FindBin::Bin/lib";
use Getopt::Long;
use WebGUI::Test;
use File::Find; use File::Find;
use WebGUI::Session; use WebGUI::Session;
# ---- END DO NOT EDIT ---- use Test::More;
plan skip_all => 'set TEST_SYNTAX to enable this test' unless $ENV{TEST_SYNTAX};
use Test::More; # increment this value for each test you create
my @modules; my @modules;
my $wgLib = "../lib/"; my $wgLib = WebGUI::Test->lib;
diag("Checking modules in $wgLib"); diag("Checking modules in $wgLib");
File::Find::find(\&getWebGUIModules, $wgLib); File::Find::find( \&getWebGUIModules, $wgLib);
my $numTests = scalar @modules; my $numTests = scalar @modules;
@ -30,36 +31,11 @@ plan tests => $numTests;
diag("Planning on $numTests tests"); diag("Planning on $numTests tests");
foreach my $package (@modules) { foreach my $package (@modules) {
my $returnVal = system("export PERL5LIB=$wgLib; perl -wc $package"); my $returnVal = system("$^X -I$wgLib -wc $package");
is($returnVal, 0, "syntax check for $package"); is($returnVal, 0, "syntax check for $package");
} }
my $session = initialize(); # this line is required
# put your tests here
cleanup($session); # this line is required
#---------------------------------------- #----------------------------------------
sub getWebGUIModules { sub getWebGUIModules {
push(@modules,$File::Find::name) if /\.pm$/; push( @modules, $File::Find::name ) if /\.pm$/;
} }
# ---- 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();
}