fix admintoggle tests

This commit is contained in:
Doug Bell 2010-07-15 12:52:13 -05:00
parent 85e218f62f
commit d34377e45d
2 changed files with 7 additions and 48 deletions

View file

@ -35,7 +35,6 @@ my @testSets = (
userId => 1,
adminStatus => 'off',
onText => q!!,
offText => q!!,
template => q!!,
output => '',
},
@ -44,19 +43,8 @@ my @testSets = (
userId => 3,
adminStatus => 'off',
onText => '',
offText => '',
template => q!!,
url => $session->url->append($homeAsset->getUrl(),'op=switchOnAdmin'),
output => \&simpleHTMLParser,
},
{
comment => 'Admin sees offText, default call',
userId => 3,
adminStatus => 'on',
onText => '',
offText => '',
template => q!!,
url => $session->url->append($homeAsset->getUrl(),'op=switchOffAdmin'),
url => $session->url->append($homeAsset->getUrl(),'op=admin'),
output => \&simpleHTMLParser,
},
{
@ -64,19 +52,8 @@ my @testSets = (
userId => 3,
adminStatus => 'off',
onText => 'Admin powers... Activate!',
offText => 'Chillin, dude',
template => q!!,
url => $session->url->append($homeAsset->getUrl(),'op=switchOnAdmin'),
output => \&simpleHTMLParser,
},
{
comment => 'Admin sees offText, custom text',
userId => 3,
adminStatus => 'on',
onText => 'Admin powers... Activate!',
offText => 'Chillin, dude',
template => q!!,
url => $session->url->append($homeAsset->getUrl(),'op=switchOffAdmin'),
url => $session->url->append($homeAsset->getUrl(),'op=admin'),
output => \&simpleHTMLParser,
},
{
@ -84,19 +61,8 @@ my @testSets = (
userId => 3,
adminStatus => 'off',
onText => 'Admin powers... Activate!',
offText => 'Chillin, dude',
template => $template->get('url'),
url => $session->url->append($homeAsset->getUrl(),'op=switchOnAdmin'),
output => \&simpleTextParser,
},
{
comment => 'Admin sees offText, custom text and template',
userId => 3,
adminStatus => 'on',
onText => 'Admin powers... Activate!',
offText => 'Chillin, dude',
template => $template->get('url'),
url => $session->url->append($homeAsset->getUrl(),'op=switchOffAdmin'),
url => $session->url->append($homeAsset->getUrl(),'op=admin'),
output => \&simpleTextParser,
},
);
@ -110,16 +76,9 @@ plan tests => $numTests + 1; ##conditional module load and TODO at end
foreach my $testSet (@testSets) {
$session->user({userId=>$testSet->{userId}});
if ($testSet->{adminStatus} eq 'off') {
$session->var->switchAdminOff();
$testSet->{label} = $testSet->{onText} || $i18n->get(516);
}
else {
$session->var->switchAdminOn();
$testSet->{label} = $testSet->{offText} || $i18n->get(517);
}
$testSet->{label} = $testSet->{onText} || $i18n->get(516);
my $output = WebGUI::Macro::AdminToggle::process( $session,
$testSet->{onText}, $testSet->{offText}, $testSet->{template} );
$testSet->{onText}, $testSet->{template} );
if (ref $testSet->{output} eq 'CODE') {
my ($url, $label) = $testSet->{output}->($output);
is($label, $testSet->{label}, $testSet->{comment}.", label");

View file

@ -28,7 +28,7 @@ my @getRefererUrlTests = (
comment => 'getRefererUrl returns the url minus the gateway',
},
{
input => 'http://www.domain.com/myUrl.html?op=switchAdminOn',
input => 'http://www.domain.com/myUrl.html?op=admin',
output => 'myUrl.html',
comment => 'getRefererUrl returns the url minus the gateway',
},
@ -50,7 +50,7 @@ my @getRefererUrlTests = (
);
use Test::More;
plan tests => 82 + scalar(@getRefererUrlTests);
plan tests => 83 + scalar(@getRefererUrlTests);
my $session = WebGUI::Test->session;
my $request = $session->request;