6 eval "use DBIx::Class::CDBICompat; use DateTime 0.55; use Clone;";
7 plan skip_all => "Clone, DateTime 0.55, Class::Trigger and DBIx::ContextualFetch required"
16 my $schema = DBICTest->init_schema();
18 DBICTest::Schema::CD->load_components(qw/CDBICompat::Relationships/);
20 DBICTest::Schema::CD->has_a( 'year', 'DateTime',
21 inflate => sub { DateTime->new( year => shift ) },
22 deflate => sub { shift->year }
24 Class::C3->reinitialize;
27 my $cd = $schema->resultset("CD")->find(3);
29 is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
31 is( $cd->year->month, 1, 'inflated month ok' );
34 my $now = DateTime->now;
38 ($cd) = $schema->resultset("CD")->search( year => $now->year );
39 is( $cd->year->year, $now->year, 'deflate ok' );
41 # re-test using alternate deflate syntax
42 $schema->class("CD")->has_a( 'year', 'DateTime',
43 inflate => sub { DateTime->new( year => shift ) },
48 $cd = $schema->resultset("CD")->find(3);
50 is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
52 is( $cd->year->month, 1, 'inflated month ok' );
59 ($cd) = $schema->resultset("CD")->search( year => $now->year );
60 is( $cd->year->year, $now->year, 'deflate ok' );