From: Nigel Metheringham Date: Tue, 4 Apr 2006 12:48:50 +0000 (+0000) Subject: Added some track test data and a cascading relationship test X-Git-Tag: v0.06001~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b8d4bd90ba3f24ab649ece077bdcd72b26c9138f;p=dbsrgits%2FDBIx-Class.git Added some track test data and a cascading relationship test --- diff --git a/t/lib/DBICTest/Setup.pm b/t/lib/DBICTest/Setup.pm index a7efea5..816a64c 100755 --- a/t/lib/DBICTest/Setup.pm +++ b/t/lib/DBICTest/Setup.pm @@ -118,4 +118,23 @@ $schema->populate('TreeLike', [ [ 4, 3, 'quux' ], ]); +$schema->populate('Track', [ + [ qw/trackid cd position title/ ], + [ 4, 2, 1, "Stung with Success"], + [ 5, 2, 2, "Stripy"], + [ 6, 2, 3, "Sticky Honey"], + [ 7, 3, 1, "Yowlin"], + [ 8, 3, 2, "Howlin"], + [ 9, 3, 3, "Fowlin"], + [ 10, 4, 1, "Boring Name"], + [ 11, 4, 2, "Boring Song"], + [ 12, 4, 3, "No More Ideas"], + [ 13, 5, 1, "Sad"], + [ 14, 5, 2, "Under The Weather"], + [ 15, 5, 3, "Suicidal"], + [ 16, 1, 1, "The Bees Knees"], + [ 17, 1, 2, "Apiary"], + [ 18, 1, 3, "Beehind You"], +]); + 1; diff --git a/t/run/06relationship.tl b/t/run/06relationship.tl index 65a2419..9d2669e 100644 --- a/t/run/06relationship.tl +++ b/t/run/06relationship.tl @@ -3,7 +3,7 @@ my $schema = shift; use strict; use warnings; -plan tests => 20; +plan tests => 21; # has_a test my $cd = $schema->resultset("CD")->find(4); @@ -131,6 +131,11 @@ my $searched = $mapped_rs->search({'mapped_artists.artistid' => {'!=', undef}}); cmp_ok($searched->count, '==', 2, "Both artist returned from map after adding another condition"); +# check join through cascaded has_many relationships +$artist = $schema->resultset("Artist")->find(1); +my $trackset = $artist->cds->search_related('tracks'); +# LEFT join means we also see the trackless additional album... +cmp_ok($trackset->count, '==', 11, "Correct number of tracks for artist"); }