Make WebGUI::PseudoRequest work with fatals. Cookies are now mocked and
tied off inside that package. ErrorHandler uses the session request object, instead of RequestUtil.
This commit is contained in:
parent
e0ce8caf5a
commit
c90fa56507
3 changed files with 34 additions and 3 deletions
|
|
@ -17,7 +17,7 @@ package WebGUI::Session::ErrorHandler;
|
|||
|
||||
use strict;
|
||||
use Log::Log4perl;
|
||||
use Apache2::RequestUtil;
|
||||
#use Apache2::RequestUtil;
|
||||
use JSON;
|
||||
use HTML::Entities qw(encode_entities);
|
||||
|
||||
|
|
@ -220,7 +220,8 @@ sub fatal {
|
|||
|
||||
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1;
|
||||
$self->session->http->setStatus("500","Server Error");
|
||||
Apache2::RequestUtil->request->content_type('text/html') if ($self->session->request);
|
||||
#Apache2::RequestUtil->request->content_type('text/html') if ($self->session->request);
|
||||
$self->session->request->content_type('text/html') if ($self->session->request);
|
||||
$self->getLogger->fatal($message);
|
||||
$self->getLogger->debug("Stack trace for FATAL ".$message."\n".$self->getStackTrace());
|
||||
$self->session->http->sendHeader if ($self->session->request);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use WebGUI::Session;
|
|||
use Test::More;
|
||||
use Test::MockObject::Extends;
|
||||
|
||||
my $numTests = 37;
|
||||
my $numTests = 39;
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
|
|
@ -223,6 +223,25 @@ foreach my $entry (qw/_debug_error _debug_warn _debug_info _debug_debug/) {
|
|||
|
||||
my $showDebug = $eh->showDebug;
|
||||
|
||||
####################################################
|
||||
#
|
||||
# fatal, stub
|
||||
#
|
||||
####################################################
|
||||
|
||||
my $newSession = WebGUI::Session->open(WebGUI::Test::root, WebGUI::Test::file);
|
||||
my $outputBuffer;
|
||||
open my $outputHandle, '>', \$outputBuffer or die "Unable to create scalar filehandle: $!\n";
|
||||
$newSession->output->setHandle($outputHandle);
|
||||
WEBGUI_FATAL: {
|
||||
$newSession->log->fatal();
|
||||
}
|
||||
ok(1, 'fatal: recovered from fatal okay');
|
||||
TODO: {
|
||||
local $TODO = 'Validate the fatal output';
|
||||
ok(0, 'output from fatal when there is a db handler and request present');
|
||||
}
|
||||
|
||||
END {
|
||||
$session->setting->set('debugIp', $origDebugIp);
|
||||
$session->setting->set('showDebug', $origShowDebug);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,17 @@ package WebGUI::PseudoRequest;
|
|||
|
||||
use strict;
|
||||
|
||||
use Test::MockObject;
|
||||
|
||||
my $mocker = Test::MockObject->new();
|
||||
$mocker->fake_module(
|
||||
'Apache2::Cookie',
|
||||
new => sub { return bless {}, 'Apache2::Cookie'; },
|
||||
expires => sub { 1; },
|
||||
domain => sub { 1; },
|
||||
bake => sub { 1; },
|
||||
);
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue