Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / search / related_has_many.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8
9 use DBICTest;
10
11 my $schema = DBICTest->init_schema();
12
13 my $cd_rs = $schema->resultset('CD')->search ({ artist => { '!=', undef }});
14
15 # create some CDs without tracks
16 $cd_rs->create({ artist => 1, title => 'trackless_foo', year => 2010 });
17 $cd_rs->create({ artist => 1, title => 'trackless_bar', year => 2010 });
18
19 my $tr_count = $schema->resultset('Track')->count;
20
21 my $tr_rs = $cd_rs->search_related('tracks');
22
23
24 my @tracks;
25 while ($tr_rs->next) {
26   push @tracks, $_;
27 }
28
29 is (scalar @tracks, $tr_count, 'Iteration is correct');
30 is ($tr_rs->count, $tr_count, 'Count is correct');
31 is (scalar ($tr_rs->all), $tr_count, 'All is correct');
32
33 done_testing;