Added quote char test, supported quoting in S::A subclass for joins
[dbsrgits/DBIx-Class.git] / t / 07pager.t
CommitLineData
59f8e584 1use Test::More;
2
9229f20a 3plan tests => 13;
59f8e584 4
5use lib qw(t/lib);
6
7use_ok('DBICTest');
8
9# first page
2a21de92 10my $it = DBICTest::CD->search(
59f8e584 11 {},
12 { order_by => 'title',
13 rows => 3,
14 page => 1 }
15);
2a21de92 16
3c5b25c5 17is( $it->pager->entries_on_this_page, 3, "entries_on_this_page ok" );
59f8e584 18
3c5b25c5 19is( $it->pager->next_page, 2, "next_page ok" );
20
21is( $it->count, 3, "count on paged rs ok" );
59f8e584 22
23is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
24
25$it->next;
26$it->next;
27
28is( $it->next, undef, "next past end of page ok" );
29
3c5b25c5 30# second page, testing with array
2a21de92 31my @page2 = DBICTest::CD->search(
59f8e584 32 {},
33 { order_by => 'title',
34 rows => 3,
35 page => 2 }
36);
59f8e584 37
2a21de92 38is( $page2[0]->title, "Generic Manufactured Singles", "second page first title ok" );
59f8e584 39
3c5b25c5 40# page a standard resultset
2a21de92 41$it = DBICTest::CD->search(
3c5b25c5 42 {},
43 { order_by => 'title',
44 rows => 3 }
59f8e584 45);
3c5b25c5 46my $page = $it->page(2);
47
9229f20a 48is( $page->count, 2, "standard resultset paged rs count ok" );
49
3c5b25c5 50is( $page->next->title, "Generic Manufactured Singles", "second page of standard resultset ok" );
9229f20a 51
52# test software-based limit paging
53$it = DBICTest::CD->search(
54 {},
55 { order_by => 'title',
56 rows => 3,
57 page => 2,
58 software_limit => 1 }
59);
60is( $it->pager->entries_on_this_page, 2, "software entries_on_this_page ok" );
61
62is( $it->pager->previous_page, 1, "software previous_page ok" );
63
64is( $it->count, 2, "software count on paged rs ok" );
65
66is( $it->next->title, "Generic Manufactured Singles", "software iterator->next ok" );