[Rt-commit] r8066 - rtir/branches/2.3-EXPERIMENTAL/t

thayes at bestpractical.com thayes at bestpractical.com
Fri Jul 6 11:35:21 EDT 2007


Author: thayes
Date: Fri Jul  6 11:35:20 2007
New Revision: 8066

Modified:
   rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t

Log:
Fixed some (mostly stylistic) errors

Modified: rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t	Fri Jul  6 11:35:20 2007
@@ -1,12 +1,11 @@
 use strict;
 
 use Test::WWW::Mechanize;
-use Test::More tests => 99;
+use Test::More tests => 107;
 
-require "rtir-test.pl";
+require "t/rtir-test.pl";
 
 my $agent = default_agent();
-#create_user();
 
 my @ir_ids;
 
@@ -29,7 +28,7 @@
 is($inc_obj->Id, $incident_ids[0], "Incident has the right ID");
 is($inc_obj->Subject, "Incident number 1", "Incident has the right subject");
 
-LinkChildToIncident(id => $ir_ids[1], incident => $incident_ids[0]);
+LinkChildToIncident(agent => $agent, id => $ir_ids[1], incident => $incident_ids[0]);
 
 ticket_is_linked_to_inc($agent, $ir_ids[0], [$incident_ids[0]]);
 ticket_is_linked_to_inc($agent, $ir_ids[1], [$incident_ids[0]]);
@@ -40,12 +39,12 @@
 is($inc_obj->Id, $incident_ids[0], "Incident has the right ID");
 is($inc_obj->Subject, "Incident number 1", "Incident has the right subject");
 
-LinkChildToIncident(id => $ir_ids[3], incident => $incident_ids[1]);
+LinkChildToIncident(agent => $agent, id => $ir_ids[3], incident => $incident_ids[1]);
 
 ticket_is_linked_to_inc($agent, $ir_ids[2], [$incident_ids[1]]);
 ticket_is_linked_to_inc($agent, $ir_ids[3], [$incident_ids[1]]);
 
-resolve_ir($agent, $ir_ids[0]);
+resolve_rtir_ticket($agent, $ir_ids[0], 'Incident Report');
 
 my @invests;
 
@@ -55,42 +54,38 @@
 push @invests, create_investigation($agent, {Incident => $incident_ids[1], Subject => 'Investigation 1 for incident ' . $incident_ids[1]});
 push @invests, create_investigation($agent, {Incident => $incident_ids[0], Subject => 'Investigation 2 for incident ' . $incident_ids[1]});
 
-resolve_inv($agent, $invests[0]);
+resolve_rtir_ticket($agent, $invests[0], 'Investigation');
 
 bulk_abandon($agent, @incident_ids);
 
-foreach(@incident_ids) {
-	ticket_state_is($agent, $_, 'abandoned', "Incident #$_ is abandoned");
+foreach my $id (@incident_ids) {
+	ticket_state_is($agent, $id, 'abandoned', "Incident $id is abandoned");
 }
 
-foreach(@ir_ids ) {
-	$agent->get(RT->Config->Get('WebURL') . "/RTIR/Display.html?id=$_");
-	$agent->content =~ qr{State:\s*</td>\s*<td[^>]*?>\s*<span class="cf-value">([\w ]+)</span>}ism;
-	diag("IR #$_ state is " . $1);
-}
-foreach(@invests) {
-	$agent->get(RT->Config->Get('WebURL') . "/RTIR/Display.html?id=$_");
-	$agent->content =~ qr{State:\s*</td>\s*<td[^>]*?>\s*<span class="cf-value">([\w ]+)</span>}ism;
-	diag("Investigation #$_ state is " . $1);
+foreach my $id (@ir_ids ) {
+	diag("IR #$id state is " . ticket_state($agent, $id)) if($ENV{'TEST_VERBOSE'});
+}
+foreach my $id (@invests) {
+	diag("IR #$id state is " . ticket_state($agent, $id)) if($ENV{'TEST_VERBOSE'});
 }
 
 
 sub bulk_abandon {
 	my $agent = shift;
-	my @toAbandon = @_;
+	my @to_abandon = @_;
 	
 	go_home($agent);
 	$agent->follow_link_ok({text => "Incidents", n => '1'}, "Followed 'Incidents' link");
 	$agent->follow_link_ok({text => "Bulk Abandon", n => '1'}, "Followed 'Bulk Abandon' link");
 	
 	$agent->form_number(3);
-	foreach my $id (@toAbandon) {
+	foreach my $id (@to_abandon) {
 		$agent->tick('SelectedTickets', $id);
 	}
 	
 	$agent->click('BulkAbandon');
 	
-	foreach my $id (@toAbandon) {
+	foreach my $id (@to_abandon) {
 		ok_and_content_like($agent, qr/Ticket $id: State changed from \w+ to abandoned/, "Incident $id abandoned");
 	}
 	
@@ -98,54 +93,15 @@
 	ok($agent->value('BulkAbandon'), "Still on Bulk Abandon page");
 }
 
-sub resolve_ir {
+sub resolve_rtir_ticket {
 	my $agent = shift;
-	my $id = shift;	
+	my $id = shift;
+	my $type = shift || 'Ticket';
 	
 	display_ticket($agent, $id);
 	$agent->follow_link_ok({text => "Quick Resolve", n => "1"}, "Followed 'Quick Resolve' link");
 	
-	is($agent->status, 200, "Attempting to resolve IR $id");
-	
-	$agent->content_like(qr/.*State changed from \w+ to resolved.*/, "Successfully resolved IR $id")
-}
-
-
-sub resolve_inv {
-	my $agent = shift;
-	my $id = shift;	
+	is($agent->status, 200, "Attempting to resolve $type #$id");
 	
-	display_ticket($agent, $id);
-	$agent->follow_link_ok({text => "Quick Resolve", n => "1"}, "Followed 'Quick Resolve' link");
-	
-	is($agent->status, 200, "Attempting to resolve Investigation $id");
-	
-	$agent->content_like(qr/.*State changed from \w+ to resolved.*/, "Successfully resolved Investigation $id")
-}
-
-#Copied straight from t/001-basic-RTIR.t
-
-sub LinkChildToIncident {
-    my %args = ( @_ );
-
-    my $id = $args{'id'};
-    my $incident = $args{'incident'};
-
-    display_ticket($agent, $id);
-
-    # Select the "Link" link from the Display page
-    $agent->follow_link_ok({text => "[Link]", n => "1"}, "Followed 'Link(to Incident)' link");
-
-    # TODO: Make sure desired incident appears on page
-
-    # Choose the incident and submit
-    $agent->form_number(3);
-    $agent->field("SelectedTicket", $incident);
-    $agent->click("LinkChild");
-
-    is ($agent->status, 200, "Attempting to link child $id to Incident $incident");
-
-    ok ($agent->content =~ /Ticket $id: Link created/g, "Incident $incident linked successfully.");
-
-    return;
+	$agent->content_like(qr/.*State changed from \w+ to resolved.*/, "Successfully resolved $type #$id")
 }


More information about the Rt-commit mailing list