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:
parent
6682be305b
commit
797f5f9363
4 changed files with 35 additions and 8 deletions
|
|
@ -20,7 +20,9 @@
|
|||
- fix: Styles were printing double head block headers.
|
||||
- fix: DB slaves were not being instanciated correctly. (thx Chris
|
||||
Palamara)
|
||||
|
||||
- fix: Paginator: addDataByArrayRef off by one error (perlDreamer Consulting
|
||||
LLC)
|
||||
|
||||
7.3.3
|
||||
- fix: Wiki Purge throws fatal
|
||||
- fix: Calendar now reports proper product ID on iCal feed
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ sub setDataByArrayRef {
|
|||
my $self = shift;
|
||||
my $rowRef = shift;
|
||||
$self->{_rowRef} = $rowRef;
|
||||
$self->{_totalRows} = $#{$rowRef};
|
||||
$self->{_totalRows} = $#{$rowRef} + 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use Tie::IxHash;
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More tests => 21; # increment this value for each test you create
|
||||
use Test::More tests => 22; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -74,6 +74,7 @@ SKIP: {
|
|||
# round
|
||||
is(WebGUI::Utility::round(47.133984233, 0), 47, 'round() - 0 significant digits');
|
||||
is(WebGUI::Utility::round(47.133984233, 3), 47.134, 'round() - multiple significant digits');
|
||||
is(WebGUI::Utility::round(47.6, 0), 48, 'round() - rounds up, too');
|
||||
|
||||
{
|
||||
# Just some basic tests for now.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue