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