Bug 14103: Improved testing coverage
As per Chris' comment #17, this improves the testing coverage. Same test plan as comment #16, but add: TEST PLAN SUPPLEMENT -------------------- 1) $ prove -v t/db_dependent/Borrower_Discharge.t -- notice only 5 tests, and generate_as_pdf not tested. 2) Apply this patch. 3) Retest as per comment #16 -- this will test the error and no error cases tweaked in Koha/Borrower/Discharge.pm 4) remove PDF::HTML $ sudo apt-get purge libpdf-fromhtml-perl 5) $ prove -v t/db_dependent/Borrower_Discharge.t -- 7 tests, all successful 6) add PDF::HTML $ sudo dpkg -i /path/to/libpdf-fromhtml-perl... -- depends on how you get it. vary accordingly. 7) $ prove -v t/db_dependent/Borrower_Discharge.t -- 7 tests, all successful -- Note that is was a different 7th test. :) 8) koha qa test tools Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
0b24910100
commit
c8d364ae72
|
|
@ -3,7 +3,9 @@ package Koha::Borrower::Discharge;
|
|||
use Modern::Perl;
|
||||
use CGI;
|
||||
use File::Temp qw( :POSIX );
|
||||
use Carp;
|
||||
|
||||
use C4::Templates qw ( gettemplate );
|
||||
use C4::Members qw( GetPendingIssues );
|
||||
use C4::Reserves qw( GetReservesFromBorrowernumber CancelReserve );
|
||||
|
||||
|
|
@ -113,11 +115,20 @@ sub generate_as_pdf {
|
|||
open my $html_fh, '>:encoding(utf8)', $html_path;
|
||||
say $html_fh $html_content;
|
||||
close $html_fh;
|
||||
require PDF::FromHTML;
|
||||
my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
|
||||
$pdf->load_file( $html_path );
|
||||
$pdf->convert;
|
||||
$pdf->write_file( $pdf_path );
|
||||
my $output = eval { require PDF::FromHTML; return; } || $@;
|
||||
if ($output && $params->{testing}) {
|
||||
carp $output;
|
||||
$pdf_path = undef;
|
||||
}
|
||||
elsif ($output) {
|
||||
die $output;
|
||||
}
|
||||
else {
|
||||
my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
|
||||
$pdf->load_file( $html_path );
|
||||
$pdf->convert;
|
||||
$pdf->write_file( $pdf_path );
|
||||
}
|
||||
|
||||
return $pdf_path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
use Test::More;
|
||||
use Test::Warn;
|
||||
use MARC::Record;
|
||||
|
||||
use C4::Biblio qw( AddBiblio );
|
||||
|
|
@ -46,6 +47,22 @@ AddReturn( $barcode );
|
|||
# Discharge possible without issue
|
||||
is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrowernumber }), 1, 'A patron without issues can be discharged' );
|
||||
|
||||
is(Koha::Borrower::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number");
|
||||
|
||||
# Check if PDF::FromHTML is installed.
|
||||
my $check = eval { require PDF::FromHTML; };
|
||||
|
||||
# Tests for if PDF::FromHTML is installed
|
||||
if ($check) {
|
||||
isnt( Koha::Borrower::Discharge::generate_as_pdf({ borrowernumber => $borrowernumber }), undef, "Temporary PDF generated." );
|
||||
}
|
||||
# Tests for if PDF::FromHTML is not installed
|
||||
else {
|
||||
warning_like { Koha::Borrower::Discharge::generate_as_pdf({ borrowernumber => $borrowernumber, testing => 1 }) }
|
||||
[ qr/Can't locate PDF\/FromHTML.pm in \@INC/ ],
|
||||
"Expected failure because of missing PDF::FromHTML.";
|
||||
}
|
||||
|
||||
# FIXME
|
||||
# At this point, there is a problem with the AutoCommit off
|
||||
# The transaction is bloked into DBIx::Class::Storage::DBI::_dbh_execute
|
||||
|
|
|
|||
Loading…
Reference in New Issue