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

(-)a/t/db_dependent/Koha/Item/Transfers.t (-1 / +1 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
23
24
use Koha::Item::Transfer;
24
use Koha::Item::Transfer;
25
use Koha::Item::Transfers;
25
use Koha::Item::Transfers;
(-)a/t/db_dependent/Koha/Libraries.t (+35 lines)
Lines 277-279 subtest 'get_hold_libraries and validate_hold_sibling' => sub { Link Here
277
    $schema->storage->txn_rollback;
277
    $schema->storage->txn_rollback;
278
278
279
};
279
};
280
281
subtest 'outgoing_transfers' => sub {
282
    plan tests => 3;
283
284
    $schema->storage->txn_begin;
285
286
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
287
    my $transfer1 = $builder->build_object(
288
        {
289
            class => 'Koha::Item::Transfers',
290
            value  => { frombranch => $library->branchcode },
291
        }
292
    );
293
    my $transfer2 = $builder->build_object(
294
        {
295
            class => 'Koha::Item::Transfers',
296
            value  => { frombranch => $library->branchcode },
297
        }
298
    );
299
300
    my $outgoing_transfers = $library->outgoing_transfers;
301
    is( ref($outgoing_transfers), 'Koha::Item::Transfers',
302
'Koha::Library->outgoing_transfers should return a set of Koha::Item::Transfers'
303
    );
304
    is( $outgoing_transfers->count, 2,
305
        'Koha::Library->outgoing_transfers should return the correct transfers'
306
    );
307
308
    $transfer1->delete;
309
    is( $library->outgoing_transfers->next->id, $transfer2->id,
310
        'Koha::Library->outgoing_transfers should return the correct cash registers'
311
    );
312
313
    $schema->storage->txn_rollback;
314
};
(-)a/t/db_dependent/StockRotationItems.t (-2 / +57 lines)
Lines 29-35 use Test::Warn; Link Here
29
use t::lib::TestBuilder;
29
use t::lib::TestBuilder;
30
use t::lib::Mocks;
30
use t::lib::Mocks;
31
31
32
use Test::More tests => 8;
32
use Test::More tests => 9;
33
33
34
my $schema = Koha::Database->new->schema;
34
my $schema = Koha::Database->new->schema;
35
35
Lines 652-655 subtest "Tests for investigate (singular)." => sub { Link Here
652
    $schema->storage->txn_rollback;
652
    $schema->storage->txn_rollback;
653
};
653
};
654
654
655
subtest "Tests for toggle_indemand" => sub {
656
    plan tests => 15;
657
    $schema->storage->txn_begin;
658
659
    my $sritem = $builder->build({
660
        source => 'Stockrotationitem',
661
        value => { 'fresh' => 0, 'indemand' => 0 }
662
    });
663
    my $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id});
664
    my $firstbranch = $dbitem->stage->branchcode_id;
665
    $dbitem->itemnumber->holdingbranch($firstbranch)->store;
666
    my $dbstage = $dbitem->stage;
667
    $dbstage->position(1)->duration(50)->store; # Configure stage.
668
    # Configure item
669
    $dbitem->itemnumber->holdingbranch($firstbranch)->store;
670
    $dbitem->itemnumber->homebranch($firstbranch)->store;
671
    # Sanity check
672
    is($dbitem->stage->stage_id, $dbstage->stage_id, "Stage sanity check.");
673
674
    # Test if an item is not in transfer, toggle always acts.
675
    is($dbitem->indemand, 0, "Item not in transfer starts with indemand disabled.");
676
    $dbitem->toggle_indemand;
677
    is($dbitem->indemand, 1, "Item not in transfer toggled correctly first time.");
678
    $dbitem->toggle_indemand;
679
    is($dbitem->indemand, 0, "Item not in transfer toggled correctly second time.");
680
681
    # Add stages
682
    my $srstage = $builder->build({
683
        source => 'Stockrotationstage',
684
        value => { duration => 50 }
685
    });
686
    my $dbstage2 = Koha::StockRotationStages->find($srstage->{stage_id});
687
    $dbstage2->move_to_group($dbitem->stage->rota_id);
688
    $dbstage2->position(2)->store;
689
    my $secondbranch = $dbstage2->branchcode_id;
690
691
    # Test an item in transfer, toggle cancels transfer and resets indemand.
692
    ok($dbitem->advance, "Advancement done.");
693
    $dbitem->get_from_storage;
694
    my $transfer = $dbitem->itemnumber->get_transfer;
695
    is(ref($transfer), 'Koha::Item::Transfer', 'Item set to in transfer as expected');
696
    is($transfer->frombranch, $firstbranch, 'Transfer from set correctly');
697
    is($transfer->tobranch, $secondbranch, 'Transfer to set correctly');
698
    is($transfer->datearrived, undef, 'Transfer datearrived not set');
699
    $dbitem->toggle_indemand;
700
    my $updated_transfer = $transfer->get_from_storage;
701
    is($updated_transfer->frombranch, $firstbranch, 'Transfer from retained correctly');
702
    is($updated_transfer->tobranch, $firstbranch, 'Transfer to updated correctly');
703
    isnt($updated_transfer->datearrived, undef, 'Transfer datearrived set as expected');
704
    is($dbitem->indemand, 0, "Item retains indemand as expected.");
705
    is($dbitem->stage_id, $dbstage->id, 'Item stage reset as expected.');
706
    is($dbitem->itemnumber->homebranch, $firstbranch, 'Item homebranch reset as expected.');
707
708
    $schema->storage->txn_rollback;
709
};
710
655
1;
711
1;
656
- 

Return to bug 22569