Fix default insert on Oracle ( $rs->create({}) with empty hashref )
[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;
8
9my $schema = DBICTest->init_schema();
10
11my $cd_rs = $schema->resultset('CD')->search ({ artist => { '!=', undef }});
12
13# create some CDs without tracks
14$cd_rs->create({ artist => 1, title => 'trackless_foo', year => 2010 });
15$cd_rs->create({ artist => 1, title => 'trackless_bar', year => 2010 });
16
17my $tr_count = $schema->resultset('Track')->count;
18
19my $tr_rs = $cd_rs->search_related('tracks');
20
21
22my @tracks;
23while ($tr_rs->next) {
24 push @tracks, $_;
25}
26
27is (scalar @tracks, $tr_count, 'Iteration is correct');
28is ($tr_rs->count, $tr_count, 'Count is correct');
29is (scalar ($tr_rs->all), $tr_count, 'All is correct');
30
31done_testing;