File: construct.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 (40 lines) | stat: -rw-r--r-- 801 bytes parent folder | download | duplicates (5)
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
use strict;
use warnings;
use Test::More;

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

{
    Film->insert({
        Title     => "Breaking the Waves",
        Director  => 'Lars von Trier',
        Rating    => 'R'
    });

    my $film = Film->construct({
        Title     => "Breaking the Waves",
        Director  => 'Lars von Trier',
    });

    isa_ok $film, "Film";
    is $film->title,    "Breaking the Waves";
    is $film->director, "Lars von Trier";
    is $film->rating,   "R",
        "constructed objects can get missing data from the db";
}

{
    package Foo;
    use base qw(Film);
    Foo->columns( TEMP => qw(temp_thing) );
    my $film = Foo->construct({
        temp_thing  => 23
    });

    ::is $film->temp_thing, 23, "construct sets temp columns";
}

done_testing;