Commit | Line | Data |
e60dc79f |
1 | use strict; |
2 | use Test::More; |
97d61088 |
3 | use lib 't/cdbi/testlib'; |
e60dc79f |
4 | |
5 | BEGIN { |
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 | |
22 | is_deeply( [sort Thing->columns("TEMP")], |
23 | [sort qw(foo bar)], |
24 | "TEMP columns set" |
25 | ); |
26 | my $thing = Thing->construct( |
27 | { thing_id => 23, foo => "this", bar => "that" } |
28 | ); |
29 | |
30 | is( $thing->id, 23 ); |
31 | is( $thing->yarrow, "hock", 'custom accessor not overwritten by column' ); |
32 | is( $thing->foo, 42, 'custom routine not overwritten by temp column' ); |
33 | is( $thing->bar, "that", 'temp column accessor generated' ); |