Document return value for Storage::rename
Add simple new test for Text.t Add ClassName.t test Prevent Form/ClassName from passing classes with spaces in them and remove redundant test for digits in regexp. Add a new test to Storage.t for getLastError
This commit is contained in:
parent
09cf2c8ed7
commit
b018b8e61e
5 changed files with 141 additions and 3 deletions
|
|
@ -71,7 +71,7 @@ Returns a class name which has been taint checked.
|
|||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $value = $self->session->form->param($self->get("name"));
|
||||
$value =~ s/[^\w\d\s:]//g;
|
||||
$value =~ s/[^\w:]//g;
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -678,7 +678,8 @@ sub getUrl {
|
|||
|
||||
=head2 renameFile ( filename, newFilename )
|
||||
|
||||
Renames an file's filename.
|
||||
Renames an file's filename. Returns true if the rename succeeded and false
|
||||
if it didn't.
|
||||
|
||||
=head3 filename
|
||||
|
||||
|
|
|
|||
129
t/Form/ClassName.t
Normal file
129
t/Form/ClassName.t
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Form::ClassName;
|
||||
use WebGUI::Session;
|
||||
use HTML::Form;
|
||||
use WebGUI::Form_Checking;
|
||||
|
||||
#The goal of this test is to verify that ClassName form elements work
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
# put your tests here
|
||||
|
||||
my $testBlock = [
|
||||
{
|
||||
key => 'Class1',
|
||||
testValue => 'WebGUI-test::Asset',
|
||||
expected => 'WebGUItest::Asset',
|
||||
comment => 'invalid: dash',
|
||||
},
|
||||
{
|
||||
key => 'Class2',
|
||||
testValue => 'WebGUI/test::Asset',
|
||||
expected => 'WebGUItest::Asset',
|
||||
comment => 'invalid: slash',
|
||||
},
|
||||
{
|
||||
key => 'Class3',
|
||||
testValue => 'WebGUI::Test Class',
|
||||
expected => 'WebGUI::TestClass',
|
||||
comment => 'invalid: space',
|
||||
},
|
||||
{
|
||||
key => 'Class4',
|
||||
testValue => 'WebGUI::Class4',
|
||||
expected => 'EQUAL',
|
||||
comment => 'valid: digit',
|
||||
},
|
||||
{
|
||||
key => 'Class5',
|
||||
testValue => 'WebGUI::Image::XY_Graph',
|
||||
expected => 'EQUAL',
|
||||
comment => 'valid: underscore',
|
||||
},
|
||||
{
|
||||
key => 'Class6',
|
||||
testValue => 'WebGUI::Class',
|
||||
expected => 'EQUAL',
|
||||
comment => 'valid: simple module',
|
||||
},
|
||||
];
|
||||
|
||||
my $formClass = 'WebGUI::Form::ClassName';
|
||||
my $formType = 'ClassName';
|
||||
|
||||
my $numTests = 11 + scalar @{ $testBlock } + 1;
|
||||
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
my ($header, $footer) = (WebGUI::Form::formHeader($session), WebGUI::Form::formFooter($session));
|
||||
|
||||
my $html = join "\n",
|
||||
$header,
|
||||
$formClass->new($session, {
|
||||
name => 'TestClass',
|
||||
value => 'WebGUI::Asset::File',
|
||||
})->toHtml,
|
||||
$footer;
|
||||
|
||||
my @forms = HTML::Form->parse($html, 'http://www.webgui.org');
|
||||
|
||||
##Test Form Generation
|
||||
|
||||
is(scalar @forms, 1, '1 form was parsed');
|
||||
|
||||
my @inputs = $forms[0]->inputs;
|
||||
is(scalar @inputs, 1, 'The form has 1 input');
|
||||
|
||||
#Basic tests
|
||||
|
||||
my $input = $inputs[0];
|
||||
is($input->name, 'TestClass', 'Checking input name');
|
||||
is($input->type, 'text', 'Checking input type');
|
||||
is($input->value, 'WebGUI::Asset::File', 'Checking default value');
|
||||
is($input->{size}, 30, 'Default size');
|
||||
is($input->{maxlength}, 255, 'Default maxlength');
|
||||
|
||||
##Test Form Output parsing
|
||||
|
||||
my $html = join "\n",
|
||||
$header,
|
||||
$formClass->new($session, {
|
||||
name => 'StorageClass',
|
||||
value => 'WebGUI::Storage::Image',
|
||||
size => 15,
|
||||
maxlength => 20,
|
||||
})->toHtml,
|
||||
$footer;
|
||||
|
||||
@forms = HTML::Form->parse($html, 'http://www.webgui.org');
|
||||
@inputs = $forms[0]->inputs;
|
||||
my $input = $inputs[0];
|
||||
is($input->name, 'StorageClass', 'Checking input name');
|
||||
is($input->value, 'WebGUI::Storage::Image', 'Checking default value');
|
||||
is($input->{size}, 15, 'set size');
|
||||
is($input->{maxlength}, 20, 'set maxlength');
|
||||
|
||||
##Test Form Output parsing
|
||||
|
||||
diag $formType;
|
||||
WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
|
||||
|
||||
|
|
@ -40,6 +40,12 @@ my $testBlock = [
|
|||
expected => "some user valuewithwhitespace",
|
||||
comment => 'Embedded whitespace is stripped',
|
||||
},
|
||||
{
|
||||
key => 'Text3',
|
||||
testValue => 'conCatenatedText',
|
||||
expected => 'EQUAL',
|
||||
comment => 'single word',
|
||||
},
|
||||
];
|
||||
|
||||
my $formType = 'text';
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use WebGUI::Storage;
|
|||
|
||||
use Test::More;
|
||||
|
||||
plan tests => 6; # increment this value for each test you create
|
||||
plan tests => 7; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -38,6 +38,8 @@ is( ref $storage1, "WebGUI::Storage", "storage will accept non GUID arguments");
|
|||
|
||||
is( $storage1->getErrorCount, 0, "No errors during path creation");
|
||||
|
||||
is( $storage1->getLastError, undef, "No errors during path creation");
|
||||
|
||||
my $storageDir1 = join '/', $uploadDir, 'fo', 'ob', 'foobar';
|
||||
|
||||
ok( (-e $storageDir1 and -d $storageDir1), "Storage location created and is a directory");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue