Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 60; |
20 |
use Test::More tests => 51; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
|
23 |
|
Lines 139-145
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
Link Here
|
139 |
is ($checkcardnum, "2", "Card number is too long"); |
139 |
is ($checkcardnum, "2", "Card number is too long"); |
140 |
|
140 |
|
141 |
|
141 |
|
142 |
# Check_Userid tests |
142 |
# Add a new borrower |
143 |
%data = ( |
143 |
%data = ( |
144 |
cardnumber => "123456789", |
144 |
cardnumber => "123456789", |
145 |
firstname => "Tomasito", |
145 |
firstname => "Tomasito", |
Lines 151-167
is ($checkcardnum, "2", "Card number is too long");
Link Here
|
151 |
dateexpiry => '', |
151 |
dateexpiry => '', |
152 |
dateenrolled => '', |
152 |
dateenrolled => '', |
153 |
); |
153 |
); |
154 |
# Add a new borrower |
|
|
155 |
my $borrowernumber = AddMember( %data ); |
154 |
my $borrowernumber = AddMember( %data ); |
156 |
is( Check_Userid( 'tomasito.non', $borrowernumber ), 1, |
|
|
157 |
'recently created userid -> unique (borrowernumber passed)' ); |
158 |
is( Check_Userid( 'tomasitoxxx', $borrowernumber ), 1, |
159 |
'non-existent userid -> unique (borrowernumber passed)' ); |
160 |
is( Check_Userid( 'tomasito.none', '' ), 0, |
161 |
'userid exists (blank borrowernumber)' ); |
162 |
is( Check_Userid( 'tomasitoxxx', '' ), 1, |
163 |
'non-existent userid -> unique (blank borrowernumber)' ); |
164 |
|
165 |
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
155 |
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
166 |
is( $borrower->{dateofbirth}, undef, 'AddMember should undef dateofbirth if empty string is given'); |
156 |
is( $borrower->{dateofbirth}, undef, 'AddMember should undef dateofbirth if empty string is given'); |
167 |
is( $borrower->{debarred}, undef, 'AddMember should undef debarred if empty string is given'); |
157 |
is( $borrower->{debarred}, undef, 'AddMember should undef debarred if empty string is given'); |
Lines 182-205
is( $borrower->{debarred}, '2042-01-01', 'ModMember should correctly set debarre
Link Here
|
182 |
is( $borrower->{dateexpiry}, '9999-12-31', 'ModMember should correctly set dateexpiry if a valid date is given'); |
172 |
is( $borrower->{dateexpiry}, '9999-12-31', 'ModMember should correctly set dateexpiry if a valid date is given'); |
183 |
is( $borrower->{dateenrolled}, '2015-09-06', 'ModMember should correctly set dateenrolled if a valid date is given'); |
173 |
is( $borrower->{dateenrolled}, '2015-09-06', 'ModMember should correctly set dateenrolled if a valid date is given'); |
184 |
|
174 |
|
185 |
# Add a new borrower with the same userid but different cardnumber |
|
|
186 |
$data{ cardnumber } = "987654321"; |
187 |
my $new_borrowernumber = AddMember( %data ); |
188 |
is( Check_Userid( 'tomasito.none', '' ), 0, |
189 |
'userid not unique (blank borrowernumber)' ); |
190 |
is( Check_Userid( 'tomasito.none', $new_borrowernumber ), 0, |
191 |
'userid not unique (second borrowernumber passed)' ); |
192 |
$borrower = Koha::Patrons->find( $new_borrowernumber )->unblessed; |
193 |
ok( $borrower->{userid} ne 'tomasito', "Borrower with duplicate userid has new userid generated" ); |
194 |
|
195 |
$data{ cardnumber } = "234567890"; |
196 |
$data{userid} = 'a_user_id'; |
197 |
$borrowernumber = AddMember( %data ); |
198 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
199 |
is( $borrower->{userid}, $data{userid}, 'AddMember should insert the given userid' ); |
200 |
|
201 |
subtest 'ModMember should not update userid if not true' => sub { |
175 |
subtest 'ModMember should not update userid if not true' => sub { |
202 |
plan tests => 3; |
176 |
plan tests => 3; |
|
|
177 |
|
178 |
$data{ cardnumber } = "234567890"; |
179 |
$data{userid} = 'a_user_id'; |
180 |
$borrowernumber = AddMember( %data ); |
181 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
182 |
|
203 |
ModMember( borrowernumber => $borrowernumber, firstname => 'Tomas', userid => '' ); |
183 |
ModMember( borrowernumber => $borrowernumber, firstname => 'Tomas', userid => '' ); |
204 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
184 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
205 |
is ( $borrower->{userid}, $data{userid}, 'ModMember should not update the userid with an empty string' ); |
185 |
is ( $borrower->{userid}, $data{userid}, 'ModMember should not update the userid with an empty string' ); |
Lines 369-378
ok( $borrowernumber > 0, 'AddMember should have inserted the patron even if no u
Link Here
|
369 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
349 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
370 |
ok( $borrower->{userid}, 'A userid should have been generated correctly' ); |
350 |
ok( $borrower->{userid}, 'A userid should have been generated correctly' ); |
371 |
|
351 |
|
372 |
# Regression tests for BZ12226 |
|
|
373 |
is( Check_Userid( C4::Context->config('user'), '' ), 0, |
374 |
'Check_Userid should return 0 for the DB user (Bug 12226)'); |
375 |
|
376 |
subtest 'purgeSelfRegistration' => sub { |
352 |
subtest 'purgeSelfRegistration' => sub { |
377 |
plan tests => 2; |
353 |
plan tests => 2; |
378 |
|
354 |
|
379 |
- |
|
|