From 7e1dde5675c9892bbba47b441225ec8d1e34498e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 31 Jul 2020 09:47:56 -0300 Subject: [PATCH] Bug 26108: Regression tests The current implementation makes the assumption that if $issue is defined, then it is the 'return' use case. This is correct, but incomplete: after verifying that there's actually an issue, the return can be rejected for various reasons. This patch introduces a regression test for one of those situations (which I consider enough for testing purposes) . It highlights that the hook shouldn't be called if there hasn't been an actual checkin. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/Circulation_hooks.t => FAIL: Tests fail because there's an unexpected warining printed by the erroneous plugin call (i.e. there's been no return but the plugin is called anyway). Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Plugins/Circulation_hooks.t | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Plugins/Circulation_hooks.t b/t/db_dependent/Koha/Plugins/Circulation_hooks.t index be0f7077e9..5f8569d9ed 100755 --- a/t/db_dependent/Koha/Plugins/Circulation_hooks.t +++ b/t/db_dependent/Koha/Plugins/Circulation_hooks.t @@ -92,7 +92,17 @@ subtest 'after_circ_action() hook tests' => sub { }; subtest 'AddReturn' => sub { - plan tests => 1; + plan tests => 2; + + t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 1); + $item_1->set({ withdrawn => 1 })->store; + + warning_is { + AddReturn( $item_1->barcode, $patron->branchcode ); + } undef, 'No hook called because no return happened'; + + t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 0); + $item_1->set({ withdrawn => 0 })->store; warning_like { AddReturn( $item_1->barcode, $patron->branchcode ); -- 2.28.0