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 638-641
subtest 'set_waiting+patron_expiration_date' => sub {
Link Here
|
638 |
|
638 |
|
639 |
$schema->storage->txn_rollback; |
639 |
$schema->storage->txn_rollback; |
640 |
|
640 |
|
641 |
1; |
641 |
subtest 'filter_by_has_cancellation_requests() tests' => sub { |
|
|
642 |
|
643 |
plan tests => 4; |
644 |
|
645 |
$schema->storage->txn_begin; |
646 |
|
647 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
648 |
|
649 |
my $item_1 = $builder->build_sample_item; |
650 |
my $item_2 = $builder->build_sample_item; |
651 |
my $item_3 = $builder->build_sample_item; |
652 |
|
653 |
my $hold_1 = $builder->build_object( |
654 |
{ |
655 |
class => 'Koha::Holds', |
656 |
value => { |
657 |
found => 'W', |
658 |
itemnumber => $item_1->id, |
659 |
biblionumber => $item_1->biblionumber, |
660 |
borrowernumber => $patron->id |
661 |
} |
662 |
} |
663 |
); |
664 |
my $hold_2 = $builder->build_object( |
665 |
{ |
666 |
class => 'Koha::Holds', |
667 |
value => { |
668 |
found => 'W', |
669 |
itemnumber => $item_2->id, |
670 |
biblionumber => $item_2->biblionumber, |
671 |
borrowernumber => $patron->id |
672 |
} |
673 |
} |
674 |
); |
675 |
my $hold_3 = $builder->build_object( |
676 |
{ |
677 |
class => 'Koha::Holds', |
678 |
value => { |
679 |
found => 'W', |
680 |
itemnumber => $item_3->id, |
681 |
biblionumber => $item_3->biblionumber, |
682 |
borrowernumber => $patron->id |
683 |
} |
684 |
} |
685 |
); |
686 |
|
687 |
my $rs = Koha::Holds->search( |
688 |
{ reserve_id => [ $hold_1->id, $hold_2->id, $hold_3->id ] } ); |
689 |
|
690 |
is( $rs->count, 3 ); |
691 |
|
692 |
my $filtered_rs = $rs->filter_by_has_cancellation_requests; |
693 |
|
694 |
is( $filtered_rs->count, 0 ); |
695 |
|
696 |
$hold_2->add_cancellation_request; |
697 |
|
698 |
$filtered_rs = $rs->filter_by_has_cancellation_requests; |
699 |
|
700 |
is( $filtered_rs->count, 1 ); |
701 |
is( $filtered_rs->next->id, $hold_2->id ); |
702 |
|
703 |
$schema->storage->txn_rollback; |
704 |
}; |
642 |
- |
|
|