# test coderef as rel_name_map
my $code_relationship = schema_with(
rel_name_map => sub {
- my ($args) = @_;
+ my ($args, $orig) = @_;
if ($args->{local_moniker} eq 'Foo') {
is_deeply(
},
'correct args for Foo passed'
);
- return 'bars_caught';
}
elsif ($args->{local_moniker} eq 'Bar') {
is_deeply(
},
'correct args for Foo passed'
);
-
- return 'fooref_caught';
}
+ else {
+ fail( 'correct args passed to rel_name_map' );
+ diag "args were: ", explain $args;
+ }
+ return $orig->({
+ Bar => { fooref => 'fooref_caught' },
+ Foo => { bars => 'bars_caught' },
+ });
}
);
is( ref($code_relationship->source('Foo')->relationship_info('bars_caught')),
'rel_name_map overrode remote_info correctly'
);
+throws_ok {
+ schema_with( rel_name_map => sub { $_[-1]->(sub{}) } ),
+} qr/reentered rel_name_map must be a hashref/, 'throws error for invalid (code) rel_name_map callback map';
# test relationship_attrs