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

(-)a/t/db_dependent/Biblio.t (-6 / +3 lines)
Lines 251-258 sub run_tests { Link Here
251
    # roll back ES index changes.
251
    # roll back ES index changes.
252
    t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
252
    t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
253
253
254
    my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
254
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
255
    $bgj_mock->mock( 'enqueue', undef );
256
255
257
    my $isbn = '0590353403';
256
    my $isbn = '0590353403';
258
    my $title = 'Foundation';
257
    my $title = 'Foundation';
Lines 639-646 subtest 'IsMarcStructureInternal' => sub { Link Here
639
subtest 'deletedbiblio_metadata' => sub {
638
subtest 'deletedbiblio_metadata' => sub {
640
    plan tests => 2;
639
    plan tests => 2;
641
640
642
    my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
641
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
643
    $bgj_mock->mock( 'enqueue', undef );
644
642
645
    my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
643
    my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
646
    my $biblio_metadata = C4::Biblio::GetXmlBiblio( $biblionumber );
644
    my $biblio_metadata = C4::Biblio::GetXmlBiblio( $biblionumber );
Lines 655-662 subtest 'DelBiblio' => sub { Link Here
655
653
656
    plan tests => 5;
654
    plan tests => 5;
657
655
658
    my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
656
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
659
    $bgj_mock->mock( 'enqueue', undef );
660
657
661
    my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, '');
658
    my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, '');
662
    my $deleted = C4::Biblio::DelBiblio( $biblionumber );
659
    my $deleted = C4::Biblio::DelBiblio( $biblionumber );
(-)a/t/db_dependent/Biblio_holdsqueue.t (+24 lines)
Lines 36-41 subtest 'ModBiblio() + holds_queue update tests' => sub { Link Here
36
36
37
    my $biblio = $builder->build_sample_biblio;
37
    my $biblio = $builder->build_sample_biblio;
38
38
39
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
40
39
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
41
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
40
    $mock->mock( 'enqueue', sub {
42
    $mock->mock( 'enqueue', sub {
41
        my ( $self, $args ) = @_;
43
        my ( $self, $args ) = @_;
Lines 69-74 subtest 'ModBiblio() + holds_queue update tests' => sub { Link Here
69
        $biblio->frameworkcode, { skip_holds_queue => 1 }
71
        $biblio->frameworkcode, { skip_holds_queue => 1 }
70
    );
72
    );
71
73
74
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
75
76
    # this call should not trigger the mocked 'enqueue'
77
    C4::Biblio::ModBiblio(
78
        $biblio->metadata->record, $biblio->id,
79
        $biblio->frameworkcode, { skip_holds_queue => 0 }
80
    );
81
82
    # this call shoul not trigger the mocked 'enqueue'
83
    C4::Biblio::ModBiblio(
84
        $biblio->metadata->record, $biblio->id,
85
        $biblio->frameworkcode, { skip_holds_queue => 1 }
86
    );
87
72
    $schema->storage->txn_rollback;
88
    $schema->storage->txn_rollback;
73
};
89
};
74
90
Lines 78-83 subtest 'DelBiblio + holds_queue update tests' => sub { Link Here
78
94
79
    $schema->storage->txn_begin;
95
    $schema->storage->txn_begin;
80
96
97
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
98
81
    my $biblio = $builder->build_sample_biblio;
99
    my $biblio = $builder->build_sample_biblio;
82
100
83
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
101
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
Lines 102-106 subtest 'DelBiblio + holds_queue update tests' => sub { Link Here
102
120
103
    C4::Biblio::DelBiblio( $biblio->id );
121
    C4::Biblio::DelBiblio( $biblio->id );
104
122
123
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
124
125
    $biblio = $builder->build_sample_biblio;
126
127
    C4::Biblio::DelBiblio( $biblio->id );
128
105
    $schema->storage->txn_rollback;
129
    $schema->storage->txn_rollback;
106
};
130
};
(-)a/t/db_dependent/Circulation_holdsqueue.t (+9 lines)
Lines 42-47 subtest 'AddIssue() and AddReturn() real-time holds queue tests' => sub { Link Here
42
42
43
    t::lib::Mocks::mock_userenv({ branchcode => $library->id });
43
    t::lib::Mocks::mock_userenv({ branchcode => $library->id });
44
    t::lib::Mocks::mock_preference( 'UpdateTotalIssuesOnCirc', 1 );
44
    t::lib::Mocks::mock_preference( 'UpdateTotalIssuesOnCirc', 1 );
45
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
45
46
46
    my $action;
47
    my $action;
47
48
Lines 62-66 subtest 'AddIssue() and AddReturn() real-time holds queue tests' => sub { Link Here
62
    $action = 'AddReturn';
63
    $action = 'AddReturn';
63
    AddReturn( $item->barcode );
64
    AddReturn( $item->barcode );
64
65
66
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
67
68
    $action = 'AddIssue';
69
    AddIssue( $patron->unblessed, $item->barcode, );
70
71
    $action = 'AddReturn';
72
    AddReturn( $item->barcode );
73
65
    $schema->storage->txn_rollback;
74
    $schema->storage->txn_rollback;
66
};
75
};
(-)a/t/db_dependent/Koha/BackgroundJobs/BatchDeleteBiblio.t (-1 / +28 lines)
Lines 28-33 use Koha::Database; Link Here
28
use Koha::BackgroundJob::BatchDeleteBiblio;
28
use Koha::BackgroundJob::BatchDeleteBiblio;
29
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
29
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
30
30
31
use t::lib::Mocks;
31
use t::lib::TestBuilder;
32
use t::lib::TestBuilder;
32
33
33
my $schema = Koha::Database->new->schema;
34
my $schema = Koha::Database->new->schema;
Lines 35-41 my $builder = t::lib::TestBuilder->new; Link Here
35
36
36
subtest "process() tests" => sub {
37
subtest "process() tests" => sub {
37
38
38
    plan tests => 1;
39
    plan tests => 2;
39
40
40
    $schema->storage->txn_begin;
41
    $schema->storage->txn_begin;
41
42
Lines 72-77 subtest "process() tests" => sub { Link Here
72
        }
73
        }
73
    );
74
    );
74
75
76
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
77
75
    $job->process(
78
    $job->process(
76
        {
79
        {
77
            record_ids => [ $biblio->id ],
80
            record_ids => [ $biblio->id ],
Lines 80-84 subtest "process() tests" => sub { Link Here
80
83
81
    is( $counter, 1, 'Holds queue update is enqueued only once' );
84
    is( $counter, 1, 'Holds queue update is enqueued only once' );
82
85
86
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
87
88
    $biblio = $builder->build_sample_biblio;
89
90
    $job = Koha::BackgroundJob::BatchDeleteBiblio->new(
91
        {
92
            status         => 'new',
93
            size           => 1,
94
            borrowernumber => undef,
95
            type           => 'batch_biblio_record_deletion',
96
            data           => encode_json {
97
                record_ids     => [ $biblio->id ],
98
            }
99
        }
100
    );
101
102
    $job->process(
103
        {
104
            record_ids => [ $biblio->id ],
105
        }
106
    );
107
108
    is( $counter, 1, 'Counter untouched with RealTimeHoldsQueue disabled' );
109
83
    $schema->storage->txn_rollback;
110
    $schema->storage->txn_rollback;
84
};
111
};
(-)a/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t (-2 / +32 lines)
Lines 25-30 use JSON qw( encode_json ); Link Here
25
use Koha::Database;
25
use Koha::Database;
26
use Koha::BackgroundJob::BatchDeleteItem;
26
use Koha::BackgroundJob::BatchDeleteItem;
27
27
28
use t::lib::Mocks;
28
use t::lib::TestBuilder;
29
use t::lib::TestBuilder;
29
30
30
my $schema = Koha::Database->new->schema;
31
my $schema = Koha::Database->new->schema;
Lines 32-38 my $builder = t::lib::TestBuilder->new; Link Here
32
33
33
subtest "process() tests" => sub {
34
subtest "process() tests" => sub {
34
35
35
    plan tests => 1;
36
    plan tests => 2;
36
37
37
    $schema->storage->txn_begin;
38
    $schema->storage->txn_begin;
38
39
Lines 47-58 subtest "process() tests" => sub { Link Here
47
        $counter++;
48
        $counter++;
48
    });
49
    });
49
50
51
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
52
50
    my $job = Koha::BackgroundJob::BatchDeleteItem->new(
53
    my $job = Koha::BackgroundJob::BatchDeleteItem->new(
51
        {
54
        {
52
            status         => 'new',
55
            status         => 'new',
53
            size           => 2,
56
            size           => 2,
54
            borrowernumber => undef,
57
            borrowernumber => undef,
55
            type           => 'batch_biblio_record_modification',
58
            type           => 'batch_item_record_deletion',
56
            data           => encode_json {
59
            data           => encode_json {
57
                record_ids     => [ $item_1->id, $item_2->id ],
60
                record_ids     => [ $item_1->id, $item_2->id ],
58
                delete_biblios => 1,
61
                delete_biblios => 1,
Lines 69-73 subtest "process() tests" => sub { Link Here
69
72
70
    is( $counter, 1, 'Holds queue update is enqueued only once' );
73
    is( $counter, 1, 'Holds queue update is enqueued only once' );
71
74
75
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
76
77
    $biblio = $builder->build_sample_biblio;
78
    my $item = $builder->build_sample_item({ biblionumber => $biblio->id });
79
80
    $job = Koha::BackgroundJob::BatchDeleteItem->new(
81
        {
82
            status         => 'new',
83
            size           => 2,
84
            borrowernumber => undef,
85
            type           => 'batch_item_record_deletion',
86
            data           => encode_json {
87
                record_ids     => [ $item->id ],
88
                delete_biblios => 1,
89
            }
90
        }
91
    );
92
93
    $job->process(
94
        {
95
            record_ids     => [ $item->id ],
96
            delete_biblios => 1,
97
        }
98
    );
99
100
    is( $counter, 1, 'Counter untouched with RealTimeHoldsQueue disabled' );
101
72
    $schema->storage->txn_rollback;
102
    $schema->storage->txn_rollback;
73
};
103
};
(-)a/t/db_dependent/Koha/Hold.t (+29 lines)
Lines 249-254 subtest 'fill() tests' => sub { Link Here
249
            );
249
            );
250
        } );
250
        } );
251
251
252
        t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
253
254
        $builder->build_object(
255
            {
256
                class => 'Koha::Holds',
257
                value => {
258
                    biblionumber   => $biblio->id,
259
                }
260
            }
261
        )->fill;
262
263
        t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
264
        # this call shouldn't add a new test
252
        $builder->build_object(
265
        $builder->build_object(
253
            {
266
            {
254
                class => 'Koha::Holds',
267
                class => 'Koha::Holds',
Lines 558-563 subtest 'cancel() tests' => sub { Link Here
558
571
559
        my $biblio = $builder->build_sample_biblio;
572
        my $biblio = $builder->build_sample_biblio;
560
573
574
        t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
575
561
        my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
576
        my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
562
        $mock->mock( 'enqueue', sub {
577
        $mock->mock( 'enqueue', sub {
563
            my ( $self, $args ) = @_;
578
            my ( $self, $args ) = @_;
Lines 586-591 subtest 'cancel() tests' => sub { Link Here
586
                }
601
                }
587
            }
602
            }
588
        )->cancel({ skip_holds_queue => 1 });
603
        )->cancel({ skip_holds_queue => 1 });
604
605
        t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
606
607
        $builder->build_object(
608
            {
609
                class => 'Koha::Holds',
610
                value => {
611
                    biblionumber   => $biblio->id,
612
                }
613
            }
614
        )->cancel({ skip_holds_queue => 0 });
589
    };
615
    };
590
616
591
    $schema->storage->txn_rollback;
617
    $schema->storage->txn_rollback;
Lines 600-605 subtest 'suspend_hold() and resume() tests' => sub { Link Here
600
    my $biblio = $builder->build_sample_biblio;
626
    my $biblio = $builder->build_sample_biblio;
601
    my $action;
627
    my $action;
602
628
629
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
630
603
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
631
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
604
    $mock->mock( 'enqueue', sub {
632
    $mock->mock( 'enqueue', sub {
605
        my ( $self, $args ) = @_;
633
        my ( $self, $args ) = @_;
Lines 615-620 subtest 'suspend_hold() and resume() tests' => sub { Link Here
615
            class => 'Koha::Holds',
643
            class => 'Koha::Holds',
616
            value => {
644
            value => {
617
                biblionumber => $biblio->id,
645
                biblionumber => $biblio->id,
646
                found        => undef,
618
            }
647
            }
619
        }
648
        }
620
    );
649
    );
(-)a/t/db_dependent/Koha/Item.t (+6 lines)
Lines 1243-1254 subtest 'store() tests' => sub { Link Here
1243
            );
1243
            );
1244
        } );
1244
        } );
1245
1245
1246
        t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
1247
1246
        # new item
1248
        # new item
1247
        my $item = $builder->build_sample_item({ biblionumber => $biblio->id });
1249
        my $item = $builder->build_sample_item({ biblionumber => $biblio->id });
1248
1250
1249
        # updated item
1251
        # updated item
1250
        $item->set({ reserves => 1 })->store;
1252
        $item->set({ reserves => 1 })->store;
1251
1253
1254
        t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
1255
        # updated item
1256
        $item->set({ reserves => 0 })->store;
1257
1252
        $schema->storage->txn_rollback;
1258
        $schema->storage->txn_rollback;
1253
    };
1259
    };
1254
};
1260
};
(-)a/t/db_dependent/Reserves.t (-1 / +27 lines)
Lines 961-966 subtest 'reserves.item_level_hold' => sub { Link Here
961
            );
961
            );
962
        } );
962
        } );
963
963
964
        t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
965
964
        # Revert the waiting status
966
        # Revert the waiting status
965
        C4::Reserves::RevertWaitingStatus(
967
        C4::Reserves::RevertWaitingStatus(
966
            { itemnumber => $item->itemnumber } );
968
            { itemnumber => $item->itemnumber } );
Lines 969-974 subtest 'reserves.item_level_hold' => sub { Link Here
969
971
970
        is( $hold->itemnumber, $item->itemnumber, 'Itemnumber should not be removed when the waiting status is revert' );
972
        is( $hold->itemnumber, $item->itemnumber, 'Itemnumber should not be removed when the waiting status is revert' );
971
973
974
        t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
975
976
        $hold->set_waiting;
977
978
        # Revert the waiting status, RealTimeHoldsQueue => shouldn't add a test
979
        C4::Reserves::RevertWaitingStatus(
980
            { itemnumber => $item->itemnumber } );
981
972
        $hold->delete;    # cleanup
982
        $hold->delete;    # cleanup
973
    };
983
    };
974
984
Lines 1428-1433 subtest 'AddReserve() tests' => sub { Link Here
1428
        );
1438
        );
1429
    } );
1439
    } );
1430
1440
1441
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
1442
1443
    AddReserve(
1444
        {
1445
            branchcode     => $library->branchcode,
1446
            borrowernumber => $patron->id,
1447
            biblionumber   => $biblio->id,
1448
        }
1449
    );
1450
1451
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
1452
1431
    AddReserve(
1453
    AddReserve(
1432
        {
1454
        {
1433
            branchcode     => $library->branchcode,
1455
            branchcode     => $library->branchcode,
Lines 1483-1488 subtest 'AlterPriorty() tests' => sub { Link Here
1483
        );
1505
        );
1484
    } );
1506
    } );
1485
1507
1508
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
1486
1509
1487
    AlterPriority( "bottom", $reserve_id, 1, 2, 1, 3 );
1510
    AlterPriority( "bottom", $reserve_id, 1, 2, 1, 3 );
1488
1511
Lines 1490-1494 subtest 'AlterPriorty() tests' => sub { Link Here
1490
1513
1491
    is($hold->priority,3,'Successfully altered priority to bottom');
1514
    is($hold->priority,3,'Successfully altered priority to bottom');
1492
1515
1516
    t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
1517
1518
    AlterPriority( "bottom", $reserve_id, 1, 2, 1, 3 );
1519
1493
    $schema->storage->txn_rollback;
1520
    $schema->storage->txn_rollback;
1494
};
1521
};
1495
- 

Return to bug 30728