1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2 use DBIx::Class::Optional::Dependencies -skip_all_without => qw( ic_dt cdbicompat );
11 my $schema = DBICTest->init_schema();
13 DBICTest::Schema::CD->load_components(qw/CDBICompat::Relationships/);
15 DBICTest::Schema::CD->has_a( 'year', 'DateTime',
16 inflate => sub { DateTime->new( year => shift ) },
17 deflate => sub { shift->year }
19 Class::C3->reinitialize if DBIx::Class::_ENV_::OLD_MRO;
22 my $cd = $schema->resultset("CD")->find(3);
24 is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
26 is( $cd->year->month, 1, 'inflated month ok' );
29 my $now = DateTime->now;
33 ($cd) = $schema->resultset("CD")->search({ year => $now->year });
34 is( $cd->year->year, $now->year, 'deflate ok' );
36 # re-test using alternate deflate syntax
37 $schema->class("CD")->has_a( 'year', 'DateTime',
38 inflate => sub { DateTime->new( year => shift ) },
43 $cd = $schema->resultset("CD")->find(3);
45 is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
47 is( $cd->year->month, 1, 'inflated month ok' );
54 ($cd) = $schema->resultset("CD")->search({ year => $now->year });
55 is( $cd->year->year, $now->year, 'deflate ok' );