Convert all no_plan tests to done_testing
[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 $@;
7
8 eval "use DBD::SQLite";
9 plan skip_all => 'needs DBD::SQLite for testing' if $@;
7da06023 10}
11
12INIT {
50891152 13 use lib 't/cdbi/testlib';
7da06023 14 require Film;
15}
16
17sub Film::get_test {
18 my $self = shift;
19 my $key = shift;
20 $self->{get_test}++;
21 return $self->{$key};
22}
23
24sub Film::set_test {
25 my($self, $key, $val) = @_;
26 $self->{set_test}++;
27 return $self->{$key} = $val;
28}
29
30
31my $film = Film->create({ Title => "No Wolf McQuade" });
32
33# Test mk_group_accessors() with a list of fields.
34{
35 Film->mk_group_accessors(test => qw(foo bar));
36 $film->foo(42);
37 is $film->foo, 42;
38
39 $film->bar(23);
40 is $film->bar, 23;
41}
42
43
44# An explicit accessor passed to mk_group_accessors should
45# ignore accessor/mutator_name_for.
46sub Film::accessor_name_for {
47 my($class, $col) = @_;
48 return "hlaglagh" if $col eq "wibble";
49 return $col;
50}
51
52sub Film::mutator_name_for {
53 my($class, $col) = @_;
54 return "hlaglagh" if $col eq "wibble";
55 return $col;
56}
57
58
59# Test with a mix of fields and field specs
60{
61 Film->mk_group_accessors(test => ("baz", [wibble_thing => "wibble"]));
62 $film->baz(42);
63 is $film->baz, 42;
64
65 $film->wibble_thing(23);
66 is $film->wibble_thing, 23;
67}
89bddb49 68
69done_testing;