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