From 8ee967da74c70811bce69b9275c7d1b680ef94c9 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Thu, 3 Nov 2022 14:40:40 +0200 Subject: [PATCH] Bug 31447: Add unit tests To test prove t/db_dependent/Circulation.t Sponsored-by: Koha-Suomi Oy --- t/db_dependent/Circulation.t | 42 +++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index b783a8268b..fd6d0d8592 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -18,7 +18,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 63; +use Test::More tests => 67; use Test::Exception; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -5693,6 +5693,46 @@ subtest "GetSoonestRenewDate tests" => sub { ); }; +subtest "CanBookBeIssued + needsconfirmation message" => sub { + plan tests => 4; + + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $biblio = $builder->build_object({ class => 'Koha::Biblios' }); + my $biblioitem = $builder->build_object({ class => 'Koha::Biblioitems', value => { biblionumber => $biblio->biblionumber }}); + my $item = $builder->build_object({ class => 'Koha::Items' , value => { biblionumber => $biblio->biblionumber }}); + + my $hold = $builder->build_object({ class => 'Koha::Holds', value => { + biblionumber => $item->biblionumber, + branchcode => $library->branchcode, + itemnumber => undef, + itemtype => undef, + priority => 1, + found => undef, + suspend => 0, + item_group_id => $item->item_group + }}); + + my ( $error, $needsconfirmation, $alerts, $messages ); + + ( $error, $needsconfirmation, $alerts, $messages ) = CanBookBeIssued( $patron, $item->barcode ); + is($needsconfirmation->{resbranchcode}, $hold->branchcode, "Branchcodes match when hold exists."); + + $hold->priority(0)->store(); + + $hold->found("W")->store(); + ( $error, $needsconfirmation, $alerts, $messages ) = CanBookBeIssued( $patron, $item->barcode ); + is($needsconfirmation->{resbranchcode}, $hold->branchcode, "Branchcodes match when hold is waiting."); + + $hold->found("T")->store(); + ( $error, $needsconfirmation, $alerts, $messages ) = CanBookBeIssued( $patron, $item->barcode ); + is($needsconfirmation->{resbranchcode}, $hold->branchcode, "Branchcodes match when hold is being transferred."); + + $hold->found("P")->store(); + ( $error, $needsconfirmation, $alerts, $messages ) = CanBookBeIssued( $patron, $item->barcode ); + is($needsconfirmation->{resbranchcode}, $hold->branchcode, "Branchcodes match when hold is being processed."); +}; + $schema->storage->txn_rollback; C4::Context->clear_syspref_cache(); $branches = Koha::Libraries->search(); -- 2.34.1