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