Introduce ad hoc requirements and add skip_without method to optdeps
[dbsrgits/DBIx-Class-Historic.git] / t / cdbi / copy.t
1 use strict;
2 use warnings;
3 use Test::More;
4
5 INIT {
6     use lib 't/cdbi/testlib';
7 }
8
9 {
10     package # hide from PAUSE
11         MyFilm;
12
13     use base 'DBIC::Test::SQLite';
14     use strict;
15
16     __PACKAGE__->set_table('Movies');
17     __PACKAGE__->columns(All => qw(id title));
18
19     sub create_sql {
20         return qq{
21                 id              INTEGER PRIMARY KEY AUTOINCREMENT,
22                 title           VARCHAR(255)
23         }
24     }
25 }
26
27 my $film = MyFilm->create({ title => "For Your Eyes Only" });
28 ok $film->id;
29
30 my $new_film = $film->copy;
31 ok $new_film->id;
32 isnt $new_film->id, $film->id, "copy() gets new primary key";
33
34 $new_film = $film->copy(42);
35 is $new_film->id, 42, "copy() with new id";
36
37 done_testing;