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

(-)a/t/db_dependent/SIP/Transaction.t (-2 / +61 lines)
Lines 4-10 Link Here
4
# Current state is very rudimentary. Please help to extend it!
4
# Current state is very rudimentary. Please help to extend it!
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use Test::More tests => 6;
7
use Test::More tests => 7;
8
8
9
use Koha::Database;
9
use Koha::Database;
10
use t::lib::TestBuilder;
10
use t::lib::TestBuilder;
Lines 209-212 subtest cancel_hold => sub { Link Here
209
    is( $item->holds->count(), 0,  "Item has 0 holds remaining");
209
    is( $item->holds->count(), 0,  "Item has 0 holds remaining");
210
};
210
};
211
211
212
subtest do_hold => sub {
213
    plan tests => 7;
214
215
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
216
    my $patron_1 = $builder->build_object(
217
        {
218
            class => 'Koha::Patrons',
219
            value => {
220
                branchcode => $library->branchcode,
221
            }
222
        }
223
    );
224
    my $patron_2 = $builder->build_object(
225
        {
226
            class => 'Koha::Patrons',
227
            value => {
228
                branchcode   => $library->branchcode,
229
                categorycode => $patron_1->categorycode,
230
            }
231
        }
232
    );
233
234
    t::lib::Mocks::mock_userenv(
235
        { branchcode => $library->branchcode, flags => 1 } );
236
237
    my $item = $builder->build_sample_item(
238
        {
239
            library => $library->branchcode,
240
        }
241
    );
242
243
    my $reserve1 = AddReserve(
244
        {
245
            branchcode     => $library->branchcode,
246
            borrowernumber => $patron_1->borrowernumber,
247
            biblionumber   => $item->biblio->biblionumber,
248
            itemnumber     => $item->itemnumber,
249
        }
250
    );
251
    is( $item->biblio->holds->count(), 1, "Hold was placed on bib" );
252
    is( $item->holds->count(),         1, "Hold was placed on specific item" );
253
254
    my $sip_patron  = C4::SIP::ILS::Patron->new( $patron_2->cardnumber );
255
    my $sip_item    = C4::SIP::ILS::Item->new( $item->barcode );
256
    my $transaction = C4::SIP::ILS::Transaction::Hold->new();
257
    is(
258
        ref $transaction,
259
        "C4::SIP::ILS::Transaction::Hold",
260
        "New transaction created"
261
    );
262
    is( $transaction->patron($sip_patron),
263
        $sip_patron, "Patron assigned to transaction" );
264
    is( $transaction->item($sip_item),
265
        $sip_item, "Item assigned to transaction" );
266
    my $hold = $transaction->do_hold();
267
    is( $item->biblio->holds->count(), 2, "Bib has 2 holds" );
268
269
    is( $patron_2->holds->next->priority, 2, 'Hold placed from SIP should have a correct priority of 2');
270
};
271
212
$schema->storage->txn_rollback;
272
$schema->storage->txn_rollback;
213
- 

Return to bug 24705