Added failing tests for inflate_column
Andy Grundman [Tue, 2 Aug 2005 02:02:14 +0000 (02:02 +0000)]
t/08inflate.t [new file with mode: 0644]
t/lib/DBICTest.pm

diff --git a/t/08inflate.t b/t/08inflate.t
new file mode 100644 (file)
index 0000000..5b5122a
--- /dev/null
@@ -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' );
index f3418c4..e23f5ef 100755 (executable)
@@ -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;