Move find_co_root into DBICTest::Util
[dbsrgits/DBIx-Class-Historic.git] / t / cdbi / copy.t
CommitLineData
83eef562 1use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
2
e60dc79f 3use strict;
4a233f30 4use warnings;
83eef562 5
e60dc79f 6use Test::More;
7
a40329c4 8use lib 't/cdbi/testlib';
e60dc79f 9
10{
8273e845 11 package # hide from PAUSE
e60dc79f 12 MyFilm;
13
97d61088 14 use base 'DBIC::Test::SQLite';
e60dc79f 15 use strict;
16
17 __PACKAGE__->set_table('Movies');
18 __PACKAGE__->columns(All => qw(id title));
19
20 sub create_sql {
21 return qq{
22 id INTEGER PRIMARY KEY AUTOINCREMENT,
23 title VARCHAR(255)
24 }
25 }
26}
27
28my $film = MyFilm->create({ title => "For Your Eyes Only" });
29ok $film->id;
30
31my $new_film = $film->copy;
32ok $new_film->id;
33isnt $new_film->id, $film->id, "copy() gets new primary key";
34
35$new_film = $film->copy(42);
36is $new_film->id, 42, "copy() with new id";
37
d9bd5195 38done_testing;