|
Lines 19-27
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 13; |
22 |
use Test::More tests => 14; |
| 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 362-367
subtest 'add_enrolment_fee_if_needed' => sub {
Link Here
|
| 362 |
$patron->delete; |
365 |
$patron->delete; |
| 363 |
}; |
366 |
}; |
| 364 |
|
367 |
|
|
|
368 |
subtest 'get_overdues' => sub { |
| 369 |
plan tests => 4; |
| 370 |
|
| 371 |
my $library = $builder->build( { source => 'Branch' } ); |
| 372 |
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); |
| 373 |
my $item_1 = $builder->build( |
| 374 |
{ |
| 375 |
source => 'Item', |
| 376 |
value => { |
| 377 |
homebranch => $library->{branchcode}, |
| 378 |
holdingbranch => $library->{branchcode}, |
| 379 |
biblionumber => $biblionumber_1 |
| 380 |
} |
| 381 |
} |
| 382 |
); |
| 383 |
my $item_2 = $builder->build( |
| 384 |
{ |
| 385 |
source => 'Item', |
| 386 |
value => { |
| 387 |
homebranch => $library->{branchcode}, |
| 388 |
holdingbranch => $library->{branchcode}, |
| 389 |
biblionumber => $biblionumber_1 |
| 390 |
} |
| 391 |
} |
| 392 |
); |
| 393 |
my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); |
| 394 |
my $item_3 = $builder->build( |
| 395 |
{ |
| 396 |
source => 'Item', |
| 397 |
value => { |
| 398 |
homebranch => $library->{branchcode}, |
| 399 |
holdingbranch => $library->{branchcode}, |
| 400 |
biblionumber => $biblionumber_2 |
| 401 |
} |
| 402 |
} |
| 403 |
); |
| 404 |
my $patron = $builder->build( |
| 405 |
{ |
| 406 |
source => 'Borrower', |
| 407 |
value => { branchcode => $library->{branchcode} } |
| 408 |
} |
| 409 |
); |
| 410 |
|
| 411 |
# Not sure how this is useful, but AddIssue pass this variable to different other subroutines |
| 412 |
$patron = GetMember( borrowernumber => $patron->{borrowernumber} ); |
| 413 |
|
| 414 |
my $module = new Test::MockModule('C4::Context'); |
| 415 |
$module->mock( 'userenv', sub { { branch => $library->{branchcode} } } ); |
| 416 |
|
| 417 |
AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) ); |
| 418 |
AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); |
| 419 |
AddIssue( $patron, $item_3->{barcode} ); |
| 420 |
|
| 421 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
| 422 |
my $overdues = $patron->get_overdues; |
| 423 |
is( $overdues->count, 2, 'Patron should have 2 overdues'); |
| 424 |
is( ref($overdues), 'Koha::Issues', 'Koha::Patron->get_overdues should return Koha::Issues' ); |
| 425 |
is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); |
| 426 |
is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); |
| 427 |
|
| 428 |
# Clean stuffs |
| 429 |
Koha::Issues->search( { borrowernumber => $patron->borrowernumber } )->delete; |
| 430 |
$patron->delete; |
| 431 |
}; |
| 432 |
|
| 365 |
$retrieved_patron_1->delete; |
433 |
$retrieved_patron_1->delete; |
| 366 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
434 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
| 367 |
|
435 |
|
| 368 |
- |
|
|