Trailing WS crusade - got to save them bits
[dbsrgits/DBIx-Class.git] / t / 69update.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my $schema = DBICTest->init_schema();
9
10 my $art = $schema->resultset("Artist")->find(1);
11
12 isa_ok $art => 'DBICTest::Artist';
13
14 my $name = 'Caterwauler McCrae';
15
16 ok($art->name($name) eq $name, 'update');
17
18 {
19   my @changed_keys = $art->is_changed;
20   is( scalar (@changed_keys), 0, 'field changed but same value' );
21 }
22
23 $art->discard_changes;
24
25 ok($art->update({ artistid => 100 }), 'update allows pk mutation');
26
27 is($art->artistid, 100, 'pk mutation applied');
28
29 my $art_100 = $schema->resultset("Artist")->find(100);
30 $art_100->artistid(101);
31 ok($art_100->update(), 'update allows pk mutation via column accessor');
32
33 done_testing;