X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=t%2Finflate%2Fdatetime_mysql.t;h=d14ee7df3221e8e83b6ac687bfac0285e9b7474a;hp=51368ad195227cf4dddba4426f8d36c1b07e318a;hb=68de943862f06cabd397d2e74d12cd9cdc999779;hpb=67b79ae10d09c925c0e120e9de21758f388c8e70 diff --git a/t/inflate/datetime_mysql.t b/t/inflate/datetime_mysql.t index 51368ad..d14ee7d 100644 --- a/t/inflate/datetime_mysql.t +++ b/t/inflate/datetime_mysql.t @@ -3,22 +3,20 @@ use warnings; use Test::More; use Test::Exception; +use Test::Warn; use lib qw(t/lib); use DBICTest; use DBICTest::Schema; +plan skip_all => 'Inflation tests need ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_mysql') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_mysql'); + { local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ }; DBICTest::Schema->load_classes('EventTZ'); DBICTest::Schema->load_classes('EventTZDeprecated'); } -eval { require DateTime::Format::MySQL }; -plan $@ - ? ( skip_all => "Need DateTime::Format::MySQL for inflation tests") - : ( tests => 33 ) -; - my $schema = DBICTest->init_schema(); # Test "timezone" parameter @@ -56,20 +54,17 @@ foreach my $tbl (qw/EventTZ EventTZDeprecated/) { # Test floating timezone warning # We expect one warning SKIP: { - skip "ENV{DBIC_FLOATING_TZ_OK} was set, skipping", 1 if $ENV{DBIC_FLOATING_TZ_OK}; - local $SIG{__WARN__} = sub { - like( - shift, - qr/You're using a floating timezone, please see the documentation of DBIx::Class::InflateColumn::DateTime for an explanation/, - 'Floating timezone warning' - ); - }; - my $event_tz_floating = $schema->resultset($tbl)->create({ - starts_at => DateTime->new(year=>2007, month=>12, day=>31, ), - created_on => DateTime->new(year=>2006, month=>1, day=>31, - hour => 13, minute => 34, second => 56, ), - }); - delete $SIG{__WARN__}; + skip "ENV{DBIC_FLOATING_TZ_OK} was set, skipping", 1 if $ENV{DBIC_FLOATING_TZ_OK}; + warnings_exist ( + sub { + $schema->resultset($tbl)->create({ + starts_at => DateTime->new(year=>2007, month=>12, day=>31 ), + created_on => DateTime->new(year=>2006, month=>1, day=>31, hour => 13, minute => 34, second => 56 ), + }); + }, + qr/You're using a floating timezone, please see the documentation of DBIx::Class::InflateColumn::DateTime for an explanation/, + 'Floating timezone warning' + ); }; # This should fail to set @@ -95,3 +90,5 @@ throws_ok ( qr/invalid date format/i, "Invalid date format exception" ); + +done_testing;