|
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 => 4; |
435 |
plan tests => 6; |
| 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 444-449
subtest 'test_import_with_password_overwrite' => sub {
Link Here
|
| 444 |
my $csv_headers = 'surname,userid,branchcode,categorycode,password'; |
444 |
my $csv_headers = 'surname,userid,branchcode,categorycode,password'; |
| 445 |
my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1"; |
445 |
my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1"; |
| 446 |
my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1"; |
446 |
my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1"; |
|
|
447 |
my $csv_blank_password = "Worel,ErnestP,$branchcode,$categorycode,"; |
| 447 |
my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled |
448 |
my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled |
| 448 |
|
449 |
|
| 449 |
#Make the test files for importing |
450 |
#Make the test files for importing |
|
Lines 454-459
subtest 'test_import_with_password_overwrite' => sub {
Link Here
|
| 454 |
open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!"; |
455 |
open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!"; |
| 455 |
my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
456 |
my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
| 456 |
|
457 |
|
|
|
458 |
my $filename_3 = make_csv($temp_dir, $csv_headers, $csv_blank_password); |
| 459 |
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}; |
| 461 |
|
| 457 |
|
462 |
|
| 458 |
my $result = $patrons_import->import_patrons($params_1, $defaults); |
463 |
my $result = $patrons_import->import_patrons($params_1, $defaults); |
| 459 |
like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected'); |
464 |
like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected'); |
|
Lines 468-473
subtest 'test_import_with_password_overwrite' => sub {
Link Here
|
| 468 |
isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten"); |
473 |
isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten"); |
| 469 |
isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided"); |
474 |
isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided"); |
| 470 |
|
475 |
|
|
|
476 |
#Save info to check not changed |
| 477 |
$orig_pass = $ernest->password; |
| 478 |
|
| 479 |
$result = $patrons_import->import_patrons($params_3, $defaults); |
| 480 |
$ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
| 481 |
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"); |
| 483 |
|
| 471 |
}; |
484 |
}; |
| 472 |
|
485 |
|
| 473 |
|
486 |
|
| 474 |
- |
|
|