X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi%2Fcolumns_dont_override_custom_accessors.t;fp=t%2Fcdbi%2Fcolumns_dont_override_custom_accessors.t;h=f9bd02794e01465e49c261c68e723eb513002875;hb=50891152d0b24649bfd67bdba97feec86b11c064;hp=0000000000000000000000000000000000000000;hpb=23209c4474d71e419b3fcf9699ae05565c2997f5;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi/columns_dont_override_custom_accessors.t b/t/cdbi/columns_dont_override_custom_accessors.t new file mode 100644 index 0000000..f9bd027 --- /dev/null +++ b/t/cdbi/columns_dont_override_custom_accessors.t @@ -0,0 +1,32 @@ +use strict; +use Test::More; + +BEGIN { + eval "use DBIx::Class::CDBICompat;"; + plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") + : (tests=> 5); +} + +{ + package Thing; + + use base 'DBIx::Class::Test::SQLite'; + + Thing->columns(TEMP => qw[foo bar]); + Thing->columns(All => qw[thing_id yarrow flower]); + sub foo { 42 } + sub yarrow { "hock" } +} + +is_deeply( [sort Thing->columns("TEMP")], + [sort qw(foo bar)], + "TEMP columns set" +); +my $thing = Thing->construct( + { thing_id => 23, foo => "this", bar => "that" } +); + +is( $thing->id, 23 ); +is( $thing->yarrow, "hock", 'custom accessor not overwritten by column' ); +is( $thing->foo, 42, 'custom routine not overwritten by temp column' ); +is( $thing->bar, "that", 'temp column accessor generated' );