Bugzilla – Attachment 38956 Details for
Bug 14103
PDF::FromHTML headaches related to optional discharging
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 14103: Improved testing coverage
PASSED-QA-Bug-14103-Improved-testing-coverage.patch (text/plain), 3.83 KB, created by
Kyle M Hall (khall)
on 2015-05-07 16:03:00 UTC
(
hide
)
Description:
[PASSED QA] Bug 14103: Improved testing coverage
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-05-07 16:03:00 UTC
Size:
3.83 KB
patch
obsolete
>From 8c209dc9ea0af14e7dbd68ab9d0dd1f6b584ee98 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 6 May 2015 13:56:30 -0400 >Subject: [PATCH] [PASSED QA] 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> >--- > Koha/Borrower/Discharge.pm | 21 ++++++++++++++++----- > t/db_dependent/Borrower_Discharge.t | 17 +++++++++++++++++ > 2 files changed, 33 insertions(+), 5 deletions(-) > >diff --git a/Koha/Borrower/Discharge.pm b/Koha/Borrower/Discharge.pm >index 9ca1587..f39475b 100644 >--- a/Koha/Borrower/Discharge.pm >+++ b/Koha/Borrower/Discharge.pm >@@ -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; > } >diff --git a/t/db_dependent/Borrower_Discharge.t b/t/db_dependent/Borrower_Discharge.t >index 7d22b0b..cb5179f 100644 >--- a/t/db_dependent/Borrower_Discharge.t >+++ b/t/db_dependent/Borrower_Discharge.t >@@ -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 >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14103
:
38837
|
38881
|
38883
|
38899
|
38943
|
38955
| 38956