X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi-t%2F68-inflate_has_a.t;fp=t%2Fcdbi-t%2F68-inflate_has_a.t;h=0000000000000000000000000000000000000000;hb=50891152d0b24649bfd67bdba97feec86b11c064;hp=0019e293d049708c5ab7f24246ebd5a086ce7b6d;hpb=23209c4474d71e419b3fcf9699ae05565c2997f5;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi-t/68-inflate_has_a.t b/t/cdbi-t/68-inflate_has_a.t deleted file mode 100644 index 0019e29..0000000 --- a/t/cdbi-t/68-inflate_has_a.t +++ /dev/null @@ -1,67 +0,0 @@ -use strict; -use warnings; -use Test::More; - -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => "Class::Trigger and DBIx::ContextualFetch required" - if $@; - - eval { require DateTime }; - plan skip_all => "Need DateTime for inflation tests" if $@; - - eval { require Clone }; - plan skip_all => "Need Clone for CDBICompat inflation tests" if $@; -} - -plan tests => 6; - -use lib qw(t/lib); -use DBICTest; - -my $schema = DBICTest->init_schema(); - -DBICTest::Schema::CD->load_components(qw/CDBICompat::Relationships/); - -DBICTest::Schema::CD->has_a( 'year', 'DateTime', - inflate => sub { DateTime->new( year => shift ) }, - deflate => sub { shift->year } -); -Class::C3->reinitialize; - -# inflation test -my $cd = $schema->resultset("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) = $schema->resultset("CD")->search( year => $now->year ); -is( $cd->year->year, $now->year, 'deflate ok' ); - -# re-test using alternate deflate syntax -$schema->class("CD")->has_a( 'year', 'DateTime', - inflate => sub { DateTime->new( year => shift ) }, - deflate => 'year' -); - -# inflation test -$cd = $schema->resultset("CD")->find(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) = $schema->resultset("CD")->search( year => $now->year ); -is( $cd->year->year, $now->year, 'deflate ok' ); -