Bugzilla – Attachment 114793 Details for
Bug 27333
Wrong exception thrown in Koha::Club::Hold::add
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27333: Regression tests
Bug-27333-Regression-tests.patch (text/plain), 4.29 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-01-04 14:17:44 UTC
(
hide
)
Description:
Bug 27333: Regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-01-04 14:17:44 UTC
Size:
4.29 KB
patch
obsolete
>From 70de51a7a5d214176ad48d9c239f1f08a5918067 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 4 Jan 2021 11:09:54 -0300 >Subject: [PATCH] Bug 27333: Regression tests > >Test for the right exceptions >--- > t/db_dependent/Koha/Club/Hold.t | 95 +++++++++++++++++++++++++-------- > 1 file changed, 73 insertions(+), 22 deletions(-) > >diff --git a/t/db_dependent/Koha/Club/Hold.t b/t/db_dependent/Koha/Club/Hold.t >index 8bc7f5811d..9c88f1049e 100755 >--- a/t/db_dependent/Koha/Club/Hold.t >+++ b/t/db_dependent/Koha/Club/Hold.t >@@ -36,7 +36,8 @@ my $builder = t::lib::TestBuilder->new; > my $schema = Koha::Database->new->schema; > > subtest 'add' => sub { >- plan tests => 5; >+ >+ plan tests => 9; > > $schema->storage->txn_begin; > >@@ -45,32 +46,82 @@ subtest 'add' => sub { > my $item1 = $builder->build_sample_item({ library => $library->branchcode }); > my $item2 = $builder->build_sample_item({ library => $library->branchcode }); > >- try { >- Koha::Club::Hold::add({ club_id => $club->id, biblio_id => $item1->biblionumber, pickup_library_id => $library->branchcode }); >- } catch { >- my $class = ref $_; >- ok($class eq 'Koha::Exceptions::ClubHold::NoPatrons', 'Exception thrown when no patron is enrolled in club'); >- }; >- >- my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->branchcode } }); >- my $e = $builder->build_object({ class => 'Koha::Club::Enrollments' , value => { club_id => $club->id, borrowernumber => $patron->borrowernumber, date_canceled => undef }} ); >- >- my $club_hold = Koha::Club::Hold::add({ >- club_id => $club->id, >- biblio_id => $item1->biblionumber, >- pickup_library_id => $library->branchcode >- }); >+ throws_ok { >+ Koha::Club::Hold::add( >+ { >+ club_id => $club->id >+ } >+ ); >+ } >+ 'Koha::Exceptions::MissingParameter', >+ 'Exception thrown when biblio_id is passed'; >+ >+ is( "$@", 'The biblio_id parameter is mandatory' ); >+ >+ throws_ok { >+ Koha::Club::Hold::add( >+ { >+ biblio_id => $item1->biblionumber >+ } >+ ); >+ } >+ 'Koha::Exceptions::MissingParameter', >+ 'Exception thrown when club_id is passed'; >+ >+ is( "$@", 'The club_id parameter is mandatory' ); >+ >+ throws_ok { >+ Koha::Club::Hold::add( >+ { >+ club_id => $club->id, >+ biblio_id => $item1->biblionumber, >+ pickup_library_id => $library->branchcode >+ } >+ ); >+ } >+ 'Koha::Exceptions::ClubHold::NoPatrons', >+ 'Exception thrown when no patron is enrolled in club'; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->branchcode } >+ } >+ ); >+ my $e = $builder->build_object( >+ { >+ class => 'Koha::Club::Enrollments', >+ value => { >+ club_id => $club->id, >+ borrowernumber => $patron->borrowernumber, >+ date_canceled => undef >+ } >+ } >+ ); >+ >+ my $club_hold = Koha::Club::Hold::add( >+ { >+ club_id => $club->id, >+ biblio_id => $item1->biblionumber, >+ pickup_library_id => $library->branchcode >+ } >+ ); > > is(blessed($club_hold), 'Koha::Club::Hold', 'add returns a Koha::Club::Hold'); > > $e->date_canceled(dt_from_string)->store; > >- try { >- Koha::Club::Hold::add({ club_id => $club->id, biblio_id => $item2->biblionumber, pickup_library_id => $library->branchcode }); >- } catch { >- my $class = ref $_; >- ok($class eq 'Koha::Exceptions::ClubHold::NoPatrons', 'Exception thrown when no patron is enrolled in club'); >- }; >+ throws_ok { >+ Koha::Club::Hold::add( >+ { >+ club_id => $club->id, >+ biblio_id => $item2->biblionumber, >+ pickup_library_id => $library->branchcode >+ } >+ ); >+ } >+ 'Koha::Exceptions::ClubHold::NoPatrons', >+ 'Exception thrown when no patron is enrolled in club'; > > my $patron_holds = Koha::Club::Hold::PatronHolds->search({ club_hold_id => $club_hold->id }); > >-- >2.30.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 27333
:
114793
|
114794
|
115827
|
115828