X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frun%2F06relationship.tl;h=65a241989a01735e0a3c9ef7e80f1b45d205f15a;hb=c7329946b4343b31ffc1e799e09f3f3b7cdee39c;hp=b0f8256a58d02bb4b8de0f0e60a4fa0bd4a71094;hpb=f9db552739e7c980acb4280cb2b6c739a769da5a;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/run/06relationship.tl b/t/run/06relationship.tl index b0f8256..65a2419 100644 --- a/t/run/06relationship.tl +++ b/t/run/06relationship.tl @@ -3,7 +3,7 @@ my $schema = shift; use strict; use warnings; -plan tests => 17; +plan tests => 20; # has_a test my $cd = $schema->resultset("CD")->find(4); @@ -111,6 +111,8 @@ like($@, qr/join condition/, 'failed when creating a rel without join condition, $cd = $schema->resultset("CD")->find(1); my @producers = $cd->producers(); is( $producers[0]->name, 'Matt S Trout', 'many_to_many ok' ); +is( $cd->producers_sorted->next->name, 'Bob The Builder', 'sorted many_to_many ok' ); +is( $cd->producers_sorted(producerid => 3)->next->name, 'Fred The Phenotype', 'sorted many_to_many with search condition ok' ); # test undirected many-to-many relationship (e.g. "related artists") my $undir_maps = $schema->resultset("Artist")->find(1)->artist_undirected_maps; @@ -119,10 +121,17 @@ is($undir_maps->count, 1, 'found 1 undirected map for artist 1'); $undir_maps = $schema->resultset("Artist")->find(2)->artist_undirected_maps; is($undir_maps->count, 1, 'found 1 undirected map for artist 2'); -my @art = $undir_maps->search_related('mapped_artists')->all; +my $mapped_rs = $undir_maps->search_related('mapped_artists'); + +my @art = $mapped_rs->all; cmp_ok(@art, '==', 2, "Both artist returned from map"); +my $searched = $mapped_rs->search({'mapped_artists.artistid' => {'!=', undef}}); + +cmp_ok($searched->count, '==', 2, "Both artist returned from map after adding another condition"); + + } 1;