import rt 3.8.11
[freeside.git] / rt / lib / t / regression / 22search_tix_by_txn.t
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Test::More tests => 10;
7
8 BEGIN{ $ENV{'TZ'} = 'GMT'};
9
10 use RT;
11 RT::LoadConfig();
12 RT::Init();
13
14 my $SUBJECT = "Search test - ".$$;
15
16 use_ok('RT::Tickets');
17 my $tix = RT::Tickets->new($RT::SystemUser);
18 can_ok($tix, 'FromSQL');
19 $tix->FromSQL('Updated = "2005-08-05" AND Subject = "$SUBJECT"');
20
21 ok(! $tix->Count, "Searching for tickets updated on a random date finds nothing" . $tix->Count);
22
23 my $ticket = RT::Ticket->new($RT::SystemUser);
24 $ticket->Create(Queue => 'General', Subject => $SUBJECT);
25 ok ($ticket->id, "We created a ticket");
26 my ($id, $txnid, $txnobj) =  $ticket->Comment( Content => 'A comment that happend on 2004-01-01');
27
28 isa_ok($txnobj, 'RT::Transaction');
29
30 ok($txnobj->CreatedObj->ISO);
31 my ( $sid,$smsg) = $txnobj->__Set(Field => 'Created', Value => '2005-08-05 20:00:56');
32 ok($sid,$smsg);
33 is($txnobj->Created,'2005-08-05 20:00:56');
34 is($txnobj->CreatedObj->ISO,'2005-08-05 20:00:56');
35
36 $tix->FromSQL(qq{Updated = "2005-08-05" AND Subject = "$SUBJECT"});
37 is( $tix->Count, 1);
38