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