Commit | Line | Data |
e60dc79f |
1 | use strict; |
2 | use Test::More; |
3 | |
4 | BEGIN { |
5 | eval "use DBIx::Class::CDBICompat;"; |
6 | plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") |
7 | : (tests=> 4); |
8 | } |
9 | |
10 | INIT { |
50891152 |
11 | use lib 't/cdbi/testlib'; |
e60dc79f |
12 | } |
13 | |
14 | { |
15 | package # hide from PAUSE |
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 | |
32 | my $film = MyFilm->create({ title => "For Your Eyes Only" }); |
33 | ok $film->id; |
34 | |
35 | my $new_film = $film->copy; |
36 | ok $new_film->id; |
37 | isnt $new_film->id, $film->id, "copy() gets new primary key"; |
38 | |
39 | $new_film = $film->copy(42); |
40 | is $new_film->id, 42, "copy() with new id"; |
41 | |