From ff1a0860819efaa7a9f61214411cf80e269807f4 Mon Sep 17 00:00:00 2001 From: OlivierRaginel Date: Tue, 2 Dec 2008 20:49:25 +0000 Subject: [PATCH] Item377: Fixed test for old TWiki versions git-svn-id: http://svn.foswiki.org/trunk@1132 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- UnitTestContrib/lib/Unit/TestCase.pm | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/UnitTestContrib/lib/Unit/TestCase.pm b/UnitTestContrib/lib/Unit/TestCase.pm index 297bc224c8..427788a677 100644 --- a/UnitTestContrib/lib/Unit/TestCase.pm +++ b/UnitTestContrib/lib/Unit/TestCase.pm @@ -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; @@ -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} @@ -307,13 +308,6 @@ sub capture { # Capture body $text .= $response->body() if $response->body(); - } - else { - open( FH, "$tmpdir/data" ); - local $/ = undef; - $text = ; - close(FH); - } return ( $text, $result ); }