};
-our @EXPORT = qw(is_empty);
+our @EXPORT = qw(is_empty parse_mail);
our ($port, $dbname);
our @SERVERS;
$tmp{'config'}{'RT'} = File::Spec->catfile(
"$tmp{'directory'}", 'RT_SiteConfig.pm'
);
- open my $config, '>', $tmp{'config'}{'RT'}
+ open( my $config, '>', $tmp{'config'}{'RT'} )
or die "Couldn't open $tmp{'config'}{'RT'}: $!";
print $config qq{
Set( \$MailCommand, sub {
my \$MIME = shift;
- open my \$handle, '>>', '$mail_catcher'
+ open( my \$handle, '>>', '$mail_catcher' )
or die "Unable to open '$mail_catcher' for appending: \$!";
\$MIME->print(\$handle);
$tmp{'log'}{'RT'} = File::Spec->catfile(
"$tmp{'directory'}", 'rt.debug.log'
);
- open my $fh, '>', $tmp{'log'}{'RT'}
+ open( my $fh, '>', $tmp{'log'}{'RT'} )
or die "Couldn't open $tmp{'config'}{'RT'}: $!";
# make world writable so apache under different user
# can write into it
SCALAR => '$',
);
my $sigil = $sigils{$type} || $sigils{'SCALAR'};
- open my $fh, '>>', $tmp{'config'}{'RT'}
+ open( my $fh, '>>', $tmp{'config'}{'RT'} )
or die "Couldn't open config file: $!";
require Data::Dumper;
my $dump = Data::Dumper::Dumper([@_[2 .. $#_]]);
my $baseurl = shift;
my $queue = shift || 'general';
my $action = shift || 'correspond';
- Test::More::ok(open(my $mail, "|$RT::BinPath/rt-mailgate --url $baseurl --queue $queue --action $action"), "Opened the mailgate - $!");
+ Test::More::ok(open(my $mail, '|-', "$RT::BinPath/rt-mailgate --url $baseurl --queue $queue --action $action"), "Opened the mailgate - $!");
return $mail;
}
$RT::Handle->dbh( undef );
RT->ConnectToDatabase;
+ # the attribute cache holds on to a stale dbh
+ delete $RT::System->{attributes};
+
return ($ret, RT::Test::Web->new);
}
my %info = $self->apache_server_info( variant => $variant );
Test::More::diag(do {
- open my $fh, '<', $tmp{'config'}{'RT'};
+ open( my $fh, '<', $tmp{'config'}{'RT'} ) or die $!;
local $/;
<$fh>
});
}
Test::More::BAIL_OUT("Couldn't start apache server, no pid file")
unless -e $opt{'pid_file'};
- open my $pid_fh, '<', $opt{'pid_file'}
+ open( my $pid_fh, '<', $opt{'pid_file'} )
or Test::More::BAIL_OUT("Couldn't open pid file: $!");
my $pid = <$pid_fh>;
chomp $pid;
Test::More::diag "reading content of '$path'" if $ENV{'TEST_VERBOSE'};
- open my $fh, "<:raw", $path
+ open( my $fh, "<:raw", $path )
or do {
warn "couldn't open file '$path': $!" unless $args{noexist};
return ''
($out_fh, $out_conf) = tempfile();
} else {
$out_conf = $args{'out'};
- open $out_fh, '>', $out_conf
+ open( $out_fh, '>', $out_conf )
or die "couldn't open '$out_conf': $!";
}
print $out_fh $text;
return ($out_fh, $out_conf);
}
+sub parse_mail {
+ my $mail = shift;
+ require RT::EmailParser;
+ my $parser = RT::EmailParser->new;
+ $parser->ParseMIMEEntityFromScalar( $mail );
+ return $parser->Entity;
+}
+
END {
my $Test = RT::Test->builder;
return if $Test->{Original_Pid} != $$;