Lines 16-22
Link Here
|
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use Test::More tests => 3; |
19 |
use Test::More tests => 12; |
20 |
use MARC::Record; |
20 |
use MARC::Record; |
21 |
|
21 |
|
22 |
use Koha::Libraries; |
22 |
use Koha::Libraries; |
Lines 109-114
ok( scalar @$priorities == 2, 'Only 2 holds remain in the reserves table' );
Link Here
|
109 |
ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' ); |
109 |
ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' ); |
110 |
ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' ); |
110 |
ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' ); |
111 |
|
111 |
|
|
|
112 |
#Bug 20844 |
113 |
#Test reverting the waiting status of holds when the reserved items are set to lost |
114 |
|
115 |
#Create bib-level hold and test what happens when the item an allocated bib-level hold is allocated on is lost when the LostBibLevelHoldsRevert syspref is enabled |
116 |
my $hold_id = C4::Reserves::AddReserve( |
117 |
$branchcode, |
118 |
4, |
119 |
$biblionumber, |
120 |
my $bibitems = q{}, |
121 |
my $priority, |
122 |
my $resdate, |
123 |
my $expdate, |
124 |
my $notes = q{}, |
125 |
$title, |
126 |
my $checkitem, |
127 |
my $found, |
128 |
); |
129 |
|
130 |
my $hold = Koha::Holds->find($hold_id); |
131 |
is( $hold->originalholdtype, 'B', 'Holds originalholdtype is "B" which is correct' ); |
132 |
ModReserveAffect($itemnumber, 4, 0); #Confirm the hold - now it's an allocated bib-level hold on $itemnumber and has status is 'W' |
133 |
$hold = Koha::Holds->find($hold_id); |
134 |
is( $hold->found, 'W', 'Hold status is "W" (waiting) which is correct' ); |
135 |
is( $hold->itemnumber, $itemnumber, 'Bib-level hold is allocated and has an itemnumber' ); |
136 |
t::lib::Mocks::mock_preference( 'LostBibLevelHoldsRevert', 1 ); |
137 |
|
138 |
if (C4::Context->preference('LostBibLevelHoldsRevert') ) { |
139 |
#When item is set to lost revert hold to bib-level (i.e. remove the itemnumber in hold record) and change reserves.found to '' |
140 |
RevertWaitingStatus({ itemnumber => $itemnumber }); |
141 |
RevertItemLevelHoldToBibLevelHold({ reserveid => $hold_id }); |
142 |
} |
143 |
$hold = Koha::Holds->find($hold_id); |
144 |
is( $hold->found, undef, 'reserve.found reverted to undef now item is lost' ); |
145 |
is( $hold->itemnumber, undef, 'Hold reverted back to unallocated bib level hold' ); |
146 |
|
147 |
#Create item-level hold and test what happens when the reserved item is set to lost |
148 |
$hold_id = C4::Reserves::AddReserve( |
149 |
$branchcode, |
150 |
4, |
151 |
$biblionumber, |
152 |
$bibitems = q{}, |
153 |
$priority, |
154 |
$resdate, |
155 |
$expdate, |
156 |
$notes = q{}, |
157 |
$title, |
158 |
$itemnumber, |
159 |
$found, |
160 |
); |
161 |
|
162 |
$hold = Koha::Holds->find($hold_id); |
163 |
is( $hold->itemnumber, $itemnumber, 'This is an item-level hold' ); |
164 |
|
165 |
is( $hold->originalholdtype, 'I', 'Holds originalholdtype is correct' ); |
166 |
ModReserveAffect($itemnumber, 4, 0); #Confirm the hold - now it's a waiting item-level hold with a reserves.found value of 'W' |
167 |
$hold = Koha::Holds->find($hold_id); |
168 |
is( $hold->found, 'W', 'Hold status is waiting' ); |
169 |
|
170 |
RevertWaitingStatus({ itemnumber => $itemnumber }); |
171 |
$hold = Koha::Holds->find($hold_id); |
172 |
is( $hold->found, undef, 'Reserves found value is reverted to undef as the reserved item has been lost' ); |
173 |
|
112 |
$schema->storage->txn_rollback; |
174 |
$schema->storage->txn_rollback; |
113 |
|
175 |
|
114 |
# Helper method to set up a Biblio. |
176 |
# Helper method to set up a Biblio. |
115 |
- |
|
|