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