Yeah, committing the new tests would help ...
[dbsrgits/DBIx-Class-Historic.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::CD->inflate_column( 'year',
9     { inflate => sub { DateTime->new( year => shift ) },
10       deflate => sub { shift->year } }
11 );
12
13 # inflation test
14 my $cd = DBICTest::CD->find(3);
15
16 is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
17
18 is( $cd->year->month, 1, 'inflated month ok' );
19
20 # deflate test
21 my $now = DateTime->now;
22 $cd->year( $now );
23 $cd->update;
24
25 ($cd) = DBICTest::CD->search( year => $now->year );
26 is( $cd->year->year, $now->year, 'deflate ok' );
27
28 }
29
30 1;