Lines 18-24
Link Here
|
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
use Test::More tests => 157; |
21 |
use Test::More tests => 158; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
24 |
# To be replaced by t::lib::Mock |
24 |
# To be replaced by t::lib::Mock |
Lines 428-433
subtest 'test_import_with_cardnumber_0' => sub {
Link Here
|
428 |
|
428 |
|
429 |
}; |
429 |
}; |
430 |
|
430 |
|
|
|
431 |
subtest 'test_import_with_password_overwrite' => sub { |
432 |
plan tests => 4; |
433 |
|
434 |
#Remove possible existing user to avoid clashes |
435 |
my $ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
436 |
$ernest->delete if $ernest; |
437 |
|
438 |
#Setup our info |
439 |
my $branchcode = $builder->build({ source => "Branch"})->{branchcode}; |
440 |
my $categorycode = $builder->build({ source => "Category"})->{categorycode}; |
441 |
my $csv_headers = 'surname,userid,branchcode,categorycode,password'; |
442 |
my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest"; |
443 |
my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern"; |
444 |
my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled |
445 |
|
446 |
#Make the test files for importing |
447 |
my $filename_1 = make_csv($temp_dir, $csv_headers, $csv_password); |
448 |
open(my $handle_1, "<", $filename_1) or die "cannot open < $filename_1: $!"; |
449 |
my $params_1 = { file => $handle_1, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
450 |
my $filename_2 = make_csv($temp_dir, $csv_headers, $csv_password_change); |
451 |
open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!"; |
452 |
my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; |
453 |
|
454 |
|
455 |
my $result = $patrons_import->import_patrons($params_1, $defaults); |
456 |
like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected'); |
457 |
$ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
458 |
isnt($ernest->password,'Ernest',"New patron is imported, password is encrypted"); |
459 |
|
460 |
#Save info to double check |
461 |
my $orig_pass = $ernest->password; |
462 |
|
463 |
$result = $patrons_import->import_patrons($params_2, $defaults); |
464 |
$ernest = Koha::Patrons->find({ userid => 'ErnestP' }); |
465 |
isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten"); |
466 |
isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided"); |
467 |
|
468 |
}; |
469 |
|
431 |
|
470 |
|
432 |
subtest 'test_prepare_columns' => sub { |
471 |
subtest 'test_prepare_columns' => sub { |
433 |
plan tests => 16; |
472 |
plan tests => 16; |