Bugzilla – Attachment 71787 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: Replace Check_userid - just move the tests
Bug-19936-Replace-Checkuserid---just-move-the-test.patch (text/plain), 6.76 KB, created by
Jonathan Druart
on 2018-02-16 14:34:13 UTC
(
hide
)
Description:
Bug 19936: Replace Check_userid - just move the tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-02-16 14:34:13 UTC
Size:
6.76 KB
patch
obsolete
>From 20609902722910597726c69482c82dbdc774ac23 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 8 Jan 2018 17:14:49 -0300 >Subject: [PATCH] Bug 19936: Replace Check_userid - just move the tests > >This patch moves the tests related to Check_userid out of Members.t >The tests must pass with only this patch applied >--- > t/db_dependent/Koha/Patrons.t | 59 +++++++++++++++++++++++++++++++++++++++++++ > t/db_dependent/Members.t | 40 ++++++----------------------- > 2 files changed, 67 insertions(+), 32 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index edda6540a6..345d0e8dd6 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1055,6 +1055,65 @@ subtest 'account_locked' => sub { > $patron->delete; > }; > >+subtest 'userid_is_valid' => sub { >+ plan tests => 9; >+ >+ 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 $borrowernumber = AddMember(%data); >+ my $patron_1 = Koha::Patrons->find($borrowernumber); >+ >+ is( Check_Userid( 'tomasito.non', $patron_1->borrowernumber ), >+ 1, 'recently created userid -> unique (borrowernumber passed)' ); >+ is( Check_Userid( 'tomasitoxxx', $patron_1->borrowernumber ), >+ 1, 'non-existent userid -> unique (borrowernumber passed)' ); >+ is( Check_Userid( 'tomasito.none', '' ), >+ 0, 'userid exists (blank borrowernumber)' ); >+ is( Check_Userid( 'tomasitoxxx', '' ), >+ 1, 'non-existent userid -> unique (blank borrowernumber)' ); >+ >+ # Regression tests for BZ12226 >+ is( Check_Userid( C4::Context->config('user'), '' ), >+ 0, 'Check_Userid should return 0 for the DB user (Bug 12226)' ); >+ >+ # Add a new borrower with the same userid but different cardnumber >+ $data{cardnumber} = "987654321"; >+ my $new_borrowernumber = AddMember(%data); >+ is( Check_Userid( 'tomasito.none', '' ), >+ 0, 'userid not unique (blank borrowernumber)' ); >+ is( Check_Userid( 'tomasito.none', $new_borrowernumber ), >+ 0, 'userid not unique (second borrowernumber passed)' ); >+ my $patron_2 = Koha::Patrons->find($new_borrowernumber); >+ ok( $patron_2->userid ne 'tomasito', >+ "Borrower with duplicate userid has new userid generated" ); >+ >+ my $new_userid = 'a_user_id'; >+ $data{cardnumber} = "234567890"; >+ $data{userid} = 'a_user_id'; >+ $borrowernumber = AddMember(%data); >+ my $patron_3 = Koha::Patrons->find($borrowernumber); >+ is( $patron_3->userid, $new_userid, >+ 'AddMember should insert the given userid' ); >+ >+ # Cleanup >+ $patron_1->delete; >+ $patron_2->delete; >+ $patron_3->delete; >+}; >+ > $retrieved_patron_1->delete; > is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); > >diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t >index ac928b2352..4e704252fe 100755 >--- a/t/db_dependent/Members.t >+++ b/t/db_dependent/Members.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 62; >+use Test::More tests => 53; > use Test::MockModule; > use Test::Exception; > >@@ -139,7 +139,7 @@ $checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, ""); > is ($checkcardnum, "2", "Card number is too long"); > > >-# Check_Userid tests >+# Add a new borrower > %data = ( > cardnumber => "123456789", > firstname => "Tomasito", >@@ -151,17 +151,7 @@ is ($checkcardnum, "2", "Card number is too long"); > dateexpiry => '', > dateenrolled => '', > ); >-# Add a new borrower > my $borrowernumber = AddMember( %data ); >-is( Check_Userid( 'tomasito.non', $borrowernumber ), 1, >- 'recently created userid -> unique (borrowernumber passed)' ); >-is( Check_Userid( 'tomasitoxxx', $borrowernumber ), 1, >- 'non-existent userid -> unique (borrowernumber passed)' ); >-is( Check_Userid( 'tomasito.none', '' ), 0, >- 'userid exists (blank borrowernumber)' ); >-is( Check_Userid( 'tomasitoxxx', '' ), 1, >- 'non-existent userid -> unique (blank borrowernumber)' ); >- > my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; > is( $borrower->{dateofbirth}, undef, 'AddMember should undef dateofbirth if empty string is given'); > is( $borrower->{debarred}, undef, 'AddMember should undef debarred if empty string is given'); >@@ -182,24 +172,14 @@ is( $borrower->{debarred}, '2042-01-01', 'ModMember should correctly set debarre > is( $borrower->{dateexpiry}, '9999-12-31', 'ModMember should correctly set dateexpiry if a valid date is given'); > is( $borrower->{dateenrolled}, '2015-09-06', 'ModMember should correctly set dateenrolled if a valid date is given'); > >-# Add a new borrower with the same userid but different cardnumber >-$data{ cardnumber } = "987654321"; >-my $new_borrowernumber = AddMember( %data ); >-is( Check_Userid( 'tomasito.none', '' ), 0, >- 'userid not unique (blank borrowernumber)' ); >-is( Check_Userid( 'tomasito.none', $new_borrowernumber ), 0, >- 'userid not unique (second borrowernumber passed)' ); >-$borrower = Koha::Patrons->find( $new_borrowernumber )->unblessed; >-ok( $borrower->{userid} ne 'tomasito', "Borrower with duplicate userid has new userid generated" ); >- >-$data{ cardnumber } = "234567890"; >-$data{userid} = 'a_user_id'; >-$borrowernumber = AddMember( %data ); >-$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; >-is( $borrower->{userid}, $data{userid}, 'AddMember should insert the given userid' ); >- > subtest 'ModMember should not update userid if not true' => sub { > plan tests => 3; >+ >+ $data{ cardnumber } = "234567890"; >+ $data{userid} = 'a_user_id'; >+ $borrowernumber = AddMember( %data ); >+ $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; >+ > ModMember( borrowernumber => $borrowernumber, firstname => 'Tomas', userid => '' ); > $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; > is ( $borrower->{userid}, $data{userid}, 'ModMember should not update the userid with an empty string' ); >@@ -369,10 +349,6 @@ ok( $borrowernumber > 0, 'AddMember should have inserted the patron even if no u > $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; > ok( $borrower->{userid}, 'A userid should have been generated correctly' ); > >-# Regression tests for BZ12226 >-is( Check_Userid( C4::Context->config('user'), '' ), 0, >- 'Check_Userid should return 0 for the DB user (Bug 12226)'); >- > subtest 'GetMemberAccountRecords' => sub { > > plan tests => 2; >-- >2.11.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 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