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

(-)a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t (-2 / +2 lines)
Lines 62-72 subtest 'after_biblio_action() and after_item_action() hooks tests' => sub { Link Here
62
    my $biblio_id;
62
    my $biblio_id;
63
63
64
    warning_like { ( $biblio_id, undef ) = C4::Biblio::AddBiblio( MARC::Record->new(), '' ); }
64
    warning_like { ( $biblio_id, undef ) = C4::Biblio::AddBiblio( MARC::Record->new(), '' ); }
65
    qr/after_biblio_action called with action: create, ref: Koha::Biblio/,
65
    qr/after_biblio_action called with action: create, ref: Koha::Biblio, biblio found/,
66
        'AddBiblio calls the hook with action=create';
66
        'AddBiblio calls the hook with action=create';
67
67
68
    warning_like { C4::Biblio::ModBiblio( MARC::Record->new(), $biblio_id, '' ); }
68
    warning_like { C4::Biblio::ModBiblio( MARC::Record->new(), $biblio_id, '' ); }
69
    qr/after_biblio_action called with action: modify, ref: Koha::Biblio/,
69
    qr/after_biblio_action called with action: modify, ref: Koha::Biblio, biblio found/,
70
        'ModBiblio calls the hook with action=modify';
70
        'ModBiblio calls the hook with action=modify';
71
71
72
    my $item;
72
    my $item;
(-)a/t/lib/plugins/Koha/Plugin/Test.pm (-2 / +11 lines)
Lines 6-11 use Modern::Perl; Link Here
6
use Koha::Exception;
6
use Koha::Exception;
7
use Koha::Plugins::Tab;
7
use Koha::Plugins::Tab;
8
8
9
use Koha::Biblios;
10
9
use MARC::Field;
11
use MARC::Field;
10
use Mojo::JSON qw( decode_json );
12
use Mojo::JSON qw( decode_json );
11
13
Lines 192-198 sub after_biblio_action { Link Here
192
    my $biblio_id = $payload->{biblio_id};
194
    my $biblio_id = $payload->{biblio_id};
193
195
194
    if ( $action ne 'delete' ) {
196
    if ( $action ne 'delete' ) {
195
        Koha::Exception->throw( "after_biblio_action called with action: $action, ref: " . ref($biblio) );
197
        $biblio = Koha::Biblios->find($biblio_id);
198
        if ($biblio) {
199
            $biblio_id = $biblio->id;
200
            Koha::Exception->throw(
201
                "after_biblio_action called with action: $action, ref: " . ref($biblio) . ", biblio found" );
202
        } else {
203
            Koha::Exception->throw(
204
                "after_biblio_action called with action: $action, ref: " . ref($biblio) . ", biblio not found" );
205
        }
196
    } else {
206
    } else {
197
        Koha::Exception->throw("after_biblio_action called with action: $action, id: $biblio_id") if $biblio_id;
207
        Koha::Exception->throw("after_biblio_action called with action: $action, id: $biblio_id") if $biblio_id;
198
    }
208
    }
199
- 

Return to bug 36542