From 033fc9f4ebb06e13e0f60442fffb7beea155362e Mon Sep 17 00:00:00 2001 From: Nicolas Legrand Date: Wed, 21 Oct 2020 12:10:19 +0200 Subject: [PATCH] Bug 24412: (follow-up) tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add some test for Koha::Hold->desk and Koha::Hold->set_waiting. Test plan: 1. prove t/db_dependent/Koha/Holds.t 2. should be green! Signed-off-by: Séverine QUEUNE Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/Holds.t | 42 ++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t index 2282290329..cc61fc04e3 100755 --- a/t/db_dependent/Koha/Holds.t +++ b/t/db_dependent/Koha/Holds.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use Test::Warn; use C4::Reserves; @@ -368,6 +368,46 @@ subtest 'cancel all with reason' => sub { $message->delete; }; +subtest 'Desks' => sub { + plan tests => 5; + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + + my $desk = Koha::Desk->new({ + desk_name => 'my_desk_name_for_test', + branchcode => $library->branchcode , + })->store; + ok($desk, "Desk created"); + my $item = $builder->build_sample_item({ library => $library->branchcode }); + my $manager = $builder->build_object( { class => "Koha::Patrons" } ); + t::lib::Mocks::mock_userenv( { patron => $manager, branchcode => $manager->branchcode } ); + + my $patron = $builder->build_object( + { + class => 'Koha::Patrons', + value => { branchcode => $library->branchcode, } + } + ); + + my $reserve_id = C4::Reserves::AddReserve( + { + branchcode => $library->branchcode, + borrowernumber => $patron->borrowernumber, + biblionumber => $item->biblionumber, + priority => 1, + itemnumber => $item->itemnumber, + } + ); + + my $hold = Koha::Holds->find($reserve_id); + + ok($reserve_id, "Hold created"); + ok($hold, "Hold found"); + $hold->set_waiting($desk->desk_id); + is($hold->found, 'W', 'Hold is waiting with correct status set'); + is($hold->desk_id, $desk->desk_id, 'Hold is attach to its desk'); + +}; + $schema->storage->txn_rollback; 1; -- 2.20.1