File: 26-mutator.t

package info (click to toggle)
libclass-dbi-perl 3.0.17-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 548 kB
  • ctags: 251
  • sloc: perl: 2,118; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (6)
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
37
38
39
40
41
42
43
44
45
46
use strict;
use Test::More;

BEGIN {
	eval "use DBD::SQLite";
	plan $@
		? (skip_all => 'needs DBD::SQLite for testing')
		: (tests => 6);
}

INIT {
	local $SIG{__WARN__} = sub {
		like $_[0], qr/clashes with built-in method/, $_[0];
	};
	use lib 't/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";