Switched tests to use DBICTest->class("...")
[dbsrgits/DBIx-Class.git] / t / run / 08inflate.tl
1 sub run_tests {
2
3 eval { require DateTime };
4 plan skip_all => "Need DateTime for inflation tests" if $@;
5
6 plan tests => 3;
7
8 DBICTest::Schema::CD->inflate_column( 'year',
9     { inflate => sub { DateTime->new( year => shift ) },
10       deflate => sub { shift->year } }
11 );
12 Class::C3->reinitialize;
13
14 # inflation test
15 my $cd = DBICTest->class("CD")->find(3);
16
17 is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
18
19 is( $cd->year->month, 1, 'inflated month ok' );
20
21 # deflate test
22 my $now = DateTime->now;
23 $cd->year( $now );
24 $cd->update;
25
26 ($cd) = DBICTest->class("CD")->search( year => $now->year );
27 is( $cd->year->year, $now->year, 'deflate ok' );
28
29 }
30
31 1;