Remove crufty code from HTMLForm that was never used.

More tests for Session/Icon.pm.  Due to the way the code is written,
this test will not test 100% of the code.  Untestable conditions include
not being able to find the toolbar directory in getToolbarOptions, and
all code that sets a default pageUrl in any icon-specific method.
This commit is contained in:
Colin Kuskie 2006-10-21 02:12:34 +00:00
parent f3ab99bc02
commit e434fb700c
2 changed files with 70 additions and 13 deletions

View file

@ -244,13 +244,11 @@ The UI level for this field. See the WebGUI developer's site for details. Defaul
=cut
sub raw {
my ($output);
my ($self, @p) = @_;
my ($value, $uiLevel) = rearrange([qw(value uiLevel)], @p);
if ($self->_uiLevelChecksOut($uiLevel)) {
$self->{_data} .= $value;
}
$self->{_data} .= $output;
}

View file

@ -16,10 +16,11 @@ use WebGUI::Test;
use WebGUI::Session;
use Test::More;
use Test::Deep;
use Test::MockObject;
use HTML::TokeParser;
my $numTests = 2;
my $numTests = 10;
my @iconTests = fetchTestSet();
@ -80,12 +81,73 @@ foreach my $test (@iconTests) {
is($alt, $label, "$method: alt okay");
is($title, $label, "$method: title okay");
$icon = $session->icon->copy($test->{urlParam2}, '/lowes');
$icon = $session->icon->$method($test->{urlParam2}, '/lowes');
($url) = linkAndText($icon, 'a', 'href');
is($url, $session->url->gateway('/lowes', $test->{urlParam2}), "$method: manual url okay");
}
####################################################
#
# drag
#
####################################################
my $icon = $session->icon->drag();
my ($alt, $title, $extras) = linkAndText($icon, 'img', 'alt', 'title', 'extras');
is($alt, $i18n->get('Drag'), "drag: alt okay");
is($title, $i18n->get('Drag'), "drag: title okay");
is($extras, '-', "drag: no extras set");
$icon = $session->icon->drag(q!onclick="doSomething()"!);
($extras) = linkAndText($icon, 'img', 'onclick');
is($extras, q!doSomething()!, "drag: set extras");
####################################################
#
# delete with confirmText
#
####################################################
$icon = $session->icon->delete('','','What did I ever do to you?');
my ($onclick) = linkAndText($icon, 'a', 'onclick');
is($onclick, "return confirm('What did I ever do to you?')", "delete: confirm text");
####################################################
#
# moveUp with disabled
#
####################################################
$icon = $session->icon->moveUp('','',1);
my $parser = HTML::TokeParser->new(\$icon);
my $anchorTag = $parser->get_tag('a');
is($anchorTag, undef, "moveUp: no anchor tag when disabled is set");
####################################################
#
# moveDown with disabled
#
####################################################
$icon = $session->icon->moveDown('','',1);
$parser = HTML::TokeParser->new(\$icon);
$anchorTag = $parser->get_tag('a');
is($anchorTag, undef, "moveDown: no anchor tag when disabled is set");
####################################################
#
# getToolbarOptions
#
####################################################
my $toolbarOptions = $session->icon->getToolbarOptions();
my $expectedOptions = {
useLanguageDefault => $i18n->get('1084', 'WebGUI'),
bullet => 'bullet',
};
cmp_deeply($expectedOptions, $toolbarOptions, 'getToolbarOptions');
sub linkAndText {
my ($text, $tag, @params) = @_;
@ -98,15 +160,6 @@ sub linkAndText {
return @parsedParams;
}
####################################################
#
# Pick up tests
# drag
# disabled for moveUp and moveDown
# confirmText for delete
#
####################################################
my $icon = $session->icon->drag();
END: {
@ -163,6 +216,12 @@ sub fetchTestSet {
urlParam => 'func=moveBottom',
urlParam2 => 'op=moveBottom',
},
{
method => 'moveDown',
label => 'Move Down',
urlParam => 'func=moveDown',
urlParam2 => 'op=moveDown',
},
{
method => 'moveLeft',
label => 'Move Left',