Bugzilla – Attachment 81406 Details for
Bug 18720
Get rid of "die" in favor of exceptions in C4::Acquisition::GetBasketAsCsv
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18720: Use exception instead of die in GetBasketAsCsv
Bug-18720-Use-exception-instead-of-die-in-GetBaske.patch (text/plain), 2.61 KB, created by
Katrin Fischer
on 2018-10-28 12:44:42 UTC
(
hide
)
Description:
Bug 18720: Use exception instead of die in GetBasketAsCsv
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-10-28 12:44:42 UTC
Size:
2.61 KB
patch
obsolete
>From e6678030bd5e0c76aebdfcc68d699ba433d329bc Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Mon, 5 Jun 2017 11:55:12 +0200 >Subject: [PATCH] Bug 18720: Use exception instead of die in GetBasketAsCsv > >Test plan: >prove t/db_dependent/Acquisition/GetBasketAsCSV.t > >Signed-off-by: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/Acquisition.pm | 3 ++- > t/db_dependent/Acquisition/GetBasketAsCSV.t | 14 +++++++++++--- > 2 files changed, 13 insertions(+), 4 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index d635a49e79..8039afac61 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -31,6 +31,7 @@ use Koha::DateUtils qw( dt_from_string output_pref ); > use Koha::Acquisition::Booksellers; > use Koha::Acquisition::Orders; > use Koha::Biblios; >+use Koha::Exceptions; > use Koha::Items; > use Koha::Number::Price; > use Koha::Libraries; >@@ -293,7 +294,7 @@ sub GetBasketAsCSV { > my @rows; > if ($csv_profile_id) { > my $csv_profile = Koha::CsvProfiles->find( $csv_profile_id ); >- die "There is no valid csv profile given" unless $csv_profile; >+ Koha::Exceptions::ObjectNotFound->throw( 'There is no valid csv profile given') unless $csv_profile; > > my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$csv_profile->csv_separator,'binary'=>1}); > my $csv_profile_content = $csv_profile->content; >diff --git a/t/db_dependent/Acquisition/GetBasketAsCSV.t b/t/db_dependent/Acquisition/GetBasketAsCSV.t >index 0f61dc2199..4dd5e6a2e3 100644 >--- a/t/db_dependent/Acquisition/GetBasketAsCSV.t >+++ b/t/db_dependent/Acquisition/GetBasketAsCSV.t >@@ -4,15 +4,16 @@ use Modern::Perl; > > use CGI; > >-use Test::More tests => 3; >+use Test::More tests => 4; > > use C4::Acquisition; > use C4::Biblio; > use Koha::Database; >-use Koha::CsvProfile; >- >+use Koha::CsvProfiles; > use Koha::Acquisition::Orders; >+ > use t::lib::Mocks; >+use Try::Tiny; > > my $schema = Koha::Database->new()->schema(); > $schema->storage->txn_begin(); >@@ -84,4 +85,11 @@ is($basket_csv3, 'biblio.author,title,quantity > "King, Stephen","Test Record",3 > ', 'CSV should be generated with user profile which does not have all headers defined'); > >+try { >+ my $basket_csv4 = C4::Acquisition::GetBasketAsCSV($basketno, $query, 'non_existant_profile_id'); >+ fail("It is not possible to export basket using non-existant profile"); >+} catch { >+ ok($_->isa("Koha::Exceptions::ObjectNotFound"), "Using non-existant profile should throw ObjectNotFound exception"); >+}; >+ > $schema->storage->txn_rollback(); >-- >2.11.0
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 18720
:
76373
|
81296
| 81406