From: Andy Grundman Date: Tue, 2 Aug 2005 13:25:02 +0000 (+0000) Subject: Added more inflate_has_a tests using alternate deflate syntax X-Git-Tag: v0.03001~94 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=759cfa82080b73917829123c542ce56c4fe5d1ad;p=dbsrgits%2FDBIx-Class.git Added more inflate_has_a tests using alternate deflate syntax --- 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' ); +