X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi-t%2Fcolumns_as_hashes.t;h=f85f50f1981c598aa089a1c18ca6d5aceca0f1b8;hb=1a304e513dc3fb708512877ab25423b567e1bedc;hp=a355291d8250536365f46f590200017e832c7b9f;hpb=8ed9eec640fc8718bbebc88dcf0fe9373f1ffd8e;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi-t/columns_as_hashes.t b/t/cdbi-t/columns_as_hashes.t index a355291..f85f50f 100644 --- a/t/cdbi-t/columns_as_hashes.t +++ b/t/cdbi-t/columns_as_hashes.t @@ -7,7 +7,7 @@ use Test::Warn; BEGIN { eval "use DBIx::Class::CDBICompat;"; plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") - : (tests=> 10); + : ('no_plan'); } use lib 't/testlib'; @@ -66,4 +66,41 @@ warning_is { is $waves->{rating}, "R"; } - \ No newline at end of file + + +{ + no warnings 'redefine'; + no warnings 'once'; + local *Actor::accessor_name_for = sub { + my($class, $col) = @_; + return "movie" if lc $col eq "film"; + return $col; + }; + + require Actor; + Actor->has_a( film => "Film" ); + + my $actor = Actor->insert({ + name => 'Emily Watson', + film => $waves, + }); + + ok !eval { $actor->film }; + is $actor->{film}->id, $waves->id, + 'hash access still works despite lack of accessor'; +} + + +# Emulate that Class::DBI inflates immediately +SKIP: { + skip "Need MySQL to run this test", 3 unless eval { 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