File: 96_is_deteministic_value.t

package info (click to toggle)
libdbix-class-perl 0.08123-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,520 kB
  • ctags: 1,695
  • sloc: perl: 19,821; sql: 353; makefile: 10
file content (65 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use strict;
use warnings;

# 6 tests

use Test::More;
use lib qw(t/lib);
use DBICTest;
plan skip_all => "DateTime required" unless eval { require DateTime };
eval "use DateTime::Format::Strptime";
plan skip_all => 'DateTime::Format::Strptime required' if $@;
use Test::Exception;

my $schema = DBICTest->init_schema();
my $artist_rs = $schema->resultset('Artist');
my $cd_rs = $schema->resultset('CD');

 {
   my $cd;
   lives_ok {
     $cd = $cd_rs->search({ year => {'=' => 1999}})->create
       ({
         artist => {name => 'Guillermo1'},
         title => 'Guillermo 1',
        });
   };
   is($cd->year, 1999);
 }

 {
   my $formatter = DateTime::Format::Strptime->new(pattern => '%Y');
   my $dt = DateTime->new(year => 2006, month => 06, day => 06,
                          formatter => $formatter );
   my $cd;
   lives_ok {
     $cd = $cd_rs->search({ year => $dt})->create
       ({
         artist => {name => 'Guillermo2'},
         title => 'Guillermo 2',
        });
   };
   is($cd->year, 2006);
 }


{
  my $artist;
  lives_ok {
    $artist = $artist_rs->search({ name => {'!=' => 'Killer'}})
      ->create({artistid => undef});
  };
  is($artist->name, undef);
}


{
  my $artist;
  lives_ok {
    $artist = $artist_rs->search({ name => [ q/ some stupid names here/]})
      ->create({artistid => undef});
  };
  is($artist->name, undef);
}

done_testing;