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

(-)a/Koha/Patrons/Import.pm (+3 lines)
Lines 402-407 sub import_patrons { Link Here
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') ) {
403
                } elsif ( $_->isa('Koha::Exceptions::Patron::Attribute::InvalidType') ) {
404
                    push @errors, { patron_attribute_invalid_type => 1, patron_id => $patron_id, attribute_type_code => $_->type };
404
                    push @errors, { patron_attribute_invalid_type => 1, patron_id => $patron_id, attribute_type_code => $_->type };
405
                } elsif ( $_->isa('Koha::Exceptions::Patron::Attribute::NonRepeatable') ) {
406
                    push @errors, { patron_attribute_non_repeatable => 1, patron_id => $patron_id, attribute => $_->attribute };
407
405
                } else {
408
                } else {
406
                    push @errors, { unknown_error => 1 };
409
                    push @errors, { unknown_error => 1 };
407
                }
410
                }
(-)a/t/db_dependent/Koha/Patrons/Import.t (-2 / +21 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 => 10;
848
    plan tests => 16;
849
849
850
    t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1);
850
    t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1);
851
851
Lines 938-943 subtest 'patron_attributes' => sub { Link Here
938
        my $fh = build_csv({ %$attributes });
938
        my $fh = build_csv({ %$attributes });
939
939
940
        my $result = $patrons_import->import_patrons({file => $fh, matchpoint => 'cardnumber'});
940
        my $result = $patrons_import->import_patrons({file => $fh, matchpoint => 'cardnumber'});
941
        is( $result->{imported}, 0 );
942
941
        my $error = $result->{errors}->[0];
943
        my $error = $result->{errors}->[0];
942
        is( $error->{patron_attribute_invalid_type}, 1 );
944
        is( $error->{patron_attribute_invalid_type}, 1 );
943
        is( $error->{patron_id}, $cardnumber );
945
        is( $error->{patron_id}, $cardnumber );
Lines 948-953 subtest 'patron_attributes' => sub { Link Here
948
950
949
    }
951
    }
950
952
953
    { # NonRepeatable
954
        my $attributes = {
955
                $repeatable_attribute_type->code => ['my repeatable attribute 1', 'my repeatable attribute 2'],
956
                $normal_attribute_type->code     => ['my normal attribute 1', 'my normal attribute 2'],
957
            };
958
        my $fh = build_csv({ %$attributes });
959
        my $result = $patrons_import->import_patrons({file => $fh, matchpoint => 'cardnumber'});
960
        is( $result->{imported}, 0 );
961
962
        my $error = $result->{errors}->[0];
963
        is( $error->{patron_attribute_non_repeatable}, 1 );
964
        is( $error->{patron_id}, $cardnumber );
965
        is( $error->{attribute}->code, $normal_attribute_type->code );
966
967
        my $patron = Koha::Patrons->find({cardnumber => $cardnumber});
968
        is( $patron, undef );
969
    }
970
951
};
971
};
952
972
953
# got is { code => $code, attribute => $attribute }
973
# got is { code => $code, attribute => $attribute }
954
- 

Return to bug 28220