From: Moritz Onken Date: Tue, 30 Jun 2009 17:45:49 +0000 (+0000) Subject: failing test X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2255d0bed048ea43ac82da903cc375ff36fe8a23;p=dbsrgits%2FDBIx-Class-Historic.git failing test --- diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index b089287..da590ff 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -44,6 +44,21 @@ __PACKAGE__->has_many( cds => 'DBICTest::Schema::CD', undef, { order_by => { -asc => 'year'} }, ); + + +__PACKAGE__->has_many( + cds_80s => 'DBICTest::Schema::CD', + sub { + my ( $rs, $self, $foreign ) = @_; + return { + "${foreign}.artist" => "${self}.artistid", + "${foreign}.year" => { '>', "1979" }, + "${foreign}.year" => { '<', "1990" } + }; + } +); + + __PACKAGE__->has_many( cds_unordered => 'DBICTest::Schema::CD' ); diff --git a/t/relationship/core.t b/t/relationship/core.t index d6cb3a3..59be451 100644 --- a/t/relationship/core.t +++ b/t/relationship/core.t @@ -323,4 +323,15 @@ is($cds->count, 1, "subjoins under left joins force_left (arrayref)"); $cds = $schema->resultset("CD")->search({ 'me.cdid' => 5 }, { join => { single_track => { cd => {} } } }); is($cds->count, 1, "subjoins under left joins force_left (hashref)"); +$artist = $schema->resultset("Artist")->create({ name => 'Michael Jackson' }); +foreach my $year (1975..1985) { + $artist->create_related('cds', { year => $year, title => 'Compilation from ' . $year }); +} + +my @cds_80s = $artist->cds_80s; + +is(@cds_80s, 6, '6 80s cds found'); + +map { ok($_->year < 1990 && $_->year > 1979) } @cds_80s; + done_testing;