[Rt-commit] r18606 - rt/3.999/branches/on-tisql/t/ticket

ruz at bestpractical.com ruz at bestpractical.com
Fri Feb 27 13:10:36 EST 2009


Author: ruz
Date: Fri Feb 27 13:10:35 2009
New Revision: 18606

Modified:
   rt/3.999/branches/on-tisql/t/ticket/search_by_watcher.t

Log:
* use tisql in the test

Modified: rt/3.999/branches/on-tisql/t/ticket/search_by_watcher.t
==============================================================================
--- rt/3.999/branches/on-tisql/t/ticket/search_by_watcher.t	(original)
+++ rt/3.999/branches/on-tisql/t/ticket/search_by_watcher.t	Fri Feb 27 13:10:35 2009
@@ -23,6 +23,7 @@
             %{ shift(@data) },
         );
         ok( $id, "ticket Created" ) or diag("error: $msg");
+
         push @res, $t;
         $total++;
     }
@@ -30,10 +31,10 @@
 }
 
 sub run_tests {
-    my $query_prefix = join ' OR ', map 'id = '. $_->id, @tickets;
+    my $query_prefix = join ' OR ', map '.id = '. $_->id, @tickets;
     foreach my $key ( sort keys %test ) {
         my $tix = RT::Model::TicketCollection->new(current_user => RT->system_user);
-        $tix->from_sql( "( $query_prefix ) AND ( $key )" );
+        $tix->tisql->query( "( $query_prefix ) AND ( $key )" );
 
         my $error = 0;
 
@@ -61,30 +62,29 @@
     { subject => 'z', requestor => 'z at example.com' },
 );
 %test = (
-    'requestor = "x at example.com"'  => { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
-    'requestor != "x at example.com"' => { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
+    '.watchers{"requestor"}.email = "x at example.com"'  => { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
+    '.watchers{"requestor"}.email != "x at example.com"' => { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
 
-    'requestor = "y at example.com"'  => { xy => 1, x => 0, y => 1, '-' => 0, z => 0 },
-    'requestor != "y at example.com"' => { xy => 0, x => 1, y => 0, '-' => 1, z => 1 },
+    '.watchers{"requestor"}.email = "y at example.com"'  => { xy => 1, x => 0, y => 1, '-' => 0, z => 0 },
+    '.watchers{"requestor"}.email != "y at example.com"' => { xy => 0, x => 1, y => 0, '-' => 1, z => 1 },
 
-    'requestor LIKE "@example.com"'     => { xy => 1, x => 1, y => 1, '-' => 0, z => 1 },
-    'requestor NOT LIKE "@example.com"' => { xy => 0, x => 0, y => 0, '-' => 1, z => 0 },
+    '.watchers{"requestor"}.email LIKE "@example.com"'     => { xy => 1, x => 1, y => 1, '-' => 0, z => 1 },
+    '.watchers{"requestor"}.email NOT LIKE "@example.com"' => { xy => 0, x => 0, y => 0, '-' => 1, z => 0 },
 
-    'requestor IS NULL'            => { xy => 0, x => 0, y => 0, '-' => 1, z => 0 },
-    'requestor IS NOT NULL'        => { xy => 1, x => 1, y => 1, '-' => 0, z => 1 },
+    'has no .watchers{"requestor"}'            => { xy => 0, x => 0, y => 0, '-' => 1, z => 0 },
+    'has .watchers{"requestor"}'         => { xy => 1, x => 1, y => 1, '-' => 0, z => 1 },
 
-# this test is a todo, we run it later
-#    'requestor = "x at example.com" AND requestor = "y at example.com"'   => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 },
-    'requestor = "x at example.com" OR requestor = "y at example.com"'    => { xy => 1, x => 1, y => 1, '-' => 0, z => 0 },
+    '.watchers{"requestor"}.email = "x at example.com" AND .watchers{"requestor"}.email = "y at example.com"'   => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 },
+    '.watchers{"requestor"}.email = "x at example.com" OR .watchers{"requestor"}.email = "y at example.com"'    => { xy => 1, x => 1, y => 1, '-' => 0, z => 0 },
 
-    'requestor != "x at example.com" AND requestor != "y at example.com"' => { xy => 0, x => 0, y => 0, '-' => 1, z => 1 },
-    'requestor != "x at example.com" OR requestor != "y at example.com"'  => { xy => 0, x => 1, y => 1, '-' => 1, z => 1 },
+    '.watchers{"requestor"}.email != "x at example.com" AND .watchers{"requestor"}.email != "y at example.com"' => { xy => 0, x => 0, y => 0, '-' => 1, z => 1 },
+    '.watchers{"requestor"}.email != "x at example.com" OR .watchers{"requestor"}.email != "y at example.com"'  => { xy => 0, x => 1, y => 1, '-' => 1, z => 1 },
 
-    'requestor = "x at example.com" AND requestor != "y at example.com"'  => { xy => 0, x => 1, y => 0, '-' => 0, z => 0 },
-    'requestor = "x at example.com" OR requestor != "y at example.com"'   => { xy => 1, x => 1, y => 0, '-' => 1, z => 1 },
+    '.watchers{"requestor"}.email = "x at example.com" AND .watchers{"requestor"}.email != "y at example.com"'  => { xy => 0, x => 1, y => 0, '-' => 0, z => 0 },
+    '.watchers{"requestor"}.email = "x at example.com" OR .watchers{"requestor"}.email != "y at example.com"'   => { xy => 1, x => 1, y => 0, '-' => 1, z => 1 },
 
-    'requestor != "x at example.com" AND requestor = "y at example.com"'  => { xy => 0, x => 0, y => 1, '-' => 0, z => 0 },
-    'requestor != "x at example.com" OR requestor = "y at example.com"'   => { xy => 1, x => 0, y => 1, '-' => 1, z => 1 },
+    '.watchers{"requestor"}.email != "x at example.com" AND .watchers{"requestor"}.email = "y at example.com"'  => { xy => 0, x => 0, y => 1, '-' => 0, z => 0 },
+    '.watchers{"requestor"}.email != "x at example.com" OR .watchers{"requestor"}.email = "y at example.com"'   => { xy => 1, x => 0, y => 1, '-' => 1, z => 1 },
 );
 @tickets = add_tix_from_data();
 {
@@ -97,68 +97,55 @@
 # mixing searches by watchers with other conditions
 # http://rt3.fsck.com/Ticket/Display.html?id=9322
 %test = (
-    'Subject LIKE "x" AND Requestor = "y at example.com"' =>
+    '.subject LIKE "x" AND .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 1, x => 0, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" AND Requestor = "y at example.com"' =>
+    '.subject NOT LIKE "x" AND .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 0, x => 0, y => 1, '-' => 0, z => 0 },
-    'Subject LIKE "x" AND Requestor != "y at example.com"' =>
+    '.subject LIKE "x" AND .watchers{"requestor"}.email != "y at example.com"' =>
         { xy => 0, x => 1, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" AND Requestor != "y at example.com"' =>
+    '.subject NOT LIKE "x" AND .watchers{"requestor"}.email != "y at example.com"' =>
         { xy => 0, x => 0, y => 0, '-' => 1, z => 1 },
 
-    'Subject LIKE "x" OR Requestor = "y at example.com"' =>
+    '.subject LIKE "x" OR .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 1, x => 1, y => 1, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" OR Requestor = "y at example.com"' =>
+    '.subject NOT LIKE "x" OR .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 1, x => 0, y => 1, '-' => 1, z => 1 },
-    'Subject LIKE "x" OR Requestor != "y at example.com"' =>
+    '.subject LIKE "x" OR .watchers{"requestor"}.email != "y at example.com"' =>
         { xy => 1, x => 1, y => 0, '-' => 1, z => 1 },
-    'Subject NOT LIKE "x" OR Requestor != "y at example.com"' =>
+    '.subject NOT LIKE "x" OR .watchers{"requestor"}.email != "y at example.com"' =>
         { xy => 0, x => 1, y => 1, '-' => 1, z => 1 },
 
-# group of cases when user doesn't exist in DB at all
-    'Subject LIKE "x" AND Requestor = "not-exist at example.com"' =>
+# group of cases when user doesnt exist in DB at all
+    '.subject LIKE "x" AND .watchers{"requestor"}.email = "not-exist at example.com"' =>
         { xy => 0, x => 0, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" AND Requestor = "not-exist at example.com"' =>
+    '.subject NOT LIKE "x" AND .watchers{"requestor"}.email = "not-exist at example.com"' =>
         { xy => 0, x => 0, y => 0, '-' => 0, z => 0 },
-    'Subject LIKE "x" AND Requestor != "not-exist at example.com"' =>
+    '.subject LIKE "x" AND .watchers{"requestor"}.email != "not-exist at example.com"' =>
+        { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
+    '.subject NOT LIKE "x" AND .watchers{"requestor"}.email != "not-exist at example.com"' =>
+        { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
+    '.subject LIKE "x" OR .watchers{"requestor"}.email = "not-exist at example.com"' =>
         { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" AND Requestor != "not-exist at example.com"' =>
+    '.subject NOT LIKE "x" OR .watchers{"requestor"}.email = "not-exist at example.com"' =>
         { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
-#    'Subject LIKE "x" OR Requestor = "not-exist at example.com"' =>
-#        { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
-#    'Subject NOT LIKE "x" OR Requestor = "not-exist at example.com"' =>
-#        { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
-    'Subject LIKE "x" OR Requestor != "not-exist at example.com"' =>
+    '.subject LIKE "x" OR .watchers{"requestor"}.email != "not-exist at example.com"' =>
         { xy => 1, x => 1, y => 1, '-' => 1, z => 1 },
-    'Subject NOT LIKE "x" OR Requestor != "not-exist at example.com"' =>
+    '.subject NOT LIKE "x" OR .watchers{"requestor"}.email != "not-exist at example.com"' =>
         { xy => 1, x => 1, y => 1, '-' => 1, z => 1 },
 
-    'Subject LIKE "z" AND (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
+    '.subject LIKE "z" AND (.watchers{"requestor"}.email = "x at example.com" OR .watchers{"requestor"}.email = "y at example.com")' =>
         { xy => 0, x => 0, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "z" AND (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
+    '.subject NOT LIKE "z" AND (.watchers{"requestor"}.email = "x at example.com" OR .watchers{"requestor"}.email = "y at example.com")' =>
         { xy => 1, x => 1, y => 1, '-' => 0, z => 0 },
-    'Subject LIKE "z" OR (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
+    '.subject LIKE "z" OR (.watchers{"requestor"}.email = "x at example.com" OR .watchers{"requestor"}.email = "y at example.com")' =>
         { xy => 1, x => 1, y => 1, '-' => 0, z => 1 },
-    'Subject NOT LIKE "z" OR (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
+    '.subject NOT LIKE "z" OR (.watchers{"requestor"}.email = "x at example.com" OR .watchers{"requestor"}.email = "y at example.com")' =>
         { xy => 1, x => 1, y => 1, '-' => 1, z => 0 },
 
     );
 run_tests();
 
 
-TODO: {
-    local $TODO = "we can't generate this query yet";
-    %test = (
-        'requestor = "x at example.com" AND requestor = "y at example.com"'
-            => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 },
-        'subject LIKE "x" OR requestor = "not-exist at example.com"' =>
-            { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
-        'subject NOT LIKE "x" OR requestor = "not-exist at example.com"' =>
-            { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
-    );
-    run_tests();
-}
-
 @data = (
     { subject => 'xy', cc => ['x at example.com'], requestor => [ 'y at example.com' ] },
     { subject => 'x-', cc => ['x at example.com'], requestor => [] },
@@ -169,24 +156,24 @@
     { subject => '-z', cc => [],                requestor => [ 'z at example.com' ] },
 );
 %test = (
-    'cc = "x at example.com" AND requestor = "y at example.com"' =>
+    '.watchers{"cc"}.email = "x at example.com" AND .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 1, 'x-' => 0, '-y' => 0, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
-    'cc = "x at example.com" OR requestor = "y at example.com"' =>
+    '.watchers{"cc"}.email = "x at example.com" OR .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 1, 'x-' => 1, '-y' => 1, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
 
-    'cc != "x at example.com" AND requestor = "y at example.com"' =>
+    '.watchers{"cc"}.email != "x at example.com" AND .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 0, 'x-' => 0, '-y' => 1, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
-    'cc != "x at example.com" OR requestor = "y at example.com"' =>
+    '.watchers{"cc"}.email != "x at example.com" OR .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 1, 'x-' => 0, '-y' => 1, '-' => 1, zz => 1, 'z-' => 1, '-z' => 1 },
 
-    'cc IS NULL AND requestor = "y at example.com"' =>
+    'has no .watchers{"cc"} AND .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 0, 'x-' => 0, '-y' => 1, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
-    'cc IS NULL OR requestor = "y at example.com"' =>
+    'has no .watchers{"cc"} OR .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 1, 'x-' => 0, '-y' => 1, '-' => 1, zz => 0, 'z-' => 0, '-z' => 1 },
 
-    'cc IS NOT NULL AND requestor = "y at example.com"' =>
+    'has .watchers{"cc"} AND .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 1, 'x-' => 0, '-y' => 0, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
-    'cc IS NOT NULL OR requestor = "y at example.com"' =>
+    'has .watchers{"cc"} OR .watchers{"requestor"}.email = "y at example.com"' =>
         { xy => 1, 'x-' => 1, '-y' => 1, '-' => 0, zz => 1, 'z-' => 1, '-z' => 0 },
 );
 @tickets = add_tix_from_data();
@@ -197,9 +184,8 @@
 }
 run_tests();
 
-
 # owner is special watcher because reference is duplicated in two places,
-# owner was an ENUM field now it's WATCHERFIELD, but should support old
+# owner was an ENUM field now its WATCHERFIELD, but should support old
 # style ENUM searches for backward compatibility
 my $nobody = RT->nobody();
 {


More information about the Rt-commit mailing list