use callback for log interception instead of on/off
This commit is contained in:
parent
8bfa022441
commit
18525e7c1b
9 changed files with 126 additions and 268 deletions
|
|
@ -519,24 +519,26 @@ my $vTag2 = WebGUI::VersionTag->getWorking($session);
|
|||
$vTag2->set({name=>"deep addChild test"});
|
||||
WebGUI::Test->addToCleanup($vTag2);
|
||||
|
||||
WebGUI::Test->interceptLogging();
|
||||
WebGUI::Test->interceptLogging( sub {
|
||||
my $log_data = shift;
|
||||
|
||||
my @deepAsset = ($root);
|
||||
my @deepAsset = ($root);
|
||||
|
||||
for (1..42) {
|
||||
$deepAsset[$_] = $deepAsset[$_-1]->addChild( {
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
groupIdView => 7,
|
||||
ownerUserId => 3, #For coverage on addChild properties
|
||||
title => "Deep Snippet $_",
|
||||
menuTitle => "Deep Snip $_",
|
||||
});
|
||||
}
|
||||
for (1..42) {
|
||||
$deepAsset[$_] = $deepAsset[$_-1]->addChild( {
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
groupIdView => 7,
|
||||
ownerUserId => 3, #For coverage on addChild properties
|
||||
title => "Deep Snippet $_",
|
||||
menuTitle => "Deep Snip $_",
|
||||
});
|
||||
}
|
||||
|
||||
$vTag2->commit;
|
||||
$vTag2->commit;
|
||||
|
||||
is($deepAsset[41]->getParent->getId, $deepAsset[40]->getId, 'addChild will not create an asset with a lineage deeper than 42 levels');
|
||||
like($WebGUI::Test::logger_warns, qr/Adding it as a sibling instead/, 'addChild logged a warning about deep assets');
|
||||
is($deepAsset[41]->getParent->getId, $deepAsset[40]->getId, 'addChild will not create an asset with a lineage deeper than 42 levels');
|
||||
like($log_data->{warn}, qr/Adding it as a sibling instead/, 'addChild logged a warning about deep assets');
|
||||
});
|
||||
|
||||
{
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
|
|
|
|||
|
|
@ -166,17 +166,17 @@ my $brokenTemplate = $importNode->addChild({
|
|||
template => q|<tmpl_if unclosedIf>If clause with no ending tag|,
|
||||
});
|
||||
|
||||
WebGUI::Test->interceptLogging;
|
||||
my $brokenOutput = $brokenTemplate->process({});
|
||||
my $logError = $WebGUI::Test::logger_error;
|
||||
my $brokenUrl = $brokenTemplate->getUrl;
|
||||
my $brokenId = $brokenTemplate->getId;
|
||||
like($brokenOutput, qr/^There is a syntax error in this template/, 'process: returned error output contains boilerplate');
|
||||
like($brokenOutput, qr/$brokenUrl/, '... and the template url');
|
||||
like($brokenOutput, qr/$brokenId/, '... and the template id');
|
||||
like($logError, qr/$brokenUrl/, 'process: logged error has the url');
|
||||
like($logError, qr/$brokenId/, '... and the template id');
|
||||
WebGUI::Test->restoreLogging;
|
||||
WebGUI::Test->interceptLogging( sub {
|
||||
my $log_data = shift;
|
||||
my $brokenOutput = $brokenTemplate->process({});
|
||||
my $brokenUrl = $brokenTemplate->getUrl;
|
||||
my $brokenId = $brokenTemplate->getId;
|
||||
like($brokenOutput, qr/^There is a syntax error in this template/, 'process: returned error output contains boilerplate');
|
||||
like($brokenOutput, qr/$brokenUrl/, '... and the template url');
|
||||
like($brokenOutput, qr/$brokenId/, '... and the template id');
|
||||
like($log_data->{error}, qr/$brokenUrl/, 'process: logged error has the url');
|
||||
like($log_data->{error}, qr/$brokenId/, '... and the template id');
|
||||
});
|
||||
|
||||
WebGUI::Test->addToCleanup(WebGUI::VersionTag->getWorking($session));
|
||||
|
||||
|
|
|
|||
|
|
@ -54,17 +54,19 @@ plan tests => 4; # Increment this number for each test you create
|
|||
#----------------------------------------------------------------------------
|
||||
# _createForm
|
||||
|
||||
WebGUI::Test->interceptLogging;
|
||||
WebGUI::Test->interceptLogging( sub {
|
||||
my $log_data = shift;
|
||||
|
||||
$df->_createForm(
|
||||
{
|
||||
name => 'test field',
|
||||
type => 'MASSIVE FORM FAILURE',
|
||||
},
|
||||
'some value'
|
||||
);
|
||||
$df->_createForm(
|
||||
{
|
||||
name => 'test field',
|
||||
type => 'MASSIVE FORM FAILURE',
|
||||
},
|
||||
'some value'
|
||||
);
|
||||
|
||||
is($WebGUI::Test::logger_error, "Unable to load form control - MASSIVE FORM FAILURE", '_createForm logs when it cannot load a form type');
|
||||
is($log_data->{error}, "Unable to load form control - MASSIVE FORM FAILURE", '_createForm logs when it cannot load a form type');
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# getContentLastModified
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue