Merge 'trunk' into 'view-deps'
[dbsrgits/DBIx-Class.git] / t / cdbi / 26-mutator.t
CommitLineData
d2cee1fa 1use strict;
2use Test::More;
3
4BEGIN {
40f05175 5 eval "use DBIx::Class::CDBICompat;";
6 plan skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"
7 if $@;
8}
9
10BEGIN {
6a3bf251 11 eval "use DBD::SQLite";
12 plan $@
13 ? (skip_all => 'needs DBD::SQLite for testing')
14 : (tests => 6);
d2cee1fa 15}
16
50891152 17use lib 't/cdbi/testlib';
d2cee1fa 18require Film;
19
20sub Film::accessor_name_for {
6a3bf251 21 my ($class, $col) = @_;
22 return "sheep" if lc $col eq "numexplodingsheep";
23 return $col;
d2cee1fa 24}
25
26my $data = {
6a3bf251 27 Title => 'Bad Taste',
28 Director => 'Peter Jackson',
29 Rating => 'R',
d2cee1fa 30};
31
32my $bt;
33eval {
6a3bf251 34 my $data = $data;
35 $data->{sheep} = 1;
36 ok $bt = Film->insert($data), "Modified accessor - with
d2cee1fa 37accessor";
6a3bf251 38 isa_ok $bt, "Film";
d2cee1fa 39};
40is $@, '', "No errors";
41
42eval {
6a3bf251 43 ok $bt->sheep(2), 'Modified accessor, set';
44 ok $bt->update, 'Update';
d2cee1fa 45};
46is $@, '', "No errors";
47