Bug 28220: Handle NonRepeatable
Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
b369d32bdf
commit
7624ab0a96
2 changed files with 24 additions and 1 deletions
|
@ -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 };
|
||||
}
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in a new issue