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