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