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

(-)a/t/db_dependent/Koha/Libraries.t (-1 / +36 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
23
24
use C4::Biblio;
24
use C4::Biblio;
25
use C4::Context;
25
use C4::Context;
Lines 300-302 subtest 'get_hold_libraries and validate_hold_sibling' => sub { Link Here
300
    $schema->storage->txn_rollback;
300
    $schema->storage->txn_rollback;
301
301
302
};
302
};
303
304
subtest 'outgoing_transfers' => sub {
305
    plan tests => 3;
306
307
    $schema->storage->txn_begin;
308
309
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
310
    my $transfer1 = $builder->build_object(
311
        {
312
            class => 'Koha::Item::Transfers',
313
            value  => { frombranch => $library->branchcode },
314
        }
315
    );
316
    my $transfer2 = $builder->build_object(
317
        {
318
            class => 'Koha::Item::Transfers',
319
            value  => { frombranch => $library->branchcode },
320
        }
321
    );
322
323
    my $outgoing_transfers = $library->outgoing_transfers;
324
    is( ref($outgoing_transfers), 'Koha::Item::Transfers',
325
'Koha::Library->outgoing_transfers should return a set of Koha::Item::Transfers'
326
    );
327
    is( $outgoing_transfers->count, 2,
328
        'Koha::Library->outgoing_transfers should return the correct number of transfers'
329
    );
330
331
    $transfer1->delete;
332
    is( $library->outgoing_transfers->next->id, $transfer2->id,
333
        'Koha::Library->outgoing_transfers should return the correct transfers'
334
    );
335
336
    $schema->storage->txn_rollback;
337
};
(-)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