File: columns_dont_override_custom_accessors.t

package info (click to toggle)
libdbix-class-perl 0.082841-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 5,236 kB
  • sloc: perl: 26,763; sql: 322; makefile: 10
file content (30 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use strict;
use warnings;
use Test::More;
use lib 't/cdbi/testlib';

{
    package Thing;

    use base 'DBIC::Test::SQLite';

    Thing->columns(TEMP => qw[foo bar]);
    Thing->columns(All  => qw[thing_id yarrow flower]);
    sub foo { 42 }
    sub yarrow { "hock" }
}

is_deeply( [sort Thing->columns("TEMP")],
           [sort qw(foo bar)],
           "TEMP columns set"
);
my $thing = Thing->construct(
    { thing_id => 23, foo => "this", bar => "that" }
);

is( $thing->id, 23 );
is( $thing->yarrow, "hock", 'custom accessor not overwritten by column' );
is( $thing->foo, 42, 'custom routine not overwritten by temp column' );
is( $thing->bar, "that", 'temp column accessor generated' );

done_testing;