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