Lines 17-27
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 59; |
20 |
use Test::More tests => 72; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Data::Dumper; |
22 |
use Data::Dumper; |
23 |
use C4::Context; |
23 |
use C4::Context; |
24 |
use Koha::Database; |
24 |
use Koha::Database; |
|
|
25 |
use Koha::List::Patron; |
26 |
|
25 |
|
27 |
|
26 |
use t::lib::Mocks; |
28 |
use t::lib::Mocks; |
27 |
use t::lib::TestBuilder; |
29 |
use t::lib::TestBuilder; |
Lines 229-234
$borrowernumber = AddMember( %data );
Link Here
|
229 |
$borrower = GetMember( borrowernumber => $borrowernumber ); |
231 |
$borrower = GetMember( borrowernumber => $borrowernumber ); |
230 |
is( $borrower->{userid}, $data{userid}, 'AddMember should insert the given userid' ); |
232 |
is( $borrower->{userid}, $data{userid}, 'AddMember should insert the given userid' ); |
231 |
|
233 |
|
|
|
234 |
#Regression tests for bug 10612 |
235 |
my $library3 = $builder->build({ |
236 |
source => 'Branch', |
237 |
}); |
238 |
$builder->build({ |
239 |
source => 'Category', |
240 |
value => { |
241 |
categorycode => 'STAFFER', |
242 |
description => 'Staff dont batch del', |
243 |
category_type => 'S', |
244 |
}, |
245 |
}); |
246 |
|
247 |
$builder->build({ |
248 |
source => 'Category', |
249 |
value => { |
250 |
categorycode => 'CIVILIAN', |
251 |
description => 'Civilian batch del', |
252 |
category_type => 'A', |
253 |
}, |
254 |
}); |
255 |
#$builder->clear( { source => 'Borrower' } ); |
256 |
my $borrower1 = $builder->build({ |
257 |
source => 'Borrower', |
258 |
value => { |
259 |
categorycode=>'STAFFER', |
260 |
branchcode => $library3->{branchcode}, |
261 |
dateexpiry => '2015-01-01', |
262 |
}, |
263 |
}); |
264 |
my $bor1inlist = $borrower1->{borrowernumber}; |
265 |
my $borrower2 = $builder->build({ |
266 |
source => 'Borrower', |
267 |
value => { |
268 |
categorycode=>'STAFFER', |
269 |
branchcode => $library3->{branchcode}, |
270 |
dateexpiry => '2015-01-01', |
271 |
}, |
272 |
}); |
273 |
my $bor2inlist = $borrower2->{borrowernumber}; |
274 |
|
275 |
$builder->build({ |
276 |
source => 'OldIssue', |
277 |
value => { |
278 |
borrowernumber => $bor2inlist, |
279 |
timestamp => '2016-01-01', |
280 |
}, |
281 |
}); |
282 |
|
283 |
my $owner = AddMember (categorycode => 'STAFFER', branchcode => $library2->{branchcode} ); |
284 |
my $list1 = AddPatronList( { name => 'Test List 1', owner => $owner } ); |
285 |
my @listpatrons = ($bor1inlist, $bor2inlist); |
286 |
AddPatronsToList( { list => $list1, borrowernumbers => \@listpatrons }); |
287 |
my $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id() } ); |
288 |
is( scalar(@$patstodel),0,'No staff deleted from list of all staff'); |
289 |
ModMember( borrowernumber => $bor2inlist, categorycode => 'CIVILIAN' ); |
290 |
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); |
291 |
ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted from list'); |
292 |
$patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } ); |
293 |
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by branchcode and list'); |
294 |
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list_id => $list1->patron_list_id() } ); |
295 |
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by expirationdate and list'); |
296 |
$patstodel = GetBorrowersToExpunge( {not_borrowered_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } ); |
297 |
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date'); |
298 |
ModMember( borrowernumber => $bor1inlist, categorycode => 'CIVILIAN' ); |
299 |
|
300 |
$builder->build({ |
301 |
source => 'Issue', |
302 |
value => { |
303 |
borrowernumber => $bor2inlist, |
304 |
}, |
305 |
}); |
306 |
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); |
307 |
is( scalar(@$patstodel),1,'Borrower with issue not deleted from list'); |
308 |
$patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } ); |
309 |
is( scalar(@$patstodel),1,'Borrower with issue not deleted by branchcode and list'); |
310 |
$patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id => $list1->patron_list_id() } ); |
311 |
is( scalar(@$patstodel),1,'Borrower with issue not deleted by category_code and list'); |
312 |
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } ); |
313 |
is( scalar(@$patstodel),1,'Borrower with issue not deleted by expiration_date and list'); |
314 |
$builder->clear( { source => 'Issue' } ); |
315 |
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); |
316 |
ok( scalar(@$patstodel)== 2,'Borrowers without issue deleted from list'); |
317 |
$patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id => $list1->patron_list_id() } ); |
318 |
is( scalar(@$patstodel),2,'Borrowers without issues deleted by category_code and list'); |
319 |
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } ); |
320 |
is( scalar(@$patstodel),2,'Borrowers without issues deleted by expiration_date and list'); |
321 |
$patstodel = GetBorrowersToExpunge( {not_borrowered_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } ); |
322 |
is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date'); |
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
232 |
# Regression tests for BZ13502 |
328 |
# Regression tests for BZ13502 |
233 |
## Remove all entries with userid='' (should be only 1 max) |
329 |
## Remove all entries with userid='' (should be only 1 max) |
234 |
$dbh->do(q|DELETE FROM borrowers WHERE userid = ''|); |
330 |
$dbh->do(q|DELETE FROM borrowers WHERE userid = ''|); |
235 |
- |
|
|