|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 25; |
20 |
use Test::More tests => 26; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
use List::MoreUtils qw( uniq ); |
23 |
use List::MoreUtils qw( uniq ); |
|
Lines 33-43
use Koha::Cache::Memory::Lite;
Link Here
|
| 33 |
use Koha::MarcSubfieldStructures; |
33 |
use Koha::MarcSubfieldStructures; |
| 34 |
|
34 |
|
| 35 |
use C4::Linker::Default qw( get_link ); |
35 |
use C4::Linker::Default qw( get_link ); |
|
|
36 |
use YAML::XS; |
| 36 |
|
37 |
|
| 37 |
BEGIN { |
38 |
BEGIN { |
| 38 |
use_ok( |
39 |
use_ok( |
| 39 |
'C4::Biblio', |
40 |
'C4::Biblio', |
| 40 |
qw( AddBiblio GetMarcFromKohaField BiblioAutoLink GetMarcSubfieldStructure GetMarcSubfieldStructureFromKohaField LinkBibHeadingsToAuthorities GetBiblioData ModBiblio GetMarcISSN GetMarcISBN GetMarcPrice GetFrameworkCode GetMarcUrls IsMarcStructureInternal GetMarcStructure GetXmlBiblio DelBiblio ) |
41 |
qw( AddBiblio GetMarcFromKohaField BiblioAutoLink GetMarcSubfieldStructure GetMarcSubfieldStructureFromKohaField LinkBibHeadingsToAuthorities GetBiblioData ModBiblio GetMarcISSN GetMarcISBN GetMarcPrice GetFrameworkCode GetMarcUrls IsMarcStructureInternal GetMarcStructure GetXmlBiblio DelBiblio prepare_host_field ) |
| 41 |
); |
42 |
); |
| 42 |
} |
43 |
} |
| 43 |
|
44 |
|
|
Lines 1378-1383
subtest 'AddBiblio/ModBiblio calling ModBiblioMarc for field 005' => sub {
Link Here
|
| 1378 |
ok( $field && $field->data, 'Record contains field 005 after ModBiblio' ); |
1379 |
ok( $field && $field->data, 'Record contains field 005 after ModBiblio' ); |
| 1379 |
}; |
1380 |
}; |
| 1380 |
|
1381 |
|
|
|
1382 |
subtest 'Prepare host field test' => sub { |
| 1383 |
plan tests => 3; |
| 1384 |
|
| 1385 |
# PrepareHostField system preference is set |
| 1386 |
my $prepare_host_fields = { |
| 1387 |
"001" => "773\$w", |
| 1388 |
"245" => "773\$t", |
| 1389 |
}; |
| 1390 |
|
| 1391 |
# Mock the system preference PrepareHostField |
| 1392 |
t::lib::Mocks::mock_preference( 'PrepareHostField', YAML::XS::Dump($prepare_host_fields) ); |
| 1393 |
|
| 1394 |
my $record = MARC::Record->new; |
| 1395 |
my $field = MARC::Field->new( '245', '', '', 'a' => 'Example' ); |
| 1396 |
$record->append_fields($field); |
| 1397 |
C4::Biblio::AddBiblio( $record, '' ); |
| 1398 |
my ($biblionumber) = C4::Biblio::AddBiblio( $record, '' ); |
| 1399 |
my $host_field = C4::Biblio::prepare_host_field( $biblionumber, '' ); |
| 1400 |
my $comp_record = MARC::Record->new; |
| 1401 |
$comp_record->append_fields($host_field); |
| 1402 |
is( $comp_record->subfield( '773', 't' ), 'Example', 'System preference host field is correct' ); |
| 1403 |
|
| 1404 |
t::lib::Mocks::mock_preference( 'PrepareHostField', '' ); |
| 1405 |
|
| 1406 |
#MARC21 |
| 1407 |
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); |
| 1408 |
my $marc_record = MARC::Record->new; |
| 1409 |
my $marc_field = MARC::Field->new( '245', '', '', 'a' => 'Example' ); |
| 1410 |
$marc_record->append_fields($marc_field); |
| 1411 |
C4::Biblio::AddBiblio( $marc_record, '' ); |
| 1412 |
my ($biblio_number) = C4::Biblio::AddBiblio( $marc_record, '' ); |
| 1413 |
my $host_marc_field = C4::Biblio::prepare_host_field( $biblio_number, '' ); |
| 1414 |
my $compiled_record = MARC::Record->new; |
| 1415 |
$compiled_record->append_fields($host_marc_field); |
| 1416 |
is( $compiled_record->subfield( '773', 't' ), 'Example', 'MARC21 host field is correct' ); |
| 1417 |
|
| 1418 |
# UNIMARC |
| 1419 |
t::lib::Mocks::mock_preference( 'marcflavour', 'UNIMARC' ); |
| 1420 |
my $unimarc_record = MARC::Record->new; |
| 1421 |
my $unimarc_field = MARC::Field->new( '200', '', '', 'a' => 'Example' ); |
| 1422 |
$unimarc_record->append_fields($unimarc_field); |
| 1423 |
my ($unimarc_biblionumber) = C4::Biblio::AddBiblio( $unimarc_record, '' ); |
| 1424 |
my $unimarc_host_field = C4::Biblio::prepare_host_field( $unimarc_biblionumber, '' ); |
| 1425 |
my $unimarc_comp_record = MARC::Record->new; |
| 1426 |
$unimarc_comp_record->append_fields($unimarc_host_field); |
| 1427 |
is( $unimarc_comp_record->subfield( '461', 't' ), 'Example', 'UNIMARC host field is correct' ); |
| 1428 |
|
| 1429 |
}; |
| 1430 |
|
| 1381 |
# Cleanup |
1431 |
# Cleanup |
| 1382 |
Koha::Caches->get_instance->clear_from_cache("MarcSubfieldStructure-"); |
1432 |
Koha::Caches->get_instance->clear_from_cache("MarcSubfieldStructure-"); |
| 1383 |
$schema->storage->txn_rollback; |
1433 |
$schema->storage->txn_rollback; |
| 1384 |
- |
|
|