Update some POD in Stow and PageTitle.

Fix several tests with bad coverage.
This commit is contained in:
Colin Kuskie 2006-09-14 15:54:54 +00:00
parent 5ab043ceb8
commit 66d98f371c
10 changed files with 78 additions and 11 deletions

View file

@ -24,7 +24,7 @@ Macro for returning the title of the current Asset.
Returns the title of the current Asset. If a WebGUI operation or function
is active, then the title is returned as a link to the Asset. If there is
no asset cached in the session variable, nothing is returned.
no asset cached in the session variable, undef is returned.
=cut

View file

@ -95,7 +95,9 @@ sub DESTROY {
=head2 get( varName )
Retrieves the current value of a stow variable.
Retrieves the current value of a stow variable. Note that if you use references, you're
getting back a reference and modifying the contents of the reference will change the
contents of the stow variable.
=head3 varName
@ -155,7 +157,7 @@ The name of the stow variable.
=head3 value
The value of the stow variable. Any scalar or reference.
The value of the stow variable. Any scalar or reference.
=cut

View file

@ -21,7 +21,6 @@ my $session = WebGUI::Test->session;
use Test::More; # increment this value for each test you create
my $homeAsset = WebGUI::Asset->getDefault($session);
$session->asset($homeAsset);
my ($versionTag, $asset, $group, @users) = setupTest($session, $homeAsset);
my @testSets = (
@ -62,7 +61,7 @@ my @testSets = (
},
);
my $numTests = scalar @testSets + 1;
my $numTests = scalar @testSets + 2;
plan tests => $numTests;
@ -73,6 +72,12 @@ SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
is(
WebGUI::Macro::CanEditText::process($session,''),
'',
q!Call with no default session asset returns ''!,
);
foreach my $testSet (@testSets) {
$session->user({userId=>$testSet->{userId}});
$session->asset($testSet->{asset});

View file

@ -22,7 +22,6 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
my $homeAsset = WebGUI::Asset->getDefault($session);
$session->asset($homeAsset);
my ($versionTag, $asset, @users) = setupTest($session, $homeAsset);
my $i18n = WebGUI::International->new($session,'Macro_EditableToggle');
@ -185,7 +184,7 @@ foreach my $testSet (@testSets) {
$numTests += 1 + (ref $testSet->{output} eq 'CODE');
}
$numTests += 1;
$numTests += 1 + 1; ##Empty session Asset plus use_ok
plan tests => $numTests;
@ -196,6 +195,12 @@ SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
is(
WebGUI::Macro::EditableToggle::process($session,'on','off',''),
'',
q!Call with no default session asset returns ''!,
);
foreach my $testSet (@testSets) {
$session->user({userId=>$testSet->{userId}});
$session->asset($testSet->{asset});

View file

@ -35,7 +35,7 @@ my @testSets = (
comment => 'linkonly argument',
},
{
label => $i18n->get(47),
label => q!!,
template => q!!,
url => $homeAsset->getUrl(),
output => \&simpleHTMLParser,
@ -75,6 +75,7 @@ skip "Unable to load $macro", $numTests-1 unless $loaded;
foreach my $testSet (@testSets) {
my $output = WebGUI::Macro::H_homeLink::process($session, $testSet->{label}, $testSet->{template});
$testSet->{label} ||= $i18n->get(47);
if (ref $testSet->{output} eq 'CODE') {
my ($url, $label) = $testSet->{output}->($output);
is($label, $testSet->{label}, $testSet->{comment}.", label");

View file

@ -47,6 +47,7 @@ foreach my $testSet (@testSets) {
}
$numTests += 1; #For the use_ok
$numTests += 1; #For macro call with undefined session asset
plan tests => $numTests;
@ -62,6 +63,12 @@ SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
is(
WebGUI::Macro::Page::process($session,'url'),
'',
q!Call with no default session asset returns ''!,
);
foreach my $testSet (@testSets) {
$session->asset($testSet->{asset});
my $class = $testSet->{className};

View file

@ -20,7 +20,7 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
my $numTests = 2;
my $numTests = 3;
$numTests += 1; #For the use_ok
plan tests => $numTests;
@ -49,6 +49,12 @@ SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
is(
WebGUI::Macro::PageTitle::process($session),
undef,
q!Call with no default session asset returns undef!,
);
##Make the homeAsset the default asset in the session.
$session->asset($homeAsset);
@ -61,6 +67,23 @@ is($macroOutput, $snippet->get('title'), "testing title returned from localy cre
}
my $origSessionRequest = $session->{_request};
my ($operation, $function) = (0,0);
my $request = Test::MockObject->new;
$request->mock('body',
sub {
my ($self, $value) = @_;
return 1 if $operation;
return 1 if $function;
return 0;
}
);
$output = WebGUI::Macro::PageTitle::process($session);
is($output, $homeAsset->get('title'), 'fetching title for site default asset');
END {
$versionTag->rollback;
}

View file

@ -43,12 +43,24 @@ my @testSets = (
width => '',
height => 7,
},
{
comment => 'width only, undef',
width => 9,
height => undef,
},
{
comment => 'height only, undef',
width => undef,
height => 17,
},
);
plan tests => 5 + 2 * scalar @testSets;
foreach my $testSet (@testSets) {
my $output = WebGUI::Macro::Spacer::process($session, $testSet->{width}, $testSet->{height});
$testSet->{width} = '' unless defined $testSet->{width};
$testSet->{height} = '' unless defined $testSet->{height};
my ($width, $height) = simpleHTMLParser($output);
is($width, $testSet->{width}, $testSet->{comment}.", width");
is($height, $testSet->{height}, $testSet->{comment}.", height");

View file

@ -22,10 +22,16 @@ use Image::Magick;
use Test::More; # increment this value for each test you create
use Test::Deep;
plan tests => 7;
plan tests => 8;
my $session = WebGUI::Test->session;
is(
WebGUI::Macro::Thumbnail::process($session, '/url-that-does-not-resolve'),
undef,
'non-existant URL returns undef'
);
my $square = WebGUI::Image->new($session, 100, 100);
$square->setBackgroundColor('#0000FF');

View file

@ -15,7 +15,7 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 26; # increment this value for each test you create
use Test::More tests => 29; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -59,3 +59,9 @@ my $milList = $stow->get("military");
push @{ $milList }, qw/foxtrot echo/;
is_deeply($stow->get("military"), [ @orig_list, qw/foxtrot echo/ ], "modifying fetched list changes stow'ed list because it is a reference");
is($stow->delete(), undef, 'deleting with no key returns undef');
is($stow->delete('noSuchKey'), undef, 'deleting non-existant variable returns undef');
$stow->set('countedKey', 5);
is($stow->delete('countedKey'), 5, 'delete method returns what was deleted');