Bugzilla – Attachment 120611 Details for
Bug 28220
Exception not caught when importing patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28220: Handle NonRepeatable
Bug-28220-Handle-NonRepeatable.patch (text/plain), 2.98 KB, created by
Jonathan Druart
on 2021-05-06 10:49:12 UTC
(
hide
)
Description:
Bug 28220: Handle NonRepeatable
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-05-06 10:49:12 UTC
Size:
2.98 KB
patch
obsolete
>From 03b6d2750c755803e5e0f154d8eb1b695cdc9bbb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 6 May 2021 10:50:07 +0200 >Subject: [PATCH] Bug 28220: Handle NonRepeatable > >--- > Koha/Patrons/Import.pm | 3 +++ > t/db_dependent/Koha/Patrons/Import.t | 22 +++++++++++++++++++++- > 2 files changed, 24 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index e3880eda441..38b1c7f44d1 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -402,6 +402,9 @@ sub import_patrons { > push @errors, { patron_attribute_unique_id_constraint => 1, patron_id => $patron_id, attribute => $_->attribute }; > } elsif ( $_->isa('Koha::Exceptions::Patron::Attribute::InvalidType') ) { > push @errors, { patron_attribute_invalid_type => 1, patron_id => $patron_id, attribute_type_code => $_->type }; >+ } elsif ( $_->isa('Koha::Exceptions::Patron::Attribute::NonRepeatable') ) { >+ push @errors, { patron_attribute_non_repeatable => 1, patron_id => $patron_id, attribute => $_->attribute }; >+ > } else { > push @errors, { unknown_error => 1 }; > } >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index edc9544944e..c8ff7ada9c2 100755 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -845,7 +845,7 @@ subtest 'test_format_dates' => sub { > > subtest 'patron_attributes' => sub { > >- plan tests => 10; >+ plan tests => 16; > > t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); > >@@ -938,6 +938,8 @@ subtest 'patron_attributes' => sub { > my $fh = build_csv({ %$attributes }); > > my $result = $patrons_import->import_patrons({file => $fh, matchpoint => 'cardnumber'}); >+ is( $result->{imported}, 0 ); >+ > my $error = $result->{errors}->[0]; > is( $error->{patron_attribute_invalid_type}, 1 ); > is( $error->{patron_id}, $cardnumber ); >@@ -948,6 +950,24 @@ subtest 'patron_attributes' => sub { > > } > >+ { # NonRepeatable >+ my $attributes = { >+ $repeatable_attribute_type->code => ['my repeatable attribute 1', 'my repeatable attribute 2'], >+ $normal_attribute_type->code => ['my normal attribute 1', 'my normal attribute 2'], >+ }; >+ my $fh = build_csv({ %$attributes }); >+ my $result = $patrons_import->import_patrons({file => $fh, matchpoint => 'cardnumber'}); >+ is( $result->{imported}, 0 ); >+ >+ my $error = $result->{errors}->[0]; >+ is( $error->{patron_attribute_non_repeatable}, 1 ); >+ is( $error->{patron_id}, $cardnumber ); >+ is( $error->{attribute}->code, $normal_attribute_type->code ); >+ >+ my $patron = Koha::Patrons->find({cardnumber => $cardnumber}); >+ is( $patron, undef ); >+ } >+ > }; > > # got is { code => $code, attribute => $attribute } >-- >2.20.1
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 28220
:
120549
|
120607
|
120608
|
120609
|
120610
|
120611
|
120612
|
120613
|
120614
|
120783
|
120784
|
120785
|
120786
|
120787
|
120788
|
120789
|
120790
|
120885
|
120886
|
120887
|
120888
|
120889
|
120890
|
120891
|
120892