1e15a34e5e89a23908e71480c366ae75832c6f9a
[dbsrgits/DBIx-Class.git] / t / cdbi / construct.t
1 use strict;
2 use Test::More;
3
4 INIT {
5     use lib 't/cdbi/testlib';
6     use Film;
7 }
8
9 {
10     Film->insert({
11         Title     => "Breaking the Waves",
12         Director  => 'Lars von Trier',
13         Rating    => 'R'
14     });
15
16     my $film = Film->construct({
17         Title     => "Breaking the Waves",
18         Director  => 'Lars von Trier',
19     });
20
21     isa_ok $film, "Film";
22     is $film->title,    "Breaking the Waves";
23     is $film->director, "Lars von Trier";
24     is $film->rating,   "R",
25         "constructed objects can get missing data from the db";
26 }
27
28 {
29     package Foo;
30     use base qw(Film);
31     Foo->columns( TEMP => qw(temp_thing) );
32     my $film = Foo->construct({
33         temp_thing  => 23
34     });
35
36     ::is $film->temp_thing, 23, "construct sets temp columns";
37 }
38
39 done_testing;