|
Lines 1-7
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
|
2 |
|
| 3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
| 4 |
use Test::More tests => 18; |
4 |
use Test::More tests => 19; |
| 5 |
use utf8; |
5 |
use utf8; |
| 6 |
use File::Basename; |
6 |
use File::Basename; |
| 7 |
use File::Temp qw/tempfile/; |
7 |
use File::Temp qw/tempfile/; |
|
Lines 18-24
BEGIN {
Link Here
|
| 18 |
t::lib::Mocks::mock_config( 'pluginsdir', $path ); |
18 |
t::lib::Mocks::mock_config( 'pluginsdir', $path ); |
| 19 |
|
19 |
|
| 20 |
use_ok('Koha::Plugins'); |
20 |
use_ok('Koha::Plugins'); |
| 21 |
use_ok('C4::ImportBatch', qw( AddImportBatch GetImportBatch AddBiblioToBatch AddItemsToImportBiblio SetMatchedBiblionumber GetImportBiblios GetItemNumbersFromImportBatch CleanBatch DeleteBatch RecordsFromMarcPlugin )); |
21 |
use_ok('C4::ImportBatch', qw( AddImportBatch GetImportBatch AddBiblioToBatch AddItemsToImportBiblio SetMatchedBiblionumber GetImportBiblios GetItemNumbersFromImportBatch CleanBatch DeleteBatch RecordsFromMarcPlugin BatchCommitRecords )); |
| 22 |
} |
22 |
} |
| 23 |
|
23 |
|
| 24 |
# Start transaction |
24 |
# Start transaction |
|
Lines 328-333
subtest "_get_commit_action" => sub {
Link Here
|
| 328 |
|
328 |
|
| 329 |
}; |
329 |
}; |
| 330 |
|
330 |
|
|
|
331 |
subtest "BatchCommitRecords overlay into framework" => sub { |
| 332 |
plan tests => 1; |
| 333 |
t::lib::Mocks::mock_config( 'enable_plugins', 0 ); |
| 334 |
my $mock_import = Test::MockModule->new("C4::ImportBatch"); |
| 335 |
my $biblio = $builder->build_sample_biblio; |
| 336 |
$mock_import->mock( _get_commit_action => sub { return ('replace',undef,$biblio->biblionumber); } ); |
| 337 |
|
| 338 |
my $import_batch = { |
| 339 |
matcher_id => 2, |
| 340 |
template_id => 2, |
| 341 |
branchcode => 'QRZ', |
| 342 |
overlay_action => 'replace', |
| 343 |
nomatch_action => 'ignore', |
| 344 |
item_action => 'ignore', |
| 345 |
import_status => 'staged', |
| 346 |
batch_type => 'z3950', |
| 347 |
file_name => 'test.mrc', |
| 348 |
comments => 'test', |
| 349 |
record_type => 'auth', |
| 350 |
}; |
| 351 |
my $id_import_batch = C4::ImportBatch::AddImportBatch($import_batch); |
| 352 |
my $import_record_id = AddBiblioToBatch( $id_import_batch, 0, $biblio->metadata->record, 'utf8', 0 ); |
| 353 |
|
| 354 |
BatchCommitRecords({ |
| 355 |
batch_id => $id_import_batch, |
| 356 |
framework => "", |
| 357 |
overlay_framework => "QQ", |
| 358 |
}); |
| 359 |
$biblio->discard_changes; |
| 360 |
is( $biblio->frameworkcode, "QQ", "Framework set on overlay" ); |
| 361 |
}; |
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 331 |
sub get_import_record { |
366 |
sub get_import_record { |
| 332 |
my $id_import_batch = shift; |
367 |
my $id_import_batch = shift; |
| 333 |
return $dbh->do('SELECT * FROM import_records WHERE import_batch_id = ?', undef, $id_import_batch); |
368 |
return $dbh->do('SELECT * FROM import_records WHERE import_batch_id = ?', undef, $id_import_batch); |
| 334 |
- |
|
|