3 use RT::Test tests => 20, config => 'Set( %FullTextSearch, Enable => 1 );';
6 my $tix = RT::Tickets->new(RT->SystemUser);
8 my $query = "Status = 'open'";
9 my ($status, $msg) = $tix->FromSQL($query);
10 ok ($status, "correct query") or diag("error: $msg");
14 my (@created,%created);
15 my $string = 'subject/content SQL test';
17 my $t = RT::Ticket->new(RT->SystemUser);
18 ok( $t->Create(Queue => 'General', Subject => $string), "Ticket Created");
19 $created{ $t->Id }++; push @created, $t->Id;
23 my $Message = MIME::Entity->build(
24 Subject => 'this is my subject',
25 From => 'jesse@example.com',
29 my $t = RT::Ticket->new(RT->SystemUser);
30 ok( $t->Create( Queue => 'General',
31 Requestor => 'jesse@example.com',
32 Subject => 'another ticket',
34 MemberOf => $created[0]
38 $created{ $t->Id }++; push @created, $t->Id;
42 my $query = ("Subject LIKE '$string' OR Content LIKE '$string'");
43 my ($status, $msg) = $tix->FromSQL($query);
44 ok ($status, "correct query") or diag("error: $msg");
47 while (my $tick = $tix->Next) {
48 $count++ if $created{ $tick->id };
50 is ($count, scalar @created, "number of returned tickets same as entered");
54 my $query = "id = $created[0] OR MemberOf = $created[0]";
55 my ($status, $msg) = $tix->FromSQL($query);
56 ok ($status, "correct query") or diag("error: $msg");
59 while (my $tick = $tix->Next) {
60 $count++ if $created{ $tick->id };
62 is ($count, scalar @created, "number of returned tickets same as entered");
65 diag "Make sure we don't barf on invalid input for IS / IS NOT";
67 my ($status, $msg) = $tix->FromSQL("Subject IS 'foobar'");
68 ok ($status, "valid query") or diag("error: $msg");
69 is $tix->Count, 0, "found no tickets";
70 unlike $tix->BuildSelectQuery, qr/foobar/, "didn't find foobar in the select";
71 like $tix->BuildSelectQuery, qr/Subject IS NULL/, "found right clause";
73 ($status, $msg) = $tix->FromSQL("Subject IS NOT 'foobar'");
74 ok ($status, "valid query") or diag("error: $msg");
75 is $tix->Count, 2, "found two tickets";
76 unlike $tix->BuildSelectQuery, qr/foobar/, "didn't find foobar in the select";
77 like $tix->BuildSelectQuery, qr/Subject IS NOT NULL/, "found right clause";
84 ($status, $msg) = $tix->FromSQL("Requestor.Signature LIKE 'foo'");
85 } qr/Invalid watcher subfield: 'Signature'/;
86 ok(!$status, "invalid query - Signature not valid") or diag("error: $msg");
88 ($status, $msg) = $tix->FromSQL("Requestor.EmailAddress LIKE 'jesse'");
89 ok ($status, "valid query") or diag("error: $msg");
90 is $tix->Count, 1, "found one ticket";
91 like $tix->First->Subject, qr/another ticket/, "found the right ticket";