merging back with HEAD
This commit is contained in:
parent
cd30eb437c
commit
f8b11b5423
42 changed files with 1201 additions and 182 deletions
|
|
@ -21,7 +21,7 @@ my $session = WebGUI::Test->session;
|
|||
|
||||
my $numTests = 1; ##For conditional load check
|
||||
my $langTests = 4; ##For language look-up tests
|
||||
$numTests += 11 + $langTests;
|
||||
$numTests += 12 + $langTests;
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
|
|
@ -76,6 +76,11 @@ SKIP: {
|
|||
undef,
|
||||
'Language check: key from non-existant file returns an empty string'
|
||||
);
|
||||
is(
|
||||
$i18n->get('key with spaces in it','WebGUI','PigLatin'),
|
||||
'Key Contained Spaces',
|
||||
'keys with spaces work'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
21
t/Macro.t
21
t/Macro.t
|
|
@ -43,7 +43,7 @@ foreach my $macro (qw/
|
|||
}
|
||||
$session->config->addToHash('macros', "Ex'tras", "Extras");
|
||||
|
||||
plan tests => 33;
|
||||
plan tests => 35;
|
||||
|
||||
my $macroText = "CompanyName: ^c;";
|
||||
my $companyName = $session->setting->get('companyName');
|
||||
|
|
@ -200,6 +200,23 @@ is(
|
|||
"Carriage returns pass through as needed."
|
||||
);
|
||||
|
||||
my $macroText = qq|^ReverseParams(1,'Single quoted parameters work properly',2);|;
|
||||
WebGUI::Macro::process($session, \$macroText),
|
||||
is(
|
||||
$macroText,
|
||||
"2Single quoted parameters work properly1",
|
||||
"Single quoted parameters work properly."
|
||||
);
|
||||
|
||||
my $macroText = qq|^ReverseParams(1,'Escaped single\\' quotes work',2);|;
|
||||
WebGUI::Macro::process($session, \$macroText),
|
||||
is(
|
||||
$macroText,
|
||||
"2Escaped single' quotes work1",
|
||||
"Escaped single quotes work."
|
||||
);
|
||||
|
||||
|
||||
tie my %quotingEdges, 'Tie::IxHash';
|
||||
%quotingEdges = (
|
||||
'^VisualMacro(text);' => '@MacroCall[`text`]:',
|
||||
|
|
@ -217,7 +234,7 @@ while (my ($inText, $outText) = each %quotingEdges) {
|
|||
is(
|
||||
$procText,
|
||||
$outText,
|
||||
"Nesting edge case: $inText",
|
||||
"Quoting/Nesting edge case: $inText",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
128
t/Paginator.t
128
t/Paginator.t
|
|
@ -20,15 +20,17 @@ use WebGUI::Paginator;
|
|||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use POSIX qw(ceil);
|
||||
use Storable qw/dclone/;
|
||||
use Data::Dumper;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
plan tests => 26; # increment this value for each test you create
|
||||
|
||||
my $startingRowNum = 0;
|
||||
my $endingRowNum = 99;
|
||||
my @paginatingData = ($startingRowNum..$endingRowNum);
|
||||
|
||||
plan tests => 15; # increment this value for each test you create
|
||||
|
||||
my $rowCount = $endingRowNum - $startingRowNum + 1;
|
||||
my $NumberOfPages = ceil($rowCount/25); ##Default page size=25
|
||||
my $url = "/home";
|
||||
|
|
@ -47,7 +49,26 @@ cmp_bag([0..24], $p->getPageData(1), 'page 1 data correct');
|
|||
cmp_bag([25..49], $p->getPageData(2), 'page 2 data correct');
|
||||
cmp_bag([ ], $p->getPageData(5), 'page 5 data correct');
|
||||
|
||||
# Test getPageLinks
|
||||
########################################################################
|
||||
#
|
||||
# getPageNumber, setPageNumber
|
||||
#
|
||||
########################################################################
|
||||
|
||||
my $p2 = WebGUI::Paginator->new($session, '/work');
|
||||
|
||||
is($p2->getPageNumber, 1, 'pageNumber set to 1 at object creation by default');
|
||||
is($p2->setPageNumber(0), 0, 'setPageNumber returns the page number set');
|
||||
is($p2->getPageNumber, 0, 'pageNumber set by setPageNumber');
|
||||
is($p2->setPageNumber(3), 3, 'setPageNumber returns the page number set');
|
||||
is($p2->getPageNumber, 3, 'pageNumber set by setPageNumber');
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# getPageLinks
|
||||
#
|
||||
########################################################################
|
||||
|
||||
my $expectedPages;
|
||||
$expectedPages = [ map { +{
|
||||
'pagination.text' => ( $_ + 1 ),
|
||||
|
|
@ -63,7 +84,6 @@ cmp_deeply(
|
|||
'page links correct',
|
||||
);
|
||||
|
||||
|
||||
$startingRowNum = 0;
|
||||
$endingRowNum = 100;
|
||||
@paginatingData = ($startingRowNum..$endingRowNum);
|
||||
|
|
@ -78,7 +98,7 @@ $p->setDataByArrayRef(\@paginatingData);
|
|||
is($p->getRowCount, $rowCount, '(101) paginator returns correct number of rows');
|
||||
is($p->getNumberOfPages, $NumberOfPages, '(101) paginator returns right number of pages (default setting)');
|
||||
|
||||
my $page1Data = $p->getPageData(1);
|
||||
$page1Data = $p->getPageData(1);
|
||||
cmp_bag([0..24], $p->getPageData(1), '(101) page 1 data correct');
|
||||
cmp_bag([25..49], $p->getPageData(2), '(101) page 2 data correct');
|
||||
cmp_bag([100 ], $p->getPageData(5), '(101) page 5 data correct');
|
||||
|
|
@ -95,11 +115,105 @@ $expectedPages = [ map { +{
|
|||
|
||||
$expectedPages->[0]->{'pagination.activePage'} = 'true';
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# getPageLinks with limits
|
||||
#
|
||||
########################################################################
|
||||
|
||||
# Test getPageLinks
|
||||
cmp_deeply(
|
||||
($p->getPageLinks)[0],
|
||||
$expectedPages,
|
||||
'page links correct',
|
||||
'set of 5 pages looks right',
|
||||
);
|
||||
|
||||
$startingRowNum = 0;
|
||||
$endingRowNum = 199;
|
||||
@paginatingData = ($startingRowNum..$endingRowNum);
|
||||
|
||||
|
||||
$p = WebGUI::Paginator->new($session, '/home', 10);
|
||||
|
||||
$rowCount = $endingRowNum - $startingRowNum + 1;
|
||||
$NumberOfPages = ceil($rowCount/10); ##Default page size=25
|
||||
|
||||
$p->setDataByArrayRef(\@paginatingData);
|
||||
|
||||
$expectedPages = [ map { +{
|
||||
'pagination.text' => ( $_ + 1 ),
|
||||
'pagination.range' => ( 10 * $_ + 1 ) . "-" . ( $_ * 10 + 10 <= $endingRowNum + 1 ? $_ * 10 + 10 : $endingRowNum + 1 ), # First row number - Last row number
|
||||
'pagination.url' => ( '/home?pn=' . ( $_ + 1 ) ), # Current page has no URL
|
||||
} } (0..$NumberOfPages-1) ];
|
||||
|
||||
|
||||
my $copy;
|
||||
$copy = dclone($expectedPages);
|
||||
$copy->[0]->{'pagination.activePage'} = 'true';
|
||||
$copy->[0]->{'pagination.url'} = '';
|
||||
|
||||
cmp_deeply(
|
||||
($p->getPageLinks)[0],
|
||||
$copy,
|
||||
'set of 20 pages looks right',
|
||||
);
|
||||
|
||||
my @pageWindow;
|
||||
$copy = dclone($expectedPages);
|
||||
$copy->[0]->{'pagination.activePage'} = 'true';
|
||||
$copy->[0]->{'pagination.url'} = '';
|
||||
@pageWindow = @{ $copy }[0..9];
|
||||
|
||||
cmp_deeply(
|
||||
($p->getPageLinks(10))[0],
|
||||
\@pageWindow,
|
||||
'set of first 10 pages selected correctly',
|
||||
);
|
||||
|
||||
$p->setPageNumber(10);
|
||||
my $copy = dclone($expectedPages);
|
||||
$copy->[9]->{'pagination.activePage'} = 'true';
|
||||
$copy->[9]->{'pagination.url'} = '';
|
||||
@pageWindow = @{ $copy }[4..13];
|
||||
|
||||
cmp_deeply(
|
||||
($p->getPageLinks(10))[0],
|
||||
\@pageWindow,
|
||||
'set of middle 10 pages @10 selected correctly',
|
||||
);
|
||||
|
||||
$p->setPageNumber(3);
|
||||
my $copy = dclone($expectedPages);
|
||||
$copy->[2]->{'pagination.activePage'} = 'true';
|
||||
$copy->[2]->{'pagination.url'} = '';
|
||||
delete $copy->[0]->{'pagination.activePage'};
|
||||
@pageWindow = @{ $copy }[0..9];
|
||||
|
||||
cmp_deeply(
|
||||
($p->getPageLinks(10))[0],
|
||||
\@pageWindow,
|
||||
'set of 10 pages selected correctly, with off edge page number (3/20)',
|
||||
);
|
||||
|
||||
$p->setPageNumber(17);
|
||||
my $copy = dclone($expectedPages);
|
||||
$copy->[16]->{'pagination.activePage'} = 'true';
|
||||
$copy->[16]->{'pagination.url'} = '';
|
||||
@pageWindow = @{ $copy }[10..19];
|
||||
|
||||
cmp_deeply(
|
||||
($p->getPageLinks(10))[0],
|
||||
\@pageWindow,
|
||||
'set of last 10 pages selected correctly, (17/20)',
|
||||
);
|
||||
|
||||
$p->setPageNumber(20);
|
||||
my $copy = dclone($expectedPages);
|
||||
$copy->[19]->{'pagination.activePage'} = 'true';
|
||||
$copy->[19]->{'pagination.url'} = '';
|
||||
@pageWindow = @{ $copy }[10..19];
|
||||
|
||||
cmp_deeply(
|
||||
($p->getPageLinks(10))[0],
|
||||
\@pageWindow,
|
||||
'set of last 10 pages selected correctly, (20/20)',
|
||||
);
|
||||
|
|
|
|||
42
t/ProfileCategory.t
Normal file
42
t/ProfileCategory.t
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/lib";
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
use WebGUI::ProfileCategory;
|
||||
|
||||
use Test::More tests => 1; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
###################################################################
|
||||
#
|
||||
# getCategories
|
||||
#
|
||||
###################################################################
|
||||
|
||||
my $categories = WebGUI::ProfileCategory->getCategories($session);
|
||||
|
||||
my @labels = map { $_->getLabel } @{ $categories };
|
||||
|
||||
$categories->[0]->set({ visible => 0});
|
||||
|
||||
my $newCategories = WebGUI::ProfileCategory->getCategories($session);
|
||||
my @newLabels = map { $_->getLabel } @{ $newCategories };
|
||||
|
||||
cmp_bag(\@newLabels, \@labels, 'Setting a category to not be visible does not change its availability through getCategories, with no options');
|
||||
|
||||
END {
|
||||
}
|
||||
206
t/Session/CheckClient.t
Normal file
206
t/Session/CheckClient.t
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# this test can take two parameters
|
||||
# first is an xml file, second indicates
|
||||
# the percentage of items to test.
|
||||
# the xml file can be downloaded from
|
||||
# http://www.user-agents.org/
|
||||
# the percent will default to 25 and
|
||||
# should be passed as a whole number
|
||||
# so 100 will test all items, 75 will
|
||||
# test 75% or 3 out of four items
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/lib";
|
||||
use lib '/data/WebGUI/t/lib';
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
# this test is for code in the WebGUI::Session::Env Module
|
||||
|
||||
my @testArray = (
|
||||
{
|
||||
agent => "",
|
||||
output => 1,
|
||||
comment => "blank user agent"
|
||||
},
|
||||
{
|
||||
agent => "<a href='http://www.unchaos.com/'> UnChaos </a> From Chaos To Order Hybrid Web Search Engine.(vadim_goncharunchaos.com)",
|
||||
output => 1,
|
||||
comment => "UnChaos hybrid search engine"
|
||||
},
|
||||
{
|
||||
agent => "(DreamPassport/3.0; isao/MyDiGiRabi)",
|
||||
output => 0,
|
||||
comment => "DreamCast DreamPassport browser"
|
||||
},
|
||||
{
|
||||
agent => "Privoxy web proxy", # I think proxy's whould be considered browsers?
|
||||
output => 0,
|
||||
comment => "s.also Privoxy/3.0 (Anonymous)"
|
||||
},
|
||||
{
|
||||
agent => "*/Nutch-0.9-dev",
|
||||
address => "123.113.184.232",
|
||||
output => 1,
|
||||
comment => "Unknown Yahoo robot"
|
||||
},
|
||||
{
|
||||
agent => "123spider-Bot (Version: 1.02, powered by www.123spider.de",
|
||||
output => 1,
|
||||
comment => "123spider.de (Germany) web directory link checking"
|
||||
},
|
||||
{
|
||||
agent => "1st ZipCommander (Net) - http://www.zipcommander.com/",
|
||||
output => 0,
|
||||
comment => "1st ZipCommander Net - IE based browser"
|
||||
},
|
||||
{
|
||||
agent => "2Bone_LinkChecker/1.0 libwww-perl/5.64",
|
||||
output => 1,
|
||||
comment => "2Bone online link checker"
|
||||
},
|
||||
{
|
||||
agent => "A-Online Search",
|
||||
output => 1,
|
||||
comment => "A-Online.at robot - now Jet2Web Search"
|
||||
},
|
||||
{
|
||||
agent => "Advanced Browser (http://www.avantbrowser.com)",
|
||||
output => 0,
|
||||
comment => "Avant Browser - IE based browser"
|
||||
},
|
||||
{
|
||||
agent => "AESOP_com_SpiderMan",
|
||||
output => 1,
|
||||
comment => "Aesop robot"
|
||||
},
|
||||
{
|
||||
agent => "Mozilla/5.0 (compatible; SpurlBot/0.2)",
|
||||
output => 1,
|
||||
comment => "Spurl.net bookmark service & search engine (84.40.30.xxx)"
|
||||
},
|
||||
{
|
||||
agent => "Mozilla/5.0 (compatible;MAINSEEK_BOT)",
|
||||
output => 1,
|
||||
comment => "Mozilla/5.0 (compatible;MAINSEEK_BOT)"
|
||||
},
|
||||
{
|
||||
agent => "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) Gecko/20021219 Chimera/0.6",
|
||||
output => 0,
|
||||
comment => "Chimera browser (Mozilla/Gecko engine) - now Camino Mac PowerPC"
|
||||
},
|
||||
{
|
||||
agent => "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/xx (KHTML like Gecko) OmniWeb/v5xx.xx",
|
||||
output => 0,
|
||||
comment => "OmniWeb 5.x.x Mac OS X browser"
|
||||
},
|
||||
{
|
||||
agent => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:x.x.x) Gecko/20041107 Firefox/x.x",
|
||||
output => 0,
|
||||
comment => "Firefox browser (Mozilla/Gecko engine) - ex Firebird WinXP"
|
||||
},
|
||||
{
|
||||
agent => "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) VoilaBot BETA 1.2 (support.voilabotorange-ftgroup.com)",
|
||||
output => 1,
|
||||
comment => "Voila.fr robot"
|
||||
},
|
||||
{
|
||||
agent => "Mozilla/5.0 (Windows;) NimbleCrawler 1.12 obeys UserAgent NimbleCrawler For problems contact: crawlerhealth",
|
||||
output => 1,
|
||||
comment => "Healthline health related search robot (72.5.115.xx)"
|
||||
},
|
||||
{
|
||||
agent => "Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8.0.2) Gecko/20060309 SeaMonkey/1.0",
|
||||
output => 0,
|
||||
comment => "SeaMonkey browser suite (ex Mozilla) on Linux"
|
||||
},
|
||||
{
|
||||
agent => "Mozilla/5.0 [en] (compatible; Gulper Web Bot 0.2.4 www.ecsl.cs.sunysb.edu/~maxim/cgi-bin/Link/GulperBot)",
|
||||
output => 1,
|
||||
comment => "Yuntis : Collaborative Web Resource Categorization and Ranking Project robot"
|
||||
},
|
||||
);
|
||||
|
||||
sub transType {
|
||||
return 0 if $_[0] =~ /(B|P)/; # browser or proxy
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub getAddress { # There are precious few that have an IP that can be gotten out of the XML so I decided to skip this.
|
||||
my $x = '69.42.78.32';
|
||||
#if( $_[0]{Comment} =~ /\d\.\d\.\d/ ) {
|
||||
# print $_[0]{Comment},"\t|\t",$_[0]{Description},"\n";
|
||||
# $x = $_[0]{Comment};
|
||||
# $x =~ s/x/2/;
|
||||
#}
|
||||
return $x;
|
||||
}
|
||||
|
||||
sub testCount {
|
||||
|
||||
if( @ARGV ) {
|
||||
if( $ARGV[0] =~ /\.xml$/ && -r $ARGV[0] ) {
|
||||
my $infile = shift @ARGV ;
|
||||
my $percent = shift @ARGV || 25;
|
||||
use XML::Simple;
|
||||
my $xml = new XML::Simple;
|
||||
my $data = $xml->XMLin($infile);
|
||||
# use Data::Dumper;
|
||||
# print Dumper $data;
|
||||
@testArray = ();
|
||||
my $c = 1;
|
||||
my $div = 20;
|
||||
my $n = $div * $percent / 100;
|
||||
foreach my $set (@{$data->{'user-agent'}}) {
|
||||
$c = 1 if $c > $div;
|
||||
if( $c <= $n ) {
|
||||
push @testArray, {
|
||||
agent => $set->{String},
|
||||
output => transType($set->{Type}),
|
||||
type => $set->{Type},
|
||||
comment => $set->{Description},
|
||||
# comment => $set->{String}, # this is handy for fine tuning the code: it shows the string that failed...
|
||||
address => getAddress($set),
|
||||
};
|
||||
}
|
||||
$c ++;
|
||||
}
|
||||
# use Data::Dumper;
|
||||
# print Dumper \@testArray;
|
||||
}
|
||||
}
|
||||
return scalar(@testArray);
|
||||
}
|
||||
|
||||
|
||||
plan tests => testCount() ;
|
||||
|
||||
my $output;
|
||||
foreach my $testSet (@testArray) {
|
||||
$output = FAKE_ENV->new( $testSet->{agent},
|
||||
$testSet->{address} || '69.42.78.32')
|
||||
->requestNotViewed();
|
||||
is($output, $testSet->{output}, $testSet->{comment});
|
||||
}
|
||||
|
||||
{ # this is a local fake of the session, used for testing only
|
||||
package FAKE_ENV;
|
||||
use base 'WebGUI::Session::Env';
|
||||
sub new { shift; return bless { _env => { HTTP_USER_AGENT => $_[0], REMOTE_ADDR => $_[1] } }, __PACKAGE__; }
|
||||
}
|
||||
|
||||
|
|
@ -95,3 +95,8 @@ foreach my $label ( @questionableTemplates ) {
|
|||
sprintf "Empty template: %s, id: %s, url: %s", @{ $label }{qw/title id url/}
|
||||
);
|
||||
}
|
||||
|
||||
END {
|
||||
defined $session &&
|
||||
$session->config->set('macros', $originalMacros);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ our $I18N = {
|
|||
lastUpdated => 1141963573,
|
||||
context => q|Test key for International macro test. DO NOT TRANSLATE|,
|
||||
},
|
||||
|
||||
'key with spaces in it' => {
|
||||
message => q|Key Contained Spaces|,
|
||||
lastUpdated => 0,
|
||||
}
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue