Commit | Line | Data |
70350518 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
a47e1233 |
8 | my $schema = DBICTest->init_schema(); |
0567538f |
9 | |
10 | BEGIN { |
11 | eval "use DBD::SQLite"; |
6c299e8b |
12 | plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 6); |
0567538f |
13 | } |
14 | |
f9db5527 |
15 | my $art = $schema->resultset("Artist")->find(1); |
0567538f |
16 | |
17 | isa_ok $art => 'DBICTest::Artist'; |
18 | |
19 | my $name = 'Caterwauler McCrae'; |
20 | |
21 | ok($art->name($name) eq $name, 'update'); |
22 | |
23 | { |
24 | my @changed_keys = $art->is_changed; |
25 | is( scalar (@changed_keys), 0, 'field changed but same value' ); |
26 | } |
27 | |
28 | $art->discard_changes; |
29 | |
5a9e0e60 |
30 | ok($art->update({ artistid => 100 }), 'update allows pk mutation'); |
31 | |
32 | is($art->artistid, 100, 'pk mutation applied'); |
6c299e8b |
33 | |
34 | my $art_100 = $schema->resultset("Artist")->find(100); |
35 | $art_100->artistid(101); |
36 | ok($art_100->update(), 'update allows pk mutation via column accessor'); |