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

(-)a/Koha/Patrons/Import.pm (-1 / +3 lines)
Lines 397-405 sub import_patrons { Link Here
397
                });
397
                });
398
            } catch {
398
            } catch {
399
                $invalid++;
399
                $invalid++;
400
                my $patron_id = defined $matchpoint ? $borrower{$matchpoint} : $matchpoint_attr_type;
400
                if ( $_->isa('Koha::Exceptions::Patron::Attribute::UniqueIDConstraint') ) {
401
                if ( $_->isa('Koha::Exceptions::Patron::Attribute::UniqueIDConstraint') ) {
401
                    my $patron_id = defined $matchpoint ? $borrower{$matchpoint} : $matchpoint_attr_type;
402
                    push @errors, { patron_attribute_unique_id_constraint => 1, patron_id => $patron_id, attribute => $_->attribute };
402
                    push @errors, { patron_attribute_unique_id_constraint => 1, patron_id => $patron_id, attribute => $_->attribute };
403
                } elsif ( $_->isa('Koha::Exceptions::Patron::Attribute::InvalidType') ) {
404
                    push @errors, { patron_attribute_invalid_type => 1, patron_id => $patron_id, attribute_type_code => $_->type };
403
                } else {
405
                } else {
404
                    push @errors, { unknown_error => 1 };
406
                    push @errors, { unknown_error => 1 };
405
                }
407
                }
(-)a/t/db_dependent/Koha/Patrons/Import.t (-3 / +19 lines)
Lines 845-851 subtest 'test_format_dates' => sub { Link Here
845
845
846
subtest 'patron_attributes' => sub {
846
subtest 'patron_attributes' => sub {
847
847
848
    plan tests => 6;
848
    plan tests => 10;
849
849
850
    t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1);
850
    t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1);
851
851
Lines 906-912 subtest 'patron_attributes' => sub { Link Here
906
        $patron->delete;
906
        $patron->delete;
907
    }
907
    }
908
908
909
    {
909
    { # UniqueIDConstraint
910
        $builder->build_object(
910
        $builder->build_object(
911
            {
911
            {
912
                class => 'Koha::Patron::Attributes',
912
                class => 'Koha::Patron::Attributes',
Lines 926-931 subtest 'patron_attributes' => sub { Link Here
926
        is( $error->{patron_id}, $cardnumber );
926
        is( $error->{patron_id}, $cardnumber );
927
        is( $error->{attribute}->code, $unique_attribute_type->code );
927
        is( $error->{attribute}->code, $unique_attribute_type->code );
928
928
929
        my $patron = Koha::Patrons->find({cardnumber => $cardnumber});
930
        is( $patron, undef, 'Patron is not created' );
931
    }
932
933
    { #InvalidType
934
        my $attributes = {
935
            $non_existent_attribute_type_code => ['my non-existent attribute'],
936
            $normal_attribute_type->code      => ['my attribute 1'],
937
        };
938
        my $fh = build_csv({ %$attributes });
939
940
        my $result = $patrons_import->import_patrons({file => $fh, matchpoint => 'cardnumber'});
941
        my $error = $result->{errors}->[0];
942
        is( $error->{patron_attribute_invalid_type}, 1 );
943
        is( $error->{patron_id}, $cardnumber );
944
        is( $error->{attribute_type_code}, $non_existent_attribute_type_code );
945
929
        my $patron = Koha::Patrons->find({cardnumber => $cardnumber});
946
        my $patron = Koha::Patrons->find({cardnumber => $cardnumber});
930
        is( $patron, undef );
947
        is( $patron, undef );
931
948
932
- 

Return to bug 28220