From: Matt S Trout Date: Mon, 5 Sep 2005 18:57:00 +0000 (+0000) Subject: Ported Sweet pager test. Worked first time. andyg++ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4f99ad18d50b78af3f9215b17af818dfb41084f5;p=dbsrgits%2FDBIx-Class-Historic.git Ported Sweet pager test. Worked first time. andyg++ --- diff --git a/t/cdbi-sweet-t/08pager.t b/t/cdbi-sweet-t/08pager.t new file mode 100644 index 0000000..ab5211a --- /dev/null +++ b/t/cdbi-sweet-t/08pager.t @@ -0,0 +1,64 @@ +use strict; +use warnings; + +use Test::More; + +eval "use DBD::SQLite"; +plan skip_all => 'needs DBD::SQLite for testing' if $@; + +plan tests => 10; + +use lib 't/lib'; + +use_ok('DBICTest'); + +DBICTest::CD->load_components(qw/CDBICompat::Pager/); + +my ( $pager, $it ) = DBICTest::CD->page( + {}, + { order_by => 'title', + rows => 3, + page => 1 } ); + +cmp_ok( $pager->entries_on_this_page, '==', 3, "entries_on_this_page ok" ); + +cmp_ok( $pager->next_page, '==', 2, "next_page ok" ); + +is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" ); + +$it->next; +$it->next; + +is( $it->next, undef, "next past end of page ok" ); + +( $pager, $it ) = DBICTest::CD->page( + {}, + { rows => 2, + page => 2, + disable_sql_paging => 1 } ); + +cmp_ok( $pager->total_entries, '==', 5, "disable_sql_paging total_entries ok" ); + +cmp_ok( $pager->previous_page, '==', 1, "disable_sql_paging previous_page ok" ); + +is( $it->next->title, "Caterwaulin' Blues", "disable_sql_paging iterator->next ok" ); + +$it->next; + +is( $it->next, undef, "disable_sql_paging next past end of page ok" ); + +# based on a failing criteria submitted by waswas +( $pager, $it ) = DBICTest::CD->page( + { title => [ + -and => + { + -like => '%bees' + }, + { + -not_like => 'Forkful%' + } + ] + }, + { rows => 5 } +); +is( $it->count, 1, "complex abstract count ok" );