Bugzilla – Attachment 115198 Details for
Bug 26282
Allow staff to decide if a hold cancellation notice will be sent when cancelling a hold
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26282: (QA follow-up) Unit tests
Bug-26282-QA-follow-up-Unit-tests.patch (text/plain), 4.50 KB, created by
Martin Renvoize (ashimema)
on 2021-01-15 13:21:28 UTC
(
hide
)
Description:
Bug 26282: (QA follow-up) Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-01-15 13:21:28 UTC
Size:
4.50 KB
patch
obsolete
>From 692dc27099f67f7d82e14adbae972d8946e6aaf0 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 8 Dec 2020 11:37:22 +0000 >Subject: [PATCH] Bug 26282: (QA follow-up) Unit tests > >This patch adds tests for the behaviour change. It tests if letter >processing takes place when notify_patron is passed. It tests all >combinations. > >Bonus: it tweaks the POD to acknowledge this new parameter. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Hold.t >=> FAIL: Tests fail! >3. Apply the rest of the patches >4. Repeat 2 >=> SUCCESS: Tests pass! No warnings! >5. Sign off :-D > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > t/db_dependent/Koha/Hold.t | 95 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 94 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t >index a6a5c4a7d6..7cee23766a 100755 >--- a/t/db_dependent/Koha/Hold.t >+++ b/t/db_dependent/Koha/Hold.t >@@ -19,11 +19,13 @@ > > use Modern::Perl; > >-use Test::More tests => 3; >+use Test::More tests => 4; > > use Test::Exception; > use Test::MockModule; >+use Test::Warn; > >+use t::lib::Mocks; > use t::lib::TestBuilder; > > use Koha::Libraries; >@@ -198,3 +200,94 @@ subtest 'is_pickup_location_valid() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'cancel() tests' => sub { >+ >+ plan tests => 12; >+ >+ $schema->storage->txn_begin; >+ >+ my $get_prepared_letter_called; >+ >+ # Mock GetPreparedLetter so it raises a warning we can look for >+ # and returns undef, so no call to EnqueueLetter happens >+ my $mocked_letter = Test::MockModule->new("C4::Letters"); >+ $mocked_letter->mock( 'GetPreparedLetter', sub { >+ $get_prepared_letter_called = 1; >+ return; >+ }); >+ >+ my $hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ cancellationdate => undef, >+ priority => 1, >+ cancellation_reason => undef, >+ } >+ } >+ ); >+ >+ # leave this things out of the test >+ t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge', 0 ); >+ t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); >+ >+ $hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ cancellationdate => undef, >+ priority => 1, >+ cancellation_reason => undef, >+ } >+ } >+ ); >+ >+ $get_prepared_letter_called = 0; >+ $hold->cancel({ cancellation_reason => 'Some reason' }); >+ ok( !$get_prepared_letter_called, 'GetPreparedLetter not called' ); >+ >+ isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); >+ is( $hold->priority, 0, 'priority gets set to 0' ); >+ is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' ); >+ >+ $hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ cancellationdate => undef, >+ priority => 1, >+ cancellation_reason => undef, >+ } >+ } >+ ); >+ >+ $get_prepared_letter_called = 0; >+ $hold->cancel({ cancellation_reason => 'Some reason', notify_patron => 1 }); >+ ok( $get_prepared_letter_called, 'GetPreparedLetter called if notify_patron and cancellation_reason passed' ); >+ >+ isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); >+ is( $hold->priority, 0, 'priority gets set to 0' ); >+ is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' ); >+ >+ $hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ cancellationdate => undef, >+ priority => 1, >+ cancellation_reason => undef, >+ } >+ } >+ ); >+ >+ $get_prepared_letter_called = 0; >+ $hold->cancel({ notify_patron => 1 }); >+ ok( $get_prepared_letter_called, 'GetPreparedLetter called if notify_patron passed' ); >+ >+ isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); >+ is( $hold->priority, 0, 'priority gets set to 0' ); >+ is( $hold->cancellation_reason, undef, 'cancellation_reason not passed' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.1
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 26282
:
109286
|
113960
|
113991
|
114007
|
114008
|
114009
|
114010
|
114011
|
114012
|
114013
|
114014
|
114015
|
114016
|
114028
|
114030
|
114031
|
114032
|
114033
|
114034
|
114035
|
114247
|
114248
|
114249
|
114250
|
114251
|
114252
|
114253
|
114254
|
114255
|
114259
|
115193
|
115194
|
115195
|
115196
|
115197
|
115198
|
115199
|
115200
|
115201
|
122448
|
122449
|
122450
|
122451
|
122452
|
122453
|
122454
|
122455
|
122456
|
122550
|
138407
|
138408
|
138409
|
138410
|
138411
|
138412
|
138413
|
138414
|
138415
|
138416
|
138417
|
138418
|
138419
|
138469
|
141210
|
171577
|
171578
|
171579
|
171580
|
171581
|
171582
|
171583
|
171584
|
171585
|
171586
|
171587
|
171588
|
171589
|
171590
|
171592
|
171593