Institute a central "load this first in testing" package
[dbsrgits/DBIx-Class.git] / xt / extra / diagnostics / malformed_rel_declaration.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
6909ab3c 3use strict;
4use warnings;
5
6use Test::More;
7use Test::Exception;
c0329273 8
6909ab3c 9use DBICTest::Schema::Artist;
10
11my $pkg = 'DBICTest::Schema::Artist';
12
13for my $call (qw(has_many might_have has_one belongs_to)) {
14 {
15 local $TODO = 'stupid stupid heuristic - needs to die'
16 if $call eq 'belongs_to';
17
18 throws_ok {
19 $pkg->$call( foos => 'nonexistent bars', { foo => 'self.artistid' } );
20 } qr/Malformed relationship condition key 'foo': must be prefixed with 'foreign.'/,
21 "Correct exception on $call with malformed foreign.";
22 }
23
24 throws_ok {
25 $pkg->has_many( foos => 'nonexistent bars', { 'foreign.foo' => 'name' } );
26 } qr/\QMalformed relationship condition value 'name': must be prefixed with 'self.'/,
27 "Correct exception on $call with malformed self.";
28}
29
30done_testing;