a0af15abc12f8ca2fda0711cf7c74a32263d49b7
[dbsrgits/DBIx-Class.git] / t / cdbi / has_many_loads_foreign_class.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2 use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
3
4 use strict;
5 use warnings;
6
7 use Test::More;
8
9 use lib 't/cdbi/testlib';
10 use Director;
11
12 # Test that has_many() will load the foreign class
13 require Class::Inspector;
14 ok !Class::Inspector->loaded( 'Film' );
15 ok eval { Director->has_many( films => 'Film' ); 1; } or diag $@;
16
17 my $shan_hua = Director->create({
18     Name    => "Shan Hua",
19 });
20
21 my $inframan = Film->create({
22     Title       => "Inframan",
23     Director    => "Shan Hua",
24 });
25 my $guillotine2 = Film->create({
26     Title       => "Flying Guillotine 2",
27     Director    => "Shan Hua",
28 });
29 my $guillotine = Film->create({
30     Title       => "Master of the Flying Guillotine",
31     Director    => "Yu Wang",
32 });
33
34 is_deeply [sort $shan_hua->films], [sort $inframan, $guillotine2];
35
36 done_testing;