Merge 'trunk' into 'column_attr'
[dbsrgits/DBIx-Class.git] / t / cdbi / columns_dont_override_custom_accessors.t
CommitLineData
e60dc79f 1use strict;
2use Test::More;
3
4BEGIN {
5 eval "use DBIx::Class::CDBICompat;";
6 plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@")
7 : (tests=> 5);
8}
9
10{
11 package Thing;
12
13 use base 'DBIx::Class::Test::SQLite';
14
15 Thing->columns(TEMP => qw[foo bar]);
16 Thing->columns(All => qw[thing_id yarrow flower]);
17 sub foo { 42 }
18 sub yarrow { "hock" }
19}
20
21is_deeply( [sort Thing->columns("TEMP")],
22 [sort qw(foo bar)],
23 "TEMP columns set"
24);
25my $thing = Thing->construct(
26 { thing_id => 23, foo => "this", bar => "that" }
27);
28
29is( $thing->id, 23 );
30is( $thing->yarrow, "hock", 'custom accessor not overwritten by column' );
31is( $thing->foo, 42, 'custom routine not overwritten by temp column' );
32is( $thing->bar, "that", 'temp column accessor generated' );