Lines 434-439
subtest 'test_import_with_cardnumber_0' => sub {
Link Here
|
434 |
|
434 |
|
435 |
}; |
435 |
}; |
436 |
|
436 |
|
|
|
437 |
subtest 'test_import_with_password_overwrite' => sub { |
438 |
plan tests => 4; |
439 |
|
440 |
#Remove possible existing user to avoid clashes |
441 |
my $ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
442 |
$ernest->delete if $ernest; |
443 |
|
444 |
#Setup our info |
445 |
my $branchcode = $builder->build({ source => "Branch"})->{branchcode}; |
446 |
my $categorycode = $builder->build({ source => "Category"})->{categorycode}; |
447 |
my $csv_headers = 'surname,userid,branchcode,categorycode,password'; |
448 |
my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest"; |
449 |
my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern"; |
450 |
my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled |
451 |
|
452 |
#Make the test files for importing |
453 |
my $filename_1 = make_csv($temp_dir, $csv_headers, $csv_password); |
454 |
open(my $handle_1, "<", $filename_1) or die "cannot open < $filename_1: $!"; |
455 |
my $params_1 = { file => $handle_1, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
456 |
my $filename_2 = make_csv($temp_dir, $csv_headers, $csv_password_change); |
457 |
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 |
|
460 |
|
461 |
my $result = $patrons_import->import_patrons($params_1, $defaults); |
462 |
like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected'); |
463 |
$ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
464 |
isnt($ernest->password,'Ernest',"New patron is imported, password is encrypted"); |
465 |
|
466 |
#Save info to double check |
467 |
my $orig_pass = $ernest->password; |
468 |
|
469 |
$result = $patrons_import->import_patrons($params_2, $defaults); |
470 |
$ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
471 |
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"); |
473 |
|
474 |
}; |
475 |
|
437 |
|
476 |
|
438 |
subtest 'test_prepare_columns' => sub { |
477 |
subtest 'test_prepare_columns' => sub { |
439 |
plan tests => 16; |
478 |
plan tests => 16; |