Massive cleanup of DateTime test dependencies, other interim
[dbsrgits/DBIx-Class.git] / t / cdbi / mk_group_accessors.t
CommitLineData
7da06023 1use strict;
2use Test::More;
3
4BEGIN {
5 eval "use DBIx::Class::CDBICompat;";
6 plan skip_all => 'Class::Trigger and DBIx::ContextualFetch required' if $@;
7da06023 7}
8
9INIT {
50891152 10 use lib 't/cdbi/testlib';
7da06023 11 require Film;
12}
13
14sub Film::get_test {
15 my $self = shift;
16 my $key = shift;
17 $self->{get_test}++;
18 return $self->{$key};
19}
20
21sub Film::set_test {
22 my($self, $key, $val) = @_;
23 $self->{set_test}++;
24 return $self->{$key} = $val;
25}
26
27
28my $film = Film->create({ Title => "No Wolf McQuade" });
29
30# Test mk_group_accessors() with a list of fields.
31{
32 Film->mk_group_accessors(test => qw(foo bar));
33 $film->foo(42);
34 is $film->foo, 42;
35
36 $film->bar(23);
37 is $film->bar, 23;
38}
39
40
41# An explicit accessor passed to mk_group_accessors should
42# ignore accessor/mutator_name_for.
43sub Film::accessor_name_for {
44 my($class, $col) = @_;
45 return "hlaglagh" if $col eq "wibble";
46 return $col;
47}
48
49sub Film::mutator_name_for {
50 my($class, $col) = @_;
51 return "hlaglagh" if $col eq "wibble";
52 return $col;
53}
54
55
56# Test with a mix of fields and field specs
57{
58 Film->mk_group_accessors(test => ("baz", [wibble_thing => "wibble"]));
59 $film->baz(42);
60 is $film->baz, 42;
61
62 $film->wibble_thing(23);
63 is $film->wibble_thing, 23;
64}
89bddb49 65
66done_testing;