@@ -, +, @@ -------------- -- yes, it should all apply smoothly. -- upgrade -- login -- Correctly got a configuration error message. -- add in: -- I even added some subdirectories -- this time an upload screen pops up -- message about no file or destination -- message about no destination -- message about no file -- message about success -- the text box has been filled in with a nice URL -- the test box should be blanked, and a success message given -- reupload a file properly -- Nice error message about a URL which points to nothing. -- this jumps immediately to the upload screen, but does not give an error message, because the URL does not have opac-retrieve-file in it. --- t/db_dependent/UploadedFiles.t | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/t/db_dependent/UploadedFiles.t +++ a/t/db_dependent/UploadedFiles.t @@ -3,7 +3,8 @@ use Modern::Perl; use File::Temp qw/ tempdir /; use Test::CGI::Multipart; -use Test::More tests => 15; +use Test::More tests => 17; +use Test::Warn; use t::lib::Mocks; @@ -44,9 +45,13 @@ open my $fh,">",($file->{filepath}); print $fh ""; close $fh; -ok(C4::UploadedFiles::DelUploadedFile($id)==1, "DelUploadedFile($id) returned 1."); -ok(C4::UploadedFiles::DelUploadedFile($id)==-1, "DelUploadedFile($id) returned -1 as expected."); +my $DelResult; +is(C4::UploadedFiles::DelUploadedFile($id),1, "DelUploadedFile($id) returned 1 as expected."); +warning_like { $DelResult=C4::UploadedFiles::DelUploadedFile($id); } qr/file for id=/, "Expected warning for deleting Dangling Entry."; +is($DelResult,-1, "DelUploadedFile($id) returned -1 as expected."); ok(! -e $file->{filepath}, "File $file->{filepath} does not exist anymore"); -is(C4::UploadedFiles::UploadFile($testfilename, '../', $testfile_fh->handle), undef, 'UploadFile with $dir containing ".." return undef'); +my $UploadResult; +warning_like { $UploadResult=C4::UploadedFiles::UploadFile($testfilename,'../',$testfile_fh->handle); } qr/^Filename or dirname contains '..'. Aborting upload/, "Expected warning for bad file upload."; +is($UploadResult, undef, "UploadFile with dir containing \"..\" return undef"); is(C4::UploadedFiles::GetUploadedFile(), undef, 'GetUploadedFile without parameters returns undef'); --