|
Lines 250-282
subtest 'test_updateClaim' => sub {
Link Here
|
| 250 |
is($result_0, undef, 'Got the expected undef from update claim with nothin'); |
250 |
is($result_0, undef, 'Got the expected undef from update claim with nothin'); |
| 251 |
|
251 |
|
| 252 |
# Given ... 3 serial. 2 of them updated. |
252 |
# Given ... 3 serial. 2 of them updated. |
| 253 |
my $serialids_1 = [90980, 90981]; |
|
|
| 254 |
my $claimdate_1 = dt_from_string('2001-01-13'); # arbitrary date some time in the past. |
253 |
my $claimdate_1 = dt_from_string('2001-01-13'); # arbitrary date some time in the past. |
| 255 |
my $claim_count_1 = 5; |
254 |
my $claim_count_1 = 5; |
| 256 |
Koha::Serial->new( { serialid => $serialids_1->[0], serialseq => 'serialseq', subscriptionid => $subscriptionid, status => 3, |
255 |
my $biblio = $builder->build_sample_biblio; |
| 257 |
biblionumber => 12345, claimdate => $claimdate_1, claims_count => $claim_count_1, } )->store(); |
256 |
my $serial1 = $builder->build_object( |
| 258 |
Koha::Serial->new( { serialid => $serialids_1->[1], serialseq => 'serialseq', subscriptionid => $subscriptionid, status => 3, |
257 |
{ |
| 259 |
biblionumber => 12345, claimdate => $claimdate_1, claims_count => $claim_count_1, } )->store(); |
258 |
class => 'Koha::Serials', |
| 260 |
Koha::Serial->new( { serialid => 90982, serialseq => 'serialseq', subscriptionid => $subscriptionid, status => 3, |
259 |
value => { |
| 261 |
biblionumber => 12345, claimdate => $claimdate_1, claims_count => $claim_count_1, } )->store(); |
260 |
serialseq => 'serialseq', |
|
|
261 |
subscriptionid => $subscriptionid, |
| 262 |
status => 3, |
| 263 |
biblionumber => $biblio->biblionumber, |
| 264 |
claimdate => $claimdate_1, |
| 265 |
claims_count => $claim_count_1, |
| 266 |
} |
| 267 |
} |
| 268 |
); |
| 269 |
my $serial2 = $builder->build_object( |
| 270 |
{ |
| 271 |
class => 'Koha::Serials', |
| 272 |
value => { |
| 273 |
serialseq => 'serialseq', |
| 274 |
subscriptionid => $subscriptionid, |
| 275 |
status => 3, |
| 276 |
biblionumber => $biblio->biblionumber, |
| 277 |
claimdate => $claimdate_1, |
| 278 |
claims_count => $claim_count_1, |
| 279 |
} |
| 280 |
} |
| 281 |
); |
| 282 |
my $serial3 = $builder->build_object( |
| 283 |
{ |
| 284 |
class => 'Koha::Serials', |
| 285 |
value => { |
| 286 |
serialseq => 'serialseq', |
| 287 |
subscriptionid => $subscriptionid, |
| 288 |
status => 3, |
| 289 |
biblionumber => $biblio->biblionumber, |
| 290 |
claimdate => $claimdate_1, |
| 291 |
claims_count => $claim_count_1, |
| 292 |
} |
| 293 |
} |
| 294 |
); |
| 262 |
|
295 |
|
| 263 |
# When ... |
296 |
# When ... |
| 264 |
my $result_1 = C4::Serials::updateClaim($serialids_1); |
297 |
my $result_1 = C4::Serials::updateClaim([$serial1->serialid, $serial2->serialid]); |
| 265 |
|
298 |
|
| 266 |
# Then ... |
299 |
# Then ... |
| 267 |
is($result_1, 2, 'Got the expected 2 from update claim with 2 serial ids'); |
300 |
is($result_1, 2, 'Got the expected 2 from update claim with 2 serial ids'); |
| 268 |
|
301 |
|
| 269 |
my @late_or_missing_issues_1_0 = C4::Serials::GetLateOrMissingIssues(undef, $serialids_1->[0]); |
302 |
my @late_or_missing_issues_1_0 = C4::Serials::GetLateOrMissingIssues(undef, $serial1->serialid); |
| 270 |
is($late_or_missing_issues_1_0[0]->{claimdate}, $today, 'Got the expected first different claim date from update claim'); |
303 |
is($late_or_missing_issues_1_0[0]->{claimdate}, $today, 'Got the expected first different claim date from update claim'); |
| 271 |
is($late_or_missing_issues_1_0[0]->{claims_count}, $claim_count_1+1, 'Got the expected first claim count from update claim'); |
304 |
is($late_or_missing_issues_1_0[0]->{claims_count}, $claim_count_1+1, 'Got the expected first claim count from update claim'); |
| 272 |
is($late_or_missing_issues_1_0[0]->{status}, 7, 'Got the expected first claim status from update claim'); |
305 |
is($late_or_missing_issues_1_0[0]->{status}, 7, 'Got the expected first claim status from update claim'); |
| 273 |
|
306 |
|
| 274 |
my @late_or_missing_issues_1_1 = C4::Serials::GetLateOrMissingIssues(undef, $serialids_1->[1]); |
307 |
my @late_or_missing_issues_1_1 = C4::Serials::GetLateOrMissingIssues(undef, $serial2->serialid); |
| 275 |
is($late_or_missing_issues_1_1[0]->{claimdate}, $today, 'Got the expected second different claim date from update claim'); |
308 |
is($late_or_missing_issues_1_1[0]->{claimdate}, $today, 'Got the expected second different claim date from update claim'); |
| 276 |
is($late_or_missing_issues_1_1[0]->{claims_count}, $claim_count_1+1, 'Got the expected second claim count from update claim'); |
309 |
is($late_or_missing_issues_1_1[0]->{claims_count}, $claim_count_1+1, 'Got the expected second claim count from update claim'); |
| 277 |
is($late_or_missing_issues_1_1[0]->{status}, 7, 'Got the expected second claim status from update claim'); |
310 |
is($late_or_missing_issues_1_1[0]->{status}, 7, 'Got the expected second claim status from update claim'); |
| 278 |
|
311 |
|
| 279 |
my @late_or_missing_issues_1_2 = C4::Serials::GetLateOrMissingIssues(undef, 90982); |
312 |
my @late_or_missing_issues_1_2 = C4::Serials::GetLateOrMissingIssues(undef, $serial3->serialid); |
| 280 |
is($late_or_missing_issues_1_2[0]->{claimdate}, output_pref({ dt => $claimdate_1, dateonly => 1}), 'Got the expected unchanged claim date from update claim'); |
313 |
is($late_or_missing_issues_1_2[0]->{claimdate}, output_pref({ dt => $claimdate_1, dateonly => 1}), 'Got the expected unchanged claim date from update claim'); |
| 281 |
is($late_or_missing_issues_1_2[0]->{claims_count}, $claim_count_1, 'Got the expected unchanged claim count from update claim'); |
314 |
is($late_or_missing_issues_1_2[0]->{claims_count}, $claim_count_1, 'Got the expected unchanged claim count from update claim'); |
| 282 |
is($late_or_missing_issues_1_2[0]->{status}, 3, 'Got the expected unchanged claim status from update claim'); |
315 |
is($late_or_missing_issues_1_2[0]->{status}, 3, 'Got the expected unchanged claim status from update claim'); |
| 283 |
- |
|
|