From c3053203ded3284056419c03061304ebf1487142 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 774508d4195..1a80452d882 100755 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -1036,6 +1036,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.31.1