View | Details | Raw Unified | Return to bug 23077
Collapse All | Expand All

(-)a/Koha/Patrons/Import.pm (-1 / +2 lines)
Lines 132-138 sub import_patrons { Link Here
132
                }
132
                }
133
            }
133
            }
134
        }
134
        }
135
        $borrower{cardnumber} = undef unless $borrower{cardnumber};
135
136
        $borrower{cardnumber} = undef if $borrower{cardnumber} eq "";
136
137
137
        # Check if borrower category code exists and if it matches to a known category. Pushing error to missing_criticals otherwise.
138
        # Check if borrower category code exists and if it matches to a known category. Pushing error to missing_criticals otherwise.
138
        $self->check_borrower_category($borrower{categorycode}, $borrowerline, $line_number, \@missing_criticals);
139
        $self->check_borrower_category($borrower{categorycode}, $borrowerline, $line_number, \@missing_criticals);
(-)a/t/db_dependent/Koha/Patrons/Import.t (-3 / +27 lines)
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 => 156;
21
use Test::More tests => 157;
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 397-408 subtest 'test_import_without_cardnumber' => sub { Link Here
397
    my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled
397
    my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled
398
398
399
    my $result = $patrons_import->import_patrons($params_1, $defaults);
399
    my $result = $patrons_import->import_patrons($params_1, $defaults);
400
    warn Data::Dumper::Dumper( $result );
401
    like($result->{feedback}->[1]->{value}, qr/^Squarepants \/ \d+/, 'First borrower imported as expected');
400
    like($result->{feedback}->[1]->{value}, qr/^Squarepants \/ \d+/, 'First borrower imported as expected');
402
    like($result->{feedback}->[2]->{value}, qr/^Star \/ \d+/, 'Second borrower imported as expected');
401
    like($result->{feedback}->[2]->{value}, qr/^Star \/ \d+/, 'Second borrower imported as expected');
403
402
404
};
403
};
405
404
405
subtest 'test_import_with_cardnumber_0' => sub {
406
    plan tests => 2;
407
408
    #Remove possible existing user with a "" as cardnumber
409
    my $zero_card = Koha::Patrons->find({ cardnumber => 0 });
410
    $zero_card->delete if $zero_card;
411
412
    my $branchcode = $builder->build({ source => "Branch"})->{branchcode};
413
    my $categorycode = $builder->build({ source => "Category"})->{categorycode};
414
    my $csv_headers  = 'cardnumber,surname, branchcode, categorycode';
415
    my $res_headers  = 'cardnumber,surname, branchcode, categorycode';
416
    my $csv_nocard_1 = "0,Squarepants,$branchcode,$categorycode";
417
418
    my $filename_1 = make_csv($temp_dir, $csv_headers, $csv_nocard_1);
419
    open(my $handle_1, "<", $filename_1) or die "cannot open < $filename_1: $!";
420
    my $params_1 = { file => $handle_1, };
421
422
    my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled
423
424
    my $result = $patrons_import->import_patrons($params_1, $defaults);
425
    like($result->{feedback}->[1]->{value}, qr/^Squarepants \/ \d+/, 'First borrower imported as expected');
426
    $zero_card = Koha::Patrons->find({ cardnumber => 0 });
427
    is($zero_card->surname.$zero_card->branchcode.$zero_card->categorycode,'Squarepants'.$branchcode.$categorycode,"Patron with cardnumber 0 is the imported patron");
428
429
};
430
406
431
407
subtest 'test_prepare_columns' => sub {
432
subtest 'test_prepare_columns' => sub {
408
    plan tests => 16;
433
    plan tests => 16;
409
- 

Return to bug 23077