8 my $schema = DBICTest->init_schema();
10 plan skip_all => 'DT inflation tests need ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_sqlite')
11 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_sqlite');
14 my $event = $schema->resultset("Event")->find(1);
16 isa_ok($event->starts_at, 'DateTime', 'DateTime returned');
18 # klunky, but makes older Test::More installs happy
19 my $starts = $event->starts_at;
20 is("$starts", '2006-04-25T22:24:33', 'Correct date/time');
23 local $TODO = "We can't do this yet before 0.09" if DBIx::Class->VERSION < 0.09;
26 $schema->resultset('Event')->search({ starts_at => $starts })->single);
27 is(eval { $row->id }, 1, 'DT in search');
30 $schema->resultset('Event')->search({ starts_at => { '>=' => $starts } })->single);
31 is(eval { $row->id }, 1, 'DT in search with condition');
34 # create using DateTime
35 my $created = $schema->resultset('Event')->create({
36 starts_at => DateTime->new(year=>2006, month=>6, day=>18),
37 created_on => DateTime->new(year=>2006, month=>6, day=>23)
39 my $created_start = $created->starts_at;
41 isa_ok($created->starts_at, 'DateTime', 'DateTime returned');
42 is("$created_start", '2006-06-18T00:00:00', 'Correct date/time');
45 isa_ok($event->created_on, 'DateTime', 'DateTime returned');
48 isa_ok($event->varchar_date, 'DateTime', 'DateTime returned');
49 isa_ok($event->varchar_datetime, 'DateTime', 'DateTime returned');
51 ## skip inflation field
52 isnt(ref($event->skip_inflation), 'DateTime', 'No DateTime returned for skip inflation column');
54 # klunky, but makes older Test::More installs happy
55 my $createo = $event->created_on;
56 is("$createo", '2006-06-22T21:00:05', 'Correct date/time');
58 my $created_cron = $created->created_on;
60 isa_ok($created->created_on, 'DateTime', 'DateTime returned');
61 is("$created_cron", '2006-06-23T00:00:00', 'Correct date/time');
63 ## varchar field using inflate_date => 1
64 my $varchar_date = $event->varchar_date;
65 is("$varchar_date", '2006-07-23T00:00:00', 'Correct date/time');
67 ## varchar field using inflate_datetime => 1
68 my $varchar_datetime = $event->varchar_datetime;
69 is("$varchar_datetime", '2006-05-22T19:05:07', 'Correct date/time');
71 ## skip inflation field
72 my $skip_inflation = $event->skip_inflation;
73 is ("$skip_inflation", '2006-04-21 18:04:06', 'Correct date/time');