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