3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test
::More tests
=> 66;
26 use Koha
::List
::Patron
;
30 use t
::lib
::TestBuilder
;
33 use_ok
('C4::Members');
36 my $schema = Koha
::Database
->schema;
37 $schema->storage->txn_begin;
38 my $builder = t
::lib
::TestBuilder
->new;
39 my $dbh = C4
::Context
->dbh;
40 $dbh->{RaiseError
} = 1;
42 # Remove invalid guarantorid's as long as we have no FK
43 $dbh->do("UPDATE borrowers b1 LEFT JOIN borrowers b2 ON b2.borrowernumber=b1.guarantorid SET b1.guarantorid=NULL where b1.guarantorid IS NOT NULL AND b2.borrowernumber IS NULL");
45 my $library1 = $builder->build({
48 my $library2 = $builder->build({
51 my $CARDNUMBER = 'TESTCARD01';
52 my $FIRSTNAME = 'Marie';
53 my $SURNAME = 'Mcknight';
54 my $CATEGORYCODE = 'S';
55 my $BRANCHCODE = $library1->{branchcode
};
57 my $CHANGED_FIRSTNAME = "Marry Ann";
58 my $EMAIL = "Marie\@email.com";
59 my $EMAILPRO = "Marie\@work.com";
60 my $PHONE = "555-12123";
62 # XXX should be randomised and checked against the database
63 my $IMPOSSIBLE_CARDNUMBER = "XYZZZ999";
65 #my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter)= @_;
78 C4
::Context
->_new_userenv ('DUMMY_SESSION_ID');
79 C4
::Context
->set_userenv ( @USERENV );
81 my $userenv = C4
::Context
->userenv
82 or BAIL_OUT
("No userenv");
84 # Make a borrower for testing
86 cardnumber
=> $CARDNUMBER,
87 firstname
=> $FIRSTNAME,
89 categorycode
=> $CATEGORYCODE,
90 branchcode
=> $BRANCHCODE,
92 dateexpiry
=> '9999-12-31',
96 my $addmem=AddMember
(%data);
97 ok
($addmem, "AddMember()");
99 my $member=GetMemberDetails
("",$CARDNUMBER)
100 or BAIL_OUT
("Cannot read member with card $CARDNUMBER");
102 ok
( $member->{firstname
} eq $FIRSTNAME &&
103 $member->{surname
} eq $SURNAME &&
104 $member->{categorycode
} eq $CATEGORYCODE &&
105 $member->{branchcode
} eq $BRANCHCODE
107 or diag
("Mismatching member details: ".Dumper
(\
%data, $member));
109 is
($member->{dateofbirth
}, undef, "Empty dates handled correctly");
111 $member->{firstname
} = $CHANGED_FIRSTNAME;
112 $member->{email
} = $EMAIL;
113 $member->{phone
} = $PHONE;
114 $member->{emailpro
} = $EMAILPRO;
116 my $changedmember=GetMemberDetails
("",$CARDNUMBER);
117 ok
( $changedmember->{firstname
} eq $CHANGED_FIRSTNAME &&
118 $changedmember->{email
} eq $EMAIL &&
119 $changedmember->{phone
} eq $PHONE &&
120 $changedmember->{emailpro
} eq $EMAILPRO
122 or diag
("Mismatching member details: ".Dumper
($member, $changedmember));
124 t
::lib
::Mocks
::mock_preference
( 'CardnumberLength', '' );
125 C4
::Context
->clear_syspref_cache();
127 my $checkcardnum=C4
::Members
::checkcardnumber
($CARDNUMBER, "");
128 is
($checkcardnum, "1", "Card No. in use");
130 $checkcardnum=C4
::Members
::checkcardnumber
($IMPOSSIBLE_CARDNUMBER, "");
131 is
($checkcardnum, "0", "Card No. not used");
133 t
::lib
::Mocks
::mock_preference
( 'CardnumberLength', '4' );
134 C4
::Context
->clear_syspref_cache();
136 $checkcardnum=C4
::Members
::checkcardnumber
($IMPOSSIBLE_CARDNUMBER, "");
137 is
($checkcardnum, "2", "Card number is too long");
141 t
::lib
::Mocks
::mock_preference
( 'AutoEmailPrimaryAddress', 'OFF' );
142 C4
::Context
->clear_syspref_cache();
144 my $notice_email = GetNoticeEmailAddress
($member->{'borrowernumber'});
145 is
($notice_email, $EMAIL, "GetNoticeEmailAddress returns correct value when AutoEmailPrimaryAddress is off");
147 t
::lib
::Mocks
::mock_preference
( 'AutoEmailPrimaryAddress', 'emailpro' );
148 C4
::Context
->clear_syspref_cache();
150 $notice_email = GetNoticeEmailAddress
($member->{'borrowernumber'});
151 is
($notice_email, $EMAILPRO, "GetNoticeEmailAddress returns correct value when AutoEmailPrimaryAddress is emailpro");
153 ok
(!$member->{is_expired
}, "GetMemberDetails() indicates that patron is not expired");
154 ModMember
(borrowernumber
=> $member->{'borrowernumber'}, dateexpiry
=> '2001-01-1');
155 $member = GetMemberDetails
($member->{'borrowernumber'});
156 ok
($member->{is_expired
}, "GetMemberDetails() indicates that patron is expired");
160 cardnumber
=> "123456789",
161 firstname
=> "Tomasito",
164 branchcode
=> $library2->{branchcode
},
171 my $borrowernumber = AddMember
( %data );
172 is
( Check_Userid
( 'tomasito.non', $borrowernumber ), 1,
173 'recently created userid -> unique (borrowernumber passed)' );
174 is
( Check_Userid
( 'tomasitoxxx', $borrowernumber ), 1,
175 'non-existent userid -> unique (borrowernumber passed)' );
176 is
( Check_Userid
( 'tomasito.none', '' ), 0,
177 'userid exists (blank borrowernumber)' );
178 is
( Check_Userid
( 'tomasitoxxx', '' ), 1,
179 'non-existent userid -> unique (blank borrowernumber)' );
181 my $borrower = GetMember
( borrowernumber
=> $borrowernumber );
182 is
( $borrower->{dateofbirth
}, undef, 'AddMember should undef dateofbirth if empty string is given');
183 is
( $borrower->{debarred
}, undef, 'AddMember should undef debarred if empty string is given');
184 isnt
( $borrower->{dateexpiry
}, '0000-00-00', 'AddMember should not set dateexpiry to 0000-00-00 if empty string is given');
185 isnt
( $borrower->{dateenrolled
}, '0000-00-00', 'AddMember should not set dateenrolled to 0000-00-00 if empty string is given');
187 ModMember
( borrowernumber
=> $borrowernumber, dateofbirth
=> '', debarred
=> '', dateexpiry
=> '', dateenrolled
=> '' );
188 $borrower = GetMember
( borrowernumber
=> $borrowernumber );
189 is
( $borrower->{dateofbirth
}, undef, 'ModMember should undef dateofbirth if empty string is given');
190 is
( $borrower->{debarred
}, undef, 'ModMember should undef debarred if empty string is given');
191 isnt
( $borrower->{dateexpiry
}, '0000-00-00', 'ModMember should not set dateexpiry to 0000-00-00 if empty string is given');
192 isnt
( $borrower->{dateenrolled
}, '0000-00-00', 'ModMember should not set dateenrolled to 0000-00-00 if empty string is given');
194 ModMember
( borrowernumber
=> $borrowernumber, dateofbirth
=> '1970-01-01', debarred
=> '2042-01-01', dateexpiry
=> '9999-12-31', dateenrolled
=> '2015-09-06' );
195 $borrower = GetMember
( borrowernumber
=> $borrowernumber );
196 is
( $borrower->{dateofbirth
}, '1970-01-01', 'ModMember should correctly set dateofbirth if a valid date is given');
197 is
( $borrower->{debarred
}, '2042-01-01', 'ModMember should correctly set debarred if a valid date is given');
198 is
( $borrower->{dateexpiry
}, '9999-12-31', 'ModMember should correctly set dateexpiry if a valid date is given');
199 is
( $borrower->{dateenrolled
}, '2015-09-06', 'ModMember should correctly set dateenrolled if a valid date is given');
201 # Add a new borrower with the same userid but different cardnumber
202 $data{ cardnumber
} = "987654321";
203 my $new_borrowernumber = AddMember
( %data );
204 is
( Check_Userid
( 'tomasito.none', '' ), 0,
205 'userid not unique (blank borrowernumber)' );
206 is
( Check_Userid
( 'tomasito.none', $new_borrowernumber ), 0,
207 'userid not unique (second borrowernumber passed)' );
208 $borrower = GetMember
( borrowernumber
=> $new_borrowernumber );
209 ok
( $borrower->{userid
} ne 'tomasito', "Borrower with duplicate userid has new userid generated" );
211 $data{ cardnumber
} = "234567890";
212 $data{userid
} = 'a_user_id';
213 $borrowernumber = AddMember
( %data );
214 $borrower = GetMember
( borrowernumber
=> $borrowernumber );
215 is
( $borrower->{userid
}, $data{userid
}, 'AddMember should insert the given userid' );
217 subtest
'ModMember should not update userid if not true' => sub {
219 ModMember
( borrowernumber
=> $borrowernumber, firstname
=> 'Tomas', userid
=> '' );
220 $borrower = GetMember
( borrowernumber
=> $borrowernumber );
221 is
( $borrower->{userid
}, $data{userid
}, 'ModMember should not update the userid with an empty string' );
222 ModMember
( borrowernumber
=> $borrowernumber, firstname
=> 'Tomas', userid
=> 0 );
223 $borrower = GetMember
( borrowernumber
=> $borrowernumber );
224 is
( $borrower->{userid
}, $data{userid
}, 'ModMember should not update the userid with an 0');
225 ModMember
( borrowernumber
=> $borrowernumber, firstname
=> 'Tomas', userid
=> undef );
226 $borrower = GetMember
( borrowernumber
=> $borrowernumber );
227 is
( $borrower->{userid
}, $data{userid
}, 'ModMember should not update the userid with an undefined value');
230 #Regression tests for bug 10612
231 my $library3 = $builder->build({
235 source
=> 'Category',
237 categorycode
=> 'STAFFER',
238 description
=> 'Staff dont batch del',
239 category_type
=> 'S',
244 source
=> 'Category',
246 categorycode
=> 'CIVILIAN',
247 description
=> 'Civilian batch del',
248 category_type
=> 'A',
253 source
=> 'Category',
255 categorycode
=> 'KIDclamp',
256 description
=> 'Kid to be guaranteed',
257 category_type
=> 'C',
261 my $borrower1 = $builder->build({
262 source
=> 'Borrower',
264 categorycode
=>'STAFFER',
265 branchcode
=> $library3->{branchcode
},
266 dateexpiry
=> '2015-01-01',
270 my $bor1inlist = $borrower1->{borrowernumber
};
271 my $borrower2 = $builder->build({
272 source
=> 'Borrower',
274 categorycode
=>'STAFFER',
275 branchcode
=> $library3->{branchcode
},
276 dateexpiry
=> '2015-01-01',
281 my $guarantee = $builder->build({
282 source
=> 'Borrower',
284 categorycode
=>'KIDclamp',
285 branchcode
=> $library3->{branchcode
},
286 dateexpiry
=> '2015-01-01',
287 guarantorid
=> undef, # will be filled later
291 my $bor2inlist = $borrower2->{borrowernumber
};
294 source
=> 'OldIssue',
296 borrowernumber
=> $bor2inlist,
297 timestamp
=> '2016-01-01',
301 my $owner = AddMember
(categorycode
=> 'STAFFER', branchcode
=> $library2->{branchcode
} );
302 my $list1 = AddPatronList
( { name
=> 'Test List 1', owner
=> $owner } );
303 my @listpatrons = ($bor1inlist, $bor2inlist);
304 AddPatronsToList
( { list
=> $list1, borrowernumbers
=> \
@listpatrons });
305 my $patstodel = GetBorrowersToExpunge
( {patron_list_id
=> $list1->patron_list_id() } );
306 is
( scalar(@
$patstodel),0,'No staff deleted from list of all staff');
307 ModMember
( borrowernumber
=> $bor2inlist, categorycode
=> 'CIVILIAN' );
308 $patstodel = GetBorrowersToExpunge
( {patron_list_id
=> $list1->patron_list_id()} );
309 ok
( scalar(@
$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted from list');
310 $patstodel = GetBorrowersToExpunge
( {branchcode
=> $library3->{branchcode
},patron_list_id
=> $list1->patron_list_id() } );
311 ok
( scalar(@
$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by branchcode and list');
312 $patstodel = GetBorrowersToExpunge
( {expired_before
=> '2015-01-02', patron_list_id
=> $list1->patron_list_id() } );
313 ok
( scalar(@
$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by expirationdate and list');
314 $patstodel = GetBorrowersToExpunge
( {not_borrowed_since
=> '2016-01-02', patron_list_id
=> $list1->patron_list_id() } );
315 ok
( scalar(@
$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date');
317 ModMember
( borrowernumber
=> $bor1inlist, categorycode
=> 'CIVILIAN' );
318 ModMember
( borrowernumber
=> $guarantee->{borrowernumber
} ,guarantorid
=>$bor1inlist );
320 $patstodel = GetBorrowersToExpunge
( {patron_list_id
=> $list1->patron_list_id()} );
321 ok
( scalar(@
$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted from list');
322 $patstodel = GetBorrowersToExpunge
( {branchcode
=> $library3->{branchcode
},patron_list_id
=> $list1->patron_list_id() } );
323 ok
( scalar(@
$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by branchcode and list');
324 $patstodel = GetBorrowersToExpunge
( {expired_before
=> '2015-01-02', patron_list_id
=> $list1->patron_list_id() } );
325 ok
( scalar(@
$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by expirationdate and list');
326 $patstodel = GetBorrowersToExpunge
( {not_borrowed_since
=> '2016-01-02', patron_list_id
=> $list1->patron_list_id() } );
327 ok
( scalar(@
$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by last issue date');
328 ModMember
( borrowernumber
=> $guarantee->{borrowernumber
}, guarantorid
=>'' );
333 borrowernumber
=> $bor2inlist,
336 $patstodel = GetBorrowersToExpunge
( {patron_list_id
=> $list1->patron_list_id()} );
337 is
( scalar(@
$patstodel),1,'Borrower with issue not deleted from list');
338 $patstodel = GetBorrowersToExpunge
( {branchcode
=> $library3->{branchcode
},patron_list_id
=> $list1->patron_list_id() } );
339 is
( scalar(@
$patstodel),1,'Borrower with issue not deleted by branchcode and list');
340 $patstodel = GetBorrowersToExpunge
( {category_code
=> 'CIVILIAN',patron_list_id
=> $list1->patron_list_id() } );
341 is
( scalar(@
$patstodel),1,'Borrower with issue not deleted by category_code and list');
342 $patstodel = GetBorrowersToExpunge
( {expired_before
=> '2015-01-02',patron_list_id
=> $list1->patron_list_id() } );
343 is
( scalar(@
$patstodel),1,'Borrower with issue not deleted by expiration_date and list');
344 $builder->schema->resultset( 'Issue' )->delete_all;
345 $patstodel = GetBorrowersToExpunge
( {patron_list_id
=> $list1->patron_list_id()} );
346 ok
( scalar(@
$patstodel)== 2,'Borrowers without issue deleted from list');
347 $patstodel = GetBorrowersToExpunge
( {category_code
=> 'CIVILIAN',patron_list_id
=> $list1->patron_list_id() } );
348 is
( scalar(@
$patstodel),2,'Borrowers without issues deleted by category_code and list');
349 $patstodel = GetBorrowersToExpunge
( {expired_before
=> '2015-01-02',patron_list_id
=> $list1->patron_list_id() } );
350 is
( scalar(@
$patstodel),2,'Borrowers without issues deleted by expiration_date and list');
351 $patstodel = GetBorrowersToExpunge
( {not_borrowed_since
=> '2016-01-02', patron_list_id
=> $list1->patron_list_id() } );
352 is
( scalar(@
$patstodel),2,'Borrowers without issues deleted by last issue date');
354 # Test GetBorrowersToExpunge and TrackLastPatronActivity
355 $dbh->do(q
|UPDATE borrowers SET lastseen
=NULL
|);
356 $builder->build({ source
=> 'Borrower', value
=> { lastseen
=> '2016-01-01 01:01:01', categorycode
=> 'CIVILIAN', guarantorid
=> undef } } );
357 $builder->build({ source
=> 'Borrower', value
=> { lastseen
=> '2016-02-02 02:02:02', categorycode
=> 'CIVILIAN', guarantorid
=> undef } } );
358 $builder->build({ source
=> 'Borrower', value
=> { lastseen
=> '2016-03-03 03:03:03', categorycode
=> 'CIVILIAN', guarantorid
=> undef } } );
359 $patstodel = GetBorrowersToExpunge
( { last_seen
=> '1999-12-12' });
360 is
( scalar @
$patstodel, 0, 'TrackLastPatronActivity - 0 patrons must be deleted' );
361 $patstodel = GetBorrowersToExpunge
( { last_seen
=> '2016-02-15' });
362 is
( scalar @
$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' );
363 $patstodel = GetBorrowersToExpunge
( { last_seen
=> '2016-04-04' });
364 is
( scalar @
$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' );
365 my $patron2 = $builder->build({ source
=> 'Borrower', value
=> { lastseen
=> undef } });
366 t
::lib
::Mocks
::mock_preference
( 'TrackLastPatronActivity', '0' );
367 Koha
::Patrons
->find( $patron2->{borrowernumber
} )->track_login;
368 is
( Koha
::Patrons
->find( $patron2->{borrowernumber
} )->lastseen, undef, 'Lastseen should not be changed' );
369 Koha
::Patrons
->find( $patron2->{borrowernumber
} )->track_login({ force
=> 1 });
370 isnt
( Koha
::Patrons
->find( $patron2->{borrowernumber
} )->lastseen, undef, 'Lastseen should be changed now' );
372 # Regression tests for BZ13502
373 ## Remove all entries with userid='' (should be only 1 max)
374 $dbh->do(q
|DELETE FROM borrowers WHERE userid
= ''|);
375 ## And create a patron with a userid=''
376 $borrowernumber = AddMember
( categorycode
=> 'S', branchcode
=> $library2->{branchcode
} );
377 $dbh->do(q
|UPDATE borrowers SET userid
= '' WHERE borrowernumber
= ?
|, undef, $borrowernumber);
378 # Create another patron and verify the userid has been generated
379 $borrowernumber = AddMember
( categorycode
=> 'S', branchcode
=> $library2->{branchcode
} );
380 ok
( $borrowernumber > 0, 'AddMember should have inserted the patron even if no userid is given' );
381 $borrower = GetMember
( borrowernumber
=> $borrowernumber );
382 ok
( $borrower->{userid
}, 'A userid should have been generated correctly' );
384 # Regression tests for BZ12226
385 is
( Check_Userid
( C4
::Context
->config('user'), '' ), 0,
386 'Check_Userid should return 0 for the DB user (Bug 12226)');
388 subtest
'GetMemberAccountRecords' => sub {
392 my $borrowernumber = $builder->build({ source
=> 'Borrower' })->{ borrowernumber
};
393 my $accountline_1 = $builder->build({
394 source
=> 'Accountline',
396 borrowernumber
=> $borrowernumber,
397 amountoutstanding
=> 64.60
401 my ($total,undef,undef) = GetMemberAccountRecords
( $borrowernumber );
402 is
( $total , 64.60, "Rounding works correctly in total calculation (single value)" );
404 my $accountline_2 = $builder->build({
405 source
=> 'Accountline',
407 borrowernumber
=> $borrowernumber,
408 amountoutstanding
=> 10.65
412 ($total,undef,undef) = GetMemberAccountRecords
( $borrowernumber );
413 is
( $total , 75.25, "Rounding works correctly in total calculation (multiple values)" );
417 subtest
'GetMemberAccountBalance' => sub {
421 my $members_mock = new Test
::MockModule
('C4::Members');
422 $members_mock->mock( 'GetMemberAccountRecords', sub {
423 my ($borrowernumber) = @_;
424 if ($borrowernumber) {
426 { amountoutstanding
=> '7', accounttype
=> 'Rent' },
427 { amountoutstanding
=> '5', accounttype
=> 'Res' },
428 { amountoutstanding
=> '3', accounttype
=> 'Pay' } );
429 return ( 15, \
@accountlines );
433 return ( 0, \
@accountlines );
437 my $person = GetMemberDetails
(undef,undef);
438 ok
( !$person , 'Expected no member details from undef,undef' );
439 $person = GetMemberDetails
(undef,'987654321');
440 is
( $person->{amountoutstanding
}, 15,
441 'Expected 15 outstanding for cardnumber.');
442 $borrowernumber = $person->{borrowernumber
};
443 $person = GetMemberDetails
($borrowernumber,undef);
444 is
( $person->{amountoutstanding
}, 15,
445 'Expected 15 outstanding for borrowernumber.');
446 $person = GetMemberDetails
($borrowernumber,'987654321');
447 is
( $person->{amountoutstanding
}, 15,
448 'Expected 15 outstanding for both borrowernumber and cardnumber.');
450 # do not count holds charges
451 t
::lib
::Mocks
::mock_preference
( 'HoldsInNoissuesCharge', '1' );
452 t
::lib
::Mocks
::mock_preference
( 'ManInvInNoissuesCharge', '0' );
453 my ($total, $total_minus_charges,
454 $other_charges) = C4
::Members
::GetMemberAccountBalance
(123);
455 is
( $total, 15 , "Total calculated correctly");
456 is
( $total_minus_charges, 15, "Holds charges are not count if HoldsInNoissuesCharge=1");
457 is
( $other_charges, 0, "Holds charges are not considered if HoldsInNoissuesCharge=1");
459 t
::lib
::Mocks
::mock_preference
( 'HoldsInNoissuesCharge', '0' );
460 ($total, $total_minus_charges,
461 $other_charges) = C4
::Members
::GetMemberAccountBalance
(123);
462 is
( $total, 15 , "Total calculated correctly");
463 is
( $total_minus_charges, 10, "Holds charges are count if HoldsInNoissuesCharge=0");
464 is
( $other_charges, 5, "Holds charges are considered if HoldsInNoissuesCharge=1");
467 subtest
'purgeSelfRegistration' => sub {
472 C4
::Members
::DeleteUnverifiedOpacRegistrations
($d);
474 $dbh->do("INSERT INTO borrower_modifications (timestamp, borrowernumber, verification_token) VALUES ('2014-01-01 01:02:03',0,?)", undef, (scalar localtime)."_$_");
476 is
( C4
::Members
::DeleteUnverifiedOpacRegistrations
($d), 3, 'Test for DeleteUnverifiedOpacRegistrations' );
478 #purge members in temporary category
480 $dbh->do("INSERT IGNORE INTO categories (categorycode) VALUES ('$c')");
481 t
::lib
::Mocks
::mock_preference
('PatronSelfRegistrationDefaultCategory', $c );
482 t
::lib
::Mocks
::mock_preference
('PatronSelfRegistrationExpireTemporaryAccountsDelay', 360);
483 C4
::Members
::DeleteExpiredOpacRegistrations
();
484 $dbh->do("INSERT INTO borrowers (surname, address, city, branchcode, categorycode, dateenrolled) VALUES ('Testaabbcc', 'Street 1', 'CITY', ?, '$c', '2014-01-01 01:02:03')", undef, $library1->{branchcode
});
485 is
( C4
::Members
::DeleteExpiredOpacRegistrations
(), 1, 'Test for DeleteExpiredOpacRegistrations');
489 my ($resultset) = @_;
490 my $found = $resultset && grep( { $_->{cardnumber
} && $_->{cardnumber
} eq $CARDNUMBER } @
$resultset );
494 # Regression tests for BZ15343
496 ( $borrowernumber, $password ) = AddMember_Opac
(surname
=>"Dick",firstname
=>'Philip',branchcode
=> $library2->{branchcode
});
497 is
( $password =~ /^[a-zA-Z]{10}$/ , 1, 'Test for autogenerated password if none submitted');
498 ( $borrowernumber, $password ) = AddMember_Opac
(surname
=>"Deckard",firstname
=>"Rick",password
=>"Nexus-6",branchcode
=> $library2->{branchcode
});
499 is
( $password eq "Nexus-6", 1, 'Test password used if submitted');
500 $borrower = GetMember
(borrowernumber
=> $borrowernumber);
501 my $hashed_up = Koha
::AuthUtils
::hash_password
("Nexus-6", $borrower->{password
});
502 is
( $borrower->{password
} eq $hashed_up, 1, 'Check password hash equals hash of submitted password' );
504 # regression test for bug 16009
507 my $patron = GetMember
(cardnumber
=> undef);
509 is
($@
, '', 'Bug 16009: GetMember(cardnumber => undef) works');
510 is
($patron, undef, 'Bug 16009: GetMember(cardnumber => undef) returns undef');