enable testing of $session->request->uploads through WebGUI::PseudoRequest. Now we need a good utility method for sending a list of files to a sub and having it return a list of filehandles to those files
This commit is contained in:
parent
175304e915
commit
4de53b2de9
2 changed files with 34 additions and 1 deletions
24
t/Storage.t
24
t/Storage.t
|
|
@ -16,10 +16,16 @@ our $todo;
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::PseudoRequest;
|
||||
|
||||
use File::Spec;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Test::MockObject;
|
||||
|
||||
my $mock = Test::MockObject->new();
|
||||
$mock->fake_module('Apache2::Request');
|
||||
$mock->fake_module('Apache2::Upload');
|
||||
|
||||
my $extensionTests = [
|
||||
{
|
||||
|
|
@ -49,7 +55,7 @@ my $extensionTests = [
|
|||
},
|
||||
];
|
||||
|
||||
plan tests => 74 + scalar @{ $extensionTests }; # increment this value for each test you create
|
||||
plan tests => 76 + scalar @{ $extensionTests }; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -373,6 +379,22 @@ like ($hexStorage->getPath, qr/$hexValue/, 'Storage path uses hexId');
|
|||
|
||||
$session->config->set('caseInsensitiveOS', 0);
|
||||
|
||||
####################################################
|
||||
#
|
||||
# addFileFromFormPost
|
||||
#
|
||||
####################################################
|
||||
|
||||
my $pseudoRequest = WebGUI::PseudoRequest->new();
|
||||
$session->{_request} = $pseudoRequest;
|
||||
|
||||
$session->http->setStatus(413);
|
||||
is($fileStore->addFileFromFormPost(), '', 'addFileFromFormPost returns empty string when HTTP status is 413');
|
||||
|
||||
$session->http->setStatus(200);
|
||||
$pseudoRequest->upload('files', []);
|
||||
is($fileStore->addFileFromFormPost('files'), undef, 'addFileFromFormPost returns empty string when asking for a form variable with no files attached');
|
||||
|
||||
END {
|
||||
foreach my $stor (
|
||||
$storage1, $storage2, $storage3, $copiedStorage,
|
||||
|
|
|
|||
|
|
@ -145,6 +145,17 @@ sub status_line {
|
|||
return $self->{status_line};
|
||||
}
|
||||
|
||||
sub upload {
|
||||
my $self = shift;
|
||||
my $formName = shift;
|
||||
my $uploadFileHandles = shift;
|
||||
return unless $formName;
|
||||
if (defined $uploadFileHandles) {
|
||||
$self->{uploads}->{$formName} = $uploadFileHandles;
|
||||
}
|
||||
return @{ $self->{uploads}->{$formName} };
|
||||
}
|
||||
|
||||
sub uri {
|
||||
my $self = shift;
|
||||
my $value = shift;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue