Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 8; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
25 |
use C4::Circulation qw( AddIssue ); |
25 |
use C4::Circulation qw( AddIssue ); |
Lines 629-632
subtest 'set_waiting+patron_expiration_date' => sub {
Link Here
|
629 |
|
629 |
|
630 |
$schema->storage->txn_rollback; |
630 |
$schema->storage->txn_rollback; |
631 |
|
631 |
|
632 |
1; |
632 |
subtest 'filter_by_has_pending_cancellation_requests() tests' => sub { |
|
|
633 |
|
634 |
plan tests => 4; |
635 |
|
636 |
$schema->storage->txn_begin; |
637 |
|
638 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
639 |
|
640 |
my $item_1 = $builder->build_sample_item; |
641 |
my $item_2 = $builder->build_sample_item; |
642 |
my $item_3 = $builder->build_sample_item; |
643 |
|
644 |
my $hold_1 = $builder->build_object( |
645 |
{ |
646 |
class => 'Koha::Holds', |
647 |
value => { |
648 |
found => 'W', |
649 |
itemnumber => $item_1->id, |
650 |
biblionumber => $item_1->biblionumber, |
651 |
borrowernumber => $patron->id |
652 |
} |
653 |
} |
654 |
); |
655 |
my $hold_2 = $builder->build_object( |
656 |
{ |
657 |
class => 'Koha::Holds', |
658 |
value => { |
659 |
found => 'W', |
660 |
itemnumber => $item_2->id, |
661 |
biblionumber => $item_2->biblionumber, |
662 |
borrowernumber => $patron->id |
663 |
} |
664 |
} |
665 |
); |
666 |
my $hold_3 = $builder->build_object( |
667 |
{ |
668 |
class => 'Koha::Holds', |
669 |
value => { |
670 |
found => 'W', |
671 |
itemnumber => $item_3->id, |
672 |
biblionumber => $item_3->biblionumber, |
673 |
borrowernumber => $patron->id |
674 |
} |
675 |
} |
676 |
); |
677 |
|
678 |
my $rs = Koha::Holds->search( |
679 |
{ reserve_id => [ $hold_1->id, $hold_2->id, $hold_3->id ] } ); |
680 |
|
681 |
is( $rs->count, 3 ); |
682 |
|
683 |
my $filtered_rs = $rs->filter_by_has_pending_cancellation_requests; |
684 |
|
685 |
is( $filtered_rs->count, 0 ); |
686 |
|
687 |
$hold_2->add_cancellation_request( { requester_id => $patron->id } ); |
688 |
|
689 |
$filtered_rs = $rs->filter_by_has_pending_cancellation_requests; |
690 |
|
691 |
is( $filtered_rs->count, 1 ); |
692 |
is( $filtered_rs->next->id, $hold_2->id ); |
693 |
|
694 |
$schema->storage->txn_rollback; |
695 |
}; |
633 |
- |
|
|