X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F08inflate_has_a.t;h=eaeddf3640c4b45330658c2b739afb9dfab27105;hb=cc0f266f9a5303f1ca7856fbbba5d0154f630409;hp=e6bd56742e13f18038c879bcd9b4544c81122905;hpb=4a07648ace2ace5b878c63aec52b7a30c1432b4d;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/08inflate_has_a.t b/t/08inflate_has_a.t index e6bd567..eaeddf3 100644 --- a/t/08inflate_has_a.t +++ b/t/08inflate_has_a.t @@ -1,7 +1,7 @@ use Test::More; use DateTime; -plan tests => 4; +plan tests => 7; use lib qw(t/lib); @@ -30,3 +30,25 @@ $cd->update; ($cd) = DBICTest::CD->search( year => $now->year ); is( $cd->year->year, $now->year, 'deflate ok' ); + +# re-test using alternate deflate syntax +DBICTest::CD->has_a( 'year', 'DateTime', + inflate => sub { DateTime->new( year => shift ) }, + deflate => 'year' +); + +# inflation test +$cd = DBICTest::CD->retrieve(3); + +is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' ); + +is( $cd->year->month, 1, 'inflated month ok' ); + +# deflate test +$now = DateTime->now; +$cd->year( $now ); +$cd->update; + +($cd) = DBICTest::CD->search( year => $now->year ); +is( $cd->year->year, $now->year, 'deflate ok' ); +