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