Make sure DBICTest is always loaded first (purely bookkeep)
[dbsrgits/DBIx-Class.git] / t / search / related_has_many.t
CommitLineData
31a8aaaf 1use strict;
2use warnings;
3
4use Test::More;
5
6use lib qw(t/lib);
31a8aaaf 7use DBICTest;
5e724964 8use DBIC::SqlMakerTest;
31a8aaaf 9
10my $schema = DBICTest->init_schema();
11
12my $cd_rs = $schema->resultset('CD')->search ({ artist => { '!=', undef }});
13
14# create some CDs without tracks
15$cd_rs->create({ artist => 1, title => 'trackless_foo', year => 2010 });
16$cd_rs->create({ artist => 1, title => 'trackless_bar', year => 2010 });
17
18my $tr_count = $schema->resultset('Track')->count;
19
20my $tr_rs = $cd_rs->search_related('tracks');
21
22
23my @tracks;
24while ($tr_rs->next) {
25 push @tracks, $_;
26}
27
28is (scalar @tracks, $tr_count, 'Iteration is correct');
29is ($tr_rs->count, $tr_count, 'Count is correct');
30is (scalar ($tr_rs->all), $tr_count, 'All is correct');
31
32done_testing;