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

(-)a/Koha/Holds.pm (+13 lines)
Lines 34-41 Koha::Holds - Koha Hold object set class Link Here
34
34
35
=head2 Class methods
35
=head2 Class methods
36
36
37
=head3 filter_by_found
38
39
    my $found_holds = $holds->filter_by_found;
40
41
Returns a filtered resultset without holds that are considered I<found>.
42
i.e. 'P', 'T' and 'W'.
43
37
=cut
44
=cut
38
45
46
sub filter_by_found {
47
    my ($self) = @_;
48
49
    return $self->search( { found => [ 'P', 'T', 'W' ] } );
50
}
51
39
=head3 waiting
52
=head3 waiting
40
53
41
returns a set of holds that are waiting from an existing set
54
returns a set of holds that are waiting from an existing set
(-)a/t/db_dependent/Koha/Holds.t (-2 / +31 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 10;
22
use Test::More tests => 11;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use C4::Circulation qw( AddIssue );
25
use C4::Circulation qw( AddIssue );
Lines 670-675 subtest 'Test Koha::Hold::item_group' => sub { Link Here
670
670
671
$schema->storage->txn_rollback;
671
$schema->storage->txn_rollback;
672
672
673
subtest 'filter_by_found() tests' => sub {
674
675
    plan tests => 5;
676
677
    $schema->storage->txn_begin;
678
679
    my $unfilled   = $builder->build_object( { class => 'Koha::Holds', value => { found => undef } } );
680
    my $processing = $builder->build_object( { class => 'Koha::Holds', value => { found => 'P' } } );
681
    my $in_transit = $builder->build_object( { class => 'Koha::Holds', value => { found => 'T' } } );
682
    my $waiting    = $builder->build_object( { class => 'Koha::Holds', value => { found => 'W' } } );
683
684
    my $holds = Koha::Holds->search(
685
        { reserve_id => [ $unfilled->id, $processing->id, $in_transit->id, $waiting->id ] },
686
        { order_by => ['reserve_id'] }
687
    );
688
689
    is( $holds->count, 4, 'Resultset count is correct' );
690
691
    my $found_holds = $holds->filter_by_found;
692
693
    is( $found_holds->count, 3, 'Resultset count is correct' );
694
695
    ok( $found_holds->next->is_in_processing, 'Status is correct (P)' );
696
    ok( $found_holds->next->is_in_transit, 'Status is correct (T)' );
697
    ok( $found_holds->next->is_waiting, 'Status is correct (W)' );
698
699
700
    $schema->storage->txn_rollback;
701
};
702
673
subtest 'filter_by_has_cancellation_requests() and filter_out_has_cancellation_requests() tests' => sub {
703
subtest 'filter_by_has_cancellation_requests() and filter_out_has_cancellation_requests() tests' => sub {
674
704
675
    plan tests => 7;
705
    plan tests => 7;
676
- 

Return to bug 32529