Skip to content

Commit

Permalink
Item175: removed redundant condition from test request and response
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@854 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Nov 22, 2008
1 parent 7ebfc6e commit effe4fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
17 changes: 1 addition & 16 deletions UnitTestContrib/lib/Unit/Request.pm
@@ -1,19 +1,4 @@
package Unit::Request;
use strict;

BEGIN {
use Foswiki;
use CGI;
my ($release) = $Foswiki::RELEASE =~ /-(\d+)\.\d+\.\d+/;
if ( $release >= 2 ) {
require Foswiki::Request;
import Foswiki::Request;
@Unit::Request::ISA = 'Foswiki::Request';
}
else {
@Unit::Request::ISA = 'CGI';
}
}

use base 'Foswiki::Request';

1;
24 changes: 6 additions & 18 deletions UnitTestContrib/lib/Unit/Response.pm
@@ -1,30 +1,18 @@
package Unit::Response;
use base 'Foswiki::Response';
use strict;

use vars qw($res);

BEGIN {
use Foswiki;
use CGI;
my ($release) = $Foswiki::RELEASE =~ /-(\d+)\.\d+\.\d+/;
no warnings qw(redefine);
if ( $release >= 2 ) {
require Foswiki::Response;
import Foswiki::Response;
@Unit::Response::ISA = qw(Foswiki::Response);
my $twiki_new = \&Foswiki::new;
*Foswiki::new =
sub { my $t = $twiki_new->(@_); $res = $t->{response}; return $t };
}
else {
@Unit::Response::ISA = qw(CGI);
*charset = sub { shift; CGI::charset(@_) };
my $twiki_new = \&Foswiki::new;
*Foswiki::new =
sub { my $t = $twiki_new->(@_); $res = $t->{cgiQuery}; return $t };
}
my $twiki_finish = \&Foswiki::finish;
*Foswiki::finish = sub { $twiki_finish->(@_); $res = undef; };
my $_new = \&Foswiki::new;
*Foswiki::new =
sub { my $t = $_new->(@_); $res = $t->{response}; return $t };
my $_finish = \&Foswiki::finish;
*Foswiki::finish = sub { $_finish->(@_); $res = undef; };
}

sub new {
Expand Down

0 comments on commit effe4fa

Please sign in to comment.