X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi%2Fcolumns_as_hashes.t;h=a8953c332188253b303ae192cefc992ad119c73f;hb=50841788d03e2342a00470eb2f458e717922615b;hp=9ae1976cfd2a3b29e8f333e9056cec110f292867;hpb=50891152d0b24649bfd67bdba97feec86b11c064;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi/columns_as_hashes.t b/t/cdbi/columns_as_hashes.t index 9ae1976..a8953c3 100644 --- a/t/cdbi/columns_as_hashes.t +++ b/t/cdbi/columns_as_hashes.t @@ -1,13 +1,12 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; +use warnings; + use Test::More; use Test::Warn; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") - : ('no_plan'); -} - use lib 't/cdbi/testlib'; use Film; @@ -26,7 +25,7 @@ local $ENV{DBIC_CDBICOMPAT_HASH_WARN} = 0; my $rating = $waves->{rating}; $waves->Rating("PG"); is $rating, "R", 'evaluation of column value is not deferred'; - } qr{^Column 'rating' of 'Film/$waves' was fetched as a hash at \Q$0}; + } qr{^Column 'rating' of 'Film/$waves' was fetched as a hash at\b}; warnings_like { is $waves->{title}, $waves->Title, "columns can be accessed as hashes"; @@ -53,15 +52,15 @@ warning_is { } '', 'DBIC_CDBICOMPAT_HASH_WARN controls warnings'; -{ +{ $waves->rating("R"); $waves->update; - + no warnings 'redefine'; local *Film::rating = sub { return "wibble"; }; - + is $waves->{rating}, "R"; } @@ -74,7 +73,7 @@ warning_is { return "movie" if lc $col eq "film"; return $col; }; - + require Actor; Actor->has_a( film => "Film" ); @@ -82,7 +81,7 @@ warning_is { name => 'Emily Watson', film => $waves, }); - + ok !eval { $actor->film }; is $actor->{film}->id, $waves->id, 'hash access still works despite lack of accessor'; @@ -91,14 +90,16 @@ warning_is { # Emulate that Class::DBI inflates immediately SKIP: { - skip "Need MySQL to run this test", 3 unless eval { require MyFoo }; - + DBIx::Class::Optional::Dependencies->skip_without([qw( Date::Simple>=3.03 test_rdbms_mysql )]); + require MyFoo; my $foo = MyFoo->insert({ name => 'Whatever', tdate => '1949-02-01', }); isa_ok $foo, 'MyFoo'; - + isa_ok $foo->{tdate}, 'Date::Simple'; is $foo->{tdate}->year, 1949; -} \ No newline at end of file +} + +done_testing;