Commit | Line | Data |
e60dc79f |
1 | use strict; |
2 | use Test::More; |
3 | |
e60dc79f |
4 | INIT { |
50891152 |
5 | use lib 't/cdbi/testlib'; |
e60dc79f |
6 | } |
7 | |
8 | { |
8273e845 |
9 | package # hide from PAUSE |
e60dc79f |
10 | MyFilm; |
11 | |
97d61088 |
12 | use base 'DBIC::Test::SQLite'; |
e60dc79f |
13 | use strict; |
14 | |
15 | __PACKAGE__->set_table('Movies'); |
16 | __PACKAGE__->columns(All => qw(id title)); |
17 | |
18 | sub create_sql { |
19 | return qq{ |
20 | id INTEGER PRIMARY KEY AUTOINCREMENT, |
21 | title VARCHAR(255) |
22 | } |
23 | } |
24 | } |
25 | |
26 | my $film = MyFilm->create({ title => "For Your Eyes Only" }); |
27 | ok $film->id; |
28 | |
29 | my $new_film = $film->copy; |
30 | ok $new_film->id; |
31 | isnt $new_film->id, $film->id, "copy() gets new primary key"; |
32 | |
33 | $new_film = $film->copy(42); |
34 | is $new_film->id, 42, "copy() with new id"; |
35 | |
d9bd5195 |
36 | done_testing; |