From: Peter Rabbitson Date: Sun, 28 Jun 2009 08:34:16 +0000 (+0000) Subject: Thetest case that started it all X-Git-Tag: v0.08108~43^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5eb45f820fd6dd9102cd61011c578ffc71049760;p=dbsrgits%2FDBIx-Class.git Thetest case that started it all --- diff --git a/t/prefetch/count.t b/t/prefetch/count.t new file mode 100644 index 0000000..fac478c --- /dev/null +++ b/t/prefetch/count.t @@ -0,0 +1,24 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +plan tests => 5; + +my $schema = DBICTest->init_schema(); + +my $cd_rs = $schema->resultset('CD')->search ( + { 'tracks.cd' => { '!=', undef } }, + { prefetch => ['tracks', 'artist'] }, +); + + +is($cd_rs->count, 5, 'CDs with tracks count'); +is($cd_rs->search_related('tracks')->count, 15, 'Tracks associated with CDs count (before SELECT()ing)'); + +is($cd_rs->all, 5, 'Amount of CD objects with tracks'); +is($cd_rs->search_related('tracks')->count, 15, 'Tracks associated with CDs count (after SELECT()ing)'); + +is($cd_rs->search_related ('tracks')->all, 15, 'Track objects associated with CDs (after SELECT()ing)');