[Rt-commit] r5837 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Thu Aug 31 22:13:40 EDT 2006


Author: ruz
Date: Thu Aug 31 22:13:39 2006
New Revision: 5837

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/t/regression/01ticket_link_searching.t

Log:
 r3674 at cubic-pc:  cubic | 2006-08-31 21:49:27 +0400
 * add tests for LinkedTo and LinkedFrom search keywords


Modified: rt/branches/3.7-EXPERIMENTAL/lib/t/regression/01ticket_link_searching.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/t/regression/01ticket_link_searching.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/t/regression/01ticket_link_searching.t	Thu Aug 31 22:13:39 2006
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-use Test::More tests => 30;
+use Test::More tests => 53;
 use strict;
 use RT;
 
@@ -156,4 +156,68 @@
 ok( $has{$parentid}, "The collection has our parent - $parentid");
 ok( !$has{$childid}, "The collection doesn't have our child - $childid");
 
+my $grand_child_ticket = new RT::Ticket( $CurrentUser );
+my ($grand_childid) = $child_ticket->Create(
+    Subject => 'test child',
+    Queue   => $queue->Id,
+    MemberOf => $childid,
+);
+ok($childid, "We created a grand child ticket");
+
+$Collection = RT::Tickets->new($CurrentUser);
+$Collection->FromSQL( "LinkedTo = $childid" );
+is($Collection->Count,1, "We found only one result");
+ok($Collection->First);
+is($Collection->First->id, $grand_childid, "We found all tickets linked to ticket #$childid");
+
+$Collection = RT::Tickets->new($CurrentUser);
+$Collection->FromSQL( "LinkedFrom = $childid" );
+is($Collection->Count,1, "We found only one result");
+ok($Collection->First);
+is($Collection->First->id, $parentid, "We found all tickets linked from ticket #$childid");
+
+$Collection = RT::Tickets->new($CurrentUser);
+$Collection->FromSQL( "LinkedTo IS NULL" );
+ok($Collection->Count, "Result is set is not empty");
+%has = ();
+while (my $t = $Collection->Next) {
+    ++$has{$t->id};
+}
+ok( $has{$parentid}, "parent is in collection");
+ok( !$has{$childid}, "child is NOT in collection");
+ok( !$has{$grand_childid}, "grand child too is not in collection");
+
+$Collection = RT::Tickets->new($CurrentUser);
+$Collection->FromSQL( "LinkedTo IS NOT NULL" );
+ok($Collection->Count, "Result set is not empty");
+%has = ();
+while (my $t = $Collection->Next) {
+    ++$has{$t->id};
+}
+ok( !$has{$parentid}, "The collection has no our parent - $parentid");
+ok( $has{$childid}, "The collection have our child - $childid");
+ok( $has{$grand_childid}, "The collection have our grand child - $grand_childid");
+
+$Collection = RT::Tickets->new($CurrentUser);
+$Collection->FromSQL( "LinkedFrom IS NULL" );
+ok($Collection->Count, "Result is set is not empty");
+%has = ();
+while (my $t = $Collection->Next) {
+    ++$has{$t->id};
+}
+ok( !$has{$parentid}, "parent is NOT in collection");
+ok( !$has{$childid}, "child is NOT in collection");
+ok( $has{$grand_childid}, "grand child is in collection");
+
+$Collection = RT::Tickets->new($CurrentUser);
+$Collection->FromSQL( "LinkedFrom IS NOT NULL" );
+ok($Collection->Count, "Result set is not empty");
+%has = ();
+while (my $t = $Collection->Next) {
+    ++$has{$t->id};
+}
+ok( $has{$parentid}, "The collection has our parent - $parentid");
+ok( $has{$childid}, "The collection have our child - $childid");
+ok( !$has{$grand_childid}, "The collection have no our grand child - $grand_childid");
+
 1;


More information about the Rt-commit mailing list