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 => 63;
22 use Data::Dumper qw/Dumper/;
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;
41 # Remove invalid guarantorid's as long as we have no FK
42 $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");
44 my $library1 = $builder->build({
47 my $library2 = $builder->build({
50 my $patron_category = $builder->build({ source => 'Category' });
51 my $CARDNUMBER = 'TESTCARD01';
52 my $FIRSTNAME = 'Marie';
53 my $SURNAME = 'Mcknight';
54 my $BRANCHCODE = $library1->{branchcode};
56 my $CHANGED_FIRSTNAME = "Marry Ann";
57 my $EMAIL = "Marie\@email.com";
58 my $EMAILPRO = "Marie\@work.com";
59 my $PHONE = "555-12123";
61 # XXX should be randomised and checked against the database
62 my $IMPOSSIBLE_CARDNUMBER = "XYZZZ999";
64 #my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter)= @_;
77 C4::Context->_new_userenv ('DUMMY_SESSION_ID');
78 C4::Context->set_userenv ( @USERENV );
80 my $userenv = C4::Context->userenv
81 or BAIL_OUT("No userenv");
83 # Make a borrower for testing
85 cardnumber => $CARDNUMBER,
86 firstname => $FIRSTNAME . q{ },
88 categorycode => $patron_category->{categorycode},
89 branchcode => $BRANCHCODE,
91 dateexpiry => '9999-12-31',
95 my $addmem=AddMember(%data);
96 ok($addmem, "AddMember()");
98 my $member = Koha::Patrons->find( { cardnumber => $CARDNUMBER } )
99 or BAIL_OUT("Cannot read member with card $CARDNUMBER");
100 $member = $member->unblessed;
102 ok ( $member->{firstname} eq $FIRSTNAME &&
103 $member->{surname} eq $SURNAME &&
104 $member->{categorycode} eq $patron_category->{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 . q{ };
112 $member->{email} = $EMAIL;
113 $member->{phone} = $PHONE;
114 $member->{emailpro} = $EMAILPRO;
116 my $changedmember = Koha::Patrons->find( { cardnumber => $CARDNUMBER } )->unblessed;
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");
155 cardnumber => "123456789",
156 firstname => "Tomasito",
158 categorycode => $patron_category->{categorycode},
159 branchcode => $library2->{branchcode},
166 my $borrowernumber = AddMember( %data );
167 is( Check_Userid( 'tomasito.non', $borrowernumber ), 1,
168 'recently created userid -> unique (borrowernumber passed)' );
169 is( Check_Userid( 'tomasitoxxx', $borrowernumber ), 1,
170 'non-existent userid -> unique (borrowernumber passed)' );
171 is( Check_Userid( 'tomasito.none', '' ), 0,
172 'userid exists (blank borrowernumber)' );
173 is( Check_Userid( 'tomasitoxxx', '' ), 1,
174 'non-existent userid -> unique (blank borrowernumber)' );
176 my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
177 is( $borrower->{dateofbirth}, undef, 'AddMember should undef dateofbirth if empty string is given');
178 is( $borrower->{debarred}, undef, 'AddMember should undef debarred if empty string is given');
179 isnt( $borrower->{dateexpiry}, '0000-00-00', 'AddMember should not set dateexpiry to 0000-00-00 if empty string is given');
180 isnt( $borrower->{dateenrolled}, '0000-00-00', 'AddMember should not set dateenrolled to 0000-00-00 if empty string is given');
182 ModMember( borrowernumber => $borrowernumber, dateofbirth => '', debarred => '', dateexpiry => '', dateenrolled => '' );
183 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
184 is( $borrower->{dateofbirth}, undef, 'ModMember should undef dateofbirth if empty string is given');
185 is( $borrower->{debarred}, undef, 'ModMember should undef debarred if empty string is given');
186 isnt( $borrower->{dateexpiry}, '0000-00-00', 'ModMember should not set dateexpiry to 0000-00-00 if empty string is given');
187 isnt( $borrower->{dateenrolled}, '0000-00-00', 'ModMember should not set dateenrolled to 0000-00-00 if empty string is given');
189 ModMember( borrowernumber => $borrowernumber, dateofbirth => '1970-01-01', debarred => '2042-01-01', dateexpiry => '9999-12-31', dateenrolled => '2015-09-06' );
190 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
191 is( $borrower->{dateofbirth}, '1970-01-01', 'ModMember should correctly set dateofbirth if a valid date is given');
192 is( $borrower->{debarred}, '2042-01-01', 'ModMember should correctly set debarred if a valid date is given');
193 is( $borrower->{dateexpiry}, '9999-12-31', 'ModMember should correctly set dateexpiry if a valid date is given');
194 is( $borrower->{dateenrolled}, '2015-09-06', 'ModMember should correctly set dateenrolled if a valid date is given');
196 # Add a new borrower with the same userid but different cardnumber
197 $data{ cardnumber } = "987654321";
198 my $new_borrowernumber = AddMember( %data );
199 is( Check_Userid( 'tomasito.none', '' ), 0,
200 'userid not unique (blank borrowernumber)' );
201 is( Check_Userid( 'tomasito.none', $new_borrowernumber ), 0,
202 'userid not unique (second borrowernumber passed)' );
203 $borrower = Koha::Patrons->find( $new_borrowernumber )->unblessed;
204 ok( $borrower->{userid} ne 'tomasito', "Borrower with duplicate userid has new userid generated" );
206 $data{ cardnumber } = "234567890";
207 $data{userid} = 'a_user_id';
208 $borrowernumber = AddMember( %data );
209 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
210 is( $borrower->{userid}, $data{userid}, 'AddMember should insert the given userid' );
212 subtest 'ModMember should not update userid if not true' => sub {
214 ModMember( borrowernumber => $borrowernumber, firstname => 'Tomas', userid => '' );
215 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
216 is ( $borrower->{userid}, $data{userid}, 'ModMember should not update the userid with an empty string' );
217 ModMember( borrowernumber => $borrowernumber, firstname => 'Tomas', userid => 0 );
218 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
219 is ( $borrower->{userid}, $data{userid}, 'ModMember should not update the userid with an 0');
220 ModMember( borrowernumber => $borrowernumber, firstname => 'Tomas', userid => undef );
221 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
222 is ( $borrower->{userid}, $data{userid}, 'ModMember should not update the userid with an undefined value');
225 #Regression tests for bug 10612
226 my $library3 = $builder->build({
230 source => 'Category',
232 categorycode => 'STAFFER',
233 description => 'Staff dont batch del',
234 category_type => 'S',
239 source => 'Category',
241 categorycode => 'CIVILIAN',
242 description => 'Civilian batch del',
243 category_type => 'A',
248 source => 'Category',
250 categorycode => 'KIDclamp',
251 description => 'Kid to be guaranteed',
252 category_type => 'C',
256 my $borrower1 = $builder->build({
257 source => 'Borrower',
259 categorycode=>'STAFFER',
260 branchcode => $library3->{branchcode},
261 dateexpiry => '2015-01-01',
265 my $bor1inlist = $borrower1->{borrowernumber};
266 my $borrower2 = $builder->build({
267 source => 'Borrower',
269 categorycode=>'STAFFER',
270 branchcode => $library3->{branchcode},
271 dateexpiry => '2015-01-01',
276 my $guarantee = $builder->build({
277 source => 'Borrower',
279 categorycode=>'KIDclamp',
280 branchcode => $library3->{branchcode},
281 dateexpiry => '2015-01-01',
282 guarantorid=> undef, # will be filled later
286 my $bor2inlist = $borrower2->{borrowernumber};
289 source => 'OldIssue',
291 borrowernumber => $bor2inlist,
292 timestamp => '2016-01-01',
296 # The following calls to GetBorrowersToExpunge are assuming that the pref
297 # IndependentBranches is off.
298 t::lib::Mocks::mock_preference('IndependentBranches', 0);
300 my $owner = AddMember (categorycode => 'STAFFER', branchcode => $library2->{branchcode} );
301 my $list1 = AddPatronList( { name => 'Test List 1', owner => $owner } );
302 my @listpatrons = ($bor1inlist, $bor2inlist);
303 AddPatronsToList( { list => $list1, borrowernumbers => \@listpatrons });
304 my $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id() } );
305 is( scalar(@$patstodel),0,'No staff deleted from list of all staff');
306 ModMember( borrowernumber => $bor2inlist, categorycode => 'CIVILIAN' );
307 $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} );
308 ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted from list');
309 $patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } );
310 ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by branchcode and list');
311 $patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list_id => $list1->patron_list_id() } );
312 ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by expirationdate and list');
313 $patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
314 ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date');
316 ModMember( borrowernumber => $bor1inlist, categorycode => 'CIVILIAN' );
317 ModMember( borrowernumber => $guarantee->{borrowernumber} ,guarantorid=>$bor1inlist );
319 $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} );
320 ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted from list');
321 $patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } );
322 ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by branchcode and list');
323 $patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list_id => $list1->patron_list_id() } );
324 ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by expirationdate and list');
325 $patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
326 ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by last issue date');
327 ModMember( borrowernumber => $guarantee->{borrowernumber}, guarantorid=>'' );
332 borrowernumber => $bor2inlist,
335 $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} );
336 is( scalar(@$patstodel),1,'Borrower with issue not deleted from list');
337 $patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } );
338 is( scalar(@$patstodel),1,'Borrower with issue not deleted by branchcode and list');
339 $patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id => $list1->patron_list_id() } );
340 is( scalar(@$patstodel),1,'Borrower with issue not deleted by category_code and list');
341 $patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } );
342 is( scalar(@$patstodel),1,'Borrower with issue not deleted by expiration_date and list');
343 $builder->schema->resultset( 'Issue' )->delete_all;
344 $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} );
345 ok( scalar(@$patstodel)== 2,'Borrowers without issue deleted from list');
346 $patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id => $list1->patron_list_id() } );
347 is( scalar(@$patstodel),2,'Borrowers without issues deleted by category_code and list');
348 $patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } );
349 is( scalar(@$patstodel),2,'Borrowers without issues deleted by expiration_date and list');
350 $patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
351 is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date');
353 # Test GetBorrowersToExpunge and TrackLastPatronActivity
354 $dbh->do(q|UPDATE borrowers SET lastseen=NULL|);
355 $builder->build({ source => 'Borrower', value => { lastseen => '2016-01-01 01:01:01', categorycode => 'CIVILIAN', guarantorid => undef } } );
356 $builder->build({ source => 'Borrower', value => { lastseen => '2016-02-02 02:02:02', categorycode => 'CIVILIAN', guarantorid => undef } } );
357 $builder->build({ source => 'Borrower', value => { lastseen => '2016-03-03 03:03:03', categorycode => 'CIVILIAN', guarantorid => undef } } );
358 $patstodel = GetBorrowersToExpunge( { last_seen => '1999-12-12' });
359 is( scalar @$patstodel, 0, 'TrackLastPatronActivity - 0 patrons must be deleted' );
360 $patstodel = GetBorrowersToExpunge( { last_seen => '2016-02-15' });
361 is( scalar @$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' );
362 $patstodel = GetBorrowersToExpunge( { last_seen => '2016-04-04' });
363 is( scalar @$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' );
364 my $patron2 = $builder->build({ source => 'Borrower', value => { lastseen => undef } });
365 t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '0' );
366 Koha::Patrons->find( $patron2->{borrowernumber} )->track_login;
367 is( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should not be changed' );
368 Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 });
369 isnt( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should be changed now' );
371 # Regression tests for BZ13502
372 ## Remove all entries with userid='' (should be only 1 max)
373 $dbh->do(q|DELETE FROM borrowers WHERE userid = ''|);
374 ## And create a patron with a userid=''
375 $borrowernumber = AddMember( categorycode => $patron_category->{categorycode}, branchcode => $library2->{branchcode} );
376 $dbh->do(q|UPDATE borrowers SET userid = '' WHERE borrowernumber = ?|, undef, $borrowernumber);
377 # Create another patron and verify the userid has been generated
378 $borrowernumber = AddMember( categorycode => $patron_category->{categorycode}, branchcode => $library2->{branchcode} );
379 ok( $borrowernumber > 0, 'AddMember should have inserted the patron even if no userid is given' );
380 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
381 ok( $borrower->{userid}, 'A userid should have been generated correctly' );
383 # Regression tests for BZ12226
384 is( Check_Userid( C4::Context->config('user'), '' ), 0,
385 'Check_Userid should return 0 for the DB user (Bug 12226)');
387 subtest 'GetMemberAccountRecords' => sub {
391 my $borrowernumber = $builder->build({ source => 'Borrower' })->{ borrowernumber };
392 my $accountline_1 = $builder->build({
393 source => 'Accountline',
395 borrowernumber => $borrowernumber,
396 amountoutstanding => 64.60
400 my ($total,undef,undef) = GetMemberAccountRecords( $borrowernumber );
401 is( $total , 64.60, "Rounding works correctly in total calculation (single value)" );
403 my $accountline_2 = $builder->build({
404 source => 'Accountline',
406 borrowernumber => $borrowernumber,
407 amountoutstanding => 10.65
411 ($total,undef,undef) = GetMemberAccountRecords( $borrowernumber );
412 is( $total , 75.25, "Rounding works correctly in total calculation (multiple values)" );
416 subtest 'GetMemberAccountBalance' => sub {
420 my $members_mock = new Test::MockModule('C4::Members');
421 $members_mock->mock( 'GetMemberAccountRecords', sub {
422 my ($borrowernumber) = @_;
423 if ($borrowernumber) {
425 { amountoutstanding => '7', accounttype => 'Rent' },
426 { amountoutstanding => '5', accounttype => 'Res' },
427 { amountoutstanding => '3', accounttype => 'Pay' } );
428 return ( 15, \@accountlines );
432 return ( 0, \@accountlines );
436 # do not count holds charges
437 t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', '1' );
438 t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', '0' );
439 my ($total, $total_minus_charges,
440 $other_charges) = C4::Members::GetMemberAccountBalance(123);
441 is( $total, 15 , "Total calculated correctly");
442 is( $total_minus_charges, 15, "Holds charges are not count if HoldsInNoissuesCharge=1");
443 is( $other_charges, 0, "Holds charges are not considered if HoldsInNoissuesCharge=1");
445 t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', '0' );
446 ($total, $total_minus_charges,
447 $other_charges) = C4::Members::GetMemberAccountBalance(123);
448 is( $total, 15 , "Total calculated correctly");
449 is( $total_minus_charges, 10, "Holds charges are count if HoldsInNoissuesCharge=0");
450 is( $other_charges, 5, "Holds charges are considered if HoldsInNoissuesCharge=1");
453 subtest 'purgeSelfRegistration' => sub {
458 C4::Members::DeleteUnverifiedOpacRegistrations($d);
460 $dbh->do("INSERT INTO borrower_modifications (timestamp, borrowernumber, verification_token) VALUES ('2014-01-01 01:02:03',0,?)", undef, (scalar localtime)."_$_");
462 is( C4::Members::DeleteUnverifiedOpacRegistrations($d), 3, 'Test for DeleteUnverifiedOpacRegistrations' );
464 #purge members in temporary category
466 $dbh->do("INSERT IGNORE INTO categories (categorycode) VALUES ('$c')");
467 t::lib::Mocks::mock_preference('PatronSelfRegistrationDefaultCategory', $c );
468 t::lib::Mocks::mock_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', 360);
469 C4::Members::DeleteExpiredOpacRegistrations();
470 $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});
471 is( C4::Members::DeleteExpiredOpacRegistrations(), 1, 'Test for DeleteExpiredOpacRegistrations');
475 my ($resultset) = @_;
476 my $found = $resultset && grep( { $_->{cardnumber} && $_->{cardnumber} eq $CARDNUMBER } @$resultset );
480 # Regression tests for BZ15343
482 ( $borrowernumber, $password ) = AddMember_Opac(surname=>"Dick",firstname=>'Philip',branchcode => $library2->{branchcode});
483 is( $password =~ /^[a-zA-Z]{10}$/ , 1, 'Test for autogenerated password if none submitted');
484 ( $borrowernumber, $password ) = AddMember_Opac(surname=>"Deckard",firstname=>"Rick",password=>"Nexus-6",branchcode => $library2->{branchcode});
485 is( $password eq "Nexus-6", 1, 'Test password used if submitted');
486 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
487 my $hashed_up = Koha::AuthUtils::hash_password("Nexus-6", $borrower->{password});
488 is( $borrower->{password} eq $hashed_up, 1, 'Check password hash equals hash of submitted password' );
490 subtest 'Trivial test for AddMember_Auto' => sub {
492 my $members_mock = Test::MockModule->new( 'C4::Members' );
493 $members_mock->mock( 'fixup_cardnumber', sub { 12345; } );
494 my $library = $builder->build({ source => 'Branch' });
495 my $category = $builder->build({ source => 'Category' });
496 my %borr = AddMember_Auto( surname=> 'Dick3', firstname => 'Philip', branchcode => $library->{branchcode}, categorycode => $category->{categorycode}, password => '34567890' );
497 ok( $borr{borrowernumber}, 'Borrower hash contains borrowernumber' );
498 is( $borr{cardnumber}, 12345, 'Borrower hash contains cardnumber' );
499 my $patron = Koha::Patrons->find( $borr{borrowernumber} );
500 isnt( $patron, undef, 'Patron found' );
503 $schema->storage->txn_rollback;