X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frun%2F08inflate_has_a.tl;h=266585ade2f991a6b51994905269657eb5067ddc;hb=70350518bbb31e5ac22fb3cb73d3e17409fcd332;hp=fe4833a31720d17322239724503674ef4828c451;hpb=2d679367e554c57e39aac9419b13a582e02916bd;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/run/08inflate_has_a.tl b/t/run/08inflate_has_a.tl index fe4833a..266585a 100644 --- a/t/run/08inflate_has_a.tl +++ b/t/run/08inflate_has_a.tl @@ -1,4 +1,11 @@ -sub run_tests { +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); eval { require DateTime }; plan skip_all => "Need DateTime for inflation tests" if $@; @@ -14,7 +21,7 @@ DBICTest::Schema::CD->has_a( 'year', 'DateTime', Class::C3->reinitialize; # inflation test -my $cd = DBICTest::CD->find(3); +my $cd = $schema->resultset("CD")->find(3); is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' ); @@ -25,17 +32,17 @@ my $now = DateTime->now; $cd->year( $now ); $cd->update; -($cd) = DBICTest::CD->search( year => $now->year ); +($cd) = $schema->resultset("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', +$schema->class("CD")->has_a( 'year', 'DateTime', inflate => sub { DateTime->new( year => shift ) }, deflate => 'year' ); # inflation test -$cd = DBICTest::CD->find(3); +$cd = $schema->resultset("CD")->find(3); is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' ); @@ -46,9 +53,6 @@ $now = DateTime->now; $cd->year( $now ); $cd->update; -($cd) = DBICTest::CD->search( year => $now->year ); +($cd) = $schema->resultset("CD")->search( year => $now->year ); is( $cd->year->year, $now->year, 'deflate ok' ); -} - -1;