Lines 97-105
my %data = (
Link Here
|
97 |
my $addmem=Koha::Patron->new(\%data)->store->borrowernumber; |
97 |
my $addmem=Koha::Patron->new(\%data)->store->borrowernumber; |
98 |
ok($addmem, "Koha::Patron->store()"); |
98 |
ok($addmem, "Koha::Patron->store()"); |
99 |
|
99 |
|
100 |
my $member = Koha::Patrons->find( { cardnumber => $CARDNUMBER } ) |
100 |
my $patron = Koha::Patrons->find( { cardnumber => $CARDNUMBER } ) |
101 |
or BAIL_OUT("Cannot read member with card $CARDNUMBER"); |
101 |
or BAIL_OUT("Cannot read member with card $CARDNUMBER"); |
102 |
$member = $member->unblessed; |
102 |
my $member = $patron->unblessed; |
103 |
|
103 |
|
104 |
ok ( $member->{firstname} eq $FIRSTNAME && |
104 |
ok ( $member->{firstname} eq $FIRSTNAME && |
105 |
$member->{surname} eq $SURNAME && |
105 |
$member->{surname} eq $SURNAME && |
Lines 114-120
$member->{firstname} = $CHANGED_FIRSTNAME . q{ };
Link Here
|
114 |
$member->{email} = $EMAIL; |
114 |
$member->{email} = $EMAIL; |
115 |
$member->{phone} = $PHONE; |
115 |
$member->{phone} = $PHONE; |
116 |
$member->{emailpro} = $EMAILPRO; |
116 |
$member->{emailpro} = $EMAILPRO; |
117 |
ModMember(%$member); |
117 |
$patron->set($member)->store; |
118 |
my $changedmember = Koha::Patrons->find( { cardnumber => $CARDNUMBER } )->unblessed; |
118 |
my $changedmember = Koha::Patrons->find( { cardnumber => $CARDNUMBER } )->unblessed; |
119 |
ok ( $changedmember->{firstname} eq $CHANGED_FIRSTNAME && |
119 |
ok ( $changedmember->{firstname} eq $CHANGED_FIRSTNAME && |
120 |
$changedmember->{email} eq $EMAIL && |
120 |
$changedmember->{email} eq $EMAIL && |
Lines 152-194
is ($checkcardnum, "2", "Card number is too long");
Link Here
|
152 |
dateenrolled => '', |
152 |
dateenrolled => '', |
153 |
); |
153 |
); |
154 |
my $borrowernumber = Koha::Patron->new( \%data )->store->borrowernumber; |
154 |
my $borrowernumber = Koha::Patron->new( \%data )->store->borrowernumber; |
155 |
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
155 |
$patron = Koha::Patrons->find( $borrowernumber ); |
|
|
156 |
my $borrower = $patron->unblessed; |
156 |
is( $borrower->{dateofbirth}, undef, 'Koha::Patron->store should undef dateofbirth if empty string is given'); |
157 |
is( $borrower->{dateofbirth}, undef, 'Koha::Patron->store should undef dateofbirth if empty string is given'); |
157 |
is( $borrower->{debarred}, undef, 'Koha::Patron->store should undef debarred if empty string is given'); |
158 |
is( $borrower->{debarred}, undef, 'Koha::Patron->store should undef debarred if empty string is given'); |
158 |
isnt( $borrower->{dateexpiry}, '0000-00-00', 'Koha::Patron->store should not set dateexpiry to 0000-00-00 if empty string is given'); |
159 |
isnt( $borrower->{dateexpiry}, '0000-00-00', 'Koha::Patron->store should not set dateexpiry to 0000-00-00 if empty string is given'); |
159 |
isnt( $borrower->{dateenrolled}, '0000-00-00', 'Koha::Patron->store should not set dateenrolled to 0000-00-00 if empty string is given'); |
160 |
isnt( $borrower->{dateenrolled}, '0000-00-00', 'Koha::Patron->store should not set dateenrolled to 0000-00-00 if empty string is given'); |
160 |
|
161 |
|
161 |
ModMember( borrowernumber => $borrowernumber, dateofbirth => '', debarred => '', dateexpiry => '', dateenrolled => '' ); |
162 |
$patron->set({ dateofbirth => '', debarred => '', dateexpiry => '', dateenrolled => '' })->store; |
162 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
163 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
163 |
is( $borrower->{dateofbirth}, undef, 'ModMember should undef dateofbirth if empty string is given'); |
164 |
is( $borrower->{dateofbirth}, undef, 'Koha::Patron->store should undef dateofbirth if empty string is given'); |
164 |
is( $borrower->{debarred}, undef, 'ModMember should undef debarred if empty string is given'); |
165 |
is( $borrower->{debarred}, undef, 'Koha::Patron->store should undef debarred if empty string is given'); |
165 |
isnt( $borrower->{dateexpiry}, '0000-00-00', 'ModMember should not set dateexpiry to 0000-00-00 if empty string is given'); |
166 |
isnt( $borrower->{dateexpiry}, '0000-00-00', 'Koha::Patron->store should not set dateexpiry to 0000-00-00 if empty string is given'); |
166 |
isnt( $borrower->{dateenrolled}, '0000-00-00', 'ModMember should not set dateenrolled to 0000-00-00 if empty string is given'); |
167 |
isnt( $borrower->{dateenrolled}, '0000-00-00', 'Koha::Patron->store should not set dateenrolled to 0000-00-00 if empty string is given'); |
167 |
|
168 |
|
168 |
ModMember( borrowernumber => $borrowernumber, dateofbirth => '1970-01-01', debarred => '2042-01-01', dateexpiry => '9999-12-31', dateenrolled => '2015-09-06' ); |
169 |
$patron->set({ dateofbirth => '1970-01-01', debarred => '2042-01-01', dateexpiry => '9999-12-31', dateenrolled => '2015-09-06' })->store; |
169 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
170 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
170 |
is( $borrower->{dateofbirth}, '1970-01-01', 'ModMember should correctly set dateofbirth if a valid date is given'); |
171 |
is( $borrower->{dateofbirth}, '1970-01-01', 'Koha::Patron->store should correctly set dateofbirth if a valid date is given'); |
171 |
is( $borrower->{debarred}, '2042-01-01', 'ModMember should correctly set debarred if a valid date is given'); |
172 |
is( $borrower->{debarred}, '2042-01-01', 'Koha::Patron->store should correctly set debarred if a valid date is given'); |
172 |
is( $borrower->{dateexpiry}, '9999-12-31', 'ModMember should correctly set dateexpiry if a valid date is given'); |
173 |
is( $borrower->{dateexpiry}, '9999-12-31', 'Koha::Patron->store should correctly set dateexpiry if a valid date is given'); |
173 |
is( $borrower->{dateenrolled}, '2015-09-06', 'ModMember should correctly set dateenrolled if a valid date is given'); |
174 |
is( $borrower->{dateenrolled}, '2015-09-06', 'Koha::Patron->store should correctly set dateenrolled if a valid date is given'); |
174 |
|
175 |
|
175 |
subtest 'ModMember should not update userid if not true' => sub { |
176 |
subtest 'Koha::Patron->store should not update userid if not true' => sub { |
176 |
plan tests => 3; |
177 |
plan tests => 3; |
177 |
|
178 |
|
178 |
$data{ cardnumber } = "234567890"; |
179 |
$data{ cardnumber } = "234567890"; |
179 |
$data{userid} = 'a_user_id'; |
180 |
$data{userid} = 'a_user_id'; |
180 |
$borrowernumber = Koha::Patron->new( \%data )->store->borrowernumber; |
181 |
$borrowernumber = Koha::Patron->new( \%data )->store->borrowernumber; |
181 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
182 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
|
|
183 |
my $borrower = $patron->unblessed; |
182 |
|
184 |
|
183 |
ModMember( borrowernumber => $borrowernumber, firstname => 'Tomas', userid => '' ); |
185 |
$patron->set( { firstname => 'Tomas', userid => '' } )->store; |
184 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
186 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
185 |
is ( $borrower->{userid}, $data{userid}, 'ModMember should not update the userid with an empty string' ); |
187 |
is ( $borrower->{userid}, $data{userid}, 'Koha::Patron->store should not update the userid with an empty string' ); |
186 |
ModMember( borrowernumber => $borrowernumber, firstname => 'Tomas', userid => 0 ); |
188 |
$patron->set( { firstname => 'Tomas', userid => 0 } )->store; |
187 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
189 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
188 |
is ( $borrower->{userid}, $data{userid}, 'ModMember should not update the userid with an 0'); |
190 |
is ( $borrower->{userid}, $data{userid}, 'Koha::Patron->store should not update the userid with an 0'); |
189 |
ModMember( borrowernumber => $borrowernumber, firstname => 'Tomas', userid => undef ); |
191 |
$patron->set( { firstname => 'Tomas', userid => undef } )->store; |
190 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
192 |
$borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
191 |
is ( $borrower->{userid}, $data{userid}, 'ModMember should not update the userid with an undefined value'); |
193 |
is ( $borrower->{userid}, $data{userid}, 'Koha::Patron->store should not update the userid with an undefined value'); |
192 |
}; |
194 |
}; |
193 |
|
195 |
|
194 |
#Regression tests for bug 10612 |
196 |
#Regression tests for bug 10612 |
Lines 272-278
my @listpatrons = ($bor1inlist, $bor2inlist);
Link Here
|
272 |
AddPatronsToList( { list => $list1, borrowernumbers => \@listpatrons }); |
274 |
AddPatronsToList( { list => $list1, borrowernumbers => \@listpatrons }); |
273 |
my $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id() } ); |
275 |
my $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id() } ); |
274 |
is( scalar(@$patstodel),0,'No staff deleted from list of all staff'); |
276 |
is( scalar(@$patstodel),0,'No staff deleted from list of all staff'); |
275 |
ModMember( borrowernumber => $bor2inlist, categorycode => 'CIVILIAN' ); |
277 |
Koha::Patrons->find($bor2inlist)->set({ categorycode => 'CIVILIAN' })->store; |
276 |
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); |
278 |
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); |
277 |
ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted from list'); |
279 |
ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted from list'); |
278 |
$patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } ); |
280 |
$patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } ); |
Lines 282-289
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inli
Link Here
|
282 |
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } ); |
284 |
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } ); |
283 |
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date'); |
285 |
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date'); |
284 |
|
286 |
|
285 |
ModMember( borrowernumber => $bor1inlist, categorycode => 'CIVILIAN' ); |
287 |
Koha::Patrons->find($bor1inlist)->set({ categorycode => 'CIVILIAN' })->store; |
286 |
ModMember( borrowernumber => $guarantee->{borrowernumber} ,guarantorid=>$bor1inlist ); |
288 |
Koha::Patrons->find($guarantee->{borrowernumber})->set({ guarantorid => $bor1inlist })->store; |
287 |
|
289 |
|
288 |
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); |
290 |
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); |
289 |
ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted from list'); |
291 |
ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted from list'); |
Lines 293-299
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list
Link Here
|
293 |
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by expirationdate and list'); |
295 |
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by expirationdate and list'); |
294 |
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } ); |
296 |
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } ); |
295 |
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by last issue date'); |
297 |
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by last issue date'); |
296 |
ModMember( borrowernumber => $guarantee->{borrowernumber}, guarantorid=>'' ); |
298 |
Koha::Patrons->find($guarantee->{borrowernumber})->set({ guarantorid => '' })->store; |
297 |
|
299 |
|
298 |
$builder->build({ |
300 |
$builder->build({ |
299 |
source => 'Issue', |
301 |
source => 'Issue', |