File: has_many_loads_foreign_class.t

package info (click to toggle)
libdbix-class-perl 0.082843-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,320 kB
  • sloc: perl: 27,215; sql: 322; sh: 29; makefile: 16
file content (33 lines) | stat: -rw-r--r-- 744 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use strict;
use warnings;
use Test::More;
use Class::Inspector ();


use lib 't/cdbi/testlib';
use Director;

# Test that has_many() will load the foreign class.
ok !Class::Inspector->loaded( 'Film' );
ok eval { Director->has_many( films => 'Film' ); 1; } || diag $@;

my $shan_hua = Director->create({
    Name    => "Shan Hua",
});

my $inframan = Film->create({
    Title       => "Inframan",
    Director    => "Shan Hua",
});
my $guillotine2 = Film->create({
    Title       => "Flying Guillotine 2",
    Director    => "Shan Hua",
});
my $guillotine = Film->create({
    Title       => "Master of the Flying Guillotine",
    Director    => "Yu Wang",
});

is_deeply [sort $shan_hua->films], [sort $inframan, $guillotine2];

done_testing;