X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F89inflate_datetime.t;h=23134262ab1c02cadc3ec00500ee5a6eb90f61ab;hb=33a126efc599d5bb1284929ba2c80527c5bd0951;hp=d92340c95d05982498ee513a3bc34cd7aac8d1ec;hpb=dda9af557c2385fb280d95dce3c4638a65bf9dd8;p=dbsrgits%2FDBIx-Class.git diff --git a/t/89inflate_datetime.t b/t/89inflate_datetime.t index d92340c..2313426 100644 --- a/t/89inflate_datetime.t +++ b/t/89inflate_datetime.t @@ -10,7 +10,7 @@ my $schema = DBICTest->init_schema(); eval { require DateTime::Format::MySQL }; plan skip_all => "Need DateTime::Format::MySQL for inflation tests" if $@; -plan tests => 17; +plan tests => 21; # inflation test my $event = $schema->resultset("Event")->find(1); @@ -70,3 +70,25 @@ $created_on = $loaded_event->created_on; is("$created_on", '2006-01-31T12:34:56', 'Loaded correct timestamp using timezone'); is($created_on->time_zone->name, 'America/Chicago', 'Correct timezone'); +# This should fail to set +my $prev_str = "$created_on"; +$loaded_event->update({ created_on => '0000-00-00' }); +is("$created_on", $prev_str, "Don't update invalid dates"); + +my $invalid = $schema->resultset('Event')->create({ + starts_at => '0000-00-00', + created_on => $created_on +}); + +is( $invalid->get_column('starts_at'), '0000-00-00', "Invalid date stored" ); +is( $invalid->starts_at, undef, "Inflate to undef" ); + +$invalid->created_on('0000-00-00'); +$invalid->update; + +{ + local $@; + eval { $invalid->created_on }; + like( $@, qr/invalid date format/i, "Invalid date format exception"); +} +