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

(-)a/t/db_dependent/Koha/Plugins/Holds_hooks.t (+1 lines)
Lines 68-73 subtest 'after_hold_create() hook tests' => sub { Link Here
68
    $test_plugin->mock( 'after_biblio_action', undef );
68
    $test_plugin->mock( 'after_biblio_action', undef );
69
    $test_plugin->mock( 'item_barcode_transform', undef );
69
    $test_plugin->mock( 'item_barcode_transform', undef );
70
    $test_plugin->mock( 'after_hold_action', undef );
70
    $test_plugin->mock( 'after_hold_action', undef );
71
    $test_plugin->mock( 'before_send_messages', undef );
71
72
72
    my $biblio = $builder->build_sample_biblio();
73
    my $biblio = $builder->build_sample_biblio();
73
    my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
74
    my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } );
(-)a/t/db_dependent/Koha/Plugins/Message_hooks.t (+79 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 under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
16
17
use Modern::Perl;
18
19
use Test::More tests => 4;
20
use Test::MockModule;
21
use Test::Warn;
22
23
use File::Basename;
24
25
use C4::Letters qw( SendQueuedMessages );
26
27
use t::lib::Mocks;
28
use t::lib::TestBuilder;
29
30
BEGIN {
31
    # Mock pluginsdir before loading Plugins module
32
    my $path = dirname(__FILE__) . '/../../../lib/plugins';
33
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
34
35
    use_ok('Koha::Plugins');
36
    use_ok('Koha::Plugins::Handler');
37
    use_ok('Koha::Plugin::Test');
38
}
39
40
my $schema  = Koha::Database->new->schema;
41
my $builder = t::lib::TestBuilder->new;
42
43
t::lib::Mocks::mock_config( 'enable_plugins', 1 );
44
45
subtest 'after_hold_create() hook tests' => sub {
46
47
    plan tests => 1;
48
49
    $schema->storage->txn_begin;
50
51
    my $plugins = Koha::Plugins->new;
52
    $plugins->InstallPlugins;
53
54
    my $plugin = Koha::Plugin::Test->new->enable;
55
56
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
57
58
    t::lib::Mocks::mock_userenv(
59
        {
60
            patron     => $patron,
61
            branchcode => $patron->branchcode
62
        }
63
    );
64
65
    # Avoid testing useless warnings
66
    my $test_plugin = Test::MockModule->new('Koha::Plugin::Test');
67
    $test_plugin->mock( 'after_item_action',      undef );
68
    $test_plugin->mock( 'after_biblio_action',    undef );
69
    $test_plugin->mock( 'item_barcode_transform', undef );
70
    $test_plugin->mock( 'after_hold_action',      undef );
71
72
    warnings_like { SendQueuedMessages(); }
73
    [qr/before_send_messages called/],
74
        'Plugin hook before_send_messages triggered when SendQueuedMessages is called';
75
76
    Koha::Plugins->RemovePlugins;
77
    $schema->storage->txn_rollback;
78
};
79
(-)a/t/db_dependent/Koha/Plugins/Plugins.t (+1 lines)
Lines 257-262 subtest 'Koha::Plugin::Test' => sub { Link Here
257
    ok( $plugin->can('intranet_catalog_biblio_enhancements_toolbar_button'), 'Test plugin can intranet_catalog_biblio_enhancements_toolbar_button' );
257
    ok( $plugin->can('intranet_catalog_biblio_enhancements_toolbar_button'), 'Test plugin can intranet_catalog_biblio_enhancements_toolbar_button' );
258
    ok( $plugin->can('opac_online_payment'), 'Test plugin can opac_online_payment' );
258
    ok( $plugin->can('opac_online_payment'), 'Test plugin can opac_online_payment' );
259
    ok( $plugin->can('after_hold_create'), 'Test plugin can after_hold_create' );
259
    ok( $plugin->can('after_hold_create'), 'Test plugin can after_hold_create' );
260
    ok( $plugin->can('before_send_messages'), 'Test plugin can before_send_messages' );
260
    ok( $plugin->can('opac_online_payment_begin'), 'Test plugin can opac_online_payment_begin' );
261
    ok( $plugin->can('opac_online_payment_begin'), 'Test plugin can opac_online_payment_begin' );
261
    ok( $plugin->can('opac_online_payment_end'), 'Test plugin can opac_online_payment_end' );
262
    ok( $plugin->can('opac_online_payment_end'), 'Test plugin can opac_online_payment_end' );
262
    ok( $plugin->can('opac_head'), 'Test plugin can opac_head' );
263
    ok( $plugin->can('opac_head'), 'Test plugin can opac_head' );
(-)a/t/lib/plugins/Koha/Plugin/Test.pm (-1 / +5 lines)
Lines 151-156 sub after_hold_create { Link Here
151
    Koha::Exception->throw("after_hold_create called with parameter " . ref($param) );
151
    Koha::Exception->throw("after_hold_create called with parameter " . ref($param) );
152
}
152
}
153
153
154
sub before_send_messages {
155
    my ( $self, $param ) = @_;
156
    Koha::Exception->throw("before_send_messages called");
157
}
158
154
sub before_biblio_action {
159
sub before_biblio_action {
155
    my ( $self, $params ) = @_;
160
    my ( $self, $params ) = @_;
156
161
157
- 

Return to bug 37869