From: Jess Robinson Date: Thu, 22 Jun 2006 22:34:43 +0000 (+0000) Subject: Tests for inflating timestamp fields to DateTime X-Git-Tag: v0.07002~75^2~91 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6665ed3bcff57969a533e4ea08522ede3e759b26;p=dbsrgits%2FDBIx-Class.git Tests for inflating timestamp fields to DateTime --- diff --git a/t/89inflate_datetime.t b/t/89inflate_datetime.t index 4145749..0c08797 100644 --- a/t/89inflate_datetime.t +++ b/t/89inflate_datetime.t @@ -23,9 +23,22 @@ is($starts, '2006-04-25T22:24:33', 'Correct date/time'); # create using DateTime my $created = $schema->resultset('Event')->create({ - starts_at => DateTime->new(year=>2006, month=>6, day=>18) + starts_at => DateTime->new(year=>2006, month=>6, day=>18), + created_on => DateTime->new(year=>2006, month=>6, day=>23) }); my $created_start = $created->starts_at; isa_ok($created->starts_at, 'DateTime', 'DateTime returned'); is($created_start, '2006-06-18T00:00:00', 'Correct date/time'); + +## timestamp field +isa_ok($event->created_on, 'DateTime', 'DateTime returned'); + +# klunky, but makes older Test::More installs happy +my $createo = $event->created_on . ''; +is($createo, '2006-06-22T21:00:05', 'Correct date/time'); + +my $created_cron = $created->created_on; + +isa_ok($created->created_on, 'DateTime', 'DateTime returned'); +is($created_cron, '2006-06-23T00:00:00', 'Correct date/time'); diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index 963eb4c..e3c739e 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -219,8 +219,8 @@ sub populate_schema { ]); $schema->populate('Event', [ - [ qw/id starts_at/ ], - [ 1, '2006-04-25 22:24:33' ], + [ qw/id starts_at created_on/ ], + [ 1, '2006-04-25 22:24:33', '2006-06-22 21:00:05'], ]); $schema->populate('Link', [ diff --git a/t/lib/DBICTest/Schema/Event.pm b/t/lib/DBICTest/Schema/Event.pm index 937d782..bce3e34 100644 --- a/t/lib/DBICTest/Schema/Event.pm +++ b/t/lib/DBICTest/Schema/Event.pm @@ -10,7 +10,8 @@ __PACKAGE__->table('event'); __PACKAGE__->add_columns( id => { data_type => 'integer', is_auto_increment => 1 }, - starts_at => { data_type => 'datetime' } + starts_at => { data_type => 'datetime' }, + created_on => { data_type => 'timestamp' } ); __PACKAGE__->set_primary_key('id');