X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2Ft%2Fregression%2F22search_tix_by_watcher.t;h=204c41c374ed18109c40e704354fa89f8f0cdda3;hp=1df7e72b2c8a8b8980e2fbe750623da65da93c94;hb=fc6209f398899f0211cfcedeb81a3cd65e04a941;hpb=ef20b2b6b1feb47ad02b5ff7525f1a0fd11d0fa4 diff --git a/rt/lib/t/regression/22search_tix_by_watcher.t b/rt/lib/t/regression/22search_tix_by_watcher.t index 1df7e72b2..204c41c37 100644 --- a/rt/lib/t/regression/22search_tix_by_watcher.t +++ b/rt/lib/t/regression/22search_tix_by_watcher.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 79; +use Test::More tests => 119; use_ok('RT'); RT::LoadConfig(); RT::Init(); @@ -40,10 +40,7 @@ sub run_tests { my $count = 0; $count++ foreach grep $_, values %{ $test{$key} }; - TODO: { - local $TODO = "we can't generate this query yet"; - is($tix->Count, $count, "found correct number of ticket(s) by '$key'") or $error = 1; - }; + is($tix->Count, $count, "found correct number of ticket(s) by '$key'") or $error = 1; my $good_tickets = 1; while ( my $ticket = $tix->Next ) { @@ -77,7 +74,8 @@ sub run_tests { '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 }, - 'Requestor = "x@example.com" AND Requestor = "y@example.com"' => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 }, +# this test is a todo, we run it later +# 'Requestor = "x@example.com" AND Requestor = "y@example.com"' => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 }, 'Requestor = "x@example.com" OR Requestor = "y@example.com"' => { xy => 1, x => 1, y => 1, '-' => 0, z => 0 }, 'Requestor != "x@example.com" AND Requestor != "y@example.com"' => { xy => 0, x => 0, y => 0, '-' => 1, z => 1 }, @@ -97,6 +95,65 @@ sub run_tests { } run_tests(); +# mixing searches by watchers with other conditions +# http://rt3.fsck.com/Ticket/Display.html?id=9322 +%test = ( + 'Subject LIKE "x" AND Requestor = "y@example.com"' => + { xy => 1, x => 0, y => 0, '-' => 0, z => 0 }, + 'Subject NOT LIKE "x" AND Requestor = "y@example.com"' => + { xy => 0, x => 0, y => 1, '-' => 0, z => 0 }, + 'Subject LIKE "x" AND Requestor != "y@example.com"' => + { xy => 0, x => 1, y => 0, '-' => 0, z => 0 }, + 'Subject NOT LIKE "x" AND Requestor != "y@example.com"' => + { xy => 0, x => 0, y => 0, '-' => 1, z => 1 }, + + 'Subject LIKE "x" OR Requestor = "y@example.com"' => + { xy => 1, x => 1, y => 1, '-' => 0, z => 0 }, + 'Subject NOT LIKE "x" OR Requestor = "y@example.com"' => + { xy => 1, x => 0, y => 1, '-' => 1, z => 1 }, + 'Subject LIKE "x" OR Requestor != "y@example.com"' => + { xy => 1, x => 1, y => 0, '-' => 1, z => 1 }, + 'Subject NOT LIKE "x" OR Requestor != "y@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@example.com"' => + { xy => 0, x => 0, y => 0, '-' => 0, z => 0 }, + 'Subject NOT LIKE "x" AND Requestor = "not-exist@example.com"' => + { xy => 0, x => 0, y => 0, '-' => 0, z => 0 }, + 'Subject LIKE "x" AND Requestor != "not-exist@example.com"' => + { xy => 1, x => 1, y => 0, '-' => 0, z => 0 }, + 'Subject NOT LIKE "x" AND Requestor != "not-exist@example.com"' => + { xy => 0, x => 0, y => 1, '-' => 1, z => 1 }, + 'Subject LIKE "x" OR Requestor = "not-exist@example.com"' => + { xy => 1, x => 1, y => 0, '-' => 0, z => 0 }, + 'Subject NOT LIKE "x" OR Requestor = "not-exist@example.com"' => + { xy => 0, x => 0, y => 1, '-' => 1, z => 1 }, + 'Subject LIKE "x" OR Requestor != "not-exist@example.com"' => + { xy => 1, x => 1, y => 1, '-' => 1, z => 1 }, + 'Subject NOT LIKE "x" OR Requestor != "not-exist@example.com"' => + { xy => 1, x => 1, y => 1, '-' => 1, z => 1 }, + + 'Subject LIKE "z" AND (Requestor = "x@example.com" OR Requestor = "y@example.com")' => + { xy => 0, x => 0, y => 0, '-' => 0, z => 0 }, + 'Subject NOT LIKE "z" AND (Requestor = "x@example.com" OR Requestor = "y@example.com")' => + { xy => 1, x => 1, y => 1, '-' => 0, z => 0 }, + 'Subject LIKE "z" OR (Requestor = "x@example.com" OR Requestor = "y@example.com")' => + { xy => 1, x => 1, y => 1, '-' => 0, z => 1 }, + 'Subject NOT LIKE "z" OR (Requestor = "x@example.com" OR Requestor = "y@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@example.com" AND Requestor = "y@example.com"' + => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 }, + ); + run_tests(); +} + @data = ( { Subject => 'xy', Cc => ['x@example.com'], Requestor => [ 'y@example.com' ] }, { Subject => 'x-', Cc => ['x@example.com'], Requestor => [] }, @@ -135,6 +192,7 @@ run_tests(); } 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 # style ENUM searches for backward compatibility