6 use Test::More tests => 15;
8 use DBICx::TestDatabase;
10 my $schema = DBICx::TestDatabase->new( 'MySchema' );
12 my $rs = $schema->resultset( 'FooCompat' );
15 my $now = DateTime->now;
16 my $epoch = $now->epoch;
18 $schema->populate( 'FooCompat', [ [ qw( id bar baz creation_time modification_time ) ], [ 1, ( $epoch ) x 4 ] ] );
21 my $row = $rs->find( 1 );
23 isa_ok( $row->bar, 'DateTime' );
24 isa_ok( $row->baz, 'DateTime' );
25 ok( $row->bar == $now, 'inflate: epoch as int' );
26 ok( $row->baz == $now, 'inflate: epoch as varchar' );
30 $rs->create( { bar => $now, baz => $now } );
31 my $row = $rs->find( 2 );
33 isa_ok( $row->bar, 'DateTime' );
34 isa_ok( $row->baz, 'DateTime' );
35 is( $row->get_column( 'bar' ), $epoch, 'deflate: epoch as int' );
36 is( $row->get_column( 'baz' ), $epoch, 'deflate: epoch as varchar' );
38 # courtesy of TimeStamp
39 isa_ok( $row->creation_time, 'DateTime' ); # courtesy of TimeStamp
40 isa_ok( $row->modification_time, 'DateTime' );
41 like( $row->get_column( 'creation_time' ), qr/^\d+$/, 'TimeStamp as epoch' );
42 like( $row->get_column( 'modification_time' ), qr/^\d+$/, 'TimeStamp as epoch' );
44 my $mtime = $row->modification_time;
46 $row->update( { name => 'test' } );
48 $row = $rs->find( 2 );
49 isa_ok( $row->modification_time, 'DateTime' );
50 like( $row->get_column( 'modification_time' ), qr/^\d+$/, 'TimeStamp as epoch' );
51 ok( $row->modification_time > $mtime, 'mtime column was updated' );