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