11 my $schema = DBICTest->init_schema();
15 $counts->{$_} = $schema->resultset($_)->count for qw/Track CD Genre/;
18 my $existing_nogen_cd = $schema->resultset('CD')->search (
19 { 'genre.genreid' => undef },
23 $schema->resultset('Track')->create ({
24 title => 'Sugar-coated',
26 title => $existing_nogen_cd->title,
28 name => 'sugar genre',
33 is ($schema->resultset('Track')->count, $counts->{Track} + 1, '1 new track');
34 is ($schema->resultset('CD')->count, $counts->{CD}, 'No new cds');
35 is ($schema->resultset('Genre')->count, $counts->{Genre} + 1, '1 new genre');
37 is ($existing_nogen_cd->genre->title, 'sugar genre', 'Correct genre assigned to CD');
43 $counts->{$_} = $schema->resultset($_)->count for qw/Artist CD Producer/;
46 my $artist = $schema->resultset('Artist')->first;
47 my $producer = $schema->resultset('Producer')->create ({ name => 'the queen of england' });
49 $schema->resultset('CD')->create ({
56 name => $producer->name,
71 is ($schema->resultset('Artist')->count, $counts->{Artist}, 'No new artists');
72 is ($schema->resultset('Producer')->count, $counts->{Producer} + 1, '1 new producers');
73 is ($schema->resultset('CD')->count, $counts->{CD} + 2, '2 new cds');
75 is ($producer->cds->count, 2, 'CDs assigned to correct producer');
77 [ $producer->cds->search ({}, { order_by => 'title' })->get_column('title')->all],
78 [ qw/queen1 queen2/ ],