fix admintoggle tests
This commit is contained in:
parent
85e218f62f
commit
d34377e45d
2 changed files with 7 additions and 48 deletions
|
|
@ -35,7 +35,6 @@ my @testSets = (
|
||||||
userId => 1,
|
userId => 1,
|
||||||
adminStatus => 'off',
|
adminStatus => 'off',
|
||||||
onText => q!!,
|
onText => q!!,
|
||||||
offText => q!!,
|
|
||||||
template => q!!,
|
template => q!!,
|
||||||
output => '',
|
output => '',
|
||||||
},
|
},
|
||||||
|
|
@ -44,19 +43,8 @@ my @testSets = (
|
||||||
userId => 3,
|
userId => 3,
|
||||||
adminStatus => 'off',
|
adminStatus => 'off',
|
||||||
onText => '',
|
onText => '',
|
||||||
offText => '',
|
|
||||||
template => q!!,
|
template => q!!,
|
||||||
url => $session->url->append($homeAsset->getUrl(),'op=switchOnAdmin'),
|
url => $session->url->append($homeAsset->getUrl(),'op=admin'),
|
||||||
output => \&simpleHTMLParser,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
comment => 'Admin sees offText, default call',
|
|
||||||
userId => 3,
|
|
||||||
adminStatus => 'on',
|
|
||||||
onText => '',
|
|
||||||
offText => '',
|
|
||||||
template => q!!,
|
|
||||||
url => $session->url->append($homeAsset->getUrl(),'op=switchOffAdmin'),
|
|
||||||
output => \&simpleHTMLParser,
|
output => \&simpleHTMLParser,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -64,19 +52,8 @@ my @testSets = (
|
||||||
userId => 3,
|
userId => 3,
|
||||||
adminStatus => 'off',
|
adminStatus => 'off',
|
||||||
onText => 'Admin powers... Activate!',
|
onText => 'Admin powers... Activate!',
|
||||||
offText => 'Chillin, dude',
|
|
||||||
template => q!!,
|
template => q!!,
|
||||||
url => $session->url->append($homeAsset->getUrl(),'op=switchOnAdmin'),
|
url => $session->url->append($homeAsset->getUrl(),'op=admin'),
|
||||||
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'),
|
|
||||||
output => \&simpleHTMLParser,
|
output => \&simpleHTMLParser,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -84,19 +61,8 @@ my @testSets = (
|
||||||
userId => 3,
|
userId => 3,
|
||||||
adminStatus => 'off',
|
adminStatus => 'off',
|
||||||
onText => 'Admin powers... Activate!',
|
onText => 'Admin powers... Activate!',
|
||||||
offText => 'Chillin, dude',
|
|
||||||
template => $template->get('url'),
|
template => $template->get('url'),
|
||||||
url => $session->url->append($homeAsset->getUrl(),'op=switchOnAdmin'),
|
url => $session->url->append($homeAsset->getUrl(),'op=admin'),
|
||||||
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'),
|
|
||||||
output => \&simpleTextParser,
|
output => \&simpleTextParser,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -110,16 +76,9 @@ plan tests => $numTests + 1; ##conditional module load and TODO at end
|
||||||
|
|
||||||
foreach my $testSet (@testSets) {
|
foreach my $testSet (@testSets) {
|
||||||
$session->user({userId=>$testSet->{userId}});
|
$session->user({userId=>$testSet->{userId}});
|
||||||
if ($testSet->{adminStatus} eq 'off') {
|
$testSet->{label} = $testSet->{onText} || $i18n->get(516);
|
||||||
$session->var->switchAdminOff();
|
|
||||||
$testSet->{label} = $testSet->{onText} || $i18n->get(516);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$session->var->switchAdminOn();
|
|
||||||
$testSet->{label} = $testSet->{offText} || $i18n->get(517);
|
|
||||||
}
|
|
||||||
my $output = WebGUI::Macro::AdminToggle::process( $session,
|
my $output = WebGUI::Macro::AdminToggle::process( $session,
|
||||||
$testSet->{onText}, $testSet->{offText}, $testSet->{template} );
|
$testSet->{onText}, $testSet->{template} );
|
||||||
if (ref $testSet->{output} eq 'CODE') {
|
if (ref $testSet->{output} eq 'CODE') {
|
||||||
my ($url, $label) = $testSet->{output}->($output);
|
my ($url, $label) = $testSet->{output}->($output);
|
||||||
is($label, $testSet->{label}, $testSet->{comment}.", label");
|
is($label, $testSet->{label}, $testSet->{comment}.", label");
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ my @getRefererUrlTests = (
|
||||||
comment => 'getRefererUrl returns the url minus the gateway',
|
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',
|
output => 'myUrl.html',
|
||||||
comment => 'getRefererUrl returns the url minus the gateway',
|
comment => 'getRefererUrl returns the url minus the gateway',
|
||||||
},
|
},
|
||||||
|
|
@ -50,7 +50,7 @@ my @getRefererUrlTests = (
|
||||||
);
|
);
|
||||||
|
|
||||||
use Test::More;
|
use Test::More;
|
||||||
plan tests => 82 + scalar(@getRefererUrlTests);
|
plan tests => 83 + scalar(@getRefererUrlTests);
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
my $request = $session->request;
|
my $request = $session->request;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue