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 => 12;
20
use Test::More tests => 13;
21
21
22
use C4::Biblio;
22
use C4::Biblio;
23
use Koha::Database;
23
use Koha::Database;
Lines 551-553 subtest 'subscriptions() tests' => sub { Link Here
551
551
552
    $schema->storage->txn_rollback;
552
    $schema->storage->txn_rollback;
553
};
553
};
554
555
subtest 'adopt_items_from_biblio() tests' => sub {
556
557
    plan tests => 2;
558
559
    $schema->storage->txn_begin;
560
561
    my $biblio1 = $builder->build_sample_biblio;
562
    my $biblio2 = $builder->build_sample_biblio;
563
    my $item1 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
564
    my $item2 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
565
566
    $biblio2->adopt_items_from_biblio($biblio1);
567
568
    $item1->discard_changes;
569
    $item2->discard_changes;
570
571
    is($item1->biblionumber, $biblio2->biblionumber, "Item 1 moved");
572
    is($item2->biblionumber, $biblio2->biblionumber, "Item 2 moved");
573
574
    $schema->storage->txn_rollback;
575
};
(-)a/t/db_dependent/Koha/Item.t (-2 / +43 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 8;
22
use Test::More tests => 9;
23
23
24
use C4::Biblio;
24
use C4::Biblio;
25
use C4::Circulation;
25
use C4::Circulation;
Lines 629-636 subtest 'Tests for itemtype' => sub { Link Here
629
    $schema->storage->txn_rollback;
629
    $schema->storage->txn_rollback;
630
};
630
};
631
631
632
subtest 'move_to_biblio() tests' => sub {
632
subtest 'Tests for relationship between item and item_orders via aqorders_item' => sub {
633
    plan tests => 2;
634
635
    my $biblio = $builder->build_sample_biblio();
636
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
637
    my $aq_budget = $builder->build({
638
        source => 'Aqbudget',
639
        value  => {
640
            budget_notes => 'test',
641
        },
642
    });
643
644
    my $order_note = 'Order for ' . $item->itemnumber;
645
646
    my $aq_order1 = $builder->build_object({
647
        class => 'Koha::Acquisition::Orders',
648
        value  => {
649
            biblionumber => $biblio->biblionumber,
650
            budget_id => $aq_budget->{budget_id},
651
            order_internalnote => $order_note,
652
        },
653
    });
654
    my $aq_order2 = $builder->build_object({
655
        class => 'Koha::Acquisition::Orders',
656
        value  => {
657
            biblionumber => $biblio->biblionumber,
658
            budget_id => $aq_budget->{budget_id},
659
        },
660
    });
661
    my $aq_order_item1 = $builder->build({
662
        source => 'AqordersItem',
663
        value  => {
664
            ordernumber => $aq_order1->ordernumber,
665
            itemnumber => $item->itemnumber,
666
        },
667
    });
668
669
    my $orders = $item->item_orders;
670
    is ($orders->count, 1, 'One order found by item with the relationship');
671
    is ($orders->next->order_internalnote, $order_note, 'Correct order found by item with the relationship');
672
};
633
673
674
subtest 'move_to_biblio() tests' => sub {
634
    plan tests => 16;
675
    plan tests => 16;
635
676
636
    $schema->storage->txn_begin;
677
    $schema->storage->txn_begin;
(-)a/t/db_dependent/Koha/SearchEngine/Indexer.t (-2 / +9 lines)
Lines 60-66 subtest 'Test indexer object creation' => sub { Link Here
60
};
60
};
61
61
62
subtest 'Test indexer calls' => sub {
62
subtest 'Test indexer calls' => sub {
63
    plan tests => 44;
63
    plan tests => 46;
64
64
65
    my @engines = ('Zebra');
65
    my @engines = ('Zebra');
66
    eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; };
66
    eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; };
Lines 70-75 subtest 'Test indexer calls' => sub { Link Here
70
            if scalar @engines == 1;
70
            if scalar @engines == 1;
71
    }
71
    }
72
72
73
    t::lib::Mocks::mock_preference( 'BiblioAddsAuthorities', 0 );
74
73
    for my $engine ( @engines ){
75
    for my $engine ( @engines ){
74
        t::lib::Mocks::mock_preference( 'SearchEngine', $engine );
76
        t::lib::Mocks::mock_preference( 'SearchEngine', $engine );
75
        my $mock_index = Test::MockModule->new("Koha::SearchEngine::".$engine."::Indexer");
77
        my $mock_index = Test::MockModule->new("Koha::SearchEngine::".$engine."::Indexer");
Lines 167-172 subtest 'Test indexer calls' => sub { Link Here
167
            $item4->move_to_biblio($biblio2, { skip_record_index => 1 });
169
            $item4->move_to_biblio($biblio2, { skip_record_index => 1 });
168
        } 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
        } undef, "index_records is not called for $engine when moving an item to another biblio (Item->move_to_biblio) if skip_record_index passed";
169
171
172
        my $item5 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
173
        my $item6 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
174
        warnings_are{
175
            $biblio2->adopt_items_from_biblio($biblio);
176
        } [$engine,"Koha::Biblio",$engine,"Koha::Biblio"], "index_records is called for both biblios for $engine when adopting items (Biblio->adopt_items_from_biblio)";
177
170
        $builder->build({
178
        $builder->build({
171
            source => 'Branchtransfer',
179
            source => 'Branchtransfer',
172
            value => {
180
            value => {
173
- 

Return to bug 22690