Lines 432-438
subtest 'test_import_with_cardnumber_0' => sub {
Link Here
|
432 |
}; |
432 |
}; |
433 |
|
433 |
|
434 |
subtest 'test_import_with_password_overwrite' => sub { |
434 |
subtest 'test_import_with_password_overwrite' => sub { |
435 |
plan tests => 6; |
435 |
plan tests => 8; |
436 |
|
436 |
|
437 |
#Remove possible existing user to avoid clashes |
437 |
#Remove possible existing user to avoid clashes |
438 |
my $ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
438 |
my $ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
Lines 440-451
subtest 'test_import_with_password_overwrite' => sub {
Link Here
|
440 |
|
440 |
|
441 |
#Setup our info |
441 |
#Setup our info |
442 |
my $branchcode = $builder->build({ source => "Branch"})->{branchcode}; |
442 |
my $branchcode = $builder->build({ source => "Branch"})->{branchcode}; |
443 |
my $categorycode = $builder->build({ source => "Category"})->{categorycode}; |
443 |
my $categorycode = $builder->build({ source => "Category", value => { category_type => 'A' } })->{categorycode}; |
|
|
444 |
my $staff_categorycode = $builder->build({ source => "Category", value => { category_type => 'S' } })->{categorycode}; |
444 |
my $csv_headers = 'surname,userid,branchcode,categorycode,password'; |
445 |
my $csv_headers = 'surname,userid,branchcode,categorycode,password'; |
445 |
my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1"; |
446 |
my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1"; |
446 |
my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1"; |
447 |
my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1"; |
447 |
my $csv_blank_password = "Worel,ErnestP,$branchcode,$categorycode,"; |
448 |
my $csv_blank_password = "Worel,ErnestP,$branchcode,$categorycode,"; |
448 |
my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled |
449 |
my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled |
|
|
450 |
my $csv_staff_password_change = "Worrell,ErnestP,$branchcode,$staff_categorycode,Vern1"; |
449 |
|
451 |
|
450 |
#Make the test files for importing |
452 |
#Make the test files for importing |
451 |
my $filename_1 = make_csv($temp_dir, $csv_headers, $csv_password); |
453 |
my $filename_1 = make_csv($temp_dir, $csv_headers, $csv_password); |
Lines 459-464
subtest 'test_import_with_password_overwrite' => sub {
Link Here
|
459 |
open(my $handle_3, "<", $filename_3) or die "cannot open < $filename_3: $!"; |
461 |
open(my $handle_3, "<", $filename_3) or die "cannot open < $filename_3: $!"; |
460 |
my $params_3 = { file => $handle_3, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
462 |
my $params_3 = { file => $handle_3, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
461 |
|
463 |
|
|
|
464 |
my $filename_4 = make_csv($temp_dir, $csv_headers, $csv_staff_password_change); |
465 |
open(my $handle_4, "<", $filename_4) or die "cannot open < $filename_4: $!"; |
466 |
my $params_4 = { file => $handle_4, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
467 |
|
462 |
|
468 |
|
463 |
my $result = $patrons_import->import_patrons($params_1, $defaults); |
469 |
my $result = $patrons_import->import_patrons($params_1, $defaults); |
464 |
like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected'); |
470 |
like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected'); |
Lines 481-486
subtest 'test_import_with_password_overwrite' => sub {
Link Here
|
481 |
is($ernest->surname,'Worel',"Patron is overwritten, surname changed"); |
487 |
is($ernest->surname,'Worel',"Patron is overwritten, surname changed"); |
482 |
is($ernest->password,$orig_pass,"Patron was overwritten but password is not overwritten if blank"); |
488 |
is($ernest->password,$orig_pass,"Patron was overwritten but password is not overwritten if blank"); |
483 |
|
489 |
|
|
|
490 |
$ernest->category($staff_categorycode); |
491 |
$ernest->store; |
492 |
|
493 |
$result = $patrons_import->import_patrons($params_4, $defaults); |
494 |
warn Data::Dumper::Dumper( $result ); |
495 |
$ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
496 |
is($ernest->surname,'Worrell',"Patron is overwritten, surname changed"); |
497 |
is($ernest->password,$orig_pass,"Patron is imported, password is not changed for staff"); |
498 |
|
484 |
}; |
499 |
}; |
485 |
|
500 |
|
486 |
|
501 |
|
487 |
- |
|
|