Commit | Line | Data |
9bc6db13 |
1 | use strict; |
2 | use Test::More; |
3 | |
4 | BEGIN { |
289ba852 |
5 | eval "use DBIx::Class::CDBICompat;"; |
6 | if ($@) { |
7 | plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); |
8 | next; |
9 | } |
10 | eval "use DBD::SQLite"; |
11 | plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 5); |
9bc6db13 |
12 | } |
13 | |
14 | use lib 't/testlib'; |
15 | require Film; |
16 | require Order; |
17 | |
18 | Film->has_many(orders => 'Order'); |
19 | Order->has_a(film => 'Film'); |
20 | |
21 | Film->create_test_film; |
22 | |
23 | my $film = Film->retrieve('Bad Taste'); |
24 | isa_ok $film => 'Film'; |
25 | |
26 | $film->add_to_orders({ orders => 10 }); |
27 | |
28 | my $bto = (Order->search(film => 'Bad Taste'))[0]; |
29 | isa_ok $bto => 'Order'; |
30 | is $bto->orders, 10, "Correct number of orders"; |
31 | |
32 | |
33 | my $infilm = $bto->film; |
34 | isa_ok $infilm, "Film"; |
35 | |
36 | is $infilm->id, $film->id, "Orders hasa Film"; |