Refactored pagination into search method, Sweet syntax is now in Compat
[dbsrgits/DBIx-Class.git] / t / 15limit.t
CommitLineData
aeaf3ce2 1use strict;
2use Test::More;
3
4BEGIN {
5 eval "use DBD::SQLite";
6 plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 5);
7}
8
9use lib qw(t/lib);
10
11use_ok('DBICTest');
12
13# test LIMIT
14my $it = DBICTest::CD->search( {},
15 { rows => 3,
16 order_by => 'title' }
17);
18is( $it->count, 3, "count ok" );
19is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
20$it->next;
21$it->next;
22is( $it->next, undef, "next past end of resultset ok" );
23
24# test OFFSET
25my @cds = DBICTest::CD->search( {},
26 { rows => 2,
27 offset => 2,
28 order_by => 'year' }
29);
30is( $cds[0]->title, "Spoonful of bees", "offset ok" );