Bug 31894: Extend after_hold_action hook
Hook actions added: after_hold_action adds new actions transfer, waiting and processing How to test: Run tests in t/db_dependent/Koha/Plugins/Holds_hooks.t Sponsored by: Gothenburg University Library Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
0106f3957d
commit
116d17d701
2 changed files with 43 additions and 1 deletions
24
Koha/Hold.pm
24
Koha/Hold.pm
|
@ -200,6 +200,14 @@ sub set_transfer {
|
|||
$self->found('T');
|
||||
$self->store();
|
||||
|
||||
Koha::Plugins->call(
|
||||
'after_hold_action',
|
||||
{
|
||||
action => 'transfer',
|
||||
payload => { hold => $self->get_from_storage }
|
||||
}
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -257,6 +265,14 @@ sub set_waiting {
|
|||
|
||||
$self->set($values)->store();
|
||||
|
||||
Koha::Plugins->call(
|
||||
'after_hold_action',
|
||||
{
|
||||
action => 'waiting',
|
||||
payload => { hold => $self->get_from_storage }
|
||||
}
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -345,6 +361,14 @@ sub set_processing {
|
|||
$self->found('P');
|
||||
$self->store();
|
||||
|
||||
Koha::Plugins->call(
|
||||
'after_hold_action',
|
||||
{
|
||||
action => 'processing',
|
||||
payload => { hold => $self->get_from_storage }
|
||||
}
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ subtest 'after_hold_action (placed) hook tests' => sub {
|
|||
|
||||
subtest 'Koha::Hold tests' => sub {
|
||||
|
||||
plan tests => 4;
|
||||
plan tests => 7;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
@ -181,6 +181,24 @@ subtest 'Koha::Hold tests' => sub {
|
|||
qr/after_hold_action called with action: resume, ref: Koha::Hold/,
|
||||
'->resume calls the after_hold_action hook';
|
||||
|
||||
warning_like {
|
||||
$hold->set_transfer;
|
||||
}
|
||||
qr/after_hold_action called with action: transfer, ref: Koha::Hold/,
|
||||
'->set_transfer calls the after_hold_action hook';
|
||||
|
||||
warning_like {
|
||||
$hold->set_processing;
|
||||
}
|
||||
qr/after_hold_action called with action: processing, ref: Koha::Hold/,
|
||||
'->set_processing calls the after_hold_action hook';
|
||||
|
||||
warning_like {
|
||||
$hold->set_waiting;
|
||||
}
|
||||
qr/after_hold_action called with action: waiting, ref: Koha::Hold/,
|
||||
'->set_waiting calls the after_hold_action hook';
|
||||
|
||||
warning_like {
|
||||
$hold->cancel;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue