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