Add a test to Utility.t to make sure that WebGUI::Utility::round also rounds up.

Add Paginator tests for paginating array data.
Fix an off by 1 error in the Paginator when handling array data.  SQL data is fine.
This commit is contained in:
Colin Kuskie 2007-01-10 03:03:31 +00:00
parent 6682be305b
commit 797f5f9363
4 changed files with 35 additions and 8 deletions

View file

@ -17,14 +17,38 @@ use WebGUI::Session;
use WebGUI::Utility;
use WebGUI::Paginator;
use Test::More tests => 1; # increment this value for each test you create
use Test::More; # increment this value for each test you create
use Test::Deep;
use POSIX qw(ceil);
my $session = WebGUI::Test->session;
my $p = WebGUI::Paginator->new($session, '/home', '', '', 1);
my $startingRowNum = 0;
my $endingRowNum = 100;
$p->setDataByQuery('select * from settings');
my @paginatingData = $startingRowNum .. $endingRowNum;
my $settingspage = $p->getPageData;
plan tests => 6; # increment this value for each test you create
is(1,1,"a test");
my $rowCount = $endingRowNum - $startingRowNum + 1;
my $NumberOfPages = ceil($rowCount/25); ##Default page size=25
my $p = WebGUI::Paginator->new($session, '/home');
isa_ok($p, 'WebGUI::Paginator', 'paginator object returned');
$p->setDataByArrayRef(\@paginatingData);
is($p->getRowCount, $rowCount, 'all data returned by paginator');
is($p->getNumberOfPages, $NumberOfPages, 'paginator returns right number of pages (default setting)');
my $page1Data = $p->getPageData(1);
cmp_bag([0..24], $page1Data, 'page 1 data correct');
use Data::Dumper;
my $page2Data = $p->getPageData(2);
cmp_bag([25..49], $page2Data, 'page 2 data correct');
my $page5Data = $p->getPageData(5);
cmp_bag([100], $page5Data, 'page 5 data correct');