Commit | Line | Data |
e60dc79f |
1 | #!/usr/bin/perl -w |
2 | |
3 | use strict; |
4 | use Test::More; |
5 | |
6 | BEGIN { |
7 | eval "use DBIx::Class::CDBICompat;"; |
8 | plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") |
146c1838 |
9 | : (tests=> 5); |
e60dc79f |
10 | } |
11 | |
12 | INIT { |
13 | use lib 't/testlib'; |
14 | use Film; |
15 | } |
16 | |
146c1838 |
17 | { |
18 | Film->insert({ |
19 | Title => "Breaking the Waves", |
20 | Director => 'Lars von Trier', |
21 | Rating => 'R' |
22 | }); |
e60dc79f |
23 | |
146c1838 |
24 | my $film = Film->construct({ |
25 | Title => "Breaking the Waves", |
26 | Director => 'Lars von Trier', |
27 | }); |
e60dc79f |
28 | |
146c1838 |
29 | isa_ok $film, "Film"; |
30 | is $film->title, "Breaking the Waves"; |
31 | is $film->director, "Lars von Trier"; |
32 | is $film->rating, "R", |
33 | "constructed objects can get missing data from the db"; |
34 | } |
35 | |
36 | { |
37 | package Foo; |
38 | use base qw(Film); |
39 | Foo->columns( TEMP => qw(temp_thing) ); |
40 | my $film = Foo->construct({ |
41 | temp_thing => 23 |
42 | }); |
43 | |
44 | ::is $film->temp_thing, 23, "construct sets temp columns"; |
45 | } |