Lines 5-10
use File::Temp qw/ tempdir /;
Link Here
|
5 |
use Test::CGI::Multipart; |
5 |
use Test::CGI::Multipart; |
6 |
use Test::More tests => 11; |
6 |
use Test::More tests => 11; |
7 |
|
7 |
|
|
|
8 |
use t::lib::Mocks::Context; |
9 |
|
8 |
use C4::Context; |
10 |
use C4::Context; |
9 |
use C4::UploadedFiles; |
11 |
use C4::UploadedFiles; |
10 |
|
12 |
|
Lines 17-26
$tcm->upload_file(
Link Here
|
17 |
); |
19 |
); |
18 |
my $cgi = $tcm->create_cgi; |
20 |
my $cgi = $tcm->create_cgi; |
19 |
|
21 |
|
20 |
# Save the value of uploadPath and set it to a temporary directory |
|
|
21 |
my $uploadPath = C4::Context->preference('uploadPath'); |
22 |
my $tempdir = tempdir(CLEANUP => 1); |
22 |
my $tempdir = tempdir(CLEANUP => 1); |
23 |
C4::Context->set_preference('uploadPath', $tempdir); |
23 |
t::lib::Mocks::Context::mock_config('uploadPath', $tempdir); |
24 |
|
24 |
|
25 |
my $testfilename = $cgi->param('testfile'); |
25 |
my $testfilename = $cgi->param('testfile'); |
26 |
my $testfile_fh = $cgi->upload('testfile'); |
26 |
my $testfile_fh = $cgi->upload('testfile'); |
Lines 38-44
ok(-e $file->{filepath}, "File $file->{filepath} exists");
Link Here
|
38 |
ok(C4::UploadedFiles::DelUploadedFile($id), "DelUploadedFile($id) returned true"); |
38 |
ok(C4::UploadedFiles::DelUploadedFile($id), "DelUploadedFile($id) returned true"); |
39 |
ok(! -e $file->{filepath}, "File $file->{filepath} does not exist anymore"); |
39 |
ok(! -e $file->{filepath}, "File $file->{filepath} does not exist anymore"); |
40 |
|
40 |
|
41 |
C4::Context->set_preference('uploadPath', $uploadPath); |
|
|
42 |
|
43 |
is(C4::UploadedFiles::UploadFile($testfilename, '../', $testfile_fh->handle), undef, 'UploadFile with $dir containing ".." return undef'); |
41 |
is(C4::UploadedFiles::UploadFile($testfilename, '../', $testfile_fh->handle), undef, 'UploadFile with $dir containing ".." return undef'); |
44 |
is(C4::UploadedFiles::GetUploadedFile(), undef, 'GetUploadedFile without parameters returns undef'); |
42 |
is(C4::UploadedFiles::GetUploadedFile(), undef, 'GetUploadedFile without parameters returns undef'); |