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