Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 56; |
20 |
use Test::More tests => 57; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 54-59
my $builder = t::lib::TestBuilder->new;
Link Here
|
54 |
|
54 |
|
55 |
my $frameworkcode = q||; |
55 |
my $frameworkcode = q||; |
56 |
|
56 |
|
|
|
57 |
|
58 |
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); |
59 |
|
57 |
# Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached |
60 |
# Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached |
58 |
$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a' and frameworkcode=?", undef, $frameworkcode); |
61 |
$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a' and frameworkcode=?", undef, $frameworkcode); |
59 |
my $cache = Koha::Caches->get_instance; |
62 |
my $cache = Koha::Caches->get_instance; |
Lines 668-673
subtest '_koha_notify_reserve() tests' => sub {
Link Here
|
668 |
|
671 |
|
669 |
}; |
672 |
}; |
670 |
|
673 |
|
|
|
674 |
subtest 'ReservesNeedReturns' => sub { |
675 |
plan tests => 4; |
676 |
|
677 |
my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } ); |
678 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
679 |
my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes', value => { rentalcharge => 0 } } ); |
680 |
my $item_info = { |
681 |
biblionumber => $biblioitem->biblionumber, |
682 |
biblioitemnumber => $biblioitem->biblioitemnumber, |
683 |
homebranch => $library->branchcode, |
684 |
holdingbranch => $library->branchcode, |
685 |
itype => $itemtype->itemtype, |
686 |
}; |
687 |
my $item = $builder->build_object( { class => 'Koha::Items', value => $item_info } ); |
688 |
my $patron = $builder->build_object( |
689 |
{ |
690 |
class => 'Koha::Patrons', |
691 |
value => { branchcode => $library->branchcode, } |
692 |
} |
693 |
); |
694 |
|
695 |
my $priority = 1; |
696 |
my ( $hold_id, $hold ); |
697 |
|
698 |
t::lib::Mocks::mock_preference('ReservesNeedReturns', 0); # '0' means 'Automatically mark a hold as found and waiting' |
699 |
$hold_id = C4::Reserves::AddReserve( |
700 |
$library->branchcode, $patron->borrowernumber, |
701 |
$item->biblionumber, '', |
702 |
$priority, undef, |
703 |
undef, '', |
704 |
"title for fee", $item->itemnumber, |
705 |
); |
706 |
$hold = Koha::Holds->find($hold_id); |
707 |
is( $hold->priority, 0, 'If ReservesNeedReturns is 0, priority must have been set to 0' ); |
708 |
is( $hold->found, 'W', 'If ReservesNeedReturns is 0, found must have been set waiting' ); |
709 |
|
710 |
$hold->delete; # cleanup |
711 |
|
712 |
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # '0' means "Don't automatically mark a hold as found and waiting" |
713 |
$hold_id = C4::Reserves::AddReserve( |
714 |
$library->branchcode, $patron->borrowernumber, |
715 |
$item->biblionumber, '', |
716 |
$priority, undef, |
717 |
undef, '', |
718 |
"title for fee", $item->itemnumber, |
719 |
); |
720 |
$hold = Koha::Holds->find($hold_id); |
721 |
is( $hold->priority, $priority, 'If ReservesNeedReturns is 1, priority must not have been set to changed' ); |
722 |
is( $hold->found, undef, 'If ReservesNeedReturns is 1, found must not have been set waiting' ); |
723 |
}; |
724 |
|
671 |
sub count_hold_print_messages { |
725 |
sub count_hold_print_messages { |
672 |
my $message_count = $dbh->selectall_arrayref(q{ |
726 |
my $message_count = $dbh->selectall_arrayref(q{ |
673 |
SELECT COUNT(*) |
727 |
SELECT COUNT(*) |
674 |
- |
|
|