View | Details | Raw Unified | Return to bug 33200
Collapse All | Expand All

(-)a/C4/Reserves.pm (-4 / +4 lines)
Lines 1757-1775 sub _Findgroupreserve { Link Here
1757
    return @results;
1757
    return @results;
1758
}
1758
}
1759
1759
1760
=head2 _Removereserve
1760
=head2 _FilterHoldsForIndependentBranches
1761
1761
1762
  @reserves = &_Removereserve( @reserves );
1762
  @reserves = &_FilterHoldsForIndependentBranches( @reserves );
1763
1763
1764
Check transfers is allowed from system preference and remove the reserves made from other branches
1764
Check transfers is allowed from system preference and remove the reserves made from other branches
1765
1765
1766
C<&_Removereserve> returns :
1766
C<&_FilterHoldsForIndependentBranches> returns :
1767
C<@results> is an array of references-to-hash whose keys are mostly
1767
C<@results> is an array of references-to-hash whose keys are mostly
1768
fields from the reserves table of the Koha database, plus
1768
fields from the reserves table of the Koha database, plus
1769
1769
1770
=cut
1770
=cut
1771
1771
1772
sub _Removereserve {
1772
sub _FilterHoldsForIndependentBranches {
1773
    my ( @reserves) = @_;
1773
    my ( @reserves) = @_;
1774
    if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) {
1774
    if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) {
1775
        my @results;
1775
        my @results;
(-)a/t/db_dependent/Reserves.t (-2 / +28 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 69;
20
use Test::More tests => 81;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 62-67 my $frameworkcode = q//; Link Here
62
62
63
63
64
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1);
64
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1);
65
t::lib::Mocks::mock_preference( 'IndependentBranchesTransfers', 0 );
65
66
66
# Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached
67
# Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached
67
$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a' and frameworkcode=?", undef, $frameworkcode);
68
$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a' and frameworkcode=?", undef, $frameworkcode);
Lines 128-133 ok(exists($reserve->{reserve_id}), 'CheckReserves() include reserve_id in its re Link Here
128
($status, $reserve, $all_reserves) = CheckReserves( $item );
129
($status, $reserve, $all_reserves) = CheckReserves( $item );
129
is($status, "Reserved", "CheckReserves Test 2");
130
is($status, "Reserved", "CheckReserves Test 2");
130
131
132
# Set the preference 'IndependentBranchesTransfers' is set to 'yes'
133
# the userenv branch and the branche code are not the same holds should be filtered
134
t::lib::Mocks::mock_preference( 'IndependentBranchesTransfers', 1 );
135
($status, $reserve, $all_reserves) = CheckReserves( $item );
136
is( $status, "", 'Reserves is filtered');
137
138
# Set the userenv branchcode to be the same to the item branchcode.
139
t::lib::Mocks::mock_userenv({ branchcode => $branchcode });
140
($status, $reserve, $all_reserves) = CheckReserves( $item );
141
is( $status, "Reserved", 'Reserves should not be filtered');
142
143
t::lib::Mocks::mock_userenv({ branchcode => $branch_1 });
144
t::lib::Mocks::mock_preference( 'IndependentBranchesTransfers', 0 );
145
my $ReservesControlBranch = C4::Context->preference('ReservesControlBranch');
146
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
147
ok(
148
	$item->homebranch eq Koha::Policy::Holds->holds_control_library( $item, $patron	),
149
    "Koha::Policy::Holds->holds_control_library returns item home branch when set to ItemHomeLibrary"
150
);
151
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' );
152
ok(
153
	$patron->branchcode eq Koha::Policy::Holds->holds_control_library( $item, $patron ),
154
    "Koha::Policy::Holds->holds_control_library returns patron home branch when set to PatronLibrary"
155
);
156
t::lib::Mocks::mock_preference( 'ReservesControlBranch', $ReservesControlBranch );
157
131
###
158
###
132
### Regression test for bug 10272
159
### Regression test for bug 10272
133
###
160
###
134
- 

Return to bug 33200