Merge 'trunk' into 'cdbicompat_integration'
[dbsrgits/DBIx-Class.git] / t / 69update.t
CommitLineData
70350518 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
a47e1233 8my $schema = DBICTest->init_schema();
0567538f 9
10BEGIN {
11 eval "use DBD::SQLite";
6c299e8b 12 plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 6);
0567538f 13}
14
f9db5527 15my $art = $schema->resultset("Artist")->find(1);
0567538f 16
17isa_ok $art => 'DBICTest::Artist';
18
19my $name = 'Caterwauler McCrae';
20
21ok($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 30ok($art->update({ artistid => 100 }), 'update allows pk mutation');
31
32is($art->artistid, 100, 'pk mutation applied');
6c299e8b 33
34my $art_100 = $schema->resultset("Artist")->find(100);
35$art_100->artistid(101);
36ok($art_100->update(), 'update allows pk mutation via column accessor');