File: copy.t

package info (click to toggle)
libdbix-class-perl 0.082843-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,320 kB
  • sloc: perl: 27,215; sql: 322; sh: 29; makefile: 16
file content (42 lines) | stat: -rw-r--r-- 938 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use strict;
use warnings;
use Test::More;

INIT {
    use lib 't/cdbi/testlib';
}

{
    package # hide from PAUSE
        MyFilm;

    use base 'DBIC::Test::SQLite';
    use strict;

    __PACKAGE__->set_table('Movies');
    __PACKAGE__->columns(All => qw(id title));

    # Disables the implicit autoinc-on-non-supplied-pk behavior
    # (and the warning that goes with it)
    # This is the same behavior as it was pre 0.082900
    __PACKAGE__->column_info('id')->{is_auto_increment} = 0;

    sub create_sql {
        return qq{
                id              INTEGER PRIMARY KEY AUTOINCREMENT,
                title           VARCHAR(255)
        }
    }
}

my $film = MyFilm->create({ title => "For Your Eyes Only" });
ok $film->id;

my $new_film = $film->copy;
ok $new_film->id;
isnt $new_film->id, $film->id, "copy() gets new primary key";

$new_film = $film->copy(42);
is $new_film->id, 42, "copy() with new id";

done_testing;