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