Institute a central "load this first in testing" package
[dbsrgits/DBIx-Class.git] / t / cdbi / construct.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2 use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
3
4 use strict;
5 use warnings;
6
7 use Test::More;
8
9 use lib 't/cdbi/testlib';
10 use Film;
11
12 {
13     Film->insert({
14         Title     => "Breaking the Waves",
15         Director  => 'Lars von Trier',
16         Rating    => 'R'
17     });
18
19     my $film = Film->construct({
20         Title     => "Breaking the Waves",
21         Director  => 'Lars von Trier',
22     });
23
24     isa_ok $film, "Film";
25     is $film->title,    "Breaking the Waves";
26     is $film->director, "Lars von Trier";
27     is $film->rating,   "R",
28         "constructed objects can get missing data from the db";
29 }
30
31 {
32     package Foo;
33     use base qw(Film);
34     Foo->columns( TEMP => qw(temp_thing) );
35     my $film = Foo->construct({
36         temp_thing  => 23
37     });
38
39     ::is $film->temp_thing, 23, "construct sets temp columns";
40 }
41
42 done_testing;