Lines 19-27
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 11; |
22 |
use Test::More tests => 12; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
|
|
24 |
use DateTime; |
24 |
|
25 |
|
|
|
26 |
use C4::Biblio; |
27 |
use C4::Circulation; |
25 |
use C4::Members; |
28 |
use C4::Members; |
26 |
|
29 |
|
27 |
use Koha::Holds; |
30 |
use Koha::Holds; |
Lines 337-342
subtest 'add_enrolment_fee_if_needed' => sub {
Link Here
|
337 |
$patron->delete; |
340 |
$patron->delete; |
338 |
}; |
341 |
}; |
339 |
|
342 |
|
|
|
343 |
subtest 'get_overdues' => sub { |
344 |
plan tests => 4; |
345 |
|
346 |
my $library = $builder->build( { source => 'Branch' } ); |
347 |
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); |
348 |
my $item_1 = $builder->build( |
349 |
{ |
350 |
source => 'Item', |
351 |
value => { |
352 |
homebranch => $library->{branchcode}, |
353 |
holdingbranch => $library->{branchcode}, |
354 |
biblionumber => $biblionumber_1 |
355 |
} |
356 |
} |
357 |
); |
358 |
my $item_2 = $builder->build( |
359 |
{ |
360 |
source => 'Item', |
361 |
value => { |
362 |
homebranch => $library->{branchcode}, |
363 |
holdingbranch => $library->{branchcode}, |
364 |
biblionumber => $biblionumber_1 |
365 |
} |
366 |
} |
367 |
); |
368 |
my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); |
369 |
my $item_3 = $builder->build( |
370 |
{ |
371 |
source => 'Item', |
372 |
value => { |
373 |
homebranch => $library->{branchcode}, |
374 |
holdingbranch => $library->{branchcode}, |
375 |
biblionumber => $biblionumber_2 |
376 |
} |
377 |
} |
378 |
); |
379 |
my $patron = $builder->build( |
380 |
{ |
381 |
source => 'Borrower', |
382 |
value => { branchcode => $library->{branchcode} } |
383 |
} |
384 |
); |
385 |
|
386 |
# Not sure how this is useful, but AddIssue pass this variable to different other subroutines |
387 |
$patron = GetMember( borrowernumber => $patron->{borrowernumber} ); |
388 |
|
389 |
my $module = new Test::MockModule('C4::Context'); |
390 |
$module->mock( 'userenv', sub { { branch => $library->{branchcode} } } ); |
391 |
|
392 |
AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) ); |
393 |
AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); |
394 |
AddIssue( $patron, $item_3->{barcode} ); |
395 |
|
396 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
397 |
my $overdues = $patron->get_overdues; |
398 |
is( $overdues->count, 2, 'Patron should have 2 overdues'); |
399 |
is( ref($overdues), 'Koha::Issues', 'Koha::Patron->get_overdues should return Koha::Issues' ); |
400 |
is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); |
401 |
is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); |
402 |
|
403 |
# Clean stuffs |
404 |
Koha::Issues->search( { borrowernumber => $patron->borrowernumber } )->delete; |
405 |
$patron->delete; |
406 |
}; |
407 |
|
340 |
$retrieved_patron_1->delete; |
408 |
$retrieved_patron_1->delete; |
341 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
409 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
342 |
|
410 |
|
343 |
- |
|
|