Lines 150-159
subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
Link Here
|
150 |
my $item = $builder->build_sample_item; |
150 |
my $item = $builder->build_sample_item; |
151 |
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); |
151 |
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); |
152 |
|
152 |
|
153 |
# Test last_returned_by_all with no borrowers |
153 |
# Test last_borrowers with no borrowers |
154 |
t::lib::Mocks::mock_preference( 'StoreLastBorrower', '3' ); |
154 |
t::lib::Mocks::mock_preference( 'StoreLastBorrower', '3' ); |
155 |
my $borrowers = $item->last_returned_by_all(); |
155 |
my $borrowers = $item->last_borrowers(); |
156 |
is( $borrowers->count, 0, 'last_returned_by_all returns empty set when no borrowers stored' ); |
156 |
is( $borrowers->count, 0, 'last_borrowers returns empty set when no borrowers stored' ); |
157 |
|
157 |
|
158 |
# Add 3 borrowers for testing, checkout/check in |
158 |
# Add 3 borrowers for testing, checkout/check in |
159 |
my @patrons; |
159 |
my @patrons; |
Lines 182-189
subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
Link Here
|
182 |
|
182 |
|
183 |
$item = $item->get_from_storage; |
183 |
$item = $item->get_from_storage; |
184 |
|
184 |
|
185 |
# Test last_returned_by_all returns all borrowers |
185 |
# Test last_borrowers returns all borrowers |
186 |
$borrowers = $item->last_returned_by_all(); |
186 |
$borrowers = $item->last_borrowers(); |
187 |
is( $borrowers->count, 3, 'Correctly returns 3 borrowers' ); |
187 |
is( $borrowers->count, 3, 'Correctly returns 3 borrowers' ); |
188 |
|
188 |
|
189 |
# Test ordering |
189 |
# Test ordering |
Lines 217-223
subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
Link Here
|
217 |
} |
217 |
} |
218 |
|
218 |
|
219 |
$item = $item->get_from_storage; |
219 |
$item = $item->get_from_storage; |
220 |
$borrowers = $item->last_returned_by_all(); |
220 |
$borrowers = $item->last_borrowers(); |
221 |
is( |
221 |
is( |
222 |
$borrowers->count, 3, |
222 |
$borrowers->count, 3, |
223 |
'We only retain 3 borrowers when the sys pref is set to 3, even though there are 5 checkouts/checkins' |
223 |
'We only retain 3 borrowers when the sys pref is set to 3, even though there are 5 checkouts/checkins' |
Lines 251-257
subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
Link Here
|
251 |
); |
251 |
); |
252 |
|
252 |
|
253 |
$item = $item->get_from_storage; |
253 |
$item = $item->get_from_storage; |
254 |
$borrowers = $item->last_returned_by_all(); |
254 |
$borrowers = $item->last_borrowers(); |
255 |
is( $borrowers->count, 2, 'StoreLastBorrower was reduced to 2, we should now only keep 2 in the table' ); |
255 |
is( $borrowers->count, 2, 'StoreLastBorrower was reduced to 2, we should now only keep 2 in the table' ); |
256 |
@borrowers_array = $borrowers->as_list; |
256 |
@borrowers_array = $borrowers->as_list; |
257 |
is( |
257 |
is( |
Lines 286-293
subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
Link Here
|
286 |
); |
286 |
); |
287 |
|
287 |
|
288 |
$item = $item->get_from_storage; |
288 |
$item = $item->get_from_storage; |
289 |
$borrowers = $item->last_returned_by_all(); |
289 |
$borrowers = $item->last_borrowers(); |
290 |
is( $borrowers->count, 0, 'last_returned_by_all respects preference value 0' ); |
290 |
is( $borrowers->count, 0, 'last_borrowers respects preference value 0' ); |
291 |
|
291 |
|
292 |
my $cleanup_patron = $builder->build( |
292 |
my $cleanup_patron = $builder->build( |
293 |
{ |
293 |
{ |
Lines 312-318
subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
Link Here
|
312 |
); |
312 |
); |
313 |
|
313 |
|
314 |
$item = $item->get_from_storage; |
314 |
$item = $item->get_from_storage; |
315 |
$borrowers = $item->last_returned_by_all(); |
315 |
$borrowers = $item->last_borrowers(); |
316 |
is( $borrowers->count, 0, 'All entries cleared when preference is 0' ); |
316 |
is( $borrowers->count, 0, 'All entries cleared when preference is 0' ); |
317 |
is( $item->last_returned_by, undef, 'last_returned_by returns undef when no records' ); |
317 |
is( $item->last_returned_by, undef, 'last_returned_by returns undef when no records' ); |
318 |
|
318 |
|
319 |
- |
|
|