Switch CDBICompat and its tests to OptDeps
[dbsrgits/DBIx-Class.git] / t / cdbi / has_many_loads_foreign_class.t
1 use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use lib 't/cdbi/testlib';
9 use Director;
10
11 # Test that has_many() will load the foreign class
12 require Class::Inspector;
13 ok !Class::Inspector->loaded( 'Film' );
14 ok eval { Director->has_many( films => 'Film' ); 1; } or diag $@;
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
33 is_deeply [sort $shan_hua->films], [sort $inframan, $guillotine2];
34
35 done_testing;