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

(-)a/t/db_dependent/Koha/Biblio.t (-1 / +23 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 14;
20
use Test::More tests => 15;
21
21
22
use C4::Biblio;
22
use C4::Biblio;
23
use Koha::Database;
23
use Koha::Database;
Lines 610-612 subtest 'get_marc_notes() UNIMARC tests' => sub { Link Here
610
610
611
    $schema->storage->txn_rollback;
611
    $schema->storage->txn_rollback;
612
};
612
};
613
614
subtest 'adopt_items_from_biblio() tests' => sub {
615
616
    plan tests => 2;
617
618
    $schema->storage->txn_begin;
619
620
    my $biblio1 = $builder->build_sample_biblio;
621
    my $biblio2 = $builder->build_sample_biblio;
622
    my $item1 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
623
    my $item2 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
624
625
    $biblio2->adopt_items_from_biblio($biblio1);
626
627
    $item1->discard_changes;
628
    $item2->discard_changes;
629
630
    is($item1->biblionumber, $biblio2->biblionumber, "Item 1 moved");
631
    is($item2->biblionumber, $biblio2->biblionumber, "Item 2 moved");
632
633
    $schema->storage->txn_rollback;
634
};
(-)a/t/db_dependent/Koha/Item.t (-1 / +42 lines)
Lines 697-704 subtest 'Tests for itemtype' => sub { Link Here
697
    $schema->storage->txn_rollback;
697
    $schema->storage->txn_rollback;
698
};
698
};
699
699
700
subtest 'move_to_biblio() tests' => sub {
700
subtest 'Tests for relationship between item and item_orders via aqorders_item' => sub {
701
    plan tests => 2;
702
703
    my $biblio = $builder->build_sample_biblio();
704
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
705
    my $aq_budget = $builder->build({
706
        source => 'Aqbudget',
707
        value  => {
708
            budget_notes => 'test',
709
        },
710
    });
711
712
    my $order_note = 'Order for ' . $item->itemnumber;
713
714
    my $aq_order1 = $builder->build_object({
715
        class => 'Koha::Acquisition::Orders',
716
        value  => {
717
            biblionumber => $biblio->biblionumber,
718
            budget_id => $aq_budget->{budget_id},
719
            order_internalnote => $order_note,
720
        },
721
    });
722
    my $aq_order2 = $builder->build_object({
723
        class => 'Koha::Acquisition::Orders',
724
        value  => {
725
            biblionumber => $biblio->biblionumber,
726
            budget_id => $aq_budget->{budget_id},
727
        },
728
    });
729
    my $aq_order_item1 = $builder->build({
730
        source => 'AqordersItem',
731
        value  => {
732
            ordernumber => $aq_order1->ordernumber,
733
            itemnumber => $item->itemnumber,
734
        },
735
    });
736
737
    my $orders = $item->item_orders;
738
    is ($orders->count, 1, 'One order found by item with the relationship');
739
    is ($orders->next->order_internalnote, $order_note, 'Correct order found by item with the relationship');
740
};
701
741
742
subtest 'move_to_biblio() tests' => sub {
702
    plan tests => 16;
743
    plan tests => 16;
703
744
704
    $schema->storage->txn_begin;
745
    $schema->storage->txn_begin;
(-)a/t/db_dependent/Koha/SearchEngine/Indexer.t (-2 / +9 lines)
Lines 61-67 subtest 'Test indexer object creation' => sub { Link Here
61
};
61
};
62
62
63
subtest 'Test indexer calls' => sub {
63
subtest 'Test indexer calls' => sub {
64
    plan tests => 44;
64
    plan tests => 46;
65
65
66
    my @engines = ('Zebra');
66
    my @engines = ('Zebra');
67
    eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; };
67
    eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; };
Lines 71-76 subtest 'Test indexer calls' => sub { Link Here
71
            if scalar @engines == 1;
71
            if scalar @engines == 1;
72
    }
72
    }
73
73
74
    t::lib::Mocks::mock_preference( 'BiblioAddsAuthorities', 0 );
75
74
    for my $engine ( @engines ){
76
    for my $engine ( @engines ){
75
        t::lib::Mocks::mock_preference( 'SearchEngine', $engine );
77
        t::lib::Mocks::mock_preference( 'SearchEngine', $engine );
76
        my $mock_index = Test::MockModule->new("Koha::SearchEngine::".$engine."::Indexer");
78
        my $mock_index = Test::MockModule->new("Koha::SearchEngine::".$engine."::Indexer");
Lines 168-173 subtest 'Test indexer calls' => sub { Link Here
168
            $item4->move_to_biblio($biblio2, { skip_record_index => 1 });
170
            $item4->move_to_biblio($biblio2, { skip_record_index => 1 });
169
        } undef, "index_records is not called for $engine when moving an item to another biblio (Item->move_to_biblio) if skip_record_index passed";
171
        } undef, "index_records is not called for $engine when moving an item to another biblio (Item->move_to_biblio) if skip_record_index passed";
170
172
173
        my $item5 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
174
        my $item6 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
175
        warnings_are{
176
            $biblio2->adopt_items_from_biblio($biblio);
177
        } [$engine,"Koha::Biblio",$engine,"Koha::Biblio"], "index_records is called for both biblios for $engine when adopting items (Biblio->adopt_items_from_biblio)";
178
171
        $builder->build(
179
        $builder->build(
172
            {
180
            {
173
                source => 'Branchtransfer',
181
                source => 'Branchtransfer',
174
- 

Return to bug 22690