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

(-)a/C4/Reserves.pm (-4 / +4 lines)
Lines 1788-1806 sub _Findgroupreserve { Link Here
1788
    return @results;
1788
    return @results;
1789
}
1789
}
1790
1790
1791
=head2 _Removereserve
1791
=head2 _FilterHoldsForIndependentBranches
1792
1792
1793
  @reserves = &_Removereserve( @reserves );
1793
  @reserves = &_FilterHoldsForIndependentBranches( @reserves );
1794
1794
1795
Check transfers is allowed from system preference and remove the reserves made from other branches
1795
Check transfers is allowed from system preference and remove the reserves made from other branches
1796
1796
1797
C<&_Removereserve> returns :
1797
C<&_FilterHoldsForIndependentBranches> returns :
1798
C<@results> is an array of references-to-hash whose keys are mostly
1798
C<@results> is an array of references-to-hash whose keys are mostly
1799
fields from the reserves table of the Koha database, plus
1799
fields from the reserves table of the Koha database, plus
1800
1800
1801
=cut
1801
=cut
1802
1802
1803
sub _Removereserve {
1803
sub _FilterHoldsForIndependentBranches {
1804
    my ( @reserves) = @_;
1804
    my ( @reserves) = @_;
1805
    if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) {
1805
    if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) {
1806
        my @results;
1806
        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 => 77;
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 129-134 ok(exists($reserve->{reserve_id}), 'CheckReserves() include reserve_id in its re Link Here
129
($status, $reserve, $all_reserves) = CheckReserves( $item );
130
($status, $reserve, $all_reserves) = CheckReserves( $item );
130
is($status, "Reserved", "CheckReserves Test 2");
131
is($status, "Reserved", "CheckReserves Test 2");
131
132
133
# Set the preference 'IndependentBranchesTransfers' is set to 'yes'
134
# the userenv branch and the branche code are not the same holds should be filtered
135
t::lib::Mocks::mock_preference( 'IndependentBranchesTransfers', 1 );
136
($status, $reserve, $all_reserves) = CheckReserves( $item );
137
is( $status, "", 'Reserves is filtered');
138
139
# Set the userenv branchcode to be the same to the item branchcode.
140
t::lib::Mocks::mock_userenv({ branchcode => $branchcode });
141
($status, $reserve, $all_reserves) = CheckReserves( $item );
142
is( $status, "Reserved", 'Reserves should not be filtered');
143
144
t::lib::Mocks::mock_userenv({ branchcode => $branch_1 });
145
t::lib::Mocks::mock_preference( 'IndependentBranchesTransfers', 0 );
146
my $ReservesControlBranch = C4::Context->preference('ReservesControlBranch');
147
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
148
ok(
149
	$item->homebranch eq Koha::Policy::Holds->holds_control_library( $item, $patron	),
150
    "Koha::Policy::Holds->holds_control_library returns item home branch when set to ItemHomeLibrary"
151
);
152
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' );
153
ok(
154
	$patron->branchcode eq Koha::Policy::Holds->holds_control_library( $item, $patron ),
155
    "Koha::Policy::Holds->holds_control_library returns patron home branch when set to PatronLibrary"
156
);
157
t::lib::Mocks::mock_preference( 'ReservesControlBranch', $ReservesControlBranch );
158
132
###
159
###
133
### Regression test for bug 10272
160
### Regression test for bug 10272
134
###
161
###
135
- 

Return to bug 33200