From: Andy Grundman Date: Tue, 2 Aug 2005 02:02:14 +0000 (+0000) Subject: Added failing tests for inflate_column X-Git-Tag: v0.03001~105 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=51516b1c2ebcb57ff4b0fe0aab3c2c839dc19d73;p=dbsrgits%2FDBIx-Class.git Added failing tests for inflate_column --- diff --git a/t/08inflate.t b/t/08inflate.t new file mode 100644 index 0000000..5b5122a --- /dev/null +++ b/t/08inflate.t @@ -0,0 +1,20 @@ +use Test::More; + +plan tests => 4; + +use lib qw(t/lib); + +use_ok('DBICTest'); + +# inflation test +my $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 +$cd->year( 2005 ); +$cd->update; + +($cd) = DBICTest::CD->search( year => 2005 ); +is( $cd->year, 2005, 'deflate ok' ); diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index f3418c4..e23f5ef 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -157,6 +157,10 @@ DBICTest::CD->add_relationship( { 'foreign.cd' => 'self.cdid' } ); #DBICTest::CD->might_have(liner_notes => 'DBICTest::LinerNotes' => qw/notes/); +DBICTest::CD->inflate_column( 'year', + { inflate => sub { DateTime->new( year => shift ) } }, + { deflate => sub { shift->year } } +); package DBICTest::Artist;