Yeah, committing the new tests would help ...
[dbsrgits/DBIx-Class.git] / t / run / 08inflate.tl
diff --git a/t/run/08inflate.tl b/t/run/08inflate.tl
new file mode 100644 (file)
index 0000000..9a69380
--- /dev/null
@@ -0,0 +1,30 @@
+sub run_tests {
+
+eval { require DateTime };
+plan skip_all => "Need DateTime for inflation tests" if $@;
+
+plan tests => 3;
+
+DBICTest::CD->inflate_column( 'year',
+    { inflate => sub { DateTime->new( year => shift ) },
+      deflate => sub { shift->year } }
+);
+
+# inflation test
+my $cd = DBICTest::CD->find(3);
+
+is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
+
+is( $cd->year->month, 1, 'inflated month ok' );
+
+# deflate test
+my $now = DateTime->now;
+$cd->year( $now );
+$cd->update;
+
+($cd) = DBICTest::CD->search( year => $now->year );
+is( $cd->year->year, $now->year, 'deflate ok' );
+
+}
+
+1;