CGI-PathInfo
view release on metacpan or search on metacpan
t/01_cgi-pathinfo.t view on Meta::CPAN
}
}
print "END\n";
exit;
########################################
# Instantation #
########################################
sub instantation {
$ENV{'PATH_INFO'} = '/test1a-value1/test1b-value2/fake.html';
my $path_info;
eval {
$path_info = CGI::PathInfo->new;
};
if ($@ or (not $path_info)) {
return 'failed standard instantation';
}
eval {
$path_info = CGI::PathInfo->new( 'stripleadingslash' => 1 );
};
if ($@ or (not $path_info)) {
return 'failed standard instantation with list parameters';
}
eval {
$path_info = CGI::PathInfo->new({ 'stripleadingslash' => 1 });
};
if ($@ or (not $path_info)) {
return 'failed standard instantation with anon hash parameters';
}
eval {
$path_info = CGI::PathInfo::new;
};
if ($@ or (not $path_info)) {
return 'failed class method instantation';
}
eval {
$path_info = new CGI::PathInfo;
};
if ($@ or (not $path_info)) {
return 'failed indirect instantation';
}
eval {
$path_info = CGI::PathInfo->new->new;
};
if ($@ or (not $path_info)) {
return 'failed instance constructor instatation'
}
eval {
local $ENV{'PATH_INFO'};
$path_info = CGI::PathInfo->new;
my @parms = $path_info->param;
if (@parms > 0) {
die ("mis-decoded undef PATH_INFO");
}
};
if ($@ or (not $path_info)) {
return "failed instance constructor instatation $@";
}
return '';
}
########################################
# Bad initialization parameters #
########################################
sub bad_initialization {
$ENV{'PATH_INFO'} = '/test1a-value1/test1b-value2/fake.html';
eval {
my $path_info = CGI::PathInfo->new([ stripleadingslash => 0,
striptrailingslash => 0,
]);
};
unless ($@) {
return 'failed to detect passing of bad parameters';
}
eval {
my $path_info = CGI::PathInfo->new( stripleadingslash => 1,
stlingslash => 1,
);
};
unless ($@) {
return 'failed to detect passing of invalid parameters';
}
eval {
my $path_info = CGI::PathInfo->new({ stripleadingslash => 1,
stlingslash => 1,
});
};
unless ($@) {
return 'failed to detect passing of invalid parameters';
}
eval {
my $path_info = CGI::PathInfo->new('a');
};
unless ($@) {
return 'failed to detect passing of odd number of parameters';
}
eval {
my $path_info = CGI::PathInfo->new( stripleadingslash => 1,
striptrailingslash => 1,
'a',
);
};
unless ($@) {
return 'failed to detect passing of odd number of parameters';
}
eval {
( run in 0.611 second using v1.01-cache-2.11-cpan-9581c071862 )