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

(-)a/t/db_dependent/Koha/Biblios.t (-33 / +43 lines)
Lines 62-99 subtest 'store' => sub { Link Here
62
    );
62
    );
63
};
63
};
64
64
65
subtest 'holds + current_holds' => sub {
66
    plan tests => 5;
67
    C4::Reserves::AddReserve(
68
        {
69
            branchcode     => $patron->branchcode,
70
            borrowernumber => $patron->borrowernumber,
71
            biblionumber   => $biblio->biblionumber,
72
        }
73
    );
74
    my $holds = $biblio->holds;
75
    is( ref($holds), 'Koha::Holds', '->holds should return a Koha::Holds object' );
76
    is( $holds->count, 1, '->holds should only return 1 hold' );
77
    is( $holds->next->borrowernumber, $patron->borrowernumber, '->holds should return the correct hold' );
78
    $holds->delete;
79
80
    # Add a hold in the future
81
    C4::Reserves::AddReserve(
82
        {
83
            branchcode       => $patron->branchcode,
84
            borrowernumber   => $patron->borrowernumber,
85
            biblionumber     => $biblio->biblionumber,
86
            reservation_date => dt_from_string->add( days => 2 ),
87
        }
88
    );
89
    $holds = $biblio->holds;
90
    is( $holds->count, 1, '->holds should return future holds' );
91
    $holds = $biblio->current_holds;
92
    is( $holds->count, 0, '->current_holds should not return future holds' );
93
    $holds->delete;
94
95
};
96
97
subtest 'waiting_or_in_transit' => sub {
65
subtest 'waiting_or_in_transit' => sub {
98
    plan tests => 4;
66
    plan tests => 4;
99
    my $biblio = $builder->build( { source => 'Biblio' } );
67
    my $biblio = $builder->build( { source => 'Biblio' } );
Lines 222-224 subtest 'custom_cover_image_url' => sub { Link Here
222
};
190
};
223
191
224
$schema->storage->txn_rollback;
192
$schema->storage->txn_rollback;
225
- 
193
194
subtest 'holds + current_holds' => sub {
195
    plan tests => 5;
196
197
    $schema->storage->txn_begin;
198
199
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
200
    my $biblio = $builder->build_sample_biblio();
201
202
    C4::Reserves::AddReserve(
203
        {
204
            branchcode     => $patron->branchcode,
205
            borrowernumber => $patron->borrowernumber,
206
            biblionumber   => $biblio->biblionumber,
207
        }
208
    );
209
210
    my $holds = $biblio->holds;
211
    is( ref($holds), 'Koha::Holds', '->holds should return a Koha::Holds object' );
212
    is( $holds->count, 1, '->holds should only return 1 hold' );
213
    is( $holds->next->borrowernumber, $patron->borrowernumber, '->holds should return the correct hold' );
214
215
    # Start fresh
216
    $biblio->holds->delete;
217
218
    # Add a hold in the future
219
    C4::Reserves::AddReserve(
220
        {
221
            branchcode       => $patron->branchcode,
222
            borrowernumber   => $patron->borrowernumber,
223
            biblionumber     => $biblio->biblionumber,
224
            reservation_date => dt_from_string->add( days => 2 ),
225
        }
226
    );
227
    $holds = $biblio->holds;
228
    is( $holds->count, 1, '->holds should return future holds' );
229
    $holds = $biblio->current_holds;
230
    is( $holds->count, 0, '->current_holds should not return future holds' );
231
232
    $schema->storage->txn_rollback;
233
};
234
235

Return to bug 25303