|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 12; |
20 |
use Test::More tests => 13; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use List::MoreUtils qw( uniq ); |
22 |
use List::MoreUtils qw( uniq ); |
| 23 |
use MARC::Record; |
23 |
use MARC::Record; |
|
Lines 643-648
subtest 'ModBiblio called from linker test' => sub {
Link Here
|
| 643 |
is($called,0,"We didn't call to link bibs because from linker"); |
643 |
is($called,0,"We didn't call to link bibs because from linker"); |
| 644 |
}; |
644 |
}; |
| 645 |
|
645 |
|
|
|
646 |
subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { |
| 647 |
plan tests => 3; |
| 648 |
|
| 649 |
# Set up mocks to ensure authorities are generated |
| 650 |
my $biblio_mod = Test::MockModule->new( 'C4::Linker::Default' ); |
| 651 |
$biblio_mod->mock( 'get_link', sub { |
| 652 |
return (undef,undef); |
| 653 |
}); |
| 654 |
# UNIMARC valid headings are built from the marc_subfield_structure for bibs and |
| 655 |
# include all subfields as valid, testing with MARC21 should be sufficient for now |
| 656 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
| 657 |
t::lib::Mocks::mock_preference('AutoCreateAuthorities', '1'); |
| 658 |
|
| 659 |
my $linker = C4::Linker::Default->new(); |
| 660 |
my $record = MARC::Record->new(); |
| 661 |
|
| 662 |
# Generate a record including all valid subfields and an invalid one 'e' |
| 663 |
my $field = MARC::Field->new('650','','','a' => 'Beach city', 'b' => 'Weirdness', 'v' => 'Fiction', 'x' => 'Books', 'y' => '21st Century', 'z' => 'Fish Stew Pizza', 'e' => 'Depicted'); |
| 664 |
|
| 665 |
$record->append_fields($field); |
| 666 |
my ( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef); |
| 667 |
|
| 668 |
is( $num_headings_changed, 1, 'We changed the one we passed' ); |
| 669 |
is_deeply( $results->{added}, |
| 670 |
{"Beach city Weirdness--Fiction--Books--21st Century--Fish Stew Pizza" => 1 }, |
| 671 |
"We added an authority record for the heading" |
| 672 |
); |
| 673 |
|
| 674 |
# Now we check the authority record itself |
| 675 |
my $authority = GetAuthority( $record->subfield('650','9') ); |
| 676 |
is( $authority->field('150')->as_string(), |
| 677 |
"Beach city Weirdness Fiction Books 21st Century Fish Stew Pizza", |
| 678 |
"The generated record contains the correct subfields" |
| 679 |
); |
| 680 |
|
| 681 |
}; |
| 682 |
|
| 646 |
# Cleanup |
683 |
# Cleanup |
| 647 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
684 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
| 648 |
$schema->storage->txn_rollback; |
685 |
$schema->storage->txn_rollback; |
| 649 |
- |
|
|