Lines 435-441
subtest 'test_import_with_cardnumber_0' => sub {
Link Here
|
435 |
}; |
435 |
}; |
436 |
|
436 |
|
437 |
subtest 'test_import_with_password_overwrite' => sub { |
437 |
subtest 'test_import_with_password_overwrite' => sub { |
438 |
plan tests => 4; |
438 |
plan tests => 6; |
439 |
|
439 |
|
440 |
#Remove possible existing user to avoid clashes |
440 |
#Remove possible existing user to avoid clashes |
441 |
my $ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
441 |
my $ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
Lines 447-452
subtest 'test_import_with_password_overwrite' => sub {
Link Here
|
447 |
my $csv_headers = 'surname,userid,branchcode,categorycode,password'; |
447 |
my $csv_headers = 'surname,userid,branchcode,categorycode,password'; |
448 |
my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1"; |
448 |
my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1"; |
449 |
my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1"; |
449 |
my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1"; |
|
|
450 |
my $csv_blank_password = "Worel,ErnestP,$branchcode,$categorycode,"; |
450 |
my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled |
451 |
my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled |
451 |
|
452 |
|
452 |
#Make the test files for importing |
453 |
#Make the test files for importing |
Lines 457-462
subtest 'test_import_with_password_overwrite' => sub {
Link Here
|
457 |
open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!"; |
458 |
open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!"; |
458 |
my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
459 |
my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
459 |
|
460 |
|
|
|
461 |
my $filename_3 = make_csv($temp_dir, $csv_headers, $csv_blank_password); |
462 |
open(my $handle_3, "<", $filename_3) or die "cannot open < $filename_3: $!"; |
463 |
my $params_3 = { file => $handle_3, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
464 |
|
460 |
|
465 |
|
461 |
my $result = $patrons_import->import_patrons($params_1, $defaults); |
466 |
my $result = $patrons_import->import_patrons($params_1, $defaults); |
462 |
like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected'); |
467 |
like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected'); |
Lines 471-476
subtest 'test_import_with_password_overwrite' => sub {
Link Here
|
471 |
isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten"); |
476 |
isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten"); |
472 |
isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided"); |
477 |
isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided"); |
473 |
|
478 |
|
|
|
479 |
#Save info to check not changed |
480 |
$orig_pass = $ernest->password; |
481 |
|
482 |
$result = $patrons_import->import_patrons($params_3, $defaults); |
483 |
$ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
484 |
is($ernest->surname,'Worel',"Patron is overwritten, surname changed"); |
485 |
is($ernest->password,$orig_pass,"Patron was overwritten but password is not overwritten if blank"); |
486 |
|
474 |
}; |
487 |
}; |
475 |
|
488 |
|
476 |
|
489 |
|
477 |
- |
|
|