First stab at restructuring with tests_recursive() - no functional changes
[dbsrgits/DBIx-Class.git] / t / cdbi / copy.t
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 {
11     use lib 't/cdbi/testlib';
12 }
13
14 {
15     package # hide from PAUSE 
16         MyFilm;
17
18     use base 'DBIx::Class::Test::SQLite';
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