fdff0826b9f8c50403e7f8930713df2e4f33ce67
[dbsrgits/DBIx-Class.git] / t / cdbi / columns_dont_override_custom_accessors.t
1 use strict;
2 use Test::More;
3 use lib 't/cdbi/testlib';
4
5 {
6     package Thing;
7
8     use base 'DBIC::Test::SQLite';
9
10     Thing->columns(TEMP => qw[foo bar]);
11     Thing->columns(All  => qw[thing_id yarrow flower]);
12     sub foo { 42 }
13     sub yarrow { "hock" }
14 }
15
16 is_deeply( [sort Thing->columns("TEMP")],
17            [sort qw(foo bar)],
18            "TEMP columns set"
19 );
20 my $thing = Thing->construct(
21     { thing_id => 23, foo => "this", bar => "that" }
22 );
23
24 is( $thing->id, 23 );
25 is( $thing->yarrow, "hock", 'custom accessor not overwritten by column' );
26 is( $thing->foo, 42, 'custom routine not overwritten by temp column' );
27 is( $thing->bar, "that", 'temp column accessor generated' );
28
29 done_testing;