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