Skip to content

Commit

Permalink
Item377: Fixed test for old TWiki versions
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@1132 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed Dec 2, 2008
1 parent a70226d commit ff1a086
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions UnitTestContrib/lib/Unit/TestCase.pm
Expand Up @@ -274,9 +274,10 @@ sub assert_html_matches {
sub capture {
my $this = shift;
my $proc = shift;

require File::Temp;
my $tmpdir = File::Temp::tempdir(CLEANUP => 1);
my $tmpfilename = "$tmpdir/data";

my $text = undef;
my $response = undef;
Expand All @@ -286,12 +287,12 @@ sub capture {

{
local *STDOUT;
open(STDOUT, ">$tmpdir/data");
open STDOUT, ">", $tmpfilename
or die "Can't open temporary STDOUT file $tmpfilename: $!";

$result = &$proc( @params );
}

if ( $release >= 5 ) {

$response =
UNIVERSAL::isa( $params[0], 'Foswiki' )
? $params[0]->{response}
Expand All @@ -307,13 +308,6 @@ sub capture {

# Capture body
$text .= $response->body() if $response->body();
}
else {
open( FH, "$tmpdir/data" );
local $/ = undef;
$text = <FH>;
close(FH);
}

return ( $text, $result );
}
Expand Down

0 comments on commit ff1a086

Please sign in to comment.