Skip to content

Commit

Permalink
Item14033: Fix up unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Apr 6, 2016
1 parent 1456e90 commit e92e820
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 9 additions & 7 deletions UnitTestContrib/test/unit/HTMLValidationTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use Error qw( :try );

my $UI_FN;
my $SCRIPT_NAME;
my $REQUEST;
my $SKIN_NAME;
my %expected_status = (
search => 302,
Expand Down Expand Up @@ -120,7 +121,8 @@ m/^(attach|changes|compare|compareauth|configure|edit|jsonrpc|login|logon|manage
}
next unless ( ref($dispatcher) eq 'HASH' ); #bad switchboard entry.

my $package = $dispatcher->{package} || 'Foswiki::UI';
my $package = $dispatcher->{package} || 'Foswiki::UI';
my $request = $dispatcher->{request} || 'Foswiki::Request';
my $function = $dispatcher->{function};
my $sub = $package . '::' . $function;

Expand All @@ -133,6 +135,7 @@ m/^(attach|changes|compare|compareauth|configure|edit|jsonrpc|login|logon|manage
eval "require $package" if ( defined($package) );
$UI_FN = $sub;
$SCRIPT_NAME = $script;
$REQUEST = $request;
};
use strict 'refs';
1;
Expand Down Expand Up @@ -178,12 +181,11 @@ sub call_UI_FN {
%constructor = ( %constructor, %{$params} );
}
my $query;
if ( $SCRIPT_NAME =~ m/^viewfile/ ) {
$query = Unit::Request::Attachment->new( \%constructor );
}
else {
$query = Unit::Request->new( \%constructor );
}

my $request = $REQUEST || 'Foswiki::Request';
$request =~ s/^Foswiki::/Unit::/;

$query = $request->new( \%constructor );
$query->path_info("/$web/$topic");
$query->method('GET');

Expand Down
12 changes: 11 additions & 1 deletion UnitTestContrib/test/unit/UIFnCompileTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use Error qw( :try );

our $UI_FN;
our $SCRIPT_NAME;
our $REQUEST;
our %expected_status_main_webhome = (
search => 302,
save => 302,
Expand Down Expand Up @@ -75,14 +76,17 @@ sub fixture_groups {
next unless ( ref($dispatcher) eq 'HASH' ); #bad switchboard entry.

my $package = $dispatcher->{package} || 'Foswiki::UI';
my $request = $dispatcher->{request} || 'Foswiki::Request';
eval "require $package; 1;" or next;
eval "require $request; 1;" or next;
my $function = $dispatcher->{function};
my $sub = $package->can($function);

no strict 'refs';
*{$script} = sub {
$UI_FN = $sub;
$SCRIPT_NAME = $script;
$REQUEST = $request;
};
use strict 'refs';
}
Expand All @@ -92,7 +96,12 @@ sub fixture_groups {

sub call_UI_FN {
my ( $this, $web, $topic, $tmpl ) = @_;
my $query = Unit::Request->new(

my $request = $REQUEST;
$request =~ s/^Foswiki::/Unit::/;
eval "require $request; 1;";

my $query = $request->new(
{
webName => [$web],
topicName => [$topic],
Expand All @@ -103,6 +112,7 @@ sub call_UI_FN {
$query->path_info("/$web/$topic");
$query->method('POST');
$this->createNewFoswikiSession( $this->{test_user_login}, $query );

my ( $responseText, $result, $stdout, $stderr );
$responseText = "Status: 500"; #errr, boom
try {
Expand Down

0 comments on commit e92e820

Please sign in to comment.