From bada56394de205c8f03db0017d2181f647749c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nyl=C3=A9n?= Date: Tue, 9 Nov 2021 15:40:22 +0100 Subject: [PATCH] Bug 14783: (QA follow-up) Add unit tests. This commit adds unit tests for Bug 14783. --- t/db_dependent/Hold.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index 73007c18a0..c662759b73 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -29,7 +29,7 @@ use Koha::Item; use Koha::DateUtils qw( dt_from_string ); use t::lib::TestBuilder; -use Test::More tests => 35; +use Test::More tests => 43; use Test::Exception; use Test::Warn; @@ -142,6 +142,32 @@ ok( !$hold->is_at_destination(), "Waiting hold where hold branchcode is not the $item->holdingbranch( $branches[1]->{branchcode} ); ok( $hold->is_at_destination(), "Waiting hold where hold branchcode is the same as the item's holdingbranch is at destination" ); +#Test method can_change_branch_opac +t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', '' ); +$hold->found(undef); +is( $hold->can_change_branch_opac, 0, "Pending hold pickup can't be changed (No change allowed)" ); +$hold->found('T'); +is( $hold->can_change_branch_opac, 0, "In transit hold pickup can't be changed (No change allowed)" ); +$hold->found('W'); +is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (No change allowed)" ); +$hold->found(undef); +$dt = dt_from_string(); +$hold->suspend_hold( $dt ); +is( $hold->can_change_branch_opac, 0, "Suspended hold pickup can't be changed (No change allowed)" ); +$hold->resume(); +t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', 'pending,intransit,suspended' ); +$hold->found(undef); +is( $hold->can_change_branch_opac, 1, "Pending hold pickup can be changed (pending,intransit,suspended allowed)" ); +$hold->found('T'); +is( $hold->can_change_branch_opac, 1, "In transit hold pickup can be changed (pending,intransit,suspended allowed)" ); +$hold->found('W'); +is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (pending,intransit,suspended allowed)" ); +$hold->found(undef); +$dt = dt_from_string(); +$hold->suspend_hold( $dt ); +is( $hold->can_change_branch_opac, 1, "Suspended hold pickup can be changed (pending,intransit,suspended allowed)" ); +$hold->resume(); + $schema->storage->txn_rollback(); subtest "store() tests" => sub { -- 2.20.1