Merge 'trunk' into 'replication_dedux'
[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 BEGIN {
11         eval "use DBD::SQLite";
12         plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 6);
13 }                                                                               
14
15 my $art = $schema->resultset("Artist")->find(1);
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
30 ok($art->update({ artistid => 100 }), 'update allows pk mutation');
31
32 is($art->artistid, 100, 'pk mutation applied');
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');