Conflicts: docs/gotcha.txt docs/previousVersion.sql lib/WebGUI/Asset/Wobject/GalleryAlbum.pm lib/WebGUI/Asset/Wobject/Navigation.pm lib/WebGUI/AssetLineage.pm lib/WebGUI/Config.pm lib/WebGUI/Form/Template.pm lib/WebGUI/Group.pm lib/WebGUI/VersionTag.pm lib/WebGUI/Workflow/Activity/TrashExpiredEvents.pm t/AdSpace.t t/Asset/AssetExportHtml.t t/Asset/AssetLineage.t t/Asset/Story.t t/Asset/Template/HTMLTemplateExpr.t t/Asset/Wobject/Gallery/00base.t t/Asset/Wobject/GalleryAlbum/00base.t t/Asset/Wobject/GalleryAlbum/ajax.t t/Asset/Wobject/InOutBoard.t t/Asset/Wobject/StoryArchive.t t/Asset/Wobject/Survey/ExpressionEngine.t t/Asset/Wobject/Survey/Reports.t t/AssetAspect/RssFeed.t t/Auth/mech.t t/Group.t t/Mail/Send.t t/Operation/AdSpace.t t/Session/ErrorHandler.t t/Session/Scratch.t t/Session/Url.t t/Shop/Cart.t t/Shop/Pay.t t/Shop/Ship.t t/Shop/ShipDriver.t t/Shop/TaxDriver/Generic.t t/Shop/Vendor.t t/VersionTag.t t/lib/WebGUI/Test.pm
117 lines
3.6 KiB
Perl
117 lines
3.6 KiB
Perl
#-------------------------------------------------------------------
|
|
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
|
#-------------------------------------------------------------------
|
|
# Please read the legal notices (docs/legal.txt) and the license
|
|
# (docs/license.txt) that came with this distribution before using
|
|
# this software.
|
|
#-------------------------------------------------------------------
|
|
# http://www.plainblack.com info@plainblack.com
|
|
#-------------------------------------------------------------------
|
|
|
|
use FindBin;
|
|
use strict;
|
|
use lib "$FindBin::Bin/../lib";
|
|
|
|
use WebGUI::Test;
|
|
use WebGUI::Session;
|
|
|
|
use Test::More;
|
|
use Test::MockObject::Extends;
|
|
use Try::Tiny;
|
|
|
|
my $numTests = 13;
|
|
|
|
plan tests => $numTests;
|
|
|
|
my $session = WebGUI::Test->session;
|
|
|
|
##Setup for security method test
|
|
my $env = $session->request->env;
|
|
$env->{REMOTE_ADDR} = '192.168.0.6';
|
|
|
|
my $eh = $session->errorHandler;
|
|
|
|
####################################################
|
|
#
|
|
# warn, security
|
|
#
|
|
####################################################
|
|
|
|
WebGUI::Test->interceptLogging( sub {
|
|
my $log_data = shift;
|
|
|
|
my $accumulated_warn = "";
|
|
$eh->warn("This is a warning");
|
|
is($log_data->{warn}, "This is a warning", "warn: Log4perl called");
|
|
$eh->warn("Second warning");
|
|
is($log_data->{warn}, "Second warning", "warn: Log4perl called again");
|
|
$eh->security('Shields up, red alert');
|
|
my $security = sprintf '%s (%d) connecting from %s attempted to %s',
|
|
$session->user->username, $session->user->userId, $session->request->address, 'Shields up, red alert';
|
|
is($log_data->{warn}, $security, 'security: calls warn with username, userId and IP address');
|
|
});
|
|
|
|
####################################################
|
|
#
|
|
# info, audit
|
|
#
|
|
####################################################
|
|
|
|
WebGUI::Test->interceptLogging( sub {
|
|
my $log_data = shift;
|
|
$eh->info("This is informative");
|
|
is($log_data->{info}, "This is informative", "info: Log4perl called");
|
|
$eh->info("More info");
|
|
is($log_data->{info}, "More info", "info: Log4perl called again");
|
|
$eh->audit('Check this out');
|
|
my $audit = sprintf '%s (%d) %s', $session->user->username, $session->user->userId, 'Check this out';
|
|
is($log_data->{info}, $audit, 'audit: calls info with username and userId');
|
|
});
|
|
|
|
####################################################
|
|
#
|
|
# debug
|
|
#
|
|
####################################################
|
|
|
|
WebGUI::Test->interceptLogging( sub {
|
|
my $log_data = shift;
|
|
$eh->debug("This is a bug");
|
|
is($log_data->{debug}, "This is a bug", "debug: Log4perl called");
|
|
$eh->debug("More bugs");
|
|
is($log_data->{debug}, "More bugs", "debug: Log4perl called again");
|
|
});
|
|
|
|
####################################################
|
|
#
|
|
# error
|
|
#
|
|
####################################################
|
|
|
|
WebGUI::Test->interceptLogging( sub {
|
|
my $log_data = shift;
|
|
$eh->error("ERROR");
|
|
is($log_data->{error}, "ERROR", "error: Log4perl called error");
|
|
$eh->error("More errors");
|
|
is($log_data->{error}, "More errors", "error: Log4perl called error again");
|
|
});
|
|
|
|
####################################################
|
|
#
|
|
# fatal, stub
|
|
#
|
|
####################################################
|
|
|
|
WebGUI::Test->interceptLogging( sub {
|
|
my $log_data = shift;
|
|
my $thrown = try {
|
|
$eh->fatal('Bad things are happenning');
|
|
fail 'fatal throws exception';
|
|
fail ' ... exception isa WebGUI::Exception::Fatal';
|
|
}
|
|
catch {
|
|
pass 'fatal throws exception';
|
|
isa_ok $_, 'WebGUI::Error::Fatal';
|
|
};
|
|
is $log_data->{fatal}, 'Bad things are happenning', 'fatal: logger called correctly';
|
|
});
|