Bug 30072: Unit tests
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
b0638ce23d
commit
f51868cb82
2 changed files with 74 additions and 1 deletions
|
@ -16,7 +16,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 4;
|
||||
use Test::More tests => 5;
|
||||
use Test::MockModule;
|
||||
use Test::Warn;
|
||||
|
||||
|
@ -80,3 +80,66 @@ subtest 'after_hold_create() hook tests' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
Koha::Plugins::Methods->delete;
|
||||
};
|
||||
|
||||
subtest 'Koha::Hold tests' => sub {
|
||||
|
||||
plan tests => 4;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $plugins = Koha::Plugins->new;
|
||||
$plugins->InstallPlugins;
|
||||
|
||||
my $plugin = Koha::Plugin::Test->new->enable;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
|
||||
# Reduce noise
|
||||
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' );
|
||||
t::lib::Mocks::mock_preference( 'HoldsLog', 0 );
|
||||
|
||||
my $hold = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Holds',
|
||||
value => {
|
||||
borrowernumber => $patron->id,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
warning_like {
|
||||
$hold->fill;
|
||||
}
|
||||
qr/after_hold_action called with action: fill, ref: Koha::Old::Hold/,
|
||||
'->fill calls the after_hold_action hook';
|
||||
|
||||
$hold = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Holds',
|
||||
value => {
|
||||
borrowernumber => $patron->id,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
warning_like {
|
||||
$hold->suspend_hold;
|
||||
}
|
||||
qr/after_hold_action called with action: suspend, ref: Koha::Hold/,
|
||||
'->suspend_hold calls the after_hold_action hook';
|
||||
|
||||
warning_like {
|
||||
$hold->resume;
|
||||
}
|
||||
qr/after_hold_action called with action: resume, ref: Koha::Hold/,
|
||||
'->resume calls the after_hold_action hook';
|
||||
|
||||
warning_like {
|
||||
$hold->cancel;
|
||||
}
|
||||
qr/after_hold_action called with action: cancel, ref: Koha::Old::Hold/,
|
||||
'->cancel calls the after_hold_action hook';
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
Koha::Plugins::Methods->delete;
|
||||
};
|
||||
|
|
|
@ -206,6 +206,16 @@ sub after_circ_action {
|
|||
}
|
||||
}
|
||||
|
||||
sub after_hold_action {
|
||||
my ( $self, $params ) = @_;
|
||||
|
||||
my $action = $params->{action};
|
||||
my $hold = $params->{payload}->{hold};
|
||||
|
||||
Koha::Exceptions::Exception->throw(
|
||||
"after_hold_action called with action: $action, ref: " . ref($hold) );
|
||||
}
|
||||
|
||||
sub api_routes {
|
||||
my ( $self, $args ) = @_;
|
||||
|
||||
|
|
Loading…
Reference in a new issue