Merge 'trunk' into 'prefetch'
[dbsrgits/DBIx-Class.git] / t / 96_is_deteministic_value.t
CommitLineData
561f003c 1use strict;
2use warnings;
3
4# 6 tests
5
c959e8d0 6use Test::More;
561f003c 7use lib qw(t/lib);
8use DBICTest;
a14185ef 9plan skip_all => "DateTime required" unless eval { require DateTime };
c959e8d0 10eval "use DateTime::Format::Strptime";
11plan skip_all => 'DateTime::Format::Strptime required' if $@;
12plan 'no_plan';
561f003c 13use Test::Exception;
14
15my $schema = DBICTest->init_schema();
16my $artist_rs = $schema->resultset('Artist');
17my $cd_rs = $schema->resultset('CD');
18
19 {
20 my $cd;
21 lives_ok {
22 $cd = $cd_rs->search({ year => {'=' => 1999}})->create
23 ({
24 artist => {name => 'Guillermo1'},
25 title => 'Guillermo 1',
26 });
27 };
28 is($cd->year, 1999);
29 }
30
31 {
32 my $formatter = DateTime::Format::Strptime->new(pattern => '%Y');
33 my $dt = DateTime->new(year => 2006, month => 06, day => 06,
34 formatter => $formatter );
35 my $cd;
36 lives_ok {
37 $cd = $cd_rs->search({ year => $dt})->create
38 ({
39 artist => {name => 'Guillermo2'},
40 title => 'Guillermo 2',
41 });
42 };
43 is($cd->year, 2006);
44 }
45
46
47{
48 my $artist;
49 lives_ok {
50 $artist = $artist_rs->search({ name => {'!=' => 'Killer'}})
51 ->create({artistid => undef});
52 };
53 is($artist->name, undef);
54}
55
56
57{
58 my $artist;
59 lives_ok {
60 $artist = $artist_rs->search({ name => [ q/ some stupid names here/]})
61 ->create({artistid => undef});
62 };
63 is($artist->name, undef);
64}
65
66
671;