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