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