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