716a9a395cddc8b3d3e7fe94f97859efbd620d4c
[dbsrgits/DBIx-Class.git] / t / multi_create / has_many.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 plan tests => 2;
9
10 my $schema = DBICTest->init_schema();
11
12 my $track_no_lyrics = $schema->resultset ('Track')
13               ->search ({ 'lyrics.lyric_id' => undef }, { join => 'lyrics' })
14                 ->first;
15
16 my $lyric = $track_no_lyrics->create_related ('lyrics', {
17   lyric_versions => [
18     { text => 'english doubled' },
19     { text => 'english doubled' },
20   ],
21 });
22 is ($lyric->lyric_versions->count, 2, "Two identical has_many's created");
23
24
25 my $link = $schema->resultset ('Link')->create ({
26   url => 'lolcats!',
27   bookmarks => [
28     {},
29     {},
30   ]
31 });
32 is ($link->bookmarks->count, 2, "Two identical default-insert has_many's created");