Column inflation tests now pass
[dbsrgits/DBIx-Class.git] / t / 08inflate.t
1 use Test::More;
2 use DateTime;
3
4 plan tests => 4;
5
6 use lib qw(t/lib);
7
8 use_ok('DBICTest');
9
10 DBICTest::CD->inflate_column( 'year',
11     { inflate => sub { DateTime->new( year => shift ) },
12       deflate => sub { shift->year } }
13 );
14
15 # inflation test
16 my $cd = DBICTest::CD->retrieve(3);
17
18 is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
19
20 is( $cd->year->month, 1, 'inflated month ok' );
21
22 # deflate test
23 my $now = DateTime->now;
24 $cd->year( $now );
25 $cd->update;
26
27 ($cd) = DBICTest::CD->search( year => $now->year );
28 is( $cd->year->year, $now->year, 'deflate ok' );