|
Lines 17-24
Link Here
|
| 17 |
use Modern::Perl; |
17 |
use Modern::Perl; |
| 18 |
|
18 |
|
| 19 |
use Test::NoWarnings; |
19 |
use Test::NoWarnings; |
| 20 |
use Test::More tests => 7; |
20 |
use Test::More tests => 11; |
| 21 |
use Test::Warn; |
21 |
use Test::Warn; |
|
|
22 |
use JSON qw( decode_json ); |
| 22 |
|
23 |
|
| 23 |
use File::Basename; |
24 |
use File::Basename; |
| 24 |
|
25 |
|
|
Lines 38-43
BEGIN {
Link Here
|
| 38 |
use_ok('Koha::Plugins'); |
39 |
use_ok('Koha::Plugins'); |
| 39 |
use_ok('Koha::Plugins::Handler'); |
40 |
use_ok('Koha::Plugins::Handler'); |
| 40 |
use_ok('Koha::Plugin::Test'); |
41 |
use_ok('Koha::Plugin::Test'); |
|
|
42 |
|
| 43 |
use_ok('Koha::BackgroundJobs'); |
| 44 |
use_ok('Koha::BackgroundJob::MARCImportCommitBatch'); |
| 45 |
use_ok('Koha::BackgroundJob::StageMARCForImport'); |
| 41 |
} |
46 |
} |
| 42 |
|
47 |
|
| 43 |
my $schema = Koha::Database->new->schema; |
48 |
my $schema = Koha::Database->new->schema; |
|
Lines 190-192
subtest 'elasticsearch_to_document() hooks tests' => sub {
Link Here
|
| 190 |
Koha::Plugins->RemovePlugins; |
195 |
Koha::Plugins->RemovePlugins; |
| 191 |
$schema->storage->txn_rollback; |
196 |
$schema->storage->txn_rollback; |
| 192 |
}; |
197 |
}; |
|
|
198 |
|
| 199 |
subtest 'before_batch_action() and after_batch_action() hooks tests' => sub { |
| 200 |
|
| 201 |
plan tests => 1; |
| 202 |
|
| 203 |
$schema->storage->txn_begin; |
| 204 |
|
| 205 |
my $plugins = Koha::Plugins->new; |
| 206 |
$plugins->InstallPlugins; |
| 207 |
|
| 208 |
my $plugin = Koha::Plugin::Test->new->enable; |
| 209 |
|
| 210 |
my $test_plugin3 = Test::MockModule->new('Koha::Plugin::Test'); |
| 211 |
$test_plugin3->mock( 'item_barcode_transform', undef ); |
| 212 |
$test_plugin3->mock( 'after_item_action', undef ); |
| 213 |
|
| 214 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 215 |
my $job = Koha::BackgroundJob::StageMARCForImport->new( |
| 216 |
{ |
| 217 |
status => 'new', |
| 218 |
size => 1, |
| 219 |
borrowernumber => $patron->borrowernumber, |
| 220 |
type => 'stage_marc_for_import', |
| 221 |
} |
| 222 |
)->store; |
| 223 |
$job = Koha::BackgroundJobs->find( $job->id ); |
| 224 |
$job->process( |
| 225 |
{ |
| 226 |
job_id => $job->id, |
| 227 |
record_type => 'biblio', |
| 228 |
encoding => 'UTF-8', |
| 229 |
format => 'ISO2709', |
| 230 |
filepath => 't/db_dependent/data/marc21/zebraexport/biblio/exported_records', |
| 231 |
filename => 'some_records', |
| 232 |
parse_items => 1, |
| 233 |
} |
| 234 |
); |
| 235 |
|
| 236 |
my $report = decode_json($job->get_from_storage->data)->{report}; |
| 237 |
my $import_batch_id = $report->{import_batch_id}; |
| 238 |
|
| 239 |
my $job2 = Koha::BackgroundJob::MARCImportCommitBatch->new( |
| 240 |
{ |
| 241 |
status => 'new', |
| 242 |
size => 1, |
| 243 |
borrowernumber => $patron->borrowernumber, |
| 244 |
type => 'marc_import_commit_batch' |
| 245 |
} |
| 246 |
)->store; |
| 247 |
$job2 = Koha::BackgroundJobs->find( $job2->id ); |
| 248 |
|
| 249 |
warning_like { |
| 250 |
$job2->process( |
| 251 |
{ |
| 252 |
job_id => $job2->id, |
| 253 |
import_batch_id => $import_batch_id, |
| 254 |
frameworkcode => q{}, |
| 255 |
} |
| 256 |
); |
| 257 |
} qr/after_batch_action called with addBiblio count: 178/, |
| 258 |
'MARCImportCommitBatch calls the after_batch_action hook'; |
| 259 |
|
| 260 |
Koha::Plugins->RemovePlugins; |
| 261 |
$schema->storage->txn_rollback; |
| 262 |
|
| 263 |
}; |