Bugzilla – Attachment 73967 Details for
Bug 19936
Move Check_userid and Generate_Userid to Koha::Patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19936: Move and add tests for Generate_Userid
Bug-19936-Move-and-add-tests-for-GenerateUserid.patch (text/plain), 3.77 KB, created by
Josef Moravec
on 2018-04-10 21:37:54 UTC
(
hide
)
Description:
Bug 19936: Move and add tests for Generate_Userid
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2018-04-10 21:37:54 UTC
Size:
3.77 KB
patch
obsolete
>From b82fa2deefc344a064419efd5a14117d0939a9a9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 8 Jan 2018 18:35:58 -0300 >Subject: [PATCH] Bug 19936: Move and add tests for Generate_Userid > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > t/db_dependent/Koha/Patrons.t | 54 ++++++++++++++++++++++++++++++++++++------- > 1 file changed, 46 insertions(+), 8 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index a26dc9f..a279a80 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 28; >+use Test::More tests => 29; > use Test::Warn; > use Time::Fake; > use DateTime; >@@ -1198,7 +1198,7 @@ subtest 'get_overdues' => sub { > }; > > subtest 'userid_is_valid' => sub { >- plan tests => 10; >+ plan tests => 8; > > my $library = $builder->build_object( { class => 'Koha::Libraries' } ); > my $patron_category = $builder->build_object( >@@ -1250,12 +1250,6 @@ subtest 'userid_is_valid' => sub { > is( $patron_2->has_valid_userid, > 0, 'The userid is already in used, it cannot be used for another patron' ); > >- $patron_2 = Koha::Patrons->find($new_borrowernumber); >- 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" ); >- > my $new_userid = 'a_user_id'; > $data{cardnumber} = "234567890"; > $data{userid} = 'a_user_id'; >@@ -1270,6 +1264,50 @@ subtest 'userid_is_valid' => sub { > $patron_3->delete; > }; > >+subtest 'generate_userid' => sub { >+ plan tests => 6; >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $patron_category = $builder->build_object( >+ { >+ class => 'Koha::Patron::Categories', >+ value => { category_type => 'P', enrolmentfee => 0 } >+ } >+ ); >+ my %data = ( >+ cardnumber => "123456789", >+ firstname => "Tomasito", >+ surname => "None", >+ categorycode => $patron_category->categorycode, >+ branchcode => $library->branchcode, >+ ); >+ >+ my $expected_userid_patron_1 = 'tomasito.none'; >+ my $userid = C4::Members::Generate_Userid( undef, $data{firstname}, $data{surname} ); >+ is( $userid, $expected_userid_patron_1, 'Generate_Userid should generate the userid we expect' ); >+ my $borrowernumber = AddMember(%data); >+ my $patron_1 = Koha::Patrons->find($borrowernumber); >+ is ( $patron_1->userid, $expected_userid_patron_1, 'The userid generated should be the one we expect' ); >+ >+ $userid = C4::Members::Generate_Userid( $borrowernumber, $data{firstname}, $data{surname} ); >+ is( $userid, $expected_userid_patron_1 . '1', 'Generate_Userid should generate the userid we expect' ); >+ $data{cardnumber} = '987654321'; >+ my $new_borrowernumber = AddMember(%data); >+ my $patron_2 = Koha::Patrons->find($new_borrowernumber); >+ 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" ); >+ >+ $userid = C4::Members::Generate_Userid( $borrowernumber, $data{firstname}, $data{surname} ); >+ is( $userid, $expected_userid_patron_1 . '2', 'Generate_Userid should generate the userid we expect' ); >+ >+ # Cleanup >+ $patron_1->delete; >+ $patron_2->delete; >+}; >+ >+ > $retrieved_patron_1->delete; > is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); > >-- >2.1.4
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 19936
:
70365
|
70366
|
70367
|
70368
|
70369
|
70370
|
70371
|
70372
|
70373
|
70374
|
71787
|
71788
|
71789
|
71790
|
71791
|
71792
|
71793
|
71794
|
71795
|
71796
|
72129
|
72130
|
72131
|
72132
|
72133
|
72134
|
72135
|
72136
|
72137
|
72138
|
72139
|
72140
|
72141
|
72142
|
72143
|
72144
|
72145
|
72146
|
72147
|
72148
|
72149
|
72150
|
72151
|
72152
|
73630
|
73631
|
73632
|
73633
|
73634
|
73635
|
73636
|
73637
|
73638
|
73639
|
73640
|
73641
|
73963
|
73964
|
73965
|
73966
|
73967
|
73968
|
73969
|
73970
|
73971
|
73972
|
73973
|
73974
|
74071
|
74072
|
74073
|
74074
|
74075
|
74076
|
74077
|
74078
|
74079
|
74080
|
74081
|
74082