Massive cleanup of DateTime test dependencies, other interim
[dbsrgits/DBIx-Class.git] / t / 96_is_deteministic_value.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6
7 BEGIN {
8   require DBIx::Class;
9   plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt')
10     unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt');
11 }
12
13 use lib qw(t/lib);
14 use DBICTest;
15
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 {
61     $artist = $artist_rs->search({ name => [ q/ some stupid names here/]})
62       ->create({artistid => undef});
63   };
64   is($artist->name, undef);
65 }
66
67 done_testing;