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

(-)a/t/db_dependent/Biblio.t (-38 / +5 lines)
Lines 639-646 subtest 'IsMarcStructureInternal' => sub { Link Here
639
subtest 'deletedbiblio_metadata' => sub {
639
subtest 'deletedbiblio_metadata' => sub {
640
    plan tests => 2;
640
    plan tests => 2;
641
641
642
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
642
    my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
643
    $mock->mock( 'enqueue', undef );
643
    $bgj_mock->mock( 'enqueue', undef );
644
644
645
    my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
645
    my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
646
    my $biblio_metadata = C4::Biblio::GetXmlBiblio( $biblionumber );
646
    my $biblio_metadata = C4::Biblio::GetXmlBiblio( $biblionumber );
Lines 653-662 subtest 'deletedbiblio_metadata' => sub { Link Here
653
653
654
subtest 'DelBiblio' => sub {
654
subtest 'DelBiblio' => sub {
655
655
656
    plan tests => 6;
656
    plan tests => 5;
657
657
658
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
658
    my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
659
    $mock->mock( 'enqueue', undef );
659
    $bgj_mock->mock( 'enqueue', undef );
660
660
661
    my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, '');
661
    my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, '');
662
    my $deleted = C4::Biblio::DelBiblio( $biblionumber );
662
    my $deleted = C4::Biblio::DelBiblio( $biblionumber );
Lines 694-732 subtest 'DelBiblio' => sub { Link Here
694
    is( $subscription->get_from_storage, undef, 'subscription should be deleted on biblio deletion' );
694
    is( $subscription->get_from_storage, undef, 'subscription should be deleted on biblio deletion' );
695
    is( $serial->get_from_storage, undef, 'serial should be deleted on biblio deletion' );
695
    is( $serial->get_from_storage, undef, 'serial should be deleted on biblio deletion' );
696
    is( $subscription_history->get_from_storage, undef, 'subscription history should be deleted on biblio deletion' );
696
    is( $subscription_history->get_from_storage, undef, 'subscription history should be deleted on biblio deletion' );
697
698
    subtest 'holds_queue update tests' => sub {
699
700
        plan tests => 1;
701
702
        $schema->storage->txn_begin;
703
704
        my $biblio = $builder->build_sample_biblio;
705
706
        my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
707
        $mock->mock( 'enqueue', sub {
708
            my ( $self, $args ) = @_;
709
            is_deeply(
710
                $args->{biblio_ids},
711
                [ $biblio->id ],
712
                '->cancel triggers a holds queue update for the related biblio'
713
            );
714
        } );
715
716
        # add a hold
717
        $builder->build_object(
718
            {
719
                class => 'Koha::Holds',
720
                value => {
721
                    biblionumber   => $biblio->id,
722
                }
723
            }
724
        );
725
726
        C4::Biblio::DelBiblio( $biblio->id );
727
728
        $schema->storage->txn_rollback;
729
    };
730
};
697
};
731
698
732
subtest 'MarcFieldForCreatorAndModifier' => sub {
699
subtest 'MarcFieldForCreatorAndModifier' => sub {
(-)a/t/db_dependent/Biblio_holdsqueue.t (+106 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 2;
21
use Test::MockModule;
22
23
use t::lib::Mocks;
24
use t::lib::TestBuilder;
25
26
use Koha::Database;
27
28
my $schema = Koha::Database->new->schema;
29
my $builder = t::lib::TestBuilder->new;
30
31
subtest 'ModBiblio() + holds_queue update tests' => sub {
32
33
    plan tests => 1;
34
35
    $schema->storage->txn_begin;
36
37
    my $biblio = $builder->build_sample_biblio;
38
39
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
40
    $mock->mock( 'enqueue', sub {
41
        my ( $self, $args ) = @_;
42
        my ($package, $filename, $line) = caller;
43
        is_deeply(
44
            $args->{biblio_ids},
45
            [ $biblio->id ],
46
            'ModBiblio triggers a holds queue update for the related biblio'
47
        );
48
    } );
49
50
    # add a hold
51
    $builder->build_object(
52
        {
53
            class => 'Koha::Holds',
54
            value => {
55
                biblionumber   => $biblio->id,
56
            }
57
        }
58
    );
59
60
    # this call will trigger the mocked 'enqueue'
61
    C4::Biblio::ModBiblio(
62
        $biblio->metadata->record, $biblio->id,
63
        $biblio->frameworkcode, { skip_holds_queue => 0 }
64
    );
65
66
    # this call will not trigger the mocked 'enqueue', so the test count is 1
67
    C4::Biblio::ModBiblio(
68
        $biblio->metadata->record, $biblio->id,
69
        $biblio->frameworkcode, { skip_holds_queue => 1 }
70
    );
71
72
    $schema->storage->txn_rollback;
73
};
74
75
subtest 'DelBiblio + holds_queue update tests' => sub {
76
77
    plan tests => 1;
78
79
    $schema->storage->txn_begin;
80
81
    my $biblio = $builder->build_sample_biblio;
82
83
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
84
    $mock->mock( 'enqueue', sub {
85
        my ( $self, $args ) = @_;
86
        is_deeply(
87
            $args->{biblio_ids},
88
            [ $biblio->id ],
89
            'DelBiblio triggers a holds queue update for the related biblio'
90
        );
91
    } );
92
93
    # add a hold
94
    $builder->build_object(
95
        {
96
            class => 'Koha::Holds',
97
            value => {
98
                biblionumber   => $biblio->id,
99
            }
100
        }
101
    );
102
103
    C4::Biblio::DelBiblio( $biblio->id );
104
105
    $schema->storage->txn_rollback;
106
};
(-)a/t/db_dependent/Circulation_holdsqueue.t (-2 / +1 lines)
Lines 52-58 subtest 'AddIssue() and AddReturn() real-time holds queue tests' => sub { Link Here
52
        is_deeply(
52
        is_deeply(
53
            $args->{biblio_ids},
53
            $args->{biblio_ids},
54
            [ $item->biblionumber ],
54
            [ $item->biblionumber ],
55
            "$action triggers a holds queue update for the related biblio from $package"
55
            "$action triggers a holds queue update for the related biblio from $package at line $line"
56
        );
56
        );
57
    } );
57
    } );
58
58
59
- 

Return to bug 29346