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

(-)a/t/db_dependent/StockRotationItems.t (-3 / +34 lines)
Lines 206-212 subtest "Tests for needs_advancing." => sub { Link Here
206
};
206
};
207
207
208
subtest "Tests for advance." => sub {
208
subtest "Tests for advance." => sub {
209
    plan tests => 15;
209
    plan tests => 23;
210
    $schema->storage->txn_begin;
210
    $schema->storage->txn_begin;
211
211
212
    my $sritem = $builder->build({
212
    my $sritem = $builder->build({
Lines 259-280 subtest "Tests for advance." => sub { Link Here
259
    $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id});
259
    $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id});
260
    ## Test results
260
    ## Test results
261
    is($dbitem->stage->stage_id, $dbstage2->stage_id, "Stage updated.");
261
    is($dbitem->stage->stage_id, $dbstage2->stage_id, "Stage updated.");
262
    is(
263
        $dbitem->itemnumber->homebranch,
264
        $dbstage2->branchcode_id,
265
        "Item homebranch updated"
266
    );
262
    my $intransfer = $dbitem->itemnumber->get_transfer;
267
    my $intransfer = $dbitem->itemnumber->get_transfer;
263
    is($intransfer->frombranch, $dbstage->branchcode_id, "Origin correct.");
268
    is($intransfer->frombranch, $dbstage->branchcode_id, "Origin correct.");
264
    is($intransfer->tobranch, $dbstage2->branchcode_id, "Target Correct.");
269
    is($intransfer->tobranch, $dbstage2->branchcode_id, "Target Correct.");
265
270
271
    # Arrive at new branch
272
    $intransfer->datearrived(DateTime->now)->store;
273
    $dbitem->itemnumber->holdingbranch($srstage->{branchcode_id})->store;
274
275
    # Test a cyclical advance
276
    ok($dbitem->advance, "Cyclical advancement done.");
277
    ## Refetch dbitem
278
    $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id});
279
    ## Test results
280
    is($dbitem->stage->stage_id, $dbstage->stage_id, "Stage updated.");
281
    is(
282
        $dbitem->itemnumber->homebranch,
283
        $dbstage->branchcode_id,
284
        "Item homebranch updated"
285
    );
286
    $intransfer = $dbitem->itemnumber->get_transfer;
287
    is($intransfer->frombranch, $dbstage2->branchcode_id, "Origin correct.");
288
    is($intransfer->tobranch, $dbstage->branchcode_id, "Target correct.");
289
290
    # Arrive at new branch
291
    $intransfer->datearrived(DateTime->now)->store;
292
    $dbitem->itemnumber->holdingbranch($srstage->{branchcode_id})->store;
293
266
    $dbstage->rota->cyclical(0)->store;         # Set Rota to non-cyclical.
294
    $dbstage->rota->cyclical(0)->store;         # Set Rota to non-cyclical.
267
295
296
    # Advance again, to end of rota.
297
    ok($dbitem->advance, "Non-cyclical advance to last stage.");
298
268
    # Arrive at new branch
299
    # Arrive at new branch
269
    $intransfer->datearrived(DateTime->now)->store;
300
    $intransfer->datearrived(DateTime->now)->store;
270
    $dbitem->itemnumber->holdingbranch($srstage->{branchcode_id})->store;
301
    $dbitem->itemnumber->holdingbranch($srstage->{branchcode_id})->store;
271
    $dbitem->itemnumber->homebranch($srstage->{branchcode_id})->store;
272
302
273
    # Advance again, Remove from rota.
303
    # Advance again, Remove from rota.
274
    ok($dbitem->advance, "Non-cyclical advance.");
304
    ok($dbitem->advance, "Non-cyclical advance.");
275
    ## Refetch dbitem
305
    ## Refetch dbitem
276
    $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id});
306
    $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id});
277
    is($dbitem, undef, "StockRotationItem has been removed.");
307
    is($dbitem, undef, "StockRotationItem has been removed.");
308
    my $item = Koha::Items->find($sritem->{itemnumber_id});
309
    is($item->homebranch, $srstage->{branchcode_id}, "Item homebranch remains");
278
310
279
    $schema->storage->txn_rollback;
311
    $schema->storage->txn_rollback;
280
};
312
};
281
- 

Return to bug 24446