Bugzilla – Attachment 97881 Details for
Bug 24421
Generated authorities are missing subfields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24421: Unit tests
Bug-24421-Unit-tests.patch (text/plain), 2.56 KB, created by
Nick Clemens
on 2020-01-24 13:44:17 UTC
(
hide
)
Description:
Bug 24421: Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2020-01-24 13:44:17 UTC
Size:
2.56 KB
patch
obsolete
>From 43d66fbb13290e9b2bcdcbbad4eb24805b3986f0 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 24 Jan 2020 13:24:45 +0000 >Subject: [PATCH] Bug 24421: Unit tests > >--- > t/db_dependent/Biblio.t | 39 ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 38 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t >index a3886789dd..cc38e07201 100755 >--- a/t/db_dependent/Biblio.t >+++ b/t/db_dependent/Biblio.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 12; >+use Test::More tests => 13; > use Test::MockModule; > use List::MoreUtils qw( uniq ); > use MARC::Record; >@@ -643,6 +643,43 @@ subtest 'ModBiblio called from linker test' => sub { > is($called,0,"We didn't call to link bibs because from linker"); > }; > >+subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { >+ plan tests => 3; >+ >+ # Set up mocks to ensure authorities are generated >+ my $biblio_mod = Test::MockModule->new( 'C4::Linker::Default' ); >+ $biblio_mod->mock( 'get_link', sub { >+ return (undef,undef); >+ }); >+ # UNIMARC valid headings are built from the marc_subfield_structure for bibs and >+ # include all subfields as valid, testing with MARC21 should be sufficient for now >+ t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); >+ t::lib::Mocks::mock_preference('AutoCreateAuthorities', '1'); >+ >+ my $linker = C4::Linker::Default->new(); >+ my $record = MARC::Record->new(); >+ >+ # Generate a record including all valid subfields and an invalid one 'e' >+ my $field = MARC::Field->new('650','','','a' => 'Beach city', 'b' => 'Weirdness', 'v' => 'Fiction', 'x' => 'Books', 'y' => '21st Century', 'z' => 'Fish Stew Pizza', 'e' => 'Depicted'); >+ >+ $record->append_fields($field); >+ my ( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef); >+ >+ is( $num_headings_changed, 1, 'We changed the one we passed' ); >+ is_deeply( $results->{added}, >+ {"Beach city Weirdness--Fiction--Books--21st Century--Fish Stew Pizza" => 1 }, >+ "We added an authority record for the heading" >+ ); >+ >+ # Now we check the authority record itself >+ my $authority = GetAuthority( $record->subfield('650','9') ); >+ is( $authority->field('150')->as_string(), >+ "Beach city Weirdness Fiction Books 21st Century Fish Stew Pizza", >+ "The generated record contains the correct subfields" >+ ); >+ >+}; >+ > # Cleanup > Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); > $schema->storage->txn_rollback; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24421
:
97358
|
97583
|
97881
|
97882
|
97968
|
97969