[Rt-commit] r7152 - rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api

ruz at bestpractical.com ruz at bestpractical.com
Mon Mar 5 10:34:53 EST 2007


Author: ruz
Date: Mon Mar  5 10:34:51 2007
New Revision: 7152

Added:
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ace.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/acl.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/action-createtickets.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/action-generic.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/action-sendemail.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/attachment.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/attachments.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/attribute.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/cachedgroupmembers.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/condition-generic.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/condition-ownerchange.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/currentuser.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/customfield.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/customfields.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/emailparser.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/group.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/groupmember.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/groupmembers.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/groups.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/handle.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/i18n.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/interface-cli.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/interface-email.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/interface-web.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/link.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/links.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/principals.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/queue.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/queues.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/record.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/rt.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/savedsearch.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/savedsearches.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scrip.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripaction.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripactions.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripcondition.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripconditions.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scrips.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-activeticketsinqueue.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-fromsql.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-generic.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-googleish.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/searchbuilder.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/system.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/template.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/templates.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ticket.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/tickets.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/tickets_overlay_sql.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/transaction.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/transactions.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/uri-fsck_com_rt.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/uri-t.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/user.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/users.t

Log:
* gen test files from inline tests

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ace.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ace.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,252 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 60 lib/RT/ACE_Overlay.pm
+
+ok(require RT::ACE);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 92 lib/RT/ACE_Overlay.pm
+
+my $Queue = RT::Queue->new($RT::SystemUser);
+
+is ($Queue->AvailableRights->{'DeleteTicket'} , 'Delete tickets', "Found the delete ticket right");
+is ($RT::System->AvailableRights->{'SuperUser'},  'Do anything and everything', "Found the superuser right");
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 350 lib/RT/ACE_Overlay.pm
+
+use_ok(RT::User);
+my $user_a = RT::User->new($RT::SystemUser);
+$user_a->Create( Name => 'DelegationA', Privileged => 1);
+ok ($user_a->Id, "Created delegation user a");
+
+my $user_b = RT::User->new($RT::SystemUser);
+$user_b->Create( Name => 'DelegationB', Privileged => 1);
+ok ($user_b->Id, "Created delegation user b");
+
+
+use_ok(RT::Queue);
+my $q = RT::Queue->new($RT::SystemUser);
+$q->Create(Name =>'DelegationTest');
+ok ($q->Id, "Created a delegation test queue");
+
+
+#------ First, we test whether a user can delegate a right that's been granted to him personally 
+my ($val, $msg) = $user_a->PrincipalObj->GrantRight(Object => $RT::System, Right => 'AdminOwnPersonalGroups');
+ok($val, $msg);
+
+($val, $msg) = $user_a->PrincipalObj->GrantRight(Object =>$q, Right => 'OwnTicket');
+ok($val, $msg);
+
+ok($user_a->HasRight( Object => $RT::System, Right => 'AdminOwnPersonalGroups')    ,"user a has the right 'AdminOwnPersonalGroups' directly");
+
+my $a_delegates = RT::Group->new($user_a);
+$a_delegates->CreatePersonalGroup(Name => 'Delegates');
+ok( $a_delegates->Id   ,"user a creates a personal group 'Delegates'");
+ok( $a_delegates->AddMember($user_b->PrincipalId)   ,"user a adds user b to personal group 'delegates'");
+
+ok( !$user_b->HasRight(Right => 'OwnTicket', Object => $q)    ,"user b does not have the right to OwnTicket' in queue 'DelegationTest'");
+ok(  $user_a->HasRight(Right => 'OwnTicket', Object => $q)  ,"user a has the right to 'OwnTicket' in queue 'DelegationTest'");
+ok(!$user_a->HasRight( Object => $RT::System, Right => 'DelegateRights')    ,"user a does not have the right 'delegate rights'");
+
+
+my $own_ticket_ace = RT::ACE->new($user_a);
+my $user_a_equiv_group = RT::Group->new($user_a);
+$user_a_equiv_group->LoadACLEquivalenceGroup($user_a->PrincipalObj);
+ok ($user_a_equiv_group->Id, "Loaded the user A acl equivalence group");
+my $user_b_equiv_group = RT::Group->new($user_b);
+$user_b_equiv_group->LoadACLEquivalenceGroup($user_b->PrincipalObj);
+ok ($user_b_equiv_group->Id, "Loaded the user B acl equivalence group");
+$own_ticket_ace->LoadByValues( PrincipalType => 'Group', PrincipalId => $user_a_equiv_group->PrincipalId, Object=>$q, RightName => 'OwnTicket');
+
+ok ($own_ticket_ace->Id, "Found the ACE we want to test with for now");
+
+
+($val, $msg) = $own_ticket_ace->Delegate(PrincipalId => $a_delegates->PrincipalId)  ;
+ok( !$val ,"user a tries and fails to delegate the right 'ownticket' in queue 'DelegationTest' to personal group 'delegates' - $msg");
+
+
+($val, $msg) = $user_a->PrincipalObj->GrantRight( Right => 'DelegateRights');
+ok($val, "user a is granted the right to 'delegate rights' - $msg");
+
+ok($user_a->HasRight( Object => $RT::System, Right => 'DelegateRights')    ,"user a has the right 'AdminOwnPersonalGroups' directly");
+
+($val, $msg) = $own_ticket_ace->Delegate(PrincipalId => $a_delegates->PrincipalId) ;
+
+ok( $val    ,"user a tries and succeeds to delegate the right 'ownticket' in queue 'DelegationTest' to personal group 'delegates' - $msg");
+ok(  $user_b->HasRight(Right => 'OwnTicket', Object => $q)  ,"user b has the right to own tickets in queue 'DelegationTest'");
+my $delegated_ace = RT::ACE->new($user_a);
+$delegated_ace->LoadByValues ( Object => $q, RightName => 'OwnTicket', PrincipalType => 'Group',
+PrincipalId => $a_delegates->PrincipalId, DelegatedBy => $user_a->PrincipalId, DelegatedFrom => $own_ticket_ace->Id);
+ok ($delegated_ace->Id, "Found the delegated ACE");
+
+ok(    $a_delegates->DeleteMember($user_b->PrincipalId)  ,"user a removes b from pg 'delegates'");
+ok(  !$user_b->HasRight(Right => 'OwnTicket', Object => $q)  ,"user b does not have the right to own tickets in queue 'DelegationTest'");
+ok(  $a_delegates->AddMember($user_b->PrincipalId)    ,"user a adds user b to personal group 'delegates'");
+ok(   $user_b->HasRight(Right => 'OwnTicket', Object=> $q) ,"user b has the right to own tickets in queue 'DelegationTest'");
+ok(   $delegated_ace->Delete ,"user a revokes pg 'delegates' right to 'OwnTickets' in queue 'DelegationTest'");
+ok( ! $user_b->HasRight(Right => 'OwnTicket', Object => $q)   ,"user b does not have the right to own tickets in queue 'DelegationTest'");
+
+($val, $msg) = $own_ticket_ace->Delegate(PrincipalId => $a_delegates->PrincipalId)  ;
+ok(  $val  ,"user a delegates pg 'delegates' right to 'OwnTickets' in queue 'DelegationTest' - $msg");
+
+ok( $user_a->HasRight(Right => 'OwnTicket', Object => $q)    ,"user a does not have the right to own tickets in queue 'DelegationTest'");
+
+($val, $msg) = $user_a->PrincipalObj->RevokeRight(Object=>$q, Right => 'OwnTicket');
+ok($val, "Revoked user a's right to own tickets in queue 'DelegationTest". $msg);
+
+ok( !$user_a->HasRight(Right => 'OwnTicket', Object => $q)    ,"user a does not have the right to own tickets in queue 'DelegationTest'");
+
+ ok( !$user_b->HasRight(Right => 'OwnTicket', Object => $q)   ,"user b does not have the right to own tickets in queue 'DelegationTest'");
+
+($val, $msg) = $user_a->PrincipalObj->GrantRight(Object=>$q, Right => 'OwnTicket');
+ok($val, $msg);
+
+ ok( $user_a->HasRight(Right => 'OwnTicket', Object => $q)   ,"user a has the right to own tickets in queue 'DelegationTest'");
+
+ ok(  !$user_b->HasRight(Right => 'OwnTicket', Object => $q)  ,"user b does not have the right to own tickets in queue 'DelegationTest'");
+
+# {{{ get back to a known clean state 
+($val, $msg) = $user_a->PrincipalObj->RevokeRight( Object => $q, Right => 'OwnTicket');
+ok($val, "Revoked user a's right to own tickets in queue 'DelegationTest -". $msg);
+ok( !$user_a->HasRight(Right => 'OwnTicket', Object => $q)    ,"make sure that user a can't own tickets in queue 'DelegationTest'");
+# }}}
+
+
+# {{{ Set up some groups and membership
+my $del1 = RT::Group->new($RT::SystemUser);
+($val, $msg) = $del1->CreateUserDefinedGroup(Name => 'Del1');
+ok( $val   ,"create a group del1 - $msg");
+
+my $del2 = RT::Group->new($RT::SystemUser);
+($val, $msg) = $del2->CreateUserDefinedGroup(Name => 'Del2');
+ok( $val   ,"create a group del2 - $msg");
+($val, $msg) = $del1->AddMember($del2->PrincipalId);
+ok( $val,"make del2 a member of del1 - $msg");
+
+my $del2a = RT::Group->new($RT::SystemUser);
+($val, $msg) = $del2a->CreateUserDefinedGroup(Name => 'Del2a');
+ok( $val   ,"create a group del2a - $msg");
+($val, $msg) = $del2->AddMember($del2a->PrincipalId);  
+ok($val    ,"make del2a a member of del2 - $msg");
+
+my $del2b = RT::Group->new($RT::SystemUser);
+($val, $msg) = $del2b->CreateUserDefinedGroup(Name => 'Del2b');
+ok( $val   ,"create a group del2b - $msg");
+($val, $msg) = $del2->AddMember($del2b->PrincipalId);  
+ok($val    ,"make del2b a member of del2 - $msg");
+
+($val, $msg) = $del2->AddMember($user_a->PrincipalId) ;
+ok($val,"make 'user a' a member of del2 - $msg");
+
+($val, $msg) = $del2b->AddMember($user_a->PrincipalId) ;
+ok($val,"make 'user a' a member of del2b - $msg");
+
+# }}}
+
+# {{{ Grant a right to a group and make sure that a submember can delegate the right and that it does not get yanked
+# when a user is removed as a submember, when they're a sumember through another path 
+($val, $msg) = $del1->PrincipalObj->GrantRight( Object=> $q, Right => 'OwnTicket');
+ok( $val   ,"grant del1  the right to 'OwnTicket' in queue 'DelegationTest' - $msg");
+
+ok(  $user_a->HasRight(Right => 'OwnTicket', Object => $q)  ,"make sure that user a can own tickets in queue 'DelegationTest'");
+
+my $group_ace= RT::ACE->new($user_a);
+$group_ace->LoadByValues( PrincipalType => 'Group', PrincipalId => $del1->PrincipalId, Object => $q, RightName => 'OwnTicket');
+
+ok ($group_ace->Id, "Found the ACE we want to test with for now");
+
+($val, $msg) = $group_ace->Delegate(PrincipalId => $a_delegates->PrincipalId);
+
+ok( $val   ,"user a tries and succeeds to delegate the right 'ownticket' in queue 'DelegationTest' to personal group 'delegates' - $msg");
+ok(  $user_b->HasRight(Right => 'OwnTicket', Object => $q)  ,"user b has the right to own tickets in queue 'DelegationTest'");
+
+
+($val, $msg) = $del2b->DeleteMember($user_a->PrincipalId);
+ok( $val   ,"remove user a from group del2b - $msg");
+ok(  $user_a->HasRight(Right => 'OwnTicket', Object => $q)  ,"user a has the right to own tickets in queue 'DelegationTest'");
+ok( $user_b->HasRight(Right => 'OwnTicket', Object => $q)    ,"user b has the right to own tickets in queue 'DelegationTest'");
+
+# }}}
+
+# {{{ When a  user is removed froom a group by the only path they're in there by, make sure the delegations go away
+($val, $msg) = $del2->DeleteMember($user_a->PrincipalId);
+ok( $val   ,"remove user a from group del2 - $msg");
+ok(  !$user_a->HasRight(Right => 'OwnTicket', Object => $q)  ,"user a does not have the right to own tickets in queue 'DelegationTest' ");
+ok(  !$user_b->HasRight(Right => 'OwnTicket', Object => $q)  ,"user b does not have the right to own tickets in queue 'DelegationTest' ");
+# }}}
+
+($val, $msg) = $del2->AddMember($user_a->PrincipalId);
+ok( $val   ,"make user a a member of group del2 - $msg");
+
+($val, $msg) = $del2->PrincipalObj->GrantRight(Object=>$q, Right => 'OwnTicket');
+ok($val, "grant the right 'own tickets' in queue 'DelegationTest' to group del2 - $msg");
+
+my $del2_right = RT::ACE->new($user_a);
+$del2_right->LoadByValues( PrincipalId => $del2->PrincipalId, PrincipalType => 'Group', Object => $q, RightName => 'OwnTicket');
+ok ($del2_right->Id, "Found the right");
+
+($val, $msg) = $del2_right->Delegate(PrincipalId => $a_delegates->PrincipalId);
+ok( $val   ,"user a tries and succeeds to delegate the right 'ownticket' in queue 'DelegationTest' gotten via del2 to personal group 'delegates' - $msg");
+
+# They have it via del1 and del2
+ok( $user_a->HasRight(Right => 'OwnTicket', Object => $q)   ,"user b has the right to own tickets in queue 'DelegationTest'");
+
+
+($val, $msg) = $del2->PrincipalObj->RevokeRight(Object=>$q, Right => 'OwnTicket');
+ok($val, "revoke the right 'own tickets' in queue 'DelegationTest' to group del2 - $msg");
+ok(  $user_a->HasRight(Right => 'OwnTicket', Object => $q)  ,"user a does has the right to own tickets in queue 'DelegationTest' via del1");
+ok(  !$user_b->HasRight(Right => 'OwnTicket', Object => $q)   ,"user b does not have the right to own tickets in queue 'DelegationTest'");
+
+($val, $msg) = $del2->PrincipalObj->GrantRight(Object=>$q, Right => 'OwnTicket');
+ok($val, "grant the right 'own tickets' in queue 'DelegationTest' to group del2 - $msg");
+
+
+$group_ace= RT::ACE->new($user_a);
+$group_ace->LoadByValues( PrincipalType => 'Group', PrincipalId => $del1->PrincipalId, Object=>$q, RightName => 'OwnTicket');
+
+ok ($group_ace->Id, "Found the ACE we want to test with for now");
+
+($val, $msg) = $group_ace->Delegate(PrincipalId => $a_delegates->PrincipalId);
+
+ok( $val   ,"user a tries and succeeds to delegate the right 'ownticket' in queue 'DelegationTest' to personal group 'delegates' - $msg");
+
+ok( $user_b->HasRight(Right => 'OwnTicket', Object => $q)    ,"user b has the right to own tickets in queue 'DelegationTest'");
+
+($val, $msg) = $del2->DeleteMember($user_a->PrincipalId);
+ok( $val   ,"remove user a from group del2 - $msg");
+
+ok(  !$user_a->HasRight(Right => 'OwnTicket', Object => $q)  ,"user a does not have the right to own tickets in queue 'DelegationTest'");
+
+ok(  !$user_b->HasRight(Right => 'OwnTicket', Object => $q)   ,"user b does not have the right to own tickets in queue 'DelegationTest'");
+
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/acl.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/acl.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/ACL_Overlay.pm
+
+ok(require RT::ACL);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/action-createtickets.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/action-createtickets.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,244 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 238 lib/RT/Action/CreateTickets.pm
+
+ok (require RT::Action::CreateTickets);
+use_ok(RT::Scrip);
+use_ok(RT::Template);
+use_ok(RT::ScripAction);
+use_ok(RT::ScripCondition);
+use_ok(RT::Ticket);
+
+my $approvalsq = RT::Queue->new($RT::SystemUser);
+$approvalsq->Create(Name => 'Approvals');
+ok ($approvalsq->Id, "Created Approvals test queue");
+
+
+my $approvals = 
+'===Create-Ticket: approval
+Queue: ___Approvals
+Type: approval
+AdminCc: {join ("\nAdminCc: ", at admins) }
+Depended-On-By: {$Tickets{"TOP"}->Id}
+Refers-To: TOP 
+Subject: Approval for ticket: {$Tickets{"TOP"}->Id} - {$Tickets{"TOP"}->Subject}
+Due: {time + 86400}
+Content-Type: text/plain
+Content: Your approval is requested for the ticket {$Tickets{"TOP"}->Id}: {$Tickets{"TOP"}->Subject}
+Blah
+Blah
+ENDOFCONTENT
+===Create-Ticket: two
+Subject: Manager approval.
+Depended-On-By: approval
+Queue: ___Approvals
+Content-Type: text/plain
+Content: 
+Your minion approved ticket {$Tickets{"TOP"}->Id}. you ok with that?
+ENDOFCONTENT
+';
+
+ok ($approvals =~ /Content/, "Read in the approvals template");
+
+my $apptemp = RT::Template->new($RT::SystemUser);
+$apptemp->Create( Content => $approvals, Name => "Approvals", Queue => "0");
+
+ok ($apptemp->Id);
+
+my $q = RT::Queue->new($RT::SystemUser);
+$q->Create(Name => 'WorkflowTest');
+ok ($q->Id, "Created workflow test queue");
+
+my $scrip = RT::Scrip->new($RT::SystemUser);
+my ($sval, $smsg) =$scrip->Create( ScripCondition => 'On Transaction',
+                ScripAction => 'Create Tickets',
+                Template => 'Approvals',
+                Queue => $q->Id);
+ok ($sval, $smsg);
+ok ($scrip->Id, "Created the scrip");
+ok ($scrip->TemplateObj->Id, "Created the scrip template");
+ok ($scrip->ConditionObj->Id, "Created the scrip condition");
+ok ($scrip->ActionObj->Id, "Created the scrip action");
+
+my $t = RT::Ticket->new($RT::SystemUser);
+my($tid, $ttrans, $tmsg) = $t->Create(Subject => "Sample workflow test",
+           Owner => "root",
+           Queue => $q->Id);
+
+ok ($tid,$tmsg);
+
+my $deps = $t->DependsOn;
+is ($deps->Count, 1, "The ticket we created depends on one other ticket");
+my $dependson= $deps->First->TargetObj;
+ok ($dependson->Id, "It depends on a real ticket");
+unlike ($dependson->Subject, qr/{/, "The subject doesn't have braces in it. that means we're interpreting expressions");
+is ($t->ReferredToBy->Count,1, "It's only referred to by one other ticket");
+is ($t->ReferredToBy->First->BaseObj->Id,$t->DependsOn->First->TargetObj->Id, "The same ticket that depends on it refers to it.");
+use RT::Action::CreateTickets;
+my $action =  RT::Action::CreateTickets->new( CurrentUser => $RT::SystemUser);;
+
+# comma-delimited templates
+my $commas = <<"EOF";
+id,Queue,Subject,Owner,Content
+ticket1,General,"foo, bar",root,blah
+ticket2,General,foo bar,root,blah
+ticket3,General,foo' bar,root,blah'boo
+ticket4,General,foo' bar,,blah'boo
+EOF
+
+
+# Comma delimited templates with missing data
+my $sparse_commas = <<"EOF";
+id,Queue,Subject,Owner,Requestor
+ticket14,General,,,bobby
+ticket15,General,,,tommy
+ticket16,General,,suzie,tommy
+ticket17,General,Foo "bar" baz,suzie,tommy
+ticket18,General,'Foo "bar" baz',suzie,tommy
+ticket19,General,'Foo bar' baz,suzie,tommy
+EOF
+
+
+# tab-delimited templates
+my $tabs = <<"EOF";
+id\tQueue\tSubject\tOwner\tContent
+ticket10\tGeneral\t"foo' bar"\troot\tblah'
+ticket11\tGeneral\tfoo, bar\troot\tblah
+ticket12\tGeneral\tfoo' bar\troot\tblah'boo
+ticket13\tGeneral\tfoo' bar\t\tblah'boo
+EOF
+
+my %expected;
+
+$expected{ticket1} = <<EOF;
+Queue: General
+Subject: foo, bar
+Owner: root
+Content: blah
+ENDOFCONTENT
+EOF
+
+$expected{ticket2} = <<EOF;
+Queue: General
+Subject: foo bar
+Owner: root
+Content: blah
+ENDOFCONTENT
+EOF
+
+$expected{ticket3} = <<EOF;
+Queue: General
+Subject: foo' bar
+Owner: root
+Content: blah'boo
+ENDOFCONTENT
+EOF
+
+$expected{ticket4} = <<EOF;
+Queue: General
+Subject: foo' bar
+Owner: 
+Content: blah'boo
+ENDOFCONTENT
+EOF
+
+$expected{ticket10} = <<EOF;
+Queue: General
+Subject: foo' bar
+Owner: root
+Content: blah'
+ENDOFCONTENT
+EOF
+
+$expected{ticket11} = <<EOF;
+Queue: General
+Subject: foo, bar
+Owner: root
+Content: blah
+ENDOFCONTENT
+EOF
+
+$expected{ticket12} = <<EOF;
+Queue: General
+Subject: foo' bar
+Owner: root
+Content: blah'boo
+ENDOFCONTENT
+EOF
+
+$expected{ticket13} = <<EOF;
+Queue: General
+Subject: foo' bar
+Owner: 
+Content: blah'boo
+ENDOFCONTENT
+EOF
+
+
+$expected{'ticket14'} = <<EOF;
+Queue: General
+Subject: 
+Owner: 
+Requestor: bobby
+EOF
+$expected{'ticket15'} = <<EOF;
+Queue: General
+Subject: 
+Owner: 
+Requestor: tommy
+EOF
+$expected{'ticket16'} = <<EOF;
+Queue: General
+Subject: 
+Owner: suzie
+Requestor: tommy
+EOF
+$expected{'ticket17'} = <<EOF;
+Queue: General
+Subject: Foo "bar" baz
+Owner: suzie
+Requestor: tommy
+EOF
+$expected{'ticket18'} = <<EOF;
+Queue: General
+Subject: Foo "bar" baz
+Owner: suzie
+Requestor: tommy
+EOF
+$expected{'ticket19'} = <<EOF;
+Queue: General
+Subject: 'Foo bar' baz
+Owner: suzie
+Requestor: tommy
+EOF
+
+
+
+
+$action->Parse(Content =>$commas);
+$action->Parse(Content =>$sparse_commas);
+$action->Parse(Content => $tabs);
+
+my %got;
+foreach (@{ $action->{'create_tickets'} }) {
+  $got{$_} = $action->{'templates'}->{$_};
+}
+
+foreach my $id ( sort keys %expected ) {
+    ok(exists($got{"create-$id"}), "template exists for $id");
+    is($got{"create-$id"}, $expected{$id}, "template is correct for $id");
+}
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/action-generic.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/action-generic.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 60 lib/RT/Action/Generic.pm
+
+ok (require RT::Action::Generic);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/action-sendemail.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/action-sendemail.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 79 lib/RT/Action/SendEmail.pm
+
+ok (require RT::Action::SendEmail);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/attachment.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/attachment.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,54 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 63 lib/RT/Attachment_Overlay.pm
+
+ok (require RT::Attachment);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 557 lib/RT/Attachment_Overlay.pm
+
+my $test1 = "From: jesse";
+my @headers = RT::Attachment->_SplitHeaders($test1);
+is ($#headers, 0, $test1 );
+
+my $test2 = qq{From: jesse
+To: bobby
+Subject: foo
+};
+
+ at headers = RT::Attachment->_SplitHeaders($test2);
+is ($#headers, 2, "testing a bunch of singline multiple headers" );
+
+
+my $test3 = qq{From: jesse
+To: bobby,
+ Suzie,
+    Sally,
+    Joey: bizzy,
+Subject: foo
+};
+
+ at headers = RT::Attachment->_SplitHeaders($test3);
+is ($#headers, 2, "testing a bunch of singline multiple headers" );
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/attachments.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/attachments.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 65 lib/RT/Attachments_Overlay.pm
+
+ok (require RT::Attachments);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/attribute.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/attribute.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,46 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 290 lib/RT/Attribute_Overlay.pm
+
+my $user = $RT::SystemUser;
+my ($id, $msg) =  $user->AddAttribute(Name => 'SavedSearch', Content => { Query => 'Foo'} );
+ok ($id, $msg);
+my $attr = RT::Attribute->new($RT::SystemUser);
+$attr->Load($id);
+ok($attr->Name eq 'SavedSearch');
+$attr->SetSubValues( Format => 'baz');
+
+my $format = $attr->SubValue('Format');
+is ($format , 'baz');
+
+$attr->SetSubValues( Format => 'bar');
+$format = $attr->SubValue('Format');
+is ($format , 'bar');
+
+$attr->DeleteAllSubValues();
+$format = $attr->SubValue('Format');
+is ($format, undef);
+
+$attr->SetSubValues(Format => 'This is a format');
+
+my $attr2 = RT::Attribute->new($RT::SystemUser);
+$attr2->Load($id);
+is ($attr2->SubValue('Format'), 'This is a format');
+$attr2->Delete;
+my $attr3 = RT::Attribute->new($RT::SystemUser);
+my ($id) = $attr3->Load($id);
+is ($id, 0);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/cachedgroupmembers.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/cachedgroupmembers.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/CachedGroupMembers_Overlay.pm
+
+ok (require RT::CachedGroupMembers);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/condition-generic.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/condition-generic.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 73 lib/RT/Condition/Generic.pm
+
+ok (require RT::Condition::Generic);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/condition-ownerchange.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/condition-ownerchange.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,55 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/Condition/OwnerChange.pm
+
+my $q = RT::Queue->new($RT::SystemUser);
+$q->Create(Name =>'ownerChangeTest');
+
+ok($q->Id, "Created a scriptest queue");
+
+my $s1 = RT::Scrip->new($RT::SystemUser);
+my ($val, $msg) =$s1->Create( Queue => $q->Id,
+             ScripAction => 'User Defined',
+             ScripCondition => 'On Owner Change',
+             CustomIsApplicableCode => '',
+             CustomPrepareCode => 'return 1',
+             CustomCommitCode => '
+                    $self->TicketObj->SetPriority($self->TicketObj->Priority+1);
+                return(1);
+            ',
+             Template => 'Blank'
+    );
+ok($val,$msg);
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+my ($tv,$ttv,$tm) = $ticket->Create(Queue => $q->Id,
+                                    Subject => "hair on fire",
+                                    InitialPriority => '20'
+                                    );
+ok($tv, $tm);
+ok($ticket->SetOwner('root'));
+is ($ticket->Priority , '21', "Ticket priority is set right");
+ok($ticket->Steal);
+is ($ticket->Priority , '22', "Ticket priority is set right");
+ok($ticket->Untake);
+is ($ticket->Priority , '23', "Ticket priority is set right");
+ok($ticket->Take);
+is ($ticket->Priority , '24', "Ticket priority is set right");
+
+
+
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/currentuser.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/currentuser.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,41 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 63 lib/RT/CurrentUser.pm
+
+ok (require RT::CurrentUser);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 202 lib/RT/CurrentUser.pm
+
+ok (my $cu = RT::CurrentUser->new('root'));
+ok (my $lh = $cu->LanguageHandle('en-us'));
+ok ($lh != undef);
+ok ($lh->isa('Locale::Maketext'));
+is ($cu->loc('TEST_STRING'), "Concrete Mixer", "Localized TEST_STRING into English");
+SKIP: {
+    skip "French localization is not enabled", 2
+        unless grep $_ && $_ =~ /^(\*|fr)$/, RT->Config->Get('LexiconLanguages');
+    ok ($lh = $cu->LanguageHandle('fr'));
+    is ($cu->loc('Before'), "Avant", "Localized TEST_STRING into French");
+}
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/customfield.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/customfield.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,78 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 308 lib/RT/CustomField_Overlay.pm
+
+use_ok(RT::CustomField);
+ok(my $cf = RT::CustomField->new($RT::SystemUser));
+ok(my ($id, $msg)=  $cf->Create( Name => 'TestingCF',
+                                 Queue => '0',
+                                 SortOrder => '1',
+                                 Description => 'A Testing custom field',
+                                 Type=> 'SelectSingle'), 'Created a global CustomField');
+ok($id != 0, 'Global custom field correctly created');
+ok ($cf->SingleValue);
+is($cf->Type, 'Select');
+is($cf->MaxValues, 1);
+
+my ($val, $msg) = $cf->SetMaxValues('0');
+ok($val, $msg);
+is($cf->Type, 'Select');
+is($cf->MaxValues, 0);
+ok(!$cf->SingleValue );
+ok(my ($bogus_val, $bogus_msg) = $cf->SetType('BogusType') , "Trying to set a custom field's type to a bogus type");
+ok($bogus_val == 0, "Unable to set a custom field's type to a bogus type");
+
+ok(my $bad_cf = RT::CustomField->new($RT::SystemUser));
+ok(my ($bad_id, $bad_msg)=  $cf->Create( Name => 'TestingCF-bad',
+                                 Queue => '0',
+                                 SortOrder => '1',
+                                 Description => 'A Testing custom field with a bogus Type',
+                                 Type=> 'SelectSingleton'), 'Created a global CustomField with a bogus type');
+ok($bad_id == 0, 'Global custom field correctly decided to not create a cf with a bogus type ');
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 373 lib/RT/CustomField_Overlay.pm
+
+ok(my $cf = RT::CustomField->new($RT::SystemUser));
+$cf->Load(1);
+ok($cf->Id == 1);
+ok(my ($val,$msg)  = $cf->AddValue(Name => 'foo' , Description => 'TestCFValue', SortOrder => '6'));
+ok($val != 0);
+ok (my ($delval, $delmsg) = $cf->DeleteValue($val));
+ok ($delval,"Deleting a cf value: $delmsg");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 565 lib/RT/CustomField_Overlay.pm
+
+ok(my $cf = RT::CustomField->new($RT::SystemUser));
+ok($cf->ValidateType('SelectSingle'));
+ok($cf->ValidateType('SelectMultiple'));
+ok(!$cf->ValidateType('SelectFooMultiple'));
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/customfields.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/customfields.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 61 lib/RT/CustomFields_Overlay.pm
+
+ok (require RT::CustomFields);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/emailparser.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/emailparser.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,46 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 72 lib/RT/EmailParser.pm
+
+ok(require RT::EmailParser);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 411 lib/RT/EmailParser.pm
+
+is(RT::EmailParser::IsRTAddress("","rt\@example.com"),1, "Regexp matched rt address" );
+is(RT::EmailParser::IsRTAddress("","frt\@example.com"),undef, "Regexp didn't match non-rt address" );
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 443 lib/RT/EmailParser.pm
+
+ at before = ("rt\@example.com", "frt\@example.com");
+ at after = ("frt\@example.com");
+ok(eq_array(RT::EmailParser::CullRTAddresses("", at before), at after), "CullRTAddresses only culls RT addresses");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/group.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/group.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,108 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 66 lib/RT/Group_Overlay.pm
+
+# {{{ Tests
+ok (require RT::Group);
+
+ok (my $group = RT::Group->new($RT::SystemUser), "instantiated a group object");
+ok (my ($id, $msg) = $group->CreateUserDefinedGroup( Name => 'TestGroup', Description => 'A test group',
+                    ), 'Created a new group');
+ok ($id != 0, "Group id is $id");
+ok ($group->Name eq 'TestGroup', "The group's name is 'TestGroup'");
+my $ng = RT::Group->new($RT::SystemUser);
+
+ok($ng->LoadUserDefinedGroup('TestGroup'), "Loaded testgroup");
+ok(($ng->id == $group->id), "Loaded the right group");
+
+
+ok (($id,$msg) = $ng->AddMember('1'), "Added a member to the group");
+ok($id, $msg);
+ok (($id,$msg) = $ng->AddMember('2' ), "Added a member to the group");
+ok($id, $msg);
+ok (($id,$msg) = $ng->AddMember('3' ), "Added a member to the group");
+ok($id, $msg);
+
+# Group 1 now has members 1, 2 ,3
+
+my $group_2 = RT::Group->new($RT::SystemUser);
+ok (my ($id_2, $msg_2) = $group_2->CreateUserDefinedGroup( Name => 'TestGroup2', Description => 'A second test group'), , 'Created a new group');
+ok ($id_2 != 0, "Created group 2 ok- $msg_2 ");
+ok (($id,$msg) = $group_2->AddMember($ng->PrincipalId), "Made TestGroup a member of testgroup2");
+ok($id, $msg);
+ok (($id,$msg) = $group_2->AddMember('1' ), "Added  member RT_System to the group TestGroup2");
+ok($id, $msg);
+
+# Group 2 how has 1, g1->{1, 2,3}
+
+my $group_3 = RT::Group->new($RT::SystemUser);
+ok (($id_3, $msg) = $group_3->CreateUserDefinedGroup( Name => 'TestGroup3', Description => 'A second test group'), 'Created a new group');
+ok ($id_3 != 0, "Created group 3 ok - $msg");
+ok (($id,$msg) =$group_3->AddMember($group_2->PrincipalId), "Made TestGroup a member of testgroup2");
+ok($id, $msg);
+
+# g3 now has g2->{1, g1->{1,2,3}}
+
+my $principal_1 = RT::Principal->new($RT::SystemUser);
+$principal_1->Load('1');
+
+my $principal_2 = RT::Principal->new($RT::SystemUser);
+$principal_2->Load('2');
+
+ok (($id,$msg) = $group_3->AddMember('1' ), "Added  member RT_System to the group TestGroup2");
+ok($id, $msg);
+
+# g3 now has 1, g2->{1, g1->{1,2,3}}
+
+ok($group_3->HasMember($principal_2) == undef, "group 3 doesn't have member 2");
+ok($group_3->HasMemberRecursively($principal_2), "group 3 has member 2 recursively");
+ok($ng->HasMember($principal_2) , "group ".$ng->Id." has member 2");
+my ($delid , $delmsg) =$ng->DeleteMember($principal_2->Id);
+ok ($delid !=0, "Sucessfully deleted it-".$delid."-".$delmsg);
+
+#Gotta reload the group objects, since we've been messing with various internals.
+# we shouldn't need to do this.
+#$ng->LoadUserDefinedGroup('TestGroup');
+#$group_2->LoadUserDefinedGroup('TestGroup2');
+#$group_3->LoadUserDefinedGroup('TestGroup');
+
+# G1 now has 1, 3
+# Group 2 how has 1, g1->{1, 3}
+# g3 now has  1, g2->{1, g1->{1, 3}}
+
+ok(!$ng->HasMember($principal_2)  , "group ".$ng->Id." no longer has member 2");
+ok($group_3->HasMemberRecursively($principal_2) == undef, "group 3 doesn't have member 2");
+ok($group_2->HasMemberRecursively($principal_2) == undef, "group 2 doesn't have member 2");
+ok($ng->HasMember($principal_2) == undef, "group 1 doesn't have member 2");;
+ok($group_3->HasMemberRecursively($principal_2) == undef, "group 3 has member 2 recursively");
+
+# }}}
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 1363 lib/RT/Group_Overlay.pm
+
+ok(my $u = RT::Group->new($RT::SystemUser));
+ok($u->Load(4), "Loaded the first user");
+ok($u->PrincipalObj->ObjectId == 4, "user 4 is the fourth principal");
+ok($u->PrincipalObj->PrincipalType eq 'Group' , "Principal 4 is a group");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/groupmember.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/groupmember.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 68 lib/RT/GroupMember_Overlay.pm
+
+ok (require RT::GroupMember);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/groupmembers.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/groupmembers.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/GroupMembers_Overlay.pm
+
+ok (require RT::GroupMembers);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/groups.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/groups.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,157 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 67 lib/RT/Groups_Overlay.pm
+
+ok (require RT::Groups);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 91 lib/RT/Groups_Overlay.pm
+
+# next had bugs
+# Groups->Limit( FIELD => 'id', OPERATOR => '!=', VALUE => xx );
+my $g = RT::Group->new($RT::SystemUser);
+my ($id, $msg) = $g->CreateUserDefinedGroup(Name => 'GroupsNotEqualTest');
+ok ($id, "created group #". $g->id) or diag("error: $msg");
+
+my $groups = RT::Groups->new($RT::SystemUser);
+$groups->Limit( FIELD => 'id', OPERATOR => '!=', VALUE => $g->id );
+$groups->LimitToUserDefinedGroups();
+my $bug = grep $_->id == $g->id, @{$groups->ItemsArrayRef};
+ok (!$bug, "didn't find group");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 269 lib/RT/Groups_Overlay.pm
+
+my $u = RT::User->new($RT::SystemUser);
+my ($id, $msg) = $u->Create( Name => 'Membertests'. $$ );
+ok ($id, 'created user') or diag "error: $msg";
+
+my $g = RT::Group->new($RT::SystemUser);
+($id, $msg) = $g->CreateUserDefinedGroup(Name => 'Membertests');
+ok ($id, $msg);
+
+my ($aid, $amsg) =$g->AddMember($u->id);
+ok ($aid, $amsg);
+ok($g->HasMember($u->PrincipalObj),"G has member u");
+
+my $groups = RT::Groups->new($RT::SystemUser);
+$groups->LimitToUserDefinedGroups();
+$groups->WithMember(PrincipalId => $u->id);
+ok ($groups->Count == 1,"found the 1 group - " . $groups->Count);
+ok ($groups->First->Id == $g->Id, "it's the right one");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 318 lib/RT/Groups_Overlay.pm
+
+my $q = RT::Queue->new($RT::SystemUser);
+my ($id, $msg) =$q->Create( Name => 'GlobalACLTest');
+ok ($id, $msg);
+
+my $testuser = RT::User->new($RT::SystemUser);
+($id,$msg) = $testuser->Create(Name => 'JustAnAdminCc');
+ok ($id,$msg);
+
+my $global_admin_cc = RT::Group->new($RT::SystemUser);
+$global_admin_cc->LoadSystemRoleGroup('AdminCc');
+ok($global_admin_cc->id, "Found the global admincc group");
+my $groups = RT::Groups->new($RT::SystemUser);
+$groups->WithRight(Right => 'OwnTicket', Object => $q);
+is($groups->Count, 1);
+($id, $msg) = $global_admin_cc->PrincipalObj->GrantRight(Right =>'OwnTicket', Object=> $RT::System);
+ok ($id,$msg);
+ok (!$testuser->HasRight(Object => $q, Right => 'OwnTicket') , "The test user does not have the right to own tickets in the test queue");
+($id, $msg) = $q->AddWatcher(Type => 'AdminCc', PrincipalId => $testuser->id);
+ok($id,$msg);
+ok ($testuser->HasRight(Object => $q, Right => 'OwnTicket') , "The test user does have the right to own tickets now. thank god.");
+
+$groups = RT::Groups->new($RT::SystemUser);
+$groups->WithRight(Right => 'OwnTicket', Object => $q);
+ok ($id,$msg);
+is($groups->Count, 3);
+
+my $RTxGroup = RT::Group->new($RT::SystemUser);
+($id, $msg) = $RTxGroup->CreateUserDefinedGroup( Name => 'RTxGroup', Description => "RTx extension group");
+ok ($id,$msg);
+is ($RTxGroup->id, $id, "group loaded");
+
+my $RTxSysObj = {};
+bless $RTxSysObj, 'RTx::System';
+*RTx::System::Id = sub { 1; };
+*RTx::System::id = *RTx::System::Id;
+my $ace = RT::Record->new($RT::SystemUser);
+$ace->Table('ACL');
+$ace->_BuildTableAttributes unless ($_TABLE_ATTR->{ref($self)});
+($id, $msg) = $ace->Create( PrincipalId => $RTxGroup->id, PrincipalType => 'Group', RightName => 'RTxGroupRight', ObjectType => 'RTx::System', ObjectId  => 1);
+ok ($id, "ACL for RTxSysObj created");
+
+my $RTxObj = {};
+bless $RTxObj, 'RTx::System::Record';
+*RTx::System::Record::Id = sub { 4; };
+*RTx::System::Record::id = *RTx::System::Record::Id;
+
+$groups = RT::Groups->new($RT::SystemUser);
+$groups->WithRight(Right => 'RTxGroupRight', Object => $RTxSysObj);
+is($groups->Count, 1, "RTxGroupRight found for RTxSysObj");
+
+$groups = RT::Groups->new($RT::SystemUser);
+$groups->WithRight(Right => 'RTxGroupRight', Object => $RTxObj);
+is($groups->Count, 0, "RTxGroupRight not found for RTxObj");
+
+$groups = RT::Groups->new($RT::SystemUser);
+$groups->WithRight(Right => 'RTxGroupRight', Object => $RTxObj, EquivObjects => [ $RTxSysObj ]);
+is($groups->Count, 1, "RTxGroupRight found for RTxObj using EquivObjects");
+
+$ace = RT::Record->new($RT::SystemUser);
+$ace->Table('ACL');
+$ace->_BuildTableAttributes unless ($_TABLE_ATTR->{ref($self)});
+($id, $msg) = $ace->Create( PrincipalId => $RTxGroup->id, PrincipalType => 'Group', RightName => 'RTxGroupRight', ObjectType => 'RTx::System::Record', ObjectId  => 5 );
+ok ($id, "ACL for RTxObj created");
+
+my $RTxObj2 = {};
+bless $RTxObj2, 'RTx::System::Record';
+*RTx::System::Record::Id = sub { 5; };
+
+$groups = RT::Groups->new($RT::SystemUser);
+$groups->WithRight(Right => 'RTxGroupRight', Object => $RTxObj2);
+is($groups->Count, 1, "RTxGroupRight found for RTxObj2");
+
+$groups = RT::Groups->new($RT::SystemUser);
+$groups->WithRight(Right => 'RTxGroupRight', Object => $RTxObj2, EquivObjects => [ $RTxSysObj ]);
+is($groups->Count, 1, "RTxGroupRight found for RTxObj2");
+
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/handle.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/handle.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 58 lib/RT/Handle.pm
+
+ok(require RT::Handle);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/i18n.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/i18n.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,39 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 89 lib/RT/I18N.pm
+
+use_ok (RT::I18N);
+ok(RT::I18N->Init);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 140 lib/RT/I18N.pm
+
+ok(my $chinese = RT::I18N->get_handle('zh_tw'));
+ok(UNIVERSAL::can($chinese, 'maketext'));
+ok($chinese->maketext('__Content-Type') =~ /utf-8/i, "Found the utf-8 charset for traditional chinese in the string ".$chinese->maketext('__Content-Type'));
+ok($chinese->encoding eq 'utf-8', "The encoding is 'utf-8' -".$chinese->encoding);
+
+ok(my $en = RT::I18N->get_handle('en'));
+ok(UNIVERSAL::can($en, 'maketext'));
+ok($en->encoding eq 'utf-8', "The encoding ".$en->encoding." is 'utf-8'");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/interface-cli.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/interface-cli.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 102 lib/RT/Interface/CLI.pm
+
+ok(require RT::Interface::CLI);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/interface-email.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/interface-email.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 97 lib/RT/Interface/Email.pm
+
+ok(require RT::Interface::Email);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/interface-web.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/interface-web.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 57 lib/RT/Interface/Web.pm
+
+use_ok(RT::Interface::Web);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/link.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/link.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,28 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 64 lib/RT/Link_Overlay.pm
+
+
+use RT::Link;
+my $link = RT::Link->new($RT::SystemUser);
+
+
+ok (ref $link);
+ok (UNIVERSAL::isa($link, 'RT::Link'));
+ok (UNIVERSAL::isa($link, 'RT::Base'));
+ok (UNIVERSAL::isa($link, 'RT::Record'));
+ok (UNIVERSAL::isa($link, 'DBIx::SearchBuilder::Record'));
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/links.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/links.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 63 lib/RT/Links_Overlay.pm
+
+ok (require RT::Links);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/principals.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/principals.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/Principals_Overlay.pm
+
+ok (require RT::Principals);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/queue.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/queue.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,115 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 61 lib/RT/Queue_Overlay.pm
+
+use RT::Queue;
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 238 lib/RT/Queue_Overlay.pm
+
+my $q = RT::Queue->new($RT::SystemUser);
+ok($q->IsValidStatus('new')== 1, 'New is a valid status');
+ok($q->IsValidStatus('f00')== 0, 'f00 is not a valid status');
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 265 lib/RT/Queue_Overlay.pm
+
+my $q = RT::Queue->new($RT::SystemUser);
+ok($q->IsActiveStatus('new')== 1, 'New is a Active status');
+ok($q->IsActiveStatus('rejected')== 0, 'Rejected is an inactive status');
+ok($q->IsActiveStatus('f00')== 0, 'f00 is not a Active status');
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 293 lib/RT/Queue_Overlay.pm
+
+my $q = RT::Queue->new($RT::SystemUser);
+ok($q->IsInactiveStatus('new')== 0, 'New is a Active status');
+ok($q->IsInactiveStatus('rejected')== 1, 'rejeected is an Inactive status');
+ok($q->IsInactiveStatus('f00')== 0, 'f00 is not a Active status');
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 335 lib/RT/Queue_Overlay.pm
+
+my $queue = RT::Queue->new($RT::SystemUser);
+my ($id, $val) = $queue->Create( Name => 'Test1');
+ok($id, $val);
+
+($id, $val) = $queue->Create( Name => '66');
+ok(!$id, $val);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 643 lib/RT/Queue_Overlay.pm
+
+my $Queue = RT::Queue->new($RT::SystemUser); my ($id, $msg) = $Queue->Create(Name => "Foo",
+                );
+ok ($id, "Foo $id was created");
+ok(my $group = RT::Group->new($RT::SystemUser));
+ok($group->LoadQueueRoleGroup(Queue => $id, Type=> 'Cc'));
+ok ($group->Id, "Found the requestors object for this Queue");
+
+
+ok ((my $add_id, $add_msg) = $Queue->AddWatcher(Type => 'Cc', Email => 'bob at fsck.com'), "Added bob at fsck.com as a requestor");
+ok ($add_id, "Add succeeded: ($add_msg)");
+ok(my $bob = RT::User->new($RT::SystemUser), "Creating a bob rt::user");
+$bob->LoadByEmail('bob at fsck.com');
+ok($bob->Id,  "Found the bob rt user");
+ok ($Queue->IsWatcher(Type => 'Cc', PrincipalId => $bob->PrincipalId), "The Queue actually has bob at fsck.com as a requestor");;
+ok ((my $add_id, $add_msg) = $Queue->DeleteWatcher(Type =>'Cc', Email => 'bob at fsck.com'), "Added bob at fsck.com as a requestor");
+ok (!$Queue->IsWatcher(Type => 'Cc', Principal => $bob->PrincipalId), "The Queue no longer has bob at fsck.com as a requestor");;
+
+
+$group = RT::Group->new($RT::SystemUser);
+ok($group->LoadQueueRoleGroup(Queue => $id, Type=> 'Cc'));
+ok ($group->Id, "Found the cc object for this Queue");
+$group = RT::Group->new($RT::SystemUser);
+ok($group->LoadQueueRoleGroup(Queue => $id, Type=> 'AdminCc'));
+ok ($group->Id, "Found the AdminCc object for this Queue");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/queues.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/queues.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/Queues_Overlay.pm
+
+ok (require RT::Queues);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/record.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/record.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,84 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 58 lib/RT/Record.pm
+
+ok (require RT::Record);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 133 lib/RT/Record.pm
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+my $group = RT::Group->new($RT::SystemUser);
+is($ticket->ObjectTypeStr, 'Ticket', "Ticket returns correct typestring");
+is($group->ObjectTypeStr, 'Group', "Group returns correct typestring");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 1029 lib/RT/Record.pm
+
+my $t1 = RT::Ticket->new($RT::SystemUser);
+my ($id, $trans, $msg) = $t1->Create(Subject => 'DepTest1', Queue => 'general');
+ok($id, "Created dep test 1 - $msg");
+
+my $t2 = RT::Ticket->new($RT::SystemUser);
+my ($id2, $trans, $msg2) = $t2->Create(Subject => 'DepTest2', Queue => 'general');
+ok($id2, "Created dep test 2 - $msg2");
+my $t3 = RT::Ticket->new($RT::SystemUser);
+my ($id3, $trans, $msg3) = $t3->Create(Subject => 'DepTest3', Queue => 'general', Type => 'approval');
+ok($id3, "Created dep test 3 - $msg3");
+my ($addid, $addmsg);
+ok (($addid, $addmsg) =$t1->AddLink( Type => 'DependsOn', Target => $t2->id));
+ok ($addid, $addmsg);
+ok (($addid, $addmsg) =$t1->AddLink( Type => 'DependsOn', Target => $t3->id));
+
+ok ($addid, $addmsg);
+my $link = RT::Link->new($RT::SystemUser);
+my ($rv, $msg) = $link->Load($addid);
+ok ($rv, $msg);
+ok ($link->LocalTarget == $t3->id, "Link LocalTarget is correct");
+ok ($link->LocalBase   == $t1->id, "Link LocalBase   is correct");
+
+ok ($t1->HasUnresolvedDependencies, "Ticket ".$t1->Id." has unresolved deps");
+ok (!$t1->HasUnresolvedDependencies( Type => 'blah' ), "Ticket ".$t1->Id." has no unresolved blahs");
+ok ($t1->HasUnresolvedDependencies( Type => 'approval' ), "Ticket ".$t1->Id." has unresolved approvals");
+ok (!$t2->HasUnresolvedDependencies, "Ticket ".$t2->Id." has no unresolved deps");
+;
+
+my ($rid, $rmsg)= $t1->Resolve();
+ok(!$rid, $rmsg);
+my ($rid2, $rmsg2) = $t2->Resolve();
+ok ($rid2, $rmsg2);
+($rid, $rmsg)= $t1->Resolve();
+ok(!$rid, $rmsg);
+my ($rid3,$rmsg3) = $t3->Resolve;
+ok ($rid3,$rmsg3);
+($rid, $rmsg)= $t1->Resolve();
+ok($rid, $rmsg);
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/rt.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/rt.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,22 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 395 lib/RT.pm
+
+ok ($RT::Nobody->Name() eq 'Nobody', "Nobody is nobody");
+ok ($RT::Nobody->Name() ne 'root', "Nobody isn't named root");
+ok ($RT::SystemUser->Name() eq 'RT_System', "The system user is RT_System");
+ok ($RT::SystemUser->Name() ne 'noname', "The system user isn't noname");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/savedsearch.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/savedsearch.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,21 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 64 lib/RT/SavedSearch.pm
+
+use_ok(RT::SavedSearch);
+
+# Real tests are in lib/t/20savedsearch.t
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/savedsearches.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/savedsearches.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,21 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 64 lib/RT/SavedSearches.pm
+
+use_ok(RT::SavedSearches);
+
+# The real tests are in lib/t/20savedsearch.t
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scrip.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scrip.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,53 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 61 lib/RT/Scrip_Overlay.pm
+
+ok (require RT::Scrip);
+
+
+my $q = RT::Queue->new($RT::SystemUser);
+$q->Create(Name => 'ScripTest');
+ok($q->Id, "Created a scriptest queue");
+
+my $s1 = RT::Scrip->new($RT::SystemUser);
+my ($val, $msg) =$s1->Create( Queue => $q->Id,
+             ScripAction => 'User Defined',
+             ScripCondition => 'User Defined',
+             CustomIsApplicableCode => 'if ($self->TicketObj->Subject =~ /fire/) { return (1);} else { return(0)}',
+             CustomPrepareCode => 'return 1',
+             CustomCommitCode => '$self->TicketObj->SetPriority("87");',
+             Template => 'Blank'
+    );
+ok($val,$msg);
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+my ($tv,$ttv,$tm) = $ticket->Create(Queue => $q->Id,
+                                    Subject => "hair on fire",
+                                    );
+ok($tv, $tm);
+
+ok ($ticket->Priority == '87', "Ticket priority is set right");
+
+
+my $ticket2 = RT::Ticket->new($RT::SystemUser);
+my ($t2v,$t2tv,$t2m) = $ticket2->Create(Queue => $q->Id,
+                                    Subject => "hair in water",
+                                    );
+ok($t2v, $t2m);
+
+ok ($ticket2->Priority != '87', "Ticket priority is set right");
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripaction.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripaction.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 63 lib/RT/ScripAction_Overlay.pm
+
+ok (require RT::ScripAction);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripactions.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripactions.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 60 lib/RT/ScripActions_Overlay.pm
+
+ok (require RT::ScripActions);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripcondition.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripcondition.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 63 lib/RT/ScripCondition_Overlay.pm
+
+ok (require RT::ScripCondition);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripconditions.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scripconditions.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 61 lib/RT/ScripConditions_Overlay.pm
+
+ok (require RT::ScripConditions);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scrips.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/scrips.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/Scrips_Overlay.pm
+
+ok (require RT::Scrips);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-activeticketsinqueue.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-activeticketsinqueue.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 61 lib/RT/Search/ActiveTicketsInQueue.pm
+
+ok (require RT::Search::Generic);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-fromsql.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-fromsql.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 61 lib/RT/Search/FromSQL.pm
+
+ok (require RT::Search::Generic);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-generic.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-generic.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 70 lib/RT/Search/Generic.pm
+
+ok (require RT::Search::Generic);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-googleish.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/search-googleish.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 61 lib/RT/Search/Googleish.pm
+
+ok (require RT::Search::Generic);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/searchbuilder.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/searchbuilder.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,49 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 60 lib/RT/SearchBuilder.pm
+
+ok (require RT::SearchBuilder);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 347 lib/RT/SearchBuilder.pm
+
+use_ok(RT::Queues);
+ok(my $queues = RT::Queues->new($RT::SystemUser), 'Created a queues object');
+ok( $queues->UnLimit(),'Unlimited the result set of the queues object');
+my $items = $queues->ItemsArrayRef();
+my @items = @{$items};
+
+ok($queues->NewItem->_Accessible('Name','read'));
+my @sorted = sort {lc($a->Name) cmp lc($b->Name)} @items;
+ok (@sorted, "We have an array of queues, sorted". join(',',map {$_->Name} @sorted));
+
+ok (@items, "We have an array of queues, raw". join(',',map {$_->Name} @items));
+my @sorted_ids = map {$_->id } @sorted;
+my @items_ids = map {$_->id } @items;
+
+is ($#sorted, $#items);
+is ($sorted[0]->Name, $items[0]->Name);
+is ($sorted[-1]->Name, $items[-1]->Name);
+is_deeply(\@items_ids, \@sorted_ids, "ItemsArrayRef sorts alphabetically by name");;
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/system.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/system.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,42 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 104 lib/RT/System.pm
+
+my $s = RT::System->new($RT::SystemUser);
+my $rights = $s->AvailableRights;
+ok ($rights, "Rights defined");
+ok ($rights->{'AdminUsers'},"AdminUsers right found");
+ok ($rights->{'CreateTicket'},"CreateTicket right found");
+ok ($rights->{'AdminGroupMembership'},"ModifyGroupMembers right found");
+ok (!$rights->{'CasdasdsreateTicket'},"bogus right not found");
+
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 147 lib/RT/System.pm
+
+use RT::System;
+my $sys = RT::System->new();
+is( $sys->Id, 1);
+is ($sys->id, 1);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/template.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/template.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,35 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/Template_Overlay.pm
+
+ok(require RT::Template);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 124 lib/RT/Template_Overlay.pm
+
+my $t = RT::Template->new($RT::SystemUser);
+$t->Create(Name => "Foo", Queue => 1);
+my $t2 = RT::Template->new($RT::Nobody);
+$t2->Load($t->Id);
+ok($t2->QueueObj->id, "Got the template's queue objet");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/templates.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/templates.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 61 lib/RT/Templates_Overlay.pm
+
+ok (require RT::Templates);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ticket.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ticket.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,314 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/Ticket_Overlay.pm
+
+use_ok ( RT::Queue);
+ok(my $testqueue = RT::Queue->new($RT::SystemUser));
+ok($testqueue->Create( Name => 'ticket tests'));
+ok($testqueue->Id != 0);
+use_ok(RT::CustomField);
+ok(my $testcf = RT::CustomField->new($RT::SystemUser));
+my ($ret, $cmsg) = $testcf->Create( Name => 'selectmulti',
+                    Queue => $testqueue->id,
+                               Type => 'SelectMultiple');
+ok($ret,"Created the custom field - ".$cmsg);
+($ret,$cmsg) = $testcf->AddValue ( Name => 'Value1',
+                        SortOrder => '1',
+                        Description => 'A testing value');
+
+ok($ret, "Added a value - ".$cmsg);
+
+ok($testcf->AddValue ( Name => 'Value2',
+                        SortOrder => '2',
+                        Description => 'Another testing value'));
+ok($testcf->AddValue ( Name => 'Value3',
+                        SortOrder => '3',
+                        Description => 'Yet Another testing value'));
+                       
+ok($testcf->Values->Count == 3);
+
+use_ok(RT::Ticket);
+
+my $u = RT::User->new($RT::SystemUser);
+$u->Load("root");
+ok ($u->Id, "Found the root user");
+ok(my $t = RT::Ticket->new($RT::SystemUser));
+ok(my ($id, $msg) = $t->Create( Queue => $testqueue->Id,
+               Subject => 'Testing',
+               Owner => $u->Id
+              ));
+ok($id != 0);
+ok ($t->OwnerObj->Id == $u->Id, "Root is the ticket owner");
+ok(my ($cfv, $cfm) =$t->AddCustomFieldValue(Field => $testcf->Id,
+                           Value => 'Value1'));
+ok($cfv != 0, "Custom field creation didn't return an error: $cfm");
+ok($t->CustomFieldValues($testcf->Id)->Count == 1);
+ok($t->CustomFieldValues($testcf->Id)->First &&
+    $t->CustomFieldValues($testcf->Id)->First->Content eq 'Value1');;
+
+ok(my ($cfdv, $cfdm) = $t->DeleteCustomFieldValue(Field => $testcf->Id,
+                        Value => 'Value1'));
+ok ($cfdv != 0, "Deleted a custom field value: $cfdm");
+ok($t->CustomFieldValues($testcf->Id)->Count == 0);
+
+ok(my $t2 = RT::Ticket->new($RT::SystemUser));
+ok($t2->Load($id));
+is($t2->Subject, 'Testing');
+is($t2->QueueObj->Id, $testqueue->id);
+ok($t2->OwnerObj->Id == $u->Id);
+
+my $t3 = RT::Ticket->new($RT::SystemUser);
+my ($id3, $msg3) = $t3->Create( Queue => $testqueue->Id,
+                                Subject => 'Testing',
+                                Owner => $u->Id);
+my ($cfv1, $cfm1) = $t->AddCustomFieldValue(Field => $testcf->Id,
+ Value => 'Value1');
+ok($cfv1 != 0, "Adding a custom field to ticket 1 is successful: $cfm");
+my ($cfv2, $cfm2) = $t3->AddCustomFieldValue(Field => $testcf->Id,
+ Value => 'Value2');
+ok($cfv2 != 0, "Adding a custom field to ticket 2 is successful: $cfm");
+my ($cfv3, $cfm3) = $t->AddCustomFieldValue(Field => $testcf->Id,
+ Value => 'Value3');
+ok($cfv3 != 0, "Adding a custom field to ticket 1 is successful: $cfm");
+ok($t->CustomFieldValues($testcf->Id)->Count == 2,
+   "This ticket has 2 custom field values");
+ok($t3->CustomFieldValues($testcf->Id)->Count == 1,
+   "This ticket has 1 custom field value");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 160 lib/RT/Ticket_Overlay.pm
+
+
+ok(require RT::Ticket, "Loading the RT::Ticket library");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 335 lib/RT/Ticket_Overlay.pm
+
+my $t = RT::Ticket->new($RT::SystemUser);
+
+ok( $t->Create(Queue => 'General', Due => '2002-05-21 00:00:00', ReferredToBy => 'http://www.cpan.org', RefersTo => 'http://fsck.com', Subject => 'This is a subject'), "Ticket Created");
+
+ok ( my $id = $t->Id, "Got ticket id");
+ok ($t->RefersTo->First->Target =~ /fsck.com/, "Got refers to");
+ok ($t->ReferredToBy->First->Base =~ /cpan.org/, "Got referredtoby");
+is ($t->ResolvedObj->Unix, 0, "It hasn't been resolved - ". $t->ResolvedObj->Unix);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 784 lib/RT/Ticket_Overlay.pm
+
+my $simple_update = <<EOF;
+Subject: target
+AddRequestor: jesse\@example.com
+EOF
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+my ($id,$msg) =$ticket->Create(Subject => 'first', Queue => 'general');
+ok($ticket->Id, "Created the test ticket - ".$id ." - ".$msg);
+$ticket->UpdateFrom822($simple_update);
+is($ticket->Subject, 'target', "changed the subject");
+my $jesse = RT::User->new($RT::SystemUser);
+$jesse->LoadByEmail('jesse at example.com');
+ok ($jesse->Id, "There's a user for jesse");
+ok($ticket->Requestors->HasMember( $jesse->PrincipalObj), "It has the jesse principal object as a requestor ");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 1220 lib/RT/Ticket_Overlay.pm
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+my ($id, $msg) = $ticket->Create(Subject => "Foo",
+                Owner => $RT::SystemUser->Id,
+                Status => 'open',
+                Requestor => ['jesse at example.com'],
+                Queue => '1'
+                );
+ok ($id, "Ticket $id was created");
+ok(my $group = RT::Group->new($RT::SystemUser));
+ok($group->LoadTicketRoleGroup(Ticket => $id, Type=> 'Requestor'));
+ok ($group->Id, "Found the requestors object for this ticket");
+
+ok(my $jesse = RT::User->new($RT::SystemUser), "Creating a jesse rt::user");
+$jesse->LoadByEmail('jesse at example.com');
+ok($jesse->Id,  "Found the jesse rt user");
+
+
+ok ($ticket->IsWatcher(Type => 'Requestor', PrincipalId => $jesse->PrincipalId), "The ticket actually has jesse at fsck.com as a requestor");
+ok ((my $add_id, $add_msg) = $ticket->AddWatcher(Type => 'Requestor', Email => 'bob at fsck.com'), "Added bob at fsck.com as a requestor");
+ok ($add_id, "Add succeeded: ($add_msg)");
+ok(my $bob = RT::User->new($RT::SystemUser), "Creating a bob rt::user");
+$bob->LoadByEmail('bob at fsck.com');
+ok($bob->Id,  "Found the bob rt user");
+ok ($ticket->IsWatcher(Type => 'Requestor', PrincipalId => $bob->PrincipalId), "The ticket actually has bob at fsck.com as a requestor");;
+ok ((my $add_id, $add_msg) = $ticket->DeleteWatcher(Type =>'Requestor', Email => 'bob at fsck.com'), "Added bob at fsck.com as a requestor");
+ok (!$ticket->IsWatcher(Type => 'Requestor', Principal => $bob->PrincipalId), "The ticket no longer has bob at fsck.com as a requestor");;
+
+
+$group = RT::Group->new($RT::SystemUser);
+ok($group->LoadTicketRoleGroup(Ticket => $id, Type=> 'Cc'));
+ok ($group->Id, "Found the cc object for this ticket");
+$group = RT::Group->new($RT::SystemUser);
+ok($group->LoadTicketRoleGroup(Ticket => $id, Type=> 'AdminCc'));
+ok ($group->Id, "Found the AdminCc object for this ticket");
+$group = RT::Group->new($RT::SystemUser);
+ok($group->LoadTicketRoleGroup(Ticket => $id, Type=> 'Owner'));
+ok ($group->Id, "Found the Owner object for this ticket");
+ok($group->HasMember($RT::SystemUser->UserObj->PrincipalObj), "the owner group has the member 'RT_System'");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 1578 lib/RT/Ticket_Overlay.pm
+
+my $t = RT::Ticket->new($RT::SystemUser);
+ok($t->Create(Queue => 'general', Subject => 'SquelchTest'));
+
+is($#{$t->SquelchMailTo}, -1, "The ticket has no squelched recipients");
+
+my @returned = $t->SquelchMailTo('nobody at example.com');
+
+is($#returned, 0, "The ticket has one squelched recipients");
+
+my @names = $t->Attributes->Names;
+is(shift @names, 'SquelchMailTo', "The attribute we have is SquelchMailTo");
+ at returned = $t->SquelchMailTo('nobody at example.com');
+
+
+is($#returned, 0, "The ticket has one squelched recipients");
+
+ at names = $t->Attributes->Names;
+is(shift @names, 'SquelchMailTo', "The attribute we have is SquelchMailTo");
+
+
+my ($ret, $msg) = $t->UnsquelchMailTo('nobody at example.com');
+ok($ret, "Removed nobody as a squelched recipient - ".$msg);
+ at returned = $t->SquelchMailTo();
+is($#returned, -1, "The ticket has no squelched recipients". join(',', at returned));
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 2716 lib/RT/Ticket_Overlay.pm
+
+my $t1 = RT::Ticket->new($RT::SystemUser);
+$t1->Create ( Subject => 'Merge test 1', Queue => 'general', Requestor => 'merge1 at example.com');
+my $t1id = $t1->id;
+my $t2 = RT::Ticket->new($RT::SystemUser);
+$t2->Create ( Subject => 'Merge test 2', Queue => 'general', Requestor => 'merge2 at example.com');
+my $t2id = $t2->id;
+my ($msg, $val) = $t1->MergeInto($t2->id);
+ok ($msg,$val);
+$t1 = RT::Ticket->new($RT::SystemUser);
+is ($t1->id, undef, "ok. we've got a blank ticket1");
+$t1->Load($t1id);
+
+is ($t1->id, $t2->id);
+
+is ($t1->Requestors->MembersObj->Count, 2);
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 2948 lib/RT/Ticket_Overlay.pm
+
+my $root = RT::User->new($RT::SystemUser);
+$root->Load('root');
+ok ($root->Id, "Loaded the root user");
+my $t = RT::Ticket->new($RT::SystemUser);
+$t->Load(1);
+$t->SetOwner('root');
+is ($t->OwnerObj->Name, 'root' , "Root owns the ticket");
+$t->Steal();
+is ($t->OwnerObj->id, $RT::SystemUser->id , "SystemUser owns the ticket");
+my $txns = RT::Transactions->new($RT::SystemUser);
+$txns->OrderBy(FIELD => 'id', ORDER => 'DESC');
+$txns->Limit(FIELD => 'ObjectId', VALUE => '1');
+$txns->Limit(FIELD => 'ObjectType', VALUE => 'RT::Ticket');
+$txns->Limit(FIELD => 'Type', OPERATOR => '!=',  VALUE => 'EmailRecord');
+
+my $steal  = $txns->First;
+ok($steal->OldValue == $root->Id , "Stolen from root");
+ok($steal->NewValue == $RT::SystemUser->Id , "Stolen by the systemuser");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 3182 lib/RT/Ticket_Overlay.pm
+
+my $tt = RT::Ticket->new($RT::SystemUser);
+my ($id, $tid, $msg)= $tt->Create(Queue => 'general',
+            Subject => 'test');
+ok($id, $msg);
+is($tt->Status, 'new', "New ticket is created as new");
+
+($id, $msg) = $tt->SetStatus('open');
+ok($id, $msg);
+like($msg, qr/open/i, "Status message is correct");
+($id, $msg) = $tt->SetStatus('resolved');
+ok($id, $msg);
+like($msg, qr/resolved/i, "Status message is correct");
+($id, $msg) = $tt->SetStatus('resolved');
+ok(!$id,$msg);
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/tickets.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/tickets.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,123 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 74 lib/RT/Tickets_Overlay.pm
+
+ok (require RT::Tickets);
+ok( my $testtickets = RT::Tickets->new( $RT::SystemUser ) );
+ok( $testtickets->LimitStatus( VALUE => 'deleted' ) );
+# Should be zero until 'allow_deleted_search'
+ok( $testtickets->Count == 0 );
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 793 lib/RT/Tickets_Overlay.pm
+
+# Test to make sure that you can search for tickets by requestor address and
+# by requestor name.
+
+my ($id,$msg);
+my $u1 = RT::User->new($RT::SystemUser);
+($id, $msg) = $u1->Create( Name => 'RequestorTestOne', EmailAddress => 'rqtest1 at example.com');
+ok ($id,$msg);
+my $u2 = RT::User->new($RT::SystemUser);
+($id, $msg) = $u2->Create( Name => 'RequestorTestTwo', EmailAddress => 'rqtest2 at example.com');
+ok ($id,$msg);
+
+my $t1 = RT::Ticket->new($RT::SystemUser);
+my ($trans);
+($id,$trans,$msg) =$t1->Create (Queue => 'general', Subject => 'Requestor test one', Requestor => [$u1->EmailAddress]);
+ok ($id, $msg);
+
+my $t2 = RT::Ticket->new($RT::SystemUser);
+($id,$trans,$msg) =$t2->Create (Queue => 'general', Subject => 'Requestor test one', Requestor => [$u2->EmailAddress]);
+ok ($id, $msg);
+
+
+my $t3 = RT::Ticket->new($RT::SystemUser);
+($id,$trans,$msg) =$t3->Create (Queue => 'general', Subject => 'Requestor test one', Requestor => [$u2->EmailAddress, $u1->EmailAddress]);
+ok ($id, $msg);
+
+
+my $tix1 = RT::Tickets->new($RT::SystemUser);
+$tix1->FromSQL('Requestor.EmailAddress LIKE "rqtest1" OR Requestor.EmailAddress LIKE "rqtest2"');
+
+is ($tix1->Count, 3);
+
+my $tix2 = RT::Tickets->new($RT::SystemUser);
+$tix2->FromSQL('Requestor.Name LIKE "TestOne" OR Requestor.Name LIKE "TestTwo"');
+
+is ($tix2->Count, 3);
+
+
+my $tix3 = RT::Tickets->new($RT::SystemUser);
+$tix3->FromSQL('Requestor.EmailAddress LIKE "rqtest1"');
+
+is ($tix3->Count, 2);
+
+my $tix4 = RT::Tickets->new($RT::SystemUser);
+$tix4->FromSQL('Requestor.Name LIKE "TestOne" ');
+
+is ($tix4->Count, 2);
+
+# Searching for tickets that have two requestors isn't supported
+# There's no way to differentiate "one requestor name that matches foo and bar"
+# and "two requestors, one matching foo and one matching bar"
+
+# my $tix5 = RT::Tickets->new($RT::SystemUser);
+# $tix5->FromSQL('Requestor.Name LIKE "TestOne" AND Requestor.Name LIKE "TestTwo"');
+# 
+# is ($tix5->Count, 1);
+# 
+# my $tix6 = RT::Tickets->new($RT::SystemUser);
+# $tix6->FromSQL('Requestor.EmailAddress LIKE "rqtest1" AND Requestor.EmailAddress LIKE "rqtest2"');
+# 
+# is ($tix6->Count, 1);
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 2079 lib/RT/Tickets_Overlay.pm
+
+my $t1 = RT::Ticket->new($RT::SystemUser);
+$t1->Create(Queue => 'general', Subject => "LimitWatchers test", Requestors => \['requestor1 at example.com']);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 2961 lib/RT/Tickets_Overlay.pm
+
+# We assume that we've got some tickets hanging around from before.
+ok( my $unlimittickets = RT::Tickets->new( $RT::SystemUser ) );
+ok( $unlimittickets->UnLimit );
+ok( $unlimittickets->Count > 0, "UnLimited tickets object should return tickets" );
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/tickets_overlay_sql.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/tickets_overlay_sql.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,79 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 273 lib/RT/Tickets_Overlay_SQL.pm
+
+use RT::Tickets;
+use strict;
+
+my $tix = RT::Tickets->new($RT::SystemUser);
+{
+    my $query = "Status = 'open'";
+    my ($status, $msg)  = $tix->FromSQL($query);
+    ok ($status, "correct query") or diag("error: $msg");
+}
+
+
+my (@created,%created);
+my $string = 'subject/content SQL test';
+{
+    my $t = RT::Ticket->new($RT::SystemUser);
+    ok( $t->Create(Queue => 'General', Subject => $string), "Ticket Created");
+    $created{ $t->Id }++; push @created, $t->Id;
+}
+
+{
+    my $Message = MIME::Entity->build(
+                     Subject     => 'this is my subject',
+                     From        => 'jesse at example.com',
+                     Data        => [ $string ],
+            );
+
+    my $t = RT::Ticket->new($RT::SystemUser);
+    ok( $t->Create( Queue => 'General',
+                    Subject => 'another ticket',
+                    MIMEObj => $Message,
+                    MemberOf => $created[0]
+                  ),
+        "Ticket Created"
+    );
+    $created{ $t->Id }++; push @created, $t->Id;
+}
+
+{
+    my $query = ("Subject LIKE '$string' OR Content LIKE '$string'");
+    my ($status, $msg) = $tix->FromSQL($query);
+    ok ($status, "correct query") or diag("error: $msg");
+
+    my $count = 0;
+    while (my $tick = $tix->Next) {
+        $count++ if $created{ $tick->id };
+    }
+    is ($count, scalar @created, "number of returned tickets same as entered");
+}
+
+{
+    my $query = "id = $created[0] OR MemberOf = $created[0]";
+    my ($status, $msg) = $tix->FromSQL($query);
+    ok ($status, "correct query") or diag("error: $msg");
+
+    my $count = 0;
+    while (my $tick = $tix->Next) {
+        $count++ if $created{ $tick->id };
+    }
+    is ($count, scalar @created, "number of returned tickets same as entered");
+}
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/transaction.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/transaction.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 67 lib/RT/Transaction_Overlay.pm
+
+ok(require RT::Transaction);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/transactions.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/transactions.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,19 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/Transactions_Overlay.pm
+
+ok (require RT::Transactions);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/uri-fsck_com_rt.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/uri-fsck_com_rt.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,44 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 64 lib/RT/URI/fsck_com_rt.pm
+
+use_ok("RT::URI::fsck_com_rt");
+my $uri = RT::URI::fsck_com_rt->new($RT::SystemUser);
+
+ok(ref($uri));
+
+ok (UNIVERSAL::isa($uri,RT::URI::fsck_com_rt), "It's an RT::URI::fsck_com_rt");
+
+ok ($uri->isa('RT::URI::base'), "It's an RT::URI::base");
+ok ($uri->isa('RT::Base'), "It's an RT::Base");
+
+is ($uri->LocalURIPrefix , 'fsck.com-rt://'.RT->Config->Get('Organization'));
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 115 lib/RT/URI/fsck_com_rt.pm
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+$ticket->Load(1);
+my $uri = RT::URI::fsck_com_rt->new($ticket->CurrentUser);
+is($uri->LocalURIPrefix. "/ticket/1" , $uri->URIForObject($ticket));
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/uri-t.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/uri-t.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,28 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 41 lib/RT/URI/t.pm
+
+use_ok("RT::URI::t");
+my $uri = RT::URI::t->new($RT::SystemUser);
+ok(ref($uri), "URI object exists");
+
+my $uristr = "t:1";
+$uri->ParseURI($uristr);
+is(ref($uri->Object), "RT::Ticket", "Object loaded is a ticket");
+is($uri->Object->Id, 1, "Object loaded has correct ID");
+is($uri->URI, 'fsck.com-rt://'.RT->Config->Get('Organization').'/ticket/1',
+   "URI object has correct URI string");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/user.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/user.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,349 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 61 lib/RT/User_Overlay.pm
+
+ok(require RT::User);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 116 lib/RT/User_Overlay.pm
+
+# Make sure we can create a user
+
+my $u1 = RT::User->new($RT::SystemUser);
+is(ref($u1), 'RT::User');
+my ($id, $msg) = $u1->Create(Name => 'CreateTest1'.$$, EmailAddress => $$.'create-test-1 at example.com');
+ok ($id, "Creating user CreateTest1 - " . $msg );
+
+# Make sure we can't create a second user with the same name
+my $u2 = RT::User->new($RT::SystemUser);
+($id, $msg) = $u2->Create(Name => 'CreateTest1'.$$, EmailAddress => $$.'create-test-2 at example.com');
+ok (!$id, $msg);
+
+
+# Make sure we can't create a second user with the same EmailAddress address
+my $u3 = RT::User->new($RT::SystemUser);
+($id, $msg) = $u3->Create(Name => 'CreateTest2'.$$, EmailAddress => $$.'create-test-1 at example.com');
+ok (!$id, $msg);
+
+# Make sure we can create a user with no EmailAddress address
+my $u4 = RT::User->new($RT::SystemUser);
+($id, $msg) = $u4->Create(Name => 'CreateTest3'.$$);
+ok ($id, $msg);
+
+# make sure we can create a second user with no EmailAddress address
+my $u5 = RT::User->new($RT::SystemUser);
+($id, $msg) = $u5->Create(Name => 'CreateTest4'.$$);
+ok ($id, $msg);
+
+# make sure we can create a user with a blank EmailAddress address
+my $u6 = RT::User->new($RT::SystemUser);
+($id, $msg) = $u6->Create(Name => 'CreateTest6'.$$, EmailAddress => '');
+ok ($id, $msg);
+# make sure we can create a second user with a blankEmailAddress address
+my $u7 = RT::User->new($RT::SystemUser);
+($id, $msg) = $u7->Create(Name => 'CreateTest7'.$$, EmailAddress => '');
+ok ($id, $msg);
+
+# Can we change the email address away from from "";
+($id,$msg) = $u7->SetEmailAddress('foo at bar'.$$);
+ok ($id, $msg);
+# can we change the address back to "";  
+($id,$msg) = $u7->SetEmailAddress('');
+ok ($id, $msg);
+is ($u7->EmailAddress, '');
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 342 lib/RT/User_Overlay.pm
+
+
+ok(my $user = RT::User->new($RT::SystemUser));
+ok($user->Load('root'), "Loaded user 'root'");
+ok($user->Privileged, "User 'root' is privileged");
+ok(my ($v,$m) = $user->SetPrivileged(0));
+ok ($v ==1, "Set unprivileged suceeded ($m)");
+ok(!$user->Privileged, "User 'root' is no longer privileged");
+ok(my ($v2,$m2) = $user->SetPrivileged(1));
+ok ($v2 ==1, "Set privileged suceeded ($m2");
+ok($user->Privileged, "User 'root' is privileged again");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 1195 lib/RT/User_Overlay.pm
+
+ok(my $u = RT::User->new($RT::SystemUser));
+ok($u->Load(1), "Loaded the first user");
+ok($u->PrincipalObj->ObjectId == 1, "user 1 is the first principal");
+is($u->PrincipalObj->PrincipalType, 'User' , "Principal 1 is a user, not a group");
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 1315 lib/RT/User_Overlay.pm
+
+my $root = RT::User->new($RT::SystemUser);
+$root->Load('root');
+ok($root->Id, "Found the root user");
+my $rootq = RT::Queue->new($root);
+$rootq->Load(1);
+ok($rootq->Id, "Loaded the first queue");
+
+ok ($rootq->CurrentUser->HasRight(Right=> 'CreateTicket', Object => $rootq), "Root can create tickets");
+
+my $new_user = RT::User->new($RT::SystemUser);
+my ($id, $msg) = $new_user->Create(Name => 'ACLTest'.$$);
+
+ok ($id, "Created a new user for acl test $msg");
+
+my $q = RT::Queue->new($new_user);
+$q->Load(1);
+ok($q->Id, "Loaded the first queue");
+
+
+ok (!$q->CurrentUser->HasRight(Right => 'CreateTicket', Object => $q), "Some random user doesn't have the right to create tickets");
+ok (my ($gval, $gmsg) = $new_user->PrincipalObj->GrantRight( Right => 'CreateTicket', Object => $q), "Granted the random user the right to create tickets");
+ok ($gval, "Grant succeeded - $gmsg");
+
+
+ok ($q->CurrentUser->HasRight(Right => 'CreateTicket', Object => $q), "The user can create tickets after we grant him the right");
+ok (my ($gval, $gmsg) = $new_user->PrincipalObj->RevokeRight( Right => 'CreateTicket', Object => $q), "revoked the random user the right to create tickets");
+ok ($gval, "Revocation succeeded - $gmsg");
+ok (!$q->CurrentUser->HasRight(Right => 'CreateTicket', Object => $q), "The user can't create tickets anymore");
+
+
+
+
+
+# Create a ticket in the queue
+my $new_tick = RT::Ticket->new($RT::SystemUser);
+my ($tickid, $tickmsg) = $new_tick->Create(Subject=> 'ACL Test', Queue => 'General');
+ok($tickid, "Created ticket: $tickid");
+# Make sure the user doesn't have the right to modify tickets in the queue
+ok (!$new_user->HasRight( Object => $new_tick, Right => 'ModifyTicket'), "User can't modify the ticket without group membership");
+# Create a new group
+my $group = RT::Group->new($RT::SystemUser);
+$group->CreateUserDefinedGroup(Name => 'ACLTest'.$$);
+ok($group->Id, "Created a new group Ok");
+# Grant a group the right to modify tickets in a queue
+ok(my ($gv,$gm) = $group->PrincipalObj->GrantRight( Object => $q, Right => 'ModifyTicket'),"Granted the group the right to modify tickets");
+ok($gv,"Grant succeeed - $gm");
+# Add the user to the group
+ok( my ($aid, $amsg) = $group->AddMember($new_user->PrincipalId), "Added the member to the group");
+ok ($aid, "Member added to group: $amsg");
+# Make sure the user does have the right to modify tickets in the queue
+ok ($new_user->HasRight( Object => $new_tick, Right => 'ModifyTicket'), "User can modify the ticket with group membership");
+
+
+# Remove the user from the group
+ok( my ($did, $dmsg) = $group->DeleteMember($new_user->PrincipalId), "Deleted the member from the group");
+ok ($did,"Deleted the group member: $dmsg");
+# Make sure the user doesn't have the right to modify tickets in the queue
+ok (!$new_user->HasRight( Object => $new_tick, Right => 'ModifyTicket'), "User can't modify the ticket without group membership");
+
+
+my $q_as_system = RT::Queue->new($RT::SystemUser);
+$q_as_system->Load(1);
+ok($q_as_system->Id, "Loaded the first queue");
+
+# Create a ticket in the queue
+my $new_tick2 = RT::Ticket->new($RT::SystemUser);
+my ($tick2id, $tickmsg) = $new_tick2->Create(Subject=> 'ACL Test 2', Queue =>$q_as_system->Id);
+ok($tick2id, "Created ticket: $tick2id");
+is($new_tick2->QueueObj->id, $q_as_system->Id, "Created a new ticket in queue 1");
+
+
+# make sure that the user can't do this without subgroup membership
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can't modify the ticket without group membership");
+
+# Create a subgroup
+my $subgroup = RT::Group->new($RT::SystemUser);
+$subgroup->CreateUserDefinedGroup(Name => 'Subgrouptest',$$);
+ok($subgroup->Id, "Created a new group ".$subgroup->Id."Ok");
+#Add the subgroup as a subgroup of the group
+my ($said, $samsg) =  $group->AddMember($subgroup->PrincipalId);
+ok ($said, "Added the subgroup as a member of the group");
+# Add the user to a subgroup of the group
+
+my ($usaid, $usamsg) =  $subgroup->AddMember($new_user->PrincipalId);
+ok($usaid,"Added the user ".$new_user->Id."to the subgroup");
+# Make sure the user does have the right to modify tickets in the queue
+ok ($new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can modify the ticket with subgroup membership");
+
+#  {{{ Deal with making sure that members of subgroups of a disabled group don't have rights
+
+my ($id, $msg);
+($id, $msg) =  $group->SetDisabled(1);
+ok ($id,$msg);
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can't modify the ticket when the group ".$group->Id. " is disabled");
+ ($id, $msg) =  $group->SetDisabled(0);
+ok($id,$msg);
+# Test what happens when we disable the group the user is a member of directly
+
+($id, $msg) =  $subgroup->SetDisabled(1);
+ ok ($id,$msg);
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can't modify the ticket when the group ".$subgroup->Id. " is disabled");
+ ($id, $msg) =  $subgroup->SetDisabled(0);
+ ok ($id,$msg);
+ok ($new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can modify the ticket without group membership");
+
+# }}}
+
+
+my ($usrid, $usrmsg) =  $subgroup->DeleteMember($new_user->PrincipalId);
+ok($usrid,"removed the user from the group - $usrmsg");
+# Make sure the user doesn't have the right to modify tickets in the queue
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can't modify the ticket without group membership");
+
+#revoke the right to modify tickets in a queue
+ok(($gv,$gm) = $group->PrincipalObj->RevokeRight( Object => $q, Right => 'ModifyTicket'),"Granted the group the right to modify tickets");
+ok($gv,"revoke succeeed - $gm");
+
+# {{{ Test the user's right to modify a ticket as a _queue_ admincc for a right granted at the _queue_ level
+
+# Grant queue admin cc the right to modify ticket in the queue 
+ok(my ($qv,$qm) = $q_as_system->AdminCc->PrincipalObj->GrantRight( Object => $q_as_system, Right => 'ModifyTicket'),"Granted the queue adminccs the right to modify tickets");
+ok($qv, "Granted the right successfully - $qm");
+
+# Add the user as a queue admincc
+ok ((my $add_id, $add_msg) = $q_as_system->AddWatcher(Type => 'AdminCc', PrincipalId => $new_user->PrincipalId)  , "Added the new user as a queue admincc");
+ok ($add_id, "the user is now a queue admincc - $add_msg");
+
+# Make sure the user does have the right to modify tickets in the queue
+ok ($new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can modify the ticket as an admincc");
+# Remove the user from the role  group
+ok ((my $del_id, $del_msg) = $q_as_system->DeleteWatcher(Type => 'AdminCc', PrincipalId => $new_user->PrincipalId)  , "Deleted the new user as a queue admincc");
+
+# Make sure the user doesn't have the right to modify tickets in the queue
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can't modify the ticket without group membership");
+
+# }}}
+
+# {{{ Test the user's right to modify a ticket as a _ticket_ admincc with the right granted at the _queue_ level
+
+# Add the user as a ticket admincc
+ok ((my $uadd_id, $uadd_msg) = $new_tick2->AddWatcher(Type => 'AdminCc', PrincipalId => $new_user->PrincipalId)  , "Added the new user as a queue admincc");
+ok ($add_id, "the user is now a queue admincc - $add_msg");
+
+# Make sure the user does have the right to modify tickets in the queue
+ok ($new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can modify the ticket as an admincc");
+
+# Remove the user from the role  group
+ok ((my $del_id, $del_msg) = $new_tick2->DeleteWatcher(Type => 'AdminCc', PrincipalId => $new_user->PrincipalId)  , "Deleted the new user as a queue admincc");
+
+# Make sure the user doesn't have the right to modify tickets in the queue
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can't modify the ticket without group membership");
+
+
+# Revoke the right to modify ticket in the queue 
+ok(my ($rqv,$rqm) = $q_as_system->AdminCc->PrincipalObj->RevokeRight( Object => $q_as_system, Right => 'ModifyTicket'),"Revokeed the queue adminccs the right to modify tickets");
+ok($rqv, "Revoked the right successfully - $rqm");
+
+# }}}
+
+
+
+# {{{ Test the user's right to modify a ticket as a _queue_ admincc for a right granted at the _system_ level
+
+# Before we start Make sure the user does not have the right to modify tickets in the queue
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can not modify the ticket without it being granted");
+ok (!$new_user->HasRight( Object => $new_tick2->QueueObj, Right => 'ModifyTicket'), "User can not modify tickets in the queue without it being granted");
+
+# Grant queue admin cc the right to modify ticket in the queue 
+ok(my ($qv,$qm) = $q_as_system->AdminCc->PrincipalObj->GrantRight( Object => $RT::System, Right => 'ModifyTicket'),"Granted the queue adminccs the right to modify tickets");
+ok($qv, "Granted the right successfully - $qm");
+
+# Make sure the user can't modify the ticket before they're added as a watcher
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can not modify the ticket without being an admincc");
+ok (!$new_user->HasRight( Object => $new_tick2->QueueObj, Right => 'ModifyTicket'), "User can not modify tickets in the queue without being an admincc");
+
+# Add the user as a queue admincc
+ok ((my $add_id, $add_msg) = $q_as_system->AddWatcher(Type => 'AdminCc', PrincipalId => $new_user->PrincipalId)  , "Added the new user as a queue admincc");
+ok ($add_id, "the user is now a queue admincc - $add_msg");
+
+# Make sure the user does have the right to modify tickets in the queue
+ok ($new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can modify the ticket as an admincc");
+ok ($new_user->HasRight( Object => $new_tick2->QueueObj, Right => 'ModifyTicket'), "User can modify tickets in the queue as an admincc");
+# Remove the user from the role  group
+ok ((my $del_id, $del_msg) = $q_as_system->DeleteWatcher(Type => 'AdminCc', PrincipalId => $new_user->PrincipalId)  , "Deleted the new user as a queue admincc");
+
+# Make sure the user doesn't have the right to modify tickets in the queue
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can't modify the ticket without group membership");
+ok (!$new_user->HasRight( Object => $new_tick2->QueueObj, Right => 'ModifyTicket'), "User can't modify tickets in the queue without group membership");
+
+# }}}
+
+# {{{ Test the user's right to modify a ticket as a _ticket_ admincc with the right granted at the _queue_ level
+
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can not modify the ticket without being an admincc");
+ok (!$new_user->HasRight( Object => $new_tick2->QueueObj, Right => 'ModifyTicket'), "User can not modify tickets in the queue obj without being an admincc");
+
+
+# Add the user as a ticket admincc
+ok ((my $uadd_id, $uadd_msg) = $new_tick2->AddWatcher(Type => 'AdminCc', PrincipalId => $new_user->PrincipalId)  , "Added the new user as a queue admincc");
+ok ($add_id, "the user is now a queue admincc - $add_msg");
+
+# Make sure the user does have the right to modify tickets in the queue
+ok ($new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can modify the ticket as an admincc");
+ok (!$new_user->HasRight( Object => $new_tick2->QueueObj, Right => 'ModifyTicket'), "User can not modify tickets in the queue obj being only a ticket admincc");
+
+# Remove the user from the role  group
+ok ((my $del_id, $del_msg) = $new_tick2->DeleteWatcher(Type => 'AdminCc', PrincipalId => $new_user->PrincipalId)  , "Deleted the new user as a queue admincc");
+
+# Make sure the user doesn't have the right to modify tickets in the queue
+ok (!$new_user->HasRight( Object => $new_tick2, Right => 'ModifyTicket'), "User can't modify the ticket without being an admincc");
+ok (!$new_user->HasRight( Object => $new_tick2->QueueObj, Right => 'ModifyTicket'), "User can not modify tickets in the queue obj without being an admincc");
+
+
+# Revoke the right to modify ticket in the queue 
+ok(my ($rqv,$rqm) = $q_as_system->AdminCc->PrincipalObj->RevokeRight( Object => $RT::System, Right => 'ModifyTicket'),"Revokeed the queue adminccs the right to modify tickets");
+ok($rqv, "Revoked the right successfully - $rqm");
+
+# }}}
+
+
+
+
+# Grant "privileged users" the system right to create users
+# Create a privileged user.
+# have that user create another user
+# Revoke the right for privileged users to create users
+# have the privileged user try to create another user and fail the ACL check
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;

Added: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/users.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/users.t	Mon Mar  5 10:34:51 2007
@@ -0,0 +1,88 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 62 lib/RT/Users_Overlay.pm
+
+ok(require RT::Users);
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+{
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+#line 235 lib/RT/Users_Overlay.pm
+
+ok(my $users = RT::Users->new($RT::SystemUser));
+$users->WhoHaveRight(Object =>$RT::System, Right =>'SuperUser');
+ok($users->Count == 1, "There is one privileged superuser - Found ". $users->Count );
+# TODO: this wants more testing
+
+my $RTxUser = RT::User->new($RT::SystemUser);
+($id, $msg) = $RTxUser->Create( Name => 'RTxUser', Comments => "RTx extension user", Privileged => 1);
+ok ($id,$msg);
+
+my $group = RT::Group->new($RT::SystemUser);
+$group->LoadACLEquivalenceGroup($RTxUser->PrincipalObj);
+
+my $RTxSysObj = {};
+bless $RTxSysObj, 'RTx::System';
+*RTx::System::Id = sub { 1; };
+*RTx::System::id = *RTx::System::Id;
+my $ace = RT::Record->new($RT::SystemUser);
+$ace->Table('ACL');
+$ace->_BuildTableAttributes unless ($_TABLE_ATTR->{ref($self)});
+($id, $msg) = $ace->Create( PrincipalId => $group->id, PrincipalType => 'Group', RightName => 'RTxUserRight', ObjectType => 'RTx::System', ObjectId  => 1 );
+ok ($id, "ACL for RTxSysObj created");
+
+my $RTxObj = {};
+bless $RTxObj, 'RTx::System::Record';
+*RTx::System::Record::Id = sub { 4; };
+*RTx::System::Record::id = *RTx::System::Record::Id;
+
+$users = RT::Users->new($RT::SystemUser);
+$users->WhoHaveRight(Right => 'RTxUserRight', Object => $RTxSysObj);
+is($users->Count, 1, "RTxUserRight found for RTxSysObj");
+
+$users = RT::Users->new($RT::SystemUser);
+$users->WhoHaveRight(Right => 'RTxUserRight', Object => $RTxObj);
+is($users->Count, 0, "RTxUserRight not found for RTxObj");
+
+$users = RT::Users->new($RT::SystemUser);
+$users->WhoHaveRight(Right => 'RTxUserRight', Object => $RTxObj, EquivObjects => [ $RTxSysObj ]);
+is($users->Count, 1, "RTxUserRight found for RTxObj using EquivObjects");
+
+$ace = RT::Record->new($RT::SystemUser);
+$ace->Table('ACL');
+$ace->_BuildTableAttributes unless ($_TABLE_ATTR->{ref($self)});
+($id, $msg) = $ace->Create( PrincipalId => $group->id, PrincipalType => 'Group', RightName => 'RTxUserRight', ObjectType => 'RTx::System::Record', ObjectId => 5 );
+ok ($id, "ACL for RTxObj created");
+
+my $RTxObj2 = {};
+bless $RTxObj2, 'RTx::System::Record';
+*RTx::System::Record::Id = sub { 5; };
+*RTx::System::Record::id = sub { 5; };
+
+$users = RT::Users->new($RT::SystemUser);
+$users->WhoHaveRight(Right => 'RTxUserRight', Object => $RTxObj2);
+is($users->Count, 1, "RTxUserRight found for RTxObj2");
+
+$users = RT::Users->new($RT::SystemUser);
+$users->WhoHaveRight(Right => 'RTxUserRight', Object => $RTxObj2, EquivObjects => [ $RTxSysObj ]);
+is($users->Count, 1, "RTxUserRight found for RTxObj2");
+
+
+
+    undef $main::_STDOUT_;
+    undef $main::_STDERR_;
+}
+
+1;


More information about the Rt-commit mailing list