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

(-)a/Koha/Patron.pm (+14 lines)
Lines 519-524 sub get_overdues { Link Here
519
    return $issues;
519
    return $issues;
520
}
520
}
521
521
522
=head3 holds
523
524
my $holds = $patron->holds
525
526
Return all the holds placed by this patron
527
528
=cut
529
530
sub holds {
531
    my ($self) = @_;
532
    my $holds_rs = $self->_result->reserves->search( {}, { order_by => 'reservedate' } );
533
    return Koha::Holds->_new_from_dbic($holds_rs);
534
}
535
522
=head3 type
536
=head3 type
523
537
524
=cut
538
=cut
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +63 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 15;
22
use Test::More tests => 16;
23
use Test::Warn;
23
use Test::Warn;
24
use DateTime;
24
use DateTime;
25
25
Lines 471-476 subtest 'get_overdues' => sub { Link Here
471
    $patron->delete;
471
    $patron->delete;
472
};
472
};
473
473
474
subtest 'holds' => sub {
475
    plan tests => 3;
476
477
    my $library = $builder->build( { source => 'Branch' } );
478
    my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' );
479
    my $item_1 = $builder->build(
480
        {
481
            source => 'Item',
482
            value  => {
483
                homebranch    => $library->{branchcode},
484
                holdingbranch => $library->{branchcode},
485
                biblionumber  => $biblionumber_1
486
            }
487
        }
488
    );
489
    my $item_2 = $builder->build(
490
        {
491
            source => 'Item',
492
            value  => {
493
                homebranch    => $library->{branchcode},
494
                holdingbranch => $library->{branchcode},
495
                biblionumber  => $biblionumber_1
496
            }
497
        }
498
    );
499
    my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' );
500
    my $item_3 = $builder->build(
501
        {
502
            source => 'Item',
503
            value  => {
504
                homebranch    => $library->{branchcode},
505
                holdingbranch => $library->{branchcode},
506
                biblionumber  => $biblionumber_2
507
            }
508
        }
509
    );
510
    my $patron = $builder->build(
511
        {
512
            source => 'Borrower',
513
            value  => { branchcode => $library->{branchcode} }
514
        }
515
    );
516
517
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
518
    my $holds = $patron->holds;
519
    is( ref($holds), 'Koha::Holds',
520
        'Koha::Patron->holds should return a Koha::Holds objects' );
521
    is( $holds->count, 0, 'There should not have holds placed by this patron yet' );
522
523
    C4::Reserves::AddReserve( $library->{branchcode},
524
        $patron->borrowernumber, $biblionumber_1 );
525
    # In the future
526
    C4::Reserves::AddReserve( $library->{branchcode},
527
        $patron->borrowernumber, $biblionumber_2, undef, undef, dt_from_string->add( days => 2 ) );
528
529
    $holds = $patron->holds;
530
    is( $holds->count, 2, 'There should have 2 holds placed by this patron' );
531
532
    $holds->delete;
533
    $patron->delete;
534
};
535
474
$retrieved_patron_1->delete;
536
$retrieved_patron_1->delete;
475
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
537
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
476
538
477
- 

Return to bug 17740