Bugzilla – Attachment 120890 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: Add test for updating an existing patron
Bug-28220-Add-test-for-updating-an-existing-patron.patch (text/plain), 3.92 KB, created by
Martin Renvoize (ashimema)
on 2021-05-12 15:57:52 UTC
(
hide
)
Description:
Bug 28220: Add test for updating an existing patron
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-05-12 15:57:52 UTC
Size:
3.92 KB
patch
obsolete
>From c72b3364855bc3c796efceb29df15ba4d28310db Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 6 May 2021 11:59:23 +0200 >Subject: [PATCH] Bug 28220: Add test for updating an existing patron > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Patrons/Import.t | 80 +++++++++++++++++++++++++++- > 1 file changed, 79 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index c8ff7ada9c..bef31e56f8 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 => 16; >+ plan tests => 17; > > t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); > >@@ -968,6 +968,84 @@ subtest 'patron_attributes' => sub { > is( $patron, undef ); > } > >+ subtest 'update existing patron' => sub { >+ plan tests => 6; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { cardnumber => $cardnumber } >+ } >+ ); >+ >+ my $attributes = { >+ $unique_attribute_type->code => ['my unique attribute 1'], >+ $repeatable_attribute_type->code => [ 'my repeatable attribute 1', 'my repeatable attribute 2' ], >+ $normal_attribute_type->code => ['my normal attribute 1'], >+ }; >+ my $fh = build_csv({ %$attributes }); >+ my $result = $patrons_import->import_patrons( >+ { >+ file => $fh, >+ matchpoint => 'cardnumber', >+ overwrite_cardnumber => 1, >+ preserve_extended_attributes => 1 >+ } >+ ); >+ >+ is( $result->{overwritten}, 1 ); >+ >+ compare_patron_attributes($patron->extended_attributes->unblessed, { %$attributes } ); >+ >+ # Adding a new non-repeatable attribute >+ my $new_attributes = { >+ $normal_attribute_type->code => ['my normal attribute 2'], >+ }; >+ $fh = build_csv({ %$new_attributes }); >+ $result = $patrons_import->import_patrons( >+ { >+ file => $fh, >+ matchpoint => 'cardnumber', >+ overwrite_cardnumber => 1, >+ preserve_extended_attributes => 1 >+ } >+ ); >+ >+ is( $result->{overwritten}, 1 ); >+ >+ # The normal_attribute_type has been replaced with 'my normal attribute 2' >+ compare_patron_attributes($patron->extended_attributes->unblessed, { %$attributes, %$new_attributes } ); >+ >+ >+ # uniqueness >+ $patron->extended_attributes->delete; # reset >+ $builder->build_object( >+ { >+ class => 'Koha::Patron::Attributes', >+ value => { code => $unique_attribute_type->code, attribute => 'unique' } >+ } >+ ); >+ $attributes = { >+ $unique_attribute_type->code => ['unique'], >+ $repeatable_attribute_type->code => [ 'my repeatable attribute 1', 'my repeatable attribute 2' ], >+ $normal_attribute_type->code => ['my normal attribute 1'], >+ }; >+ $fh = build_csv({ %$attributes }); >+ $result = $patrons_import->import_patrons( >+ { >+ file => $fh, >+ matchpoint => 'cardnumber', >+ overwrite_cardnumber => 1, >+ preserve_extended_attributes => 1 >+ } >+ ); >+ >+ is( $result->{overwritten}, 0 ); >+ >+ compare_patron_attributes($patron->extended_attributes->unblessed, { %$attributes } ); >+ >+ }; >+ > }; > > # 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