Bugzilla – Attachment 91183 Details for
Bug 23077
Can't import patrons without cardnumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23077: Fix import of cardnumber 0
Bug-23077-Fix-import-of-cardnumber-0.patch (text/plain), 3.28 KB, created by
Nick Clemens (kidclamp)
on 2019-07-02 10:59:55 UTC
(
hide
)
Description:
Bug 23077: Fix import of cardnumber 0
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-07-02 10:59:55 UTC
Size:
3.28 KB
patch
obsolete
>From b85e86fc4c44c39160d67c91540405b624fbd9f9 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 2 Jul 2019 10:58:53 +0000 >Subject: [PATCH] Bug 23077: Fix import of cardnumber 0 > >--- > Koha/Patrons/Import.pm | 3 ++- > t/db_dependent/Koha/Patrons/Import.t | 29 +++++++++++++++++++++++++++-- > 2 files changed, 29 insertions(+), 3 deletions(-) > >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index d98e44d7c5..b18db0d7ad 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -132,7 +132,8 @@ sub import_patrons { > } > } > } >- $borrower{cardnumber} = undef unless $borrower{cardnumber}; >+ >+ $borrower{cardnumber} = undef if $borrower{cardnumber} eq ""; > > # Check if borrower category code exists and if it matches to a known category. Pushing error to missing_criticals otherwise. > $self->check_borrower_category($borrower{categorycode}, $borrowerline, $line_number, \@missing_criticals); >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index 78470cdcdc..b41a2654a0 100644 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 156; >+use Test::More tests => 157; > use Test::Warn; > > # To be replaced by t::lib::Mock >@@ -397,12 +397,37 @@ subtest 'test_import_without_cardnumber' => sub { > my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled > > my $result = $patrons_import->import_patrons($params_1, $defaults); >- warn Data::Dumper::Dumper( $result ); > like($result->{feedback}->[1]->{value}, qr/^Squarepants \/ \d+/, 'First borrower imported as expected'); > like($result->{feedback}->[2]->{value}, qr/^Star \/ \d+/, 'Second borrower imported as expected'); > > }; > >+subtest 'test_import_with_cardnumber_0' => sub { >+ plan tests => 2; >+ >+ #Remove possible existing user with a "" as cardnumber >+ my $zero_card = Koha::Patrons->find({ cardnumber => 0 }); >+ $zero_card->delete if $zero_card; >+ >+ my $branchcode = $builder->build({ source => "Branch"})->{branchcode}; >+ my $categorycode = $builder->build({ source => "Category"})->{categorycode}; >+ my $csv_headers = 'cardnumber,surname, branchcode, categorycode'; >+ my $res_headers = 'cardnumber,surname, branchcode, categorycode'; >+ my $csv_nocard_1 = "0,Squarepants,$branchcode,$categorycode"; >+ >+ my $filename_1 = make_csv($temp_dir, $csv_headers, $csv_nocard_1); >+ open(my $handle_1, "<", $filename_1) or die "cannot open < $filename_1: $!"; >+ my $params_1 = { file => $handle_1, }; >+ >+ my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled >+ >+ my $result = $patrons_import->import_patrons($params_1, $defaults); >+ like($result->{feedback}->[1]->{value}, qr/^Squarepants \/ \d+/, 'First borrower imported as expected'); >+ $zero_card = Koha::Patrons->find({ cardnumber => 0 }); >+ is($zero_card->surname.$zero_card->branchcode.$zero_card->categorycode,'Squarepants'.$branchcode.$categorycode,"Patron with cardnumber 0 is the imported patron"); >+ >+}; >+ > > subtest 'test_prepare_columns' => sub { > plan tests => 16; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23077
:
90415
|
90416
|
90417
|
90418
|
90474
|
90475
|
91181
|
91182
|
91183
|
91315
|
91316
|
91317