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 558-560 subtest 'subscriptions() tests' => sub { Link Here
558
558
559
    $schema->storage->txn_rollback;
559
    $schema->storage->txn_rollback;
560
};
560
};
561
562
subtest 'adopt_items_from_biblio() tests' => sub {
563
564
    plan tests => 2;
565
566
    $schema->storage->txn_begin;
567
568
    my $biblio1 = $builder->build_sample_biblio;
569
    my $biblio2 = $builder->build_sample_biblio;
570
    my $item1 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
571
    my $item2 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
572
573
    $biblio2->adopt_items_from_biblio($biblio1);
574
575
    $item1->discard_changes;
576
    $item2->discard_changes;
577
578
    is($item1->biblionumber, $biblio2->biblionumber, "Item 1 moved");
579
    is($item2->biblionumber, $biblio2->biblionumber, "Item 2 moved");
580
581
    $schema->storage->txn_rollback;
582
};
(-)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 517-524 subtest 'Tests for itemtype' => sub { Link Here
517
    $schema->storage->txn_rollback;
517
    $schema->storage->txn_rollback;
518
};
518
};
519
519
520
subtest 'move_to_biblio() tests' => sub {
520
subtest 'Tests for relationship between item and item_orders via aqorders_item' => sub {
521
    plan tests => 2;
522
523
    my $biblio = $builder->build_sample_biblio();
524
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
525
    my $aq_budget = $builder->build({
526
        source => 'Aqbudget',
527
        value  => {
528
            budget_notes => 'test',
529
        },
530
    });
531
532
    my $order_note = 'Order for ' . $item->itemnumber;
533
534
    my $aq_order1 = $builder->build_object({
535
        class => 'Koha::Acquisition::Orders',
536
        value  => {
537
            biblionumber => $biblio->biblionumber,
538
            budget_id => $aq_budget->{budget_id},
539
            order_internalnote => $order_note,
540
        },
541
    });
542
    my $aq_order2 = $builder->build_object({
543
        class => 'Koha::Acquisition::Orders',
544
        value  => {
545
            biblionumber => $biblio->biblionumber,
546
            budget_id => $aq_budget->{budget_id},
547
        },
548
    });
549
    my $aq_order_item1 = $builder->build({
550
        source => 'AqordersItem',
551
        value  => {
552
            ordernumber => $aq_order1->ordernumber,
553
            itemnumber => $item->itemnumber,
554
        },
555
    });
556
557
    my $orders = $item->item_orders;
558
    is ($orders->count, 1, 'One order found by item with the relationship');
559
    is ($orders->next->order_internalnote, $order_note, 'Correct order found by item with the relationship');
560
};
521
561
562
subtest 'move_to_biblio() tests' => sub {
522
    plan tests => 16;
563
    plan tests => 16;
523
564
524
    $schema->storage->txn_begin;
565
    $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