add TODO on constraint check
[dbsrgits/DBIx-Class.git] / t / cdbi-t / columns_dont_override_custom_accessors.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More;
5
6 BEGIN {
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
23 is_deeply( [sort Thing->columns("TEMP")],
24            [sort qw(foo bar)],
25            "TEMP columns set"
26 );
27 my $thing = Thing->construct(
28     { thing_id => 23, foo => "this", bar => "that" }
29 );
30
31 is( $thing->id, 23 );
32 is( $thing->yarrow, "hock", 'custom accessor not overwritten by column' );
33 is( $thing->foo, 42, 'custom routine not overwritten by temp column' );
34 is( $thing->bar, "that", 'temp column accessor generated' );