File: 26-mutator.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 (36 lines) | stat: -rw-r--r-- 603 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
31
32
33
34
35
36
use strict;
use warnings;
use Test::More;

use lib 't/cdbi/testlib';
require Film;

sub Film::accessor_name_for {
  my ($class, $col) = @_;
  return "sheep" if lc $col eq "numexplodingsheep";
  return $col;
}

my $data = {
  Title    => 'Bad Taste',
  Director => 'Peter Jackson',
  Rating   => 'R',
};

my $bt;
eval {
  my $data = $data;
  $data->{sheep} = 1;
  ok $bt = Film->insert($data), "Modified accessor - with
accessor";
  isa_ok $bt, "Film";
};
is $@, '', "No errors";

eval {
  ok $bt->sheep(2), 'Modified accessor, set';
  ok $bt->update, 'Update';
};
is $@, '', "No errors";

done_testing;