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