@@ -, +, @@ --- t/db_dependent/Reserves.t | 97 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) --- a/t/db_dependent/Reserves.t +++ a/t/db_dependent/Reserves.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 77; +use Test::More tests => 78; use Test::MockModule; use Test::Warn; @@ -1406,6 +1406,101 @@ subtest 'ModReserveAffect logging' => sub { like( $log->info, qr{$expected}, 'Timestamp logged is the current one' ); }; +subtest 'ModReserve logging' => sub { + + plan tests => 2; + + t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); + + my $item = $builder->build_sample_item; + my $patron = $builder->build_object( + { + class => "Koha::Patrons", + value => { branchcode => $item->homebranch } + } + ); + + my $hold1 = $builder->build_object( + { + class => "Koha::Holds", + value => { + found => "W", + priority => 0, + itemnumber => undef, + biblionumber => $item->biblionumber, + waitingdate => undef, + cancellationdate => undef, + item_level_hold => 0, + lowestPriority => 0, + expirationdate => '2022-12-24', + suspend_until => undef, + suspend => 0, + itemtype => undef, + borrowernumber => $patron->borrowernumber + } + } + ); + + my $other_branch = $builder->build_object( { class => "Koha::Libraries" } ); + + # Test changing expiration date + my $params = { + rank => $hold1->priority, + reserve_id => $hold1->reserve_id, + biblionumber => $item->biblionumber, + borrowernumber => $patron->borrowernumber, + branchcode => $hold1->branchcode, + expirationdate => "2022-12-31", + }; + + ModReserve($params); + my $log = Koha::ActionLogs->search( + { module => 'HOLDS', action => 'MODIFY', object => $hold1->reserve_id } + )->next; + my $expected = sprintf q{'expirationdate' => '%s'}, + $params->{expirationdate}; + like( $log->info, qr{$expected}, + 'Expiration date should have changed in logs' ); + + # Test making other changes + my $hold2 = $builder->build_object( + { + class => "Koha::Holds", + value => { + found => undef, + priority => 1, + itemnumber => undef, + biblionumber => $item->biblionumber, + waitingdate => undef, + cancellationdate => undef, + item_level_hold => 0, + lowestPriority => 0, + expirationdate => '2022-12-24', + suspend_until => undef, + suspend => 0, + itemtype => undef, + borrowernumber => $patron->borrowernumber + } + } + ); + + $params = { + rank => $hold2->priority, + reserve_id => $hold2->reserve_id, + biblionumber => $item->biblionumber, + borrowernumber => $patron->borrowernumber, + branchcode => $other_branch->branchcode, + }; + + ModReserve($params); + $log = Koha::ActionLogs->search( + { module => 'HOLDS', action => 'MODIFY', object => $hold2->reserve_id } + )->next; + $expected = sprintf q{'branchcode' => '%s'}, $other_branch->branchcode; + like( $log->info, qr{$expected}, 'Branchcode should have changed in logs' ); + +}; + sub count_hold_print_messages { my $message_count = $dbh->selectall_arrayref(q{ SELECT COUNT(*) --