From 98359711300c0ea3b008566ce2ec61c26603a769 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 8 Mar 2021 11:43:04 -0300 Subject: [PATCH] Bug 27797: (QA follow-up) Make tests more robust This patch makes the tests mock things so the complex holds scenarios where existing data could interfere, don't get in the middle with what we need to test. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/holds.t => SUCCESS: Nothing broke Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/api/v1/holds.t | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index b88e325d26c..7179d061620 100755 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -1008,6 +1008,21 @@ subtest 'add() tests' => sub { return Koha::Libraries->search( { branchcode => [ $library_2->branchcode, $library_3->branchcode ] } ); }); + my $can_be_reserved = 'OK'; + my $mock_reserves = Test::MockModule->new('C4::Reserves'); + $mock_reserves->mock( 'CanItemBeReserved', sub + { + return { status => $can_be_reserved } + } + + ); + $mock_reserves->mock( 'CanBookBeReserved', sub + { + return { status => $can_be_reserved } + } + + ); + my $biblio = $builder->build_sample_biblio; my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); -- 2.30.1