Merge 'trunk' into 'replication_dedux'
[dbsrgits/DBIx-Class.git] / t / cdbi-t / copy.t
CommitLineData
e60dc79f 1#!/usr/bin/perl -w
2
3use strict;
4use Test::More;
5
6BEGIN {
7 eval "use DBIx::Class::CDBICompat;";
8 plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@")
9 : (tests=> 4);
10}
11
12INIT {
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
34my $film = MyFilm->create({ title => "For Your Eyes Only" });
35ok $film->id;
36
37my $new_film = $film->copy;
38ok $new_film->id;
39isnt $new_film->id, $film->id, "copy() gets new primary key";
40
41$new_film = $film->copy(42);
42is $new_film->id, 42, "copy() with new id";
43