Check relationship declarations more consistently
[dbsrgits/DBIx-Class.git] / t / relationship / malformed_declaration.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6 use lib qw(t/lib);
7 use DBICTest::Schema::Artist;
8
9 my $pkg = 'DBICTest::Schema::Artist';
10
11 for my $call (qw(has_many might_have has_one belongs_to)) {
12   {
13     local $TODO = 'stupid stupid heuristic - needs to die'
14       if $call eq 'belongs_to';
15
16     throws_ok {
17       $pkg->$call( foos => 'nonexistent bars', { foo => 'self.artistid' } );
18     } qr/Malformed relationship condition key 'foo': must be prefixed with 'foreign.'/,
19     "Correct exception on $call with malformed foreign.";
20   }
21
22   throws_ok {
23     $pkg->has_many( foos => 'nonexistent bars', { 'foreign.foo' => 'name' } );
24   } qr/\QMalformed relationship condition value 'name': must be prefixed with 'self.'/,
25   "Correct exception on $call with malformed self.";
26 }
27
28 done_testing;