Bugzilla – Attachment 142135 Details for
Bug 29480
Add email address as a method for generating the userid when self registering in OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29480: (follow up) Add tests to subtest generate_userid
Bug-29480-follow-up-Add-tests-to-subtest-generateu.patch (text/plain), 3.89 KB, created by
Magnus Enger
on 2022-10-19 08:58:18 UTC
(
hide
)
Description:
Bug 29480: (follow up) Add tests to subtest generate_userid
Filename:
MIME Type:
Creator:
Magnus Enger
Created:
2022-10-19 08:58:18 UTC
Size:
3.89 KB
patch
obsolete
>From 23dc4837bfaabd862645605d9dc69f9dc6ae3127 Mon Sep 17 00:00:00 2001 >From: Magnus Enger <magnus@libriotech.no> >Date: Wed, 19 Oct 2022 10:55:54 +0200 >Subject: [PATCH] Bug 29480: (follow up) Add tests to subtest generate_userid > >--- > t/db_dependent/Koha/Patrons.t | 38 +++++++++++++++++++++++++++++++++-- > 1 file changed, 36 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 627f0f9f4d..766eb53793 100755 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1602,7 +1602,7 @@ subtest 'userid_is_valid' => sub { > }; > > subtest 'generate_userid' => sub { >- plan tests => 7; >+ plan tests => 12; > > my $library = $builder->build_object( { class => 'Koha::Libraries' } ); > my $patron_category = $builder->build_object( >@@ -1617,8 +1617,12 @@ subtest 'generate_userid' => sub { > surname => "Ãoné", > categorycode => $patron_category->categorycode, > branchcode => $library->branchcode, >+ email => 'tomasito@example.com', > ); > >+ # "default" should generate userids like firstname.surname >+ t::lib::Mocks::mock_preference( 'PatronSelfRegistrationUseridGenerationMethod', 'default' ); >+ > my $expected_userid_patron_1 = 'tomasito.none'; > my $new_patron = Koha::Patron->new({ firstname => $data{firstname}, surname => $data{surname} } ); > $new_patron->generate_userid; >@@ -1637,7 +1641,7 @@ subtest 'generate_userid' => sub { > isnt( $patron_2->userid, 'tomasito', > "Patron with duplicate userid has new userid generated" ); > is( $patron_2->userid, $expected_userid_patron_1 . '1', # TODO we could make that configurable >- "Patron with duplicate userid has new userid generated (1 is appened" ); >+ "Patron with duplicate userid has new userid generated (1 is appended)" ); > > $new_patron->generate_userid; > $userid = $new_patron->userid; >@@ -1652,6 +1656,36 @@ subtest 'generate_userid' => sub { > # Cleanup > $patron_1->delete; > $patron_2->delete; >+ >+ # "email" should use email as userid if there is an email, otherwise fall back to firstname.surname >+ t::lib::Mocks::mock_preference( 'PatronSelfRegistrationUseridGenerationMethod', 'email' ); >+ >+ my $new_patron_email = Koha::Patron->new({ firstname => $data{firstname}, surname => $data{surname}, email => $data{email} } ); >+ $new_patron_email->generate_userid; >+ my $userid_email = $new_patron_email->userid; >+ is( $userid_email, $data{email}, 'userid should be the email address' ); >+ my $borrowernumber_email = Koha::Patron->new(\%data)->store->borrowernumber; >+ my $patron_1_email = Koha::Patrons->find($borrowernumber_email); >+ is ( $patron_1_email->userid, $data{email}, 'userid should be the email address also after storing' ); >+ >+ my $expected_userid_email_in_use = 'tomasito.none'; >+ $new_patron_email->generate_userid; >+ $userid = $new_patron_email->userid; >+ is( $userid, $expected_userid_email_in_use, 'generate_userid should default to firstname.surname if email is already in use' ); >+ >+ my $expected_userid_noemail = 'tomasito.none'; >+ my $new_patron_noemail = Koha::Patron->new({ firstname => $data{firstname}, surname => $data{surname} } ); >+ $new_patron_noemail->generate_userid; >+ my $userid_noemail = $new_patron_noemail->userid; >+ is( $userid_noemail, $expected_userid_noemail, 'generate_userid should default to firstname.surname wheren there is no email address' ); >+ delete $data{email}; >+ $data{cardnumber} = '9876543210'; >+ my $borrowernumber_noemail = Koha::Patron->new(\%data)->store->borrowernumber; >+ my $patron_2_noemail = Koha::Patrons->find($borrowernumber_noemail); >+ is ( $patron_2_noemail->userid, $expected_userid_noemail, 'generate_userid should be firstname.surname also after storing' ); >+ >+ $patron_1_email->delete; >+ $patron_2_noemail->delete; > }; > > $nb_of_patrons = Koha::Patrons->search->count; >-- >2.32.0
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 29480
:
127636
|
127679
|
142133
|
142134
| 142135 |
142136