From: Peter Rabbitson Date: Tue, 4 Aug 2009 13:20:35 +0000 (+0000) Subject: fix merge fallout X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=83896879877a43c1d63f6ffda0298b7efff0a66e;p=dbsrgits%2FDBIx-Class-Historic.git fix merge fallout --- diff --git a/t/multi_create/multilev_might_have_PKeqFK.t b/t/multi_create/multilev_might_have_PKeqFK.t deleted file mode 100644 index 8b8b59d..0000000 --- a/t/multi_create/multilev_might_have_PKeqFK.t +++ /dev/null @@ -1,105 +0,0 @@ -use strict; -use warnings; - -use Test::More; -use Test::Exception; -use lib qw(t/lib); -use DBICTest; - -sub mc_diag { diag (@_) if $ENV{DBIC_MULTICREATE_DEBUG} }; - -plan tests => 13; - -my $schema = DBICTest->init_schema(); - -mc_diag (<<'DG'); -* Test a multilevel might-have with a PK == FK in the might_have/has_many table - -CD -> might have -> Artwork - \ - \-> has_many \ - --> Artwork_to_Artist - /-> has_many / - / - Artist -DG - -lives_ok (sub { - my $cd = $schema->resultset('CD')->create ({ - artist => { name => 'the cincinnati kid' }, - title => 'Music to code by until the cows come home', - year => 2008, - artwork => { - artwork_to_artist => [ - { artist => { name => 'cowboy joe' } }, - { artist => { name => 'billy the kid' } }, - ], - }, - }); - - isa_ok ($cd, 'DBICTest::CD', 'Main CD object created'); - is ($cd->title, 'Music to code by until the cows come home', 'Correct CD title'); - is ($cd->artist->name, 'the cincinnati kid', 'Correct artist created for CD'); - - my $art_obj = $cd->artwork; - ok ($art_obj->has_column_loaded ('cd_id'), 'PK/FK present on artwork object'); - is ($art_obj->artists->count, 2, 'Correct artwork creator count via the new object'); - is_deeply ( - [ sort $art_obj->artists->get_column ('name')->all ], - [ 'billy the kid', 'cowboy joe' ], - 'Artists named correctly when queried via object', - ); - - my $artwork = $schema->resultset('Artwork')->search ( - { 'cd.title' => 'Music to code by until the cows come home' }, - { join => 'cd' }, - )->single; - is ($artwork->artists->count, 2, 'Correct artwork creator count via a new search'); - is_deeply ( - [ sort $artwork->artists->get_column ('name')->all ], - [ 'billy the kid', 'cowboy joe' ], - 'Artists named correctly queried via a new search', - ); -}, 'multilevel might-have with a PK == FK in the might_have/has_many table ok'); - - -mc_diag (<<'DG'); -* Try the same as above in a different direction - -Artist -> has_many -> Artwork_to_Artist -> belongs_to - / - belongs_to <- CD <- belongs_to <- Artwork <-/ - \ - \-> Artist2 - -DG - -lives_ok (sub { - $schema->resultset ('Artist')->create ({ - name => 'The wooled wolf', - artwork_to_artist => [{ - artwork => { - cd => { - title => 'Wool explosive', - year => 1999, - artist => { name => 'The black exploding sheep' }, - } - } - }], - }); - - my $art2 = $schema->resultset ('Artist')->find ({ name => 'The black exploding sheep' }); - ok ($art2, 'Second artist exists'); - - my $cd = $art2->cds->single; - is ($cd->title, 'Wool explosive', 'correctly created CD'); - - is_deeply ( - [ $cd->artwork->artists->get_column ('name')->all ], - [ 'The wooled wolf' ], - 'Artist correctly attached to artwork', - ); - -}, 'Diamond chain creation ok'); - -1; diff --git a/t/multi_create/multilev_single_PKeqFK.t b/t/multi_create/multilev_single_PKeqFK.t index 07101a2..a730b2b 100644 --- a/t/multi_create/multilev_single_PKeqFK.t +++ b/t/multi_create/multilev_single_PKeqFK.t @@ -8,7 +8,7 @@ use DBICTest; sub mc_diag { diag (@_) if $ENV{DBIC_MULTICREATE_DEBUG} }; -plan tests => 26; +plan tests => 30; my $schema = DBICTest->init_schema(); @@ -102,4 +102,43 @@ for my $type (qw/has_one might_have/) { }, "multilevel $type with a PK == FK in the $type/has_many table ok"); } -1; + +mc_diag (<<'DG'); +* Try a diamond multicreate + +Artist -> has_many -> Artwork_to_Artist -> belongs_to + / + belongs_to <- CD <- belongs_to <- Artwork <-/ + \ + \-> Artist2 + +DG + +lives_ok (sub { + $schema->resultset ('Artist')->create ({ + name => 'The wooled wolf', + artwork_to_artist => [{ + artwork => { + cd => { + title => 'Wool explosive', + year => 1999, + artist => { name => 'The black exploding sheep' }, + } + } + }], + }); + + my $art2 = $schema->resultset ('Artist')->find ({ name => 'The black exploding sheep' }); + ok ($art2, 'Second artist exists'); + + my $cd = $art2->cds->single; + is ($cd->title, 'Wool explosive', 'correctly created CD'); + + is_deeply ( + [ $cd->artwork->artists->get_column ('name')->all ], + [ 'The wooled wolf' ], + 'Artist correctly attached to artwork', + ); + +}, 'Diamond chain creation ok'); +