View | Details | Raw Unified | Return to bug 19830
Collapse All | Expand All

(-)a/Koha/Patron.pm (-3 / +15 lines)
Lines 512-525 sub add_enrolment_fee_if_needed { Link Here
512
512
513
=head3 checkouts
513
=head3 checkouts
514
514
515
my $issues = $patron->checkouts
515
my $checkouts = $patron->checkouts
516
516
517
=cut
517
=cut
518
518
519
sub checkouts {
519
sub checkouts {
520
    my ($self) = @_;
520
    my ($self) = @_;
521
    my $issues = $self->_result->issues;
521
    my $checkouts = $self->_result->issues;
522
    return Koha::Checkouts->_new_from_dbic( $issues );
522
    return Koha::Checkouts->_new_from_dbic( $checkouts );
523
}
524
525
=head3 old_checkouts
526
527
my $old_checkouts = $patron->old_checkouts
528
529
=cut
530
531
sub old_checkouts {
532
    my ($self) = @_;
533
    my $old_checkouts = $self->_result->old_issues;
534
    return Koha::Old::Checkouts->_new_from_dbic( $old_checkouts );
523
}
535
}
524
536
525
=head3 get_overdues
537
=head3 get_overdues
(-)a/t/db_dependent/Koha/Patrons.t (-6 / +21 lines)
Lines 430-437 subtest 'add_enrolment_fee_if_needed' => sub { Link Here
430
    $patron->delete;
430
    $patron->delete;
431
};
431
};
432
432
433
subtest 'checkouts + get_overdues' => sub {
433
subtest 'checkouts + get_overdues + old_checkouts' => sub {
434
    plan tests => 8;
434
    plan tests => 12;
435
435
436
    my $library = $builder->build( { source => 'Branch' } );
436
    my $library = $builder->build( { source => 'Branch' } );
437
    my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' );
437
    my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' );
Lines 441-447 subtest 'checkouts + get_overdues' => sub { Link Here
441
            value  => {
441
            value  => {
442
                homebranch    => $library->{branchcode},
442
                homebranch    => $library->{branchcode},
443
                holdingbranch => $library->{branchcode},
443
                holdingbranch => $library->{branchcode},
444
                biblionumber  => $biblionumber_1
444
                biblionumber  => $biblionumber_1,
445
                itemlost      => 0,
446
                withdrawn     => 0,
445
            }
447
            }
446
        }
448
        }
447
    );
449
    );
Lines 451-457 subtest 'checkouts + get_overdues' => sub { Link Here
451
            value  => {
453
            value  => {
452
                homebranch    => $library->{branchcode},
454
                homebranch    => $library->{branchcode},
453
                holdingbranch => $library->{branchcode},
455
                holdingbranch => $library->{branchcode},
454
                biblionumber  => $biblionumber_1
456
                biblionumber  => $biblionumber_1,
457
                itemlost      => 0,
458
                withdrawn     => 0,
455
            }
459
            }
456
        }
460
        }
457
    );
461
    );
Lines 462-468 subtest 'checkouts + get_overdues' => sub { Link Here
462
            value  => {
466
            value  => {
463
                homebranch    => $library->{branchcode},
467
                homebranch    => $library->{branchcode},
464
                holdingbranch => $library->{branchcode},
468
                holdingbranch => $library->{branchcode},
465
                biblionumber  => $biblionumber_2
469
                biblionumber  => $biblionumber_2,
470
                itemlost      => 0,
471
                withdrawn     => 0,
466
            }
472
            }
467
        }
473
        }
468
    );
474
    );
Lines 477-482 subtest 'checkouts + get_overdues' => sub { Link Here
477
    my $checkouts = $patron->checkouts;
483
    my $checkouts = $patron->checkouts;
478
    is( $checkouts->count, 0, 'checkouts should not return any issues for that patron' );
484
    is( $checkouts->count, 0, 'checkouts should not return any issues for that patron' );
479
    is( ref($checkouts), 'Koha::Checkouts', 'checkouts should return a Koha::Checkouts object' );
485
    is( ref($checkouts), 'Koha::Checkouts', 'checkouts should return a Koha::Checkouts object' );
486
    my $old_checkouts = $patron->old_checkouts;
487
    is( $old_checkouts->count, 0, 'old_checkouts should not return any issues for that patron' );
488
    is( ref($old_checkouts), 'Koha::Old::Checkouts', 'old_checkouts should return a Koha::Old::Checkouts object' );
480
489
481
    # Not sure how this is useful, but AddIssue pass this variable to different other subroutines
490
    # Not sure how this is useful, but AddIssue pass this variable to different other subroutines
482
    $patron = Koha::Patrons->find( $patron->borrowernumber )->unblessed;
491
    $patron = Koha::Patrons->find( $patron->borrowernumber )->unblessed;
Lines 499-504 subtest 'checkouts + get_overdues' => sub { Link Here
499
    is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' );
508
    is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' );
500
    is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' );
509
    is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' );
501
510
511
512
    C4::Circulation::AddReturn( $item_1->{barcode} );
513
    C4::Circulation::AddReturn( $item_2->{barcode} );
514
    $old_checkouts = $patron->old_checkouts;
515
    is( $old_checkouts->count, 2, 'old_checkouts should return 2 old checkouts that patron' );
516
    is( ref($old_checkouts), 'Koha::Old::Checkouts', 'old_checkouts should return a Koha::Old::Checkouts object' );
517
502
    # Clean stuffs
518
    # Clean stuffs
503
    Koha::Checkouts->search( { borrowernumber => $patron->borrowernumber } )->delete;
519
    Koha::Checkouts->search( { borrowernumber => $patron->borrowernumber } )->delete;
504
    $patron->delete;
520
    $patron->delete;
505
- 

Return to bug 19830