diff options
author | ivan <ivan> | 2004-12-03 20:40:48 +0000 |
---|---|---|
committer | ivan <ivan> | 2004-12-03 20:40:48 +0000 |
commit | d39d52aac8f38ea9115628039f0df5aa3ac826de (patch) | |
tree | c77529c4e4dbb9bf832fcef14538dc16b2f7a110 /rt/lib/t | |
parent | c582e92888b4a5553e1b4e5214cf35217e4a0cf0 (diff) |
import rt 3.2.2
Diffstat (limited to 'rt/lib/t')
-rw-r--r-- | rt/lib/t/00smoke.t.in | 2 | ||||
-rw-r--r-- | rt/lib/t/02regression.t.in | 1 | ||||
-rw-r--r-- | rt/lib/t/03web.pl.in | 78 | ||||
-rw-r--r-- | rt/lib/t/05cronsupport.pl.in | 84 |
4 files changed, 163 insertions, 2 deletions
diff --git a/rt/lib/t/00smoke.t.in b/rt/lib/t/00smoke.t.in index 11f0a9c43..288dd4aae 100644 --- a/rt/lib/t/00smoke.t.in +++ b/rt/lib/t/00smoke.t.in @@ -8,7 +8,7 @@ ok(RT::LoadConfig); ok(RT::Init, "Basic initialization and DB connectivity"); use File::Find; -File::Find::find({wanted => \&wanted}, '.'); +File::Find::find({wanted => \&wanted}, 'lib/'); sub wanted { /^*\.pm\z/s && ok(require $_, "Requiring '$_'"); } diff --git a/rt/lib/t/02regression.t.in b/rt/lib/t/02regression.t.in index 7862ef407..c2e3277a9 100644 --- a/rt/lib/t/02regression.t.in +++ b/rt/lib/t/02regression.t.in @@ -44,3 +44,4 @@ sub wanted_regression { /^*\.t\z/s && require $_; } require "@RT_LIB_PATH@/t/03web.pl"; require "@RT_LIB_PATH@/t/04_send_email.pl"; +require "@RT_LIB_PATH@/t/05cronsupport.pl"; diff --git a/rt/lib/t/03web.pl.in b/rt/lib/t/03web.pl.in index 4fe2d3ef3..25c26e711 100644 --- a/rt/lib/t/03web.pl.in +++ b/rt/lib/t/03web.pl.in @@ -67,7 +67,83 @@ ok( $agent->{'content'} =~ qr{$string} , "Found the content"); # }}} +# {{{ Query Builder tests + +my $response = $agent->get($url."Search/Build.html"); +ok( $response->is_success, "Fetched " . $url."Search/Build.html" ); + +# Parsing TicketSQL +# +# Adding items + +# set the first value +ok($agent->form_name('BuildQuery')); +$agent->field("AttachmentField", "Subject"); +$agent->field("AttachmentOp", "LIKE"); +$agent->field("ValueOfAttachment", "aaa"); +$agent->submit(); + +# set the next value +ok($agent->form_name('BuildQuery')); +$agent->field("AttachmentField", "Subject"); +$agent->field("AttachmentOp", "LIKE"); +$agent->field("ValueOfAttachment", "bbb"); +$agent->submit(); + +ok($agent->form_name('BuildQuery')); + +# get the query +my $query = $agent->current_form->find_input("Query")->value; +# strip whitespace from ends +$query =~ s/^\s*//g; +$query =~ s/\s*$//g; + +# collapse other whitespace +$query =~ s/\s+/ /g; + +is ($query, "Subject LIKE 'aaa' AND Subject LIKE 'bbb'"); + +# - new items go one level down +# - add items at currently selected level +# - if nothing is selected, add at end, one level down +# +# move left +# - error if nothing selected +# - same item should be selected after move +# - can't move left if you're at the top level +# +# move right +# - error if nothing selected +# - same item should be selected after move +# - can always move right (no max depth...should there be?) +# +# move up +# - error if nothing selected +# - same item should be selected after move +# - can't move up if you're first in the list +# +# move down +# - error if nothing selected +# - same item should be selected after move +# - can't move down if you're last in the list +# +# toggle +# - error if nothing selected +# - change all aggregators in the grouping +# - don't change any others +# +# delete +# - error if nothing selected +# - delete currently selected item +# - delete all children of a grouping +# - if delete leaves a node with no children, delete that, too +# - what should be selected? +# +# Clear +# - clears entire query +# - clears it from the session, too +# }}} use File::Find; find ( \&wanted , 'html/'); @@ -83,7 +159,7 @@ sub test_get { $file =~ s#^html/##; ok ($agent->get("$url/$file", "GET $url/$file")); is ($agent->{'status'}, 200, "Loaded $file"); - ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file "); +# ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file "); ok( $agent->{'content'} !~ /Not logged in/i, "Still logged in for $file"); ok( $agent->{'content'} !~ /System error/i, "Didn't get a Mason compilation error on $file"); diff --git a/rt/lib/t/05cronsupport.pl.in b/rt/lib/t/05cronsupport.pl.in new file mode 100644 index 000000000..a6b3d7451 --- /dev/null +++ b/rt/lib/t/05cronsupport.pl.in @@ -0,0 +1,84 @@ +#!@PERL@ -w + +use strict; + +### Set up some testing data. Test the testing data because why not? + +# Create a user with rights, a queue, and some tickets. +my $user_obj = RT::User->new($RT::SystemUser); +my ($ret, $msg) = $user_obj->LoadOrCreateByEmail('tara@example.com'); +ok($ret, 'record test user creation'); +$user_obj->SetName('tara'); +$user_obj->PrincipalObj->GrantRight(Right => 'SuperUser'); +my $CurrentUser = RT::CurrentUser->new('tara'); + +# Create our template, which will be used for tests of RT::Action::Record*. + +my $template_content = 'RT-Send-Cc: tla@example.com +RT-Send-Bcc: jesse@example.com + +This is a content string with no content.'; + +my $template_obj = RT::Template->new($CurrentUser); +$template_obj->Create(Queue => '0', + Name => 'recordtest', + Description => 'testing Record actions', + Content => $template_content, + ); + +# Create a queue and some tickets. + +my $queue_obj = RT::Queue->new($CurrentUser); +($ret, $msg) = $queue_obj->Create(Name => 'recordtest', Description => 'queue for Action::Record testing'); +ok($ret, 'record test queue creation'); + +my $ticket1 = RT::Ticket->new($CurrentUser); +my ($id, $tobj, $msg2) = $ticket1->Create(Queue => $queue_obj, + Requestor => ['tara@example.com'], + Subject => 'bork bork bork', + Priority => 22, + ); +ok($id, 'record test ticket creation 1'); +my $ticket2 = RT::Ticket->new($CurrentUser); +($id, $tobj, $msg2) = $ticket2->Create(Queue => $queue_obj, + Requestor => ['root@localhost'], + Subject => 'hurdy gurdy' + ); +ok($id, 'record test ticket creation 2'); + + +### OK. Have data, will travel. + +# First test the search. + +ok(require RT::Search::FromSQL, "Search::FromSQL loaded"); +my $ticketsqlstr = "Requestor.EmailAddress = '" . $CurrentUser->EmailAddress . + "' AND Priority > '20'"; +my $search = RT::Search::FromSQL->new(Argument => $ticketsqlstr, TicketsObj => RT::Tickets->new($CurrentUser), + ); +is(ref($search), 'RT::Search::FromSQL', "search created"); +ok($search->Prepare(), "fromsql search run"); +my $counter = 0; +while(my $t = $search->TicketsObj->Next() ) { + is($t->Id(), $ticket1->Id(), "fromsql search results 1"); + $counter++; +} +is ($counter, 1, "fromsql search results 2"); + +# Right. Now test the actions. + +ok(require RT::Action::RecordComment); +ok(require RT::Action::RecordCorrespondence); + +my ($comment_act, $correspond_act); +ok($comment_act = RT::Action::RecordComment->new(TicketObj => $ticket1, TemplateObj => $template_obj, CurrentUser => $CurrentUser), "RecordComment created"); +ok($correspond_act = RT::Action::RecordCorrespondence->new(TicketObj => $ticket2, TemplateObj => $template_obj, CurrentUser => $CurrentUser), "RecordCorrespondence created"); +ok($comment_act->Prepare(), "Comment prepared"); +ok($correspond_act->Prepare(), "Correspond prepared"); +ok($comment_act->Commit(), "Comment committed"); +ok($correspond_act->Commit(), "Correspondence committed"); + +# Now test for loop suppression. +my ($trans, $desc, $transaction) = $ticket2->Comment(MIMEObj => $template_obj->MIMEObj); +my $bogus_action = RT::Action::RecordComment->new(TicketObj => $ticket1, TemplateObj => $template_obj, TransactionObj => $transaction, CurrentUser => $CurrentUser); +ok(!$bogus_action->Prepare(), "Comment aborted to prevent loop"); |