Move find_co_root into DBICTest::Util
[dbsrgits/DBIx-Class-Historic.git] / t / cdbi / copy.t
1 use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use lib 't/cdbi/testlib';
9
10 {
11     package # hide from PAUSE
12         MyFilm;
13
14     use base 'DBIC::Test::SQLite';
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
28 my $film = MyFilm->create({ title => "For Your Eyes Only" });
29 ok $film->id;
30
31 my $new_film = $film->copy;
32 ok $new_film->id;
33 isnt $new_film->id, $film->id, "copy() gets new primary key";
34
35 $new_film = $film->copy(42);
36 is $new_film->id, 42, "copy() with new id";
37
38 done_testing;