import rt 3.8.10
[freeside.git] / rt / t / api / tickets_overlay_sql.t
index 7980886..5bc6140 100644 (file)
@@ -1,7 +1,6 @@
 
 use RT;
-use RT::Test tests => 7;
-
+use RT::Test tests => 19;
 
 {
 
@@ -33,6 +32,7 @@ my $string = 'subject/content SQL test';
 
     my $t = RT::Ticket->new($RT::SystemUser);
     ok( $t->Create( Queue => 'General',
+                    Requestor => 'jesse@example.com',
                     Subject => 'another ticket',
                     MIMEObj => $Message,
                     MemberOf => $created[0]
@@ -66,7 +66,30 @@ my $string = 'subject/content SQL test';
     is ($count, scalar @created, "number of returned tickets same as entered");
 }
 
+diag "Make sure we don't barf on invalid input for IS / IS NOT";
+{
+    my ($status, $msg) = $tix->FromSQL("Subject IS 'foobar'");
+    ok ($status, "valid query") or diag("error: $msg");
+    is $tix->Count, 0, "found no tickets";
+    unlike $tix->BuildSelectQuery, qr/foobar/, "didn't find foobar in the select";
+    like $tix->BuildSelectQuery, qr/Subject IS NULL/, "found right clause";
+    
+    my ($status, $msg) = $tix->FromSQL("Subject IS NOT 'foobar'");
+    ok ($status, "valid query") or diag("error: $msg");
+    is $tix->Count, 2, "found two tickets";
+    unlike $tix->BuildSelectQuery, qr/foobar/, "didn't find foobar in the select";
+    like $tix->BuildSelectQuery, qr/Subject IS NOT NULL/, "found right clause";
+}
+
+{
+    my ($status, $msg) = $tix->FromSQL("Requestor.Signature LIKE 'foo'");
+    ok (!$status, "invalid query - Signature not valid") or diag("error: $msg");
 
+    my ($status, $msg) = $tix->FromSQL("Requestor.EmailAddress LIKE 'jesse'");
+    ok ($status, "valid query") or diag("error: $msg");
+    is $tix->Count, 1, "found one ticket";
+    like $tix->First->Subject, qr/another ticket/, "found the right ticket";
+}
 
 }