From a6bf4aa2d951d278bfa6dd7ff0808aaed02d0326 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 31 Jan 2020 14:18:14 +0000 Subject: [PATCH] Bug 24094: Unit tests Signed-off-by: Myka Kennedy Stephens --- t/db_dependent/Biblio.t | 24 +++++++++++++++++++++++- t/db_dependent/Heading_MARC21.t | 8 +++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index ab1553b81c..4b8f29723b 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -645,7 +645,7 @@ subtest 'ModBiblio called from linker test' => sub { }; subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { - plan tests => 3; + plan tests => 6; # Set up mocks to ensure authorities are generated my $biblio_mod = Test::MockModule->new( 'C4::Linker::Default' ); @@ -679,6 +679,28 @@ subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { "The generated record contains the correct subfields" ); + # Example series link with volume and punctuation + $record = MARC::Record->new(); + $field = MARC::Field->new('800','','','a' => 'Tolkien, J. R. R.', 'q' => '(John Ronald Reuel),', 'd' => '1892-1973.', 't' => 'Lord of the rings ;', 'v' => '1'); + $record->append_fields($field); + + ( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef); + + is( $num_headings_changed, 1, 'We changed the one we passed' ); + is_deeply( $results->{added}, + {"Tolkien, J. R. R. (John Ronald Reuel), 1892-1973. Lord of the rings ;" => 1 }, + "We added an authority record for the heading" + ); + + # Now we check the authority record itself + $authority = GetAuthority( $record->subfield('800','9') ); + is( $authority->field('100')->as_string(), + "Tolkien, J. R. R. (John Ronald Reuel), 1892-1973. Lord of the rings", + "The generated record contains the correct subfields" + ); + + + }; # Cleanup diff --git a/t/db_dependent/Heading_MARC21.t b/t/db_dependent/Heading_MARC21.t index 0e1f1c9a72..ba8e2e3e35 100755 --- a/t/db_dependent/Heading_MARC21.t +++ b/t/db_dependent/Heading_MARC21.t @@ -6,7 +6,7 @@ use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 5; use C4::Context; BEGIN { @@ -19,4 +19,10 @@ SKIP: { my $heading = C4::Heading->new_from_bib_field($field); is($heading->display_form(), 'Uncles--Fiction', 'Display form generation'); is($heading->search_form(), 'Uncles generalsubdiv Fiction', 'Search form generation'); + + $field = MARC::Field->new( '830', ' ', '4', a => 'The dark is rising ;', v => '3' ); + $heading = C4::Heading->new_from_bib_field($field); + is($heading->display_form(), 'The dark is rising ;', 'Display form generation'); + is($heading->search_form(), 'The dark is rising', 'Search form generation'); + } -- 2.11.0