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 692-699 subtest 'Tests for itemtype' => sub { Link Here
692
    $schema->storage->txn_rollback;
692
    $schema->storage->txn_rollback;
693
};
693
};
694
694
695
subtest 'move_to_biblio() tests' => sub {
695
subtest 'Tests for relationship between item and item_orders via aqorders_item' => sub {
696
    plan tests => 2;
697
698
    my $biblio = $builder->build_sample_biblio();
699
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
700
    my $aq_budget = $builder->build({
701
        source => 'Aqbudget',
702
        value  => {
703
            budget_notes => 'test',
704
        },
705
    });
706
707
    my $order_note = 'Order for ' . $item->itemnumber;
708
709
    my $aq_order1 = $builder->build_object({
710
        class => 'Koha::Acquisition::Orders',
711
        value  => {
712
            biblionumber => $biblio->biblionumber,
713
            budget_id => $aq_budget->{budget_id},
714
            order_internalnote => $order_note,
715
        },
716
    });
717
    my $aq_order2 = $builder->build_object({
718
        class => 'Koha::Acquisition::Orders',
719
        value  => {
720
            biblionumber => $biblio->biblionumber,
721
            budget_id => $aq_budget->{budget_id},
722
        },
723
    });
724
    my $aq_order_item1 = $builder->build({
725
        source => 'AqordersItem',
726
        value  => {
727
            ordernumber => $aq_order1->ordernumber,
728
            itemnumber => $item->itemnumber,
729
        },
730
    });
731
732
    my $orders = $item->item_orders;
733
    is ($orders->count, 1, 'One order found by item with the relationship');
734
    is ($orders->next->order_internalnote, $order_note, 'Correct order found by item with the relationship');
735
};
696
736
737
subtest 'move_to_biblio() tests' => sub {
697
    plan tests => 16;
738
    plan tests => 16;
698
739
699
    $schema->storage->txn_begin;
740
    $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