[Rt-commit] r8461 - in rt/branches/3.7-EXPERIMENTAL-TUNIS/lib: RT

ruz at bestpractical.com ruz at bestpractical.com
Wed Aug 8 19:58:14 EDT 2007


Author: ruz
Date: Wed Aug  8 19:58:13 2007
New Revision: 8461

Modified:
   rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm
   rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/utils.pl

Log:
* add run_mailgate to RT::Test, move it from lib/t/utils.pl

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm	Wed Aug  8 19:58:13 2007
@@ -245,4 +245,46 @@
     return 1;
 }
 
+sub run_mailgate {
+    my $self = shift;
+
+    require RT::Test::Web;
+    my %args = (
+        url     => RT::Test::Web->rt_base_url,
+        message => '',
+        action  => 'correspond',
+        queue   => 'General',
+        @_
+    );
+    my $message = delete $args{'message'};
+
+    my $cmd = $RT::BinPath .'/rt-mailgate';
+    die "Couldn't find mailgate ($cmd) command" unless -f $cmd;
+
+    $cmd .= ' --debug';
+    while( my ($k,$v) = each %args ) {
+        next unless $v;
+        $cmd .= " --$k '$v'";
+    }
+    $cmd .= ' 2>&1';
+
+    DBIx::SearchBuilder::Record::Cachable->FlushCache;
+
+    require IPC::Open2;
+    my ($child_out, $child_in);
+    my $pid = IPC::Open2::open2($child_out, $child_in, $cmd);
+
+    if ( UNIVERSAL::isa($message, 'MIME::Entity') ) {
+        $message->print( $child_in );
+    } else {
+        print $child_in $message;
+    }
+    close $child_in;
+
+    my $result = do { local $/; <$child_out> };
+    close $child_out;
+    waitpid $pid, 0;
+    return ($?, $result);
+}
+
 1;

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/utils.pl
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/utils.pl	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/utils.pl	Wed Aug  8 19:58:13 2007
@@ -6,44 +6,9 @@
 use RT;
 RT::LoadConfig();
 
-use IPC::Open2;
-
-our $url = RT->Config->Get('WebURL');
-our $mailgate = $RT::BinPath .'/rt-mailgate';
-die "Couldn't find mailgate ($mailgate) command" unless -f $mailgate;
-$mailgate .= ' --debug';
-
 sub run_gate {
-    my %args = (
-        url     => $url,
-        message => '',
-        action  => 'correspond',
-        queue   => 'General',
-        @_
-    );
-    my $message = delete $args{'message'};
-
-    my $cmd = $mailgate;
-    while( my ($k,$v) = each %args ) {
-        next unless $v;
-        $cmd .= " --$k '$v'";
-    }
-    $cmd .= ' 2>&1';
-
-    DBIx::SearchBuilder::Record::Cachable->FlushCache;
-
-    my ($child_out, $child_in);
-    my $pid = open2($child_out, $child_in, $cmd);
-    if ( UNIVERSAL::isa($message, 'MIME::Entity') ) {
-        $message->print( $child_in );
-    } else {
-        print $child_in $message;
-    }
-    close $child_in;
-    my $result = do { local $/; <$child_out> };
-    close $child_out;
-    waitpid $pid, 0;
-    return ($?, $result);
+    require RT::Test;
+    return RT::Test->run_mailgate(@_);
 }
 
 sub create_ticket_via_gate {


More information about the Rt-commit mailing list