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