|
Lines 5-11
Link Here
|
| 5 |
use Modern::Perl; |
5 |
use Modern::Perl; |
| 6 |
|
6 |
|
| 7 |
use Test::NoWarnings; |
7 |
use Test::NoWarnings; |
| 8 |
use Test::More tests => 13; |
8 |
use Test::More tests => 14; |
| 9 |
|
9 |
|
| 10 |
use Getopt::Long; |
10 |
use Getopt::Long; |
| 11 |
use MARC::Record; |
11 |
use MARC::Record; |
|
Lines 162-168
subtest 'Test merge A1 to modified A1, test strict mode' => sub {
Link Here
|
| 162 |
) |
162 |
) |
| 163 |
); |
163 |
); |
| 164 |
my $MARC2 = MARC::Record->new; |
164 |
my $MARC2 = MARC::Record->new; |
| 165 |
$MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Batman', '9' => $authid1 ) ); |
165 |
$MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'BATMAN', '9' => $authid1 ) ); |
| 166 |
$MARC2->append_fields( MARC::Field->new( '245', '', '', 'a' => 'All the way to heaven' ) ); |
166 |
$MARC2->append_fields( MARC::Field->new( '245', '', '', 'a' => 'All the way to heaven' ) ); |
| 167 |
my ($biblionumber1) = AddBiblio( $MARC1, '' ); |
167 |
my ($biblionumber1) = AddBiblio( $MARC1, '' ); |
| 168 |
my ($biblionumber2) = AddBiblio( $MARC2, '' ); |
168 |
my ($biblionumber2) = AddBiblio( $MARC2, '' ); |
|
Lines 677-682
subtest "Test bibs not auto linked when merging" => sub {
Link Here
|
| 677 |
|
677 |
|
| 678 |
}; |
678 |
}; |
| 679 |
|
679 |
|
|
|
680 |
subtest 'ModBiblio calls from merge' => sub { |
| 681 |
|
| 682 |
plan tests => 5; |
| 683 |
|
| 684 |
$schema->storage->txn_begin; |
| 685 |
|
| 686 |
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); |
| 687 |
t::lib::Mocks::mock_preference( 'AuthorityControlledIndicators', '' ); |
| 688 |
t::lib::Mocks::mock_preference( 'IncludeSeeFromInSearches', '1' ); |
| 689 |
|
| 690 |
my $auth_record = MARC::Record->new(); |
| 691 |
$auth_record->insert_fields_ordered( MARC::Field->new( '109', '1', ' ', a => 'Brown,', 'c' => 'Father' ) ); |
| 692 |
my $authid = AddAuthority( $auth_record, undef, $authtype1, { skip_record_index => 1 } ); |
| 693 |
|
| 694 |
my $auth_record_modified = $auth_record->clone; |
| 695 |
$auth_record_modified->field('109')->update( c => 'Father (Fictitious character)' ); |
| 696 |
|
| 697 |
my $biblio_record = MARC::Record->new(); |
| 698 |
$biblio_record->insert_fields_ordered( |
| 699 |
MARC::Field->new( '609', '1', '1', a => 'Brown,', 'c' => 'Father', 9 => $authid ) ); |
| 700 |
my $biblionumber = AddBiblio( $biblio_record, '', { skip_record_index => 1 } ); |
| 701 |
|
| 702 |
my $biblio_module = Test::MockModule->new('C4::AuthoritiesMarc'); |
| 703 |
$biblio_module->mock( |
| 704 |
'ModBiblio', |
| 705 |
sub { warn 'ModBiblio called'; } |
| 706 |
); |
| 707 |
|
| 708 |
warnings_are { |
| 709 |
merge( |
| 710 |
{ |
| 711 |
mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid, MARCto => $auth_record_modified, |
| 712 |
biblionumbers => [$biblionumber], |
| 713 |
} |
| 714 |
); |
| 715 |
} |
| 716 |
["ModBiblio called"], "real modification of bibliographic record, ModBiblio called"; |
| 717 |
|
| 718 |
t::lib::Mocks::mock_preference( 'SearchEngine', 'Elasticsearch' ); |
| 719 |
my $mock_index = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Indexer'); |
| 720 |
$mock_index->mock( 'index_records', sub { warn 'index_records called'; } ); |
| 721 |
|
| 722 |
warnings_are { |
| 723 |
merge( |
| 724 |
{ |
| 725 |
mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid, MARCto => $auth_record, |
| 726 |
biblionumbers => [$biblionumber], |
| 727 |
} |
| 728 |
); |
| 729 |
} |
| 730 |
["index_records called"], "no real modification of bibliographic record, index_records called"; |
| 731 |
|
| 732 |
t::lib::Mocks::mock_preference( 'IncludeSeeFromInSearches', '0' ); |
| 733 |
t::lib::Mocks::mock_preference( 'IncludeSeeAlsoFromInSearches', '0' ); |
| 734 |
warnings_are { |
| 735 |
merge( |
| 736 |
{ |
| 737 |
mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid, MARCto => $auth_record, |
| 738 |
biblionumbers => [$biblionumber], |
| 739 |
} |
| 740 |
); |
| 741 |
} |
| 742 |
[], "no real modification of bibliographic record, index_records not called"; |
| 743 |
|
| 744 |
my $auth_record2 = MARC::Record->new(); |
| 745 |
$auth_record2->insert_fields_ordered( MARC::Field->new( '109', '1', ' ', a => 'Chesterton, G.K.' ) ); |
| 746 |
my $authid2 = AddAuthority( $auth_record2, undef, $authtype1, { skip_record_index => 1 } ); |
| 747 |
|
| 748 |
my $biblio_record2 = MARC::Record->new(); |
| 749 |
$biblio_record2->insert_fields_ordered( |
| 750 |
MARC::Field->new( '109', '1', ' ', a => 'Chesterton, G.K.', 9 => $authid2 ) ); |
| 751 |
my $biblionumber2 = AddBiblio( $biblio_record2, '', { skip_record_index => 1 } ); |
| 752 |
|
| 753 |
my $num_biblio_edited; |
| 754 |
warnings_are { |
| 755 |
$num_biblio_edited = merge( |
| 756 |
{ |
| 757 |
mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid2, MARCto => $auth_record2, |
| 758 |
biblionumbers => [ $biblionumber, $biblionumber2 ], |
| 759 |
} |
| 760 |
); |
| 761 |
} |
| 762 |
["ModBiblio called"], "real modification of bibliographic record, ModBiblio called"; |
| 763 |
is( $num_biblio_edited, 1, 'only one bibliographic record updated while merging two authorities' ); |
| 764 |
|
| 765 |
$schema->storage->txn_rollback; |
| 766 |
|
| 767 |
}; |
| 768 |
|
| 680 |
sub set_mocks { |
769 |
sub set_mocks { |
| 681 |
|
770 |
|
| 682 |
# After we removed the Zebra code from merge, we only need to mock |
771 |
# After we removed the Zebra code from merge, we only need to mock |
| 683 |
- |
|
|