|
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 |
}; |