X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F96multi_create.t;h=810b6eb68de3a9f150f5869d41c7c7f40346bb3d;hb=7d9fbacf13c288615dc718bbb76deb9fa28d8aa9;hp=4f32e68010c8caed73958d2bc2bdf8c4bdcd4b65;hpb=9c6d6d935cf5ef946fafec02a33a3d2415ba706f;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/96multi_create.t b/t/96multi_create.t index 4f32e68..810b6eb 100644 --- a/t/96multi_create.t +++ b/t/96multi_create.t @@ -120,3 +120,44 @@ CREATE_RELATED2 :{ ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class'); } } + +my $cdp = $schema->resultset('CD_to_Producer')->create({ + cd => { artist => 1, title => 'foo', year => 2000 }, + producer => { name => 'jorge' } + }); + +ok($cdp, 'join table record created ok'); + +SPECIAL_CASE: { + my $kurt_cobain = { name => 'Kurt Cobain' }; + + my $in_utero = $schema->resultset('CD')->new({ + title => 'In Utero', + year => 1993 + }); + + $kurt_cobain->{cds} = [ $in_utero ]; + + + $schema->resultset('Artist')->populate([ $kurt_cobain ]); # %) + $a = $schema->resultset('Artist')->find({name => 'Kurt Cobain'}); + + is($a->name, 'Kurt Cobain', 'Artist insertion ok'); + is($a->cds && $a->cds->first && $a->cds->first->title, + 'In Utero', 'CD insertion ok'); +} + +SPECIAL_CASE2: { + my $pink_floyd = { name => 'Pink Floyd' }; + + my $the_wall = { title => 'The Wall', year => 1979 }; + + $pink_floyd->{cds} = [ $the_wall ]; + + + $schema->resultset('Artist')->populate([ $pink_floyd ]); # %) + $a = $schema->resultset('Artist')->find({name => 'Pink Floyd'}); + + is($a->name, 'Pink Floyd', 'Artist insertion ok'); + is($a->cds && $a->cds->first->title, 'The Wall', 'CD insertion ok'); +}