Bugzilla – Attachment 108753 Details for
Bug 25534
Add ability to specifying and store a reason when cancelling a hold
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25534: (QA follow-up) Unit tests
Bug-25534-QA-follow-up-Unit-tests.patch (text/plain), 6.41 KB, created by
Kyle M Hall (khall)
on 2020-08-20 17:10:38 UTC
(
hide
)
Description:
Bug 25534: (QA follow-up) Unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-08-20 17:10:38 UTC
Size:
6.41 KB
patch
obsolete
>From 32b3a66e630b9c4b67fb8ee82fed3b199e1dc906 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 20 Aug 2020 12:26:14 -0400 >Subject: [PATCH] Bug 25534: (QA follow-up) Unit tests > >--- > t/db_dependent/Koha/Holds.t | 138 +++++++++++++++++++++++++++++++++++- > 1 file changed, 136 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t >index 055dd18d11..007c073e61 100644 >--- a/t/db_dependent/Koha/Holds.t >+++ b/t/db_dependent/Koha/Holds.t >@@ -19,12 +19,13 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 4; > use Test::Warn; > > use C4::Reserves; >-use Koha::Holds; >+use Koha::AuthorisedValueCategory; > use Koha::Database; >+use Koha::Holds; > > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -252,6 +253,139 @@ subtest 'cancel' => sub { > > }; > >+subtest 'cancel with reason' => sub { >+ plan tests => 7; >+ my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } ); >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes', value => { rentalcharge => 0 } } ); >+ my $item_info = { >+ biblionumber => $biblioitem->biblionumber, >+ biblioitemnumber => $biblioitem->biblioitemnumber, >+ homebranch => $library->branchcode, >+ holdingbranch => $library->branchcode, >+ itype => $itemtype->itemtype, >+ }; >+ my $item = $builder->build_object( { class => 'Koha::Items', value => $item_info } ); >+ my $manager = $builder->build_object( { class => "Koha::Patrons" } ); >+ t::lib::Mocks::mock_userenv( { patron => $manager, branchcode => $manager->branchcode } ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->branchcode, } >+ } >+ ); >+ >+ my $reserve_id = C4::Reserves::AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber, >+ priority => 1, >+ itemnumber => $item->itemnumber, >+ } >+ ); >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ >+ ok($reserve_id, "Hold created"); >+ ok($hold, "Hold found"); >+ >+ my $av = Koha::AuthorisedValue->new( { category => 'HOLD_CANCELLATION', authorised_value => 'TEST_REASON' } )->store; >+ Koha::Notice::Templates->search({ code => 'HOLD_CANCELLATION'})->delete(); >+ my $notice = Koha::Notice::Template->new({ >+ name => 'Hold cancellation', >+ module => 'reserves', >+ code => 'HOLD_CANCELLATION', >+ title => 'Hold cancelled', >+ content => 'Your hold was cancelled.', >+ message_transport_type => 'email', >+ branchcode => q{}, >+ })->store(); >+ >+ $hold->cancel({cancellation_reason => 'TEST_REASON'}); >+ >+ $hold = Koha::Holds->find($reserve_id); >+ is( $hold, undef, 'Hold is not in the reserves table'); >+ $hold = Koha::Old::Holds->find($reserve_id); >+ ok( $hold, 'Hold was found in the old reserves table'); >+ >+ my $message = Koha::Notice::Messages->find({ borrowernumber => $patron->id, letter_code => 'HOLD_CANCELLATION'}); >+ ok( $message, 'Found hold cancellation message'); >+ is( $message->subject, 'Hold cancelled', 'Message has correct title' ); >+ is( $message->content, 'Your hold was cancelled.', 'Message has correct content'); >+ >+ $notice->delete; >+ $av->delete; >+ $message->delete; >+}; >+ >+subtest 'cancel all with reason' => sub { >+ plan tests => 7; >+ my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } ); >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes', value => { rentalcharge => 0 } } ); >+ my $item_info = { >+ biblionumber => $biblioitem->biblionumber, >+ biblioitemnumber => $biblioitem->biblioitemnumber, >+ homebranch => $library->branchcode, >+ holdingbranch => $library->branchcode, >+ itype => $itemtype->itemtype, >+ }; >+ my $item = $builder->build_object( { class => 'Koha::Items', value => $item_info } ); >+ my $manager = $builder->build_object( { class => "Koha::Patrons" } ); >+ t::lib::Mocks::mock_userenv( { patron => $manager, branchcode => $manager->branchcode } ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->branchcode, } >+ } >+ ); >+ >+ my $reserve_id = C4::Reserves::AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber, >+ priority => 1, >+ itemnumber => $item->itemnumber, >+ } >+ ); >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ >+ ok($reserve_id, "Hold created"); >+ ok($hold, "Hold found"); >+ >+ my $av = Koha::AuthorisedValue->new( { category => 'HOLD_CANCELLATION', authorised_value => 'TEST_REASON' } )->store; >+ Koha::Notice::Templates->search({ code => 'HOLD_CANCELLATION'})->delete(); >+ my $notice = Koha::Notice::Template->new({ >+ name => 'Hold cancellation', >+ module => 'reserves', >+ code => 'HOLD_CANCELLATION', >+ title => 'Hold cancelled', >+ content => 'Your hold was cancelled.', >+ message_transport_type => 'email', >+ branchcode => q{}, >+ })->store(); >+ >+ ModReserveCancelAll($item->id, $patron->id, 'TEST_REASON'); >+ >+ $hold = Koha::Holds->find($reserve_id); >+ is( $hold, undef, 'Hold is not in the reserves table'); >+ $hold = Koha::Old::Holds->find($reserve_id); >+ ok( $hold, 'Hold was found in the old reserves table'); >+ >+ my $message = Koha::Notice::Messages->find({ borrowernumber => $patron->id, letter_code => 'HOLD_CANCELLATION'}); >+ ok( $message, 'Found hold cancellation message'); >+ is( $message->subject, 'Hold cancelled', 'Message has correct title' ); >+ is( $message->content, 'Your hold was cancelled.', 'Message has correct content'); >+ >+ $av->delete; >+ $message->delete; >+}; >+ > $schema->storage->txn_rollback; > > 1; >-- >2.24.1 (Apple Git-126)
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 25534
:
105034
|
105035
|
105036
|
105077
|
105078
|
105079
|
105105
|
105106
|
105108
|
105109
|
105110
|
105111
|
105112
|
105113
|
105114
|
105115
|
105116
|
105117
|
105118
|
105119
|
105120
|
105121
|
105122
|
105147
|
105148
|
105149
|
105150
|
105151
|
108476
|
108477
|
108478
|
108479
|
108480
|
108481
|
108746
|
108747
|
108748
|
108749
|
108750
|
108751
|
108752
|
108753
|
108754
|
108755
|
108756
|
108757
|
108805
|
108806
|
108891
|
108892
|
108893
|
108894
|
108895
|
108896
|
108897
|
108898
|
108899
|
108900
|
108901
|
108902
|
108903
|
108904
|
108977
|
108985
|
108986
|
108990
|
114026
|
114027
|
114788