Commit | Line | Data |
561f003c |
1 | use strict; |
2 | use warnings; |
3 | |
c959e8d0 |
4 | use Test::More; |
68de9438 |
5 | use Test::Exception; |
6 | |
4bea1fe7 |
7 | use lib qw(t/lib); |
8 | use DBICTest; |
9 | |
68de9438 |
10 | BEGIN { |
11 | require DBIx::Class; |
12 | plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') |
13 | unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); |
14 | } |
15 | |
561f003c |
16 | my $schema = DBICTest->init_schema(); |
17 | my $artist_rs = $schema->resultset('Artist'); |
18 | my $cd_rs = $schema->resultset('CD'); |
19 | |
20 | { |
21 | my $cd; |
22 | lives_ok { |
23 | $cd = $cd_rs->search({ year => {'=' => 1999}})->create |
24 | ({ |
25 | artist => {name => 'Guillermo1'}, |
26 | title => 'Guillermo 1', |
27 | }); |
28 | }; |
29 | is($cd->year, 1999); |
30 | } |
31 | |
32 | { |
33 | my $formatter = DateTime::Format::Strptime->new(pattern => '%Y'); |
34 | my $dt = DateTime->new(year => 2006, month => 06, day => 06, |
35 | formatter => $formatter ); |
36 | my $cd; |
37 | lives_ok { |
38 | $cd = $cd_rs->search({ year => $dt})->create |
39 | ({ |
40 | artist => {name => 'Guillermo2'}, |
41 | title => 'Guillermo 2', |
42 | }); |
43 | }; |
44 | is($cd->year, 2006); |
45 | } |
46 | |
47 | |
48 | { |
49 | my $artist; |
50 | lives_ok { |
51 | $artist = $artist_rs->search({ name => {'!=' => 'Killer'}}) |
52 | ->create({artistid => undef}); |
53 | }; |
54 | is($artist->name, undef); |
55 | } |
56 | |
57 | |
58 | { |
59 | my $artist; |
60 | lives_ok { |
1de54066 |
61 | $artist = $artist_rs->search({ name => [ qw(some stupid names here) ]}) |
561f003c |
62 | ->create({artistid => undef}); |
63 | }; |
64 | is($artist->name, undef); |
65 | } |
66 | |
89bddb49 |
67 | done_testing; |