Added quote char test, supported quoting in S::A subclass for joins
[dbsrgits/DBIx-Class.git] / t / 08inflate.t
CommitLineData
51516b1c 1use Test::More;
8bc482e9 2
3eval { require DateTime };
4plan skip_all => "Need DateTime for inflation tests" if $@;
51516b1c 5
6plan tests => 4;
7
8use lib qw(t/lib);
9
10use_ok('DBICTest');
11
0e5c2582 12DBICTest::CD->inflate_column( 'year',
13 { inflate => sub { DateTime->new( year => shift ) },
14 deflate => sub { shift->year } }
15);
16
51516b1c 17# inflation test
656796f2 18my $cd = DBICTest::CD->find(3);
0e5c2582 19
51516b1c 20is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
21
22is( $cd->year->month, 1, 'inflated month ok' );
23
24# deflate test
cabca325 25my $now = DateTime->now;
26$cd->year( $now );
51516b1c 27$cd->update;
28
cabca325 29($cd) = DBICTest::CD->search( year => $now->year );
0e5c2582 30is( $cd->year->year, $now->year, 'deflate ok' );