Bug 6874: Catch warnings for clean tests.
I hate noisy tests, so I cleaned them up. MEGA TEST PLAN -------------- git checkout -b bug_6874 origin/master git bz apply 6874 -- yes, it should all apply smoothly. I intentionally restored an old backup from a couple months ago to force the upgrade. staff client: -- upgrade -- login Koha administration MARC Bibliographic framework MARC structure (for BKS) Search for 856 Subfields Edit (for u) Other options Plugin: upload.pl Save changes Search the catalog tab {choose a word, any word. I used fancy, because I knew we had a cookbook} click first link Edit Edit record 8 (that's the tab name) click the name for 856 scroll down to u and click the plugin icon -- Correctly got a configuration error message. At a command prompt: vi ~/koha-dev/etc/koha-conf.xml /enable_plug -- add in: <upload_path>{appropriate path. I used /home/mtompset/uploads}</upload_path> :wq mkdir {appropriate path used} -- I even added some subdirectories sudo chown -R -v www-data.www-data {appropriate path used} Back in staff client: click the plugin icon again -- this time an upload screen pops up click the 'Upload file' button -- message about no file or destination browse for a file, select one click the 'Upload file' button -- message about no destination click the 'Cancel' button click the plugin icon click a destination radio button click the 'Upload file' button -- message about no file browse for a file, select one click the 'Upload file' button -- message about success click the 'close' button. -- the text box has been filled in with a nice URL click the plugin icon click cancel click the plugin icon click delete -- the test box should be blanked, and a success message given click Close -- reupload a file properly click the plugin icon click delete click upload file browse for a file, select a destination, click upload file click close on success message click 'Clone this subfield' click the second plugin icon click delete click close click the first plugin icon -- Nice error message about a URL which points to nothing. click cancel In the second 856$u type in a URL (eg. www.google.com) click the second plugin icon -- 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. click save (we need to save the bibliographic record) In OPAC: search for the same word (I used fancy) find the entry you just updated with links click the two links. The dangling entry should give you a 500 error, and the other link should work just fine. get back to the detail page In staff client: edit edit record 8 change the 856$u to a valid file in the first link. save In OPAC: refresh the detail page, and click the first link again this time it should get downloaded nicely. From a command line: prove -v t/db_dependent/UploadedFiles.t perldoc C4::Biblio perldoc C4::UploadedFiles One more round of tests tomorrow, and this should be ready. :) Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Tested on top of 5010 Followed mostly mega test plan, seems to work :) Can upload, delete, modify, etc Test runs Ok No koha-qa errors I view this as valuable addition, dangling since 2011! As with 5010, I consider this can be pushed (for 3.22) and we can fix anything wrong later. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
This commit is contained in:
parent
b36f4674a0
commit
b113318bb2
1 changed files with 9 additions and 4 deletions
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue