throw in an extra limit, sophisticate test a bit
[dbsrgits/DBIx-Class.git] / t / prefetch / with_limit.t
index 6e849f2..08df104 100644 (file)
@@ -8,7 +8,7 @@ use Test::Exception;
 use lib qw(t/lib);
 use DBICTest;
 
-plan tests => 7;
+plan tests => 9;
 
 my $schema = DBICTest->init_schema();
 
@@ -83,3 +83,11 @@ throws_ok (
   qr/resultsets prefetching has_many/,
   'single() with multiprefetch is illegal',
 );
+
+my $artist = $use_prefetch->search({'cds.title' => $artist_many_cds->cds->first->title })->next;
+is($artist->cds->count, 1, "count on search limiting prefetched has_many");
+
+# try with double limit
+my $artist2 = $use_prefetch->search({'cds.title' => { '!=' => $artist_many_cds->cds->first->title } })->slice (0,0)->next;
+is($artist2->cds->count, 2, "count on search limiting prefetched has_many");
+