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

(-)a/t/db_dependent/Koha/Plugins/Holds_hooks.t (-1 / +64 lines)
Lines 16-22 Link Here
16
16
17
use Modern::Perl;
17
use Modern::Perl;
18
18
19
use Test::More tests => 4;
19
use Test::More tests => 5;
20
use Test::MockModule;
20
use Test::MockModule;
21
use Test::Warn;
21
use Test::Warn;
22
22
Lines 80-82 subtest 'after_hold_create() hook tests' => sub { Link Here
80
    $schema->storage->txn_rollback;
80
    $schema->storage->txn_rollback;
81
    Koha::Plugins::Methods->delete;
81
    Koha::Plugins::Methods->delete;
82
};
82
};
83
84
subtest 'Koha::Hold tests' => sub {
85
86
    plan tests => 4;
87
88
    $schema->storage->txn_begin;
89
90
    my $plugins = Koha::Plugins->new;
91
    $plugins->InstallPlugins;
92
93
    my $plugin = Koha::Plugin::Test->new->enable;
94
95
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
96
97
    # Reduce noise
98
    t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' );
99
    t::lib::Mocks::mock_preference( 'HoldsLog',    0 );
100
101
    my $hold = $builder->build_object(
102
        {
103
            class => 'Koha::Holds',
104
            value => {
105
                borrowernumber => $patron->id,
106
            }
107
        }
108
    );
109
110
    warning_like {
111
        $hold->fill;
112
    }
113
    qr/after_hold_action called with action: fill, ref: Koha::Old::Hold/,
114
      '->fill calls the after_hold_action hook';
115
116
    $hold = $builder->build_object(
117
        {
118
            class => 'Koha::Holds',
119
            value => {
120
                borrowernumber => $patron->id,
121
            }
122
        }
123
    );
124
125
    warning_like {
126
        $hold->suspend_hold;
127
    }
128
    qr/after_hold_action called with action: suspend, ref: Koha::Hold/,
129
      '->suspend_hold calls the after_hold_action hook';
130
131
    warning_like {
132
        $hold->resume;
133
    }
134
    qr/after_hold_action called with action: resume, ref: Koha::Hold/,
135
      '->resume calls the after_hold_action hook';
136
137
    warning_like {
138
        $hold->cancel;
139
    }
140
    qr/after_hold_action called with action: cancel, ref: Koha::Old::Hold/,
141
      '->cancel calls the after_hold_action hook';
142
143
    $schema->storage->txn_rollback;
144
    Koha::Plugins::Methods->delete;
145
};
(-)a/t/lib/plugins/Koha/Plugin/Test.pm (-1 / +10 lines)
Lines 206-211 sub after_circ_action { Link Here
206
    }
206
    }
207
}
207
}
208
208
209
sub after_hold_action {
210
    my ( $self, $params ) = @_;
211
212
    my $action = $params->{action};
213
    my $hold   = $params->{payload}->{hold};
214
215
    Koha::Exceptions::Exception->throw(
216
        "after_hold_action called with action: $action, ref: " . ref($hold) );
217
}
218
209
sub api_routes {
219
sub api_routes {
210
    my ( $self, $args ) = @_;
220
    my ( $self, $args ) = @_;
211
221
212
- 

Return to bug 30072