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