Trailing WS crusade - got to save them bits
[dbsrgits/DBIx-Class.git] / t / cdbi / copy.t
CommitLineData
e60dc79f 1use strict;
2use Test::More;
3
4BEGIN {
5 eval "use DBIx::Class::CDBICompat;";
6 plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@")
7 : (tests=> 4);
8}
9
10INIT {
50891152 11 use lib 't/cdbi/testlib';
e60dc79f 12}
13
14{
8273e845 15 package # hide from PAUSE
e60dc79f 16 MyFilm;
17
97d61088 18 use base 'DBIC::Test::SQLite';
e60dc79f 19 use strict;
20
21 __PACKAGE__->set_table('Movies');
22 __PACKAGE__->columns(All => qw(id title));
23
24 sub create_sql {
25 return qq{
26 id INTEGER PRIMARY KEY AUTOINCREMENT,
27 title VARCHAR(255)
28 }
29 }
30}
31
32my $film = MyFilm->create({ title => "For Your Eyes Only" });
33ok $film->id;
34
35my $new_film = $film->copy;
36ok $new_film->id;
37isnt $new_film->id, $film->id, "copy() gets new primary key";
38
39$new_film = $film->copy(42);
40is $new_film->id, 42, "copy() with new id";
41