Bugzilla – Attachment 106073 Details for
Bug 25189
AutoCreateAuthorities can repeatedly generate authority records when using Default linker
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25189: Unit tests
Bug-25189-Unit-tests.patch (text/plain), 2.94 KB, created by
Martin Renvoize (ashimema)
on 2020-06-19 11:50:35 UTC
(
hide
)
Description:
Bug 25189: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-06-19 11:50:35 UTC
Size:
2.94 KB
patch
obsolete
>From ad8d28fede2156b2a66df09eca903ceee9753488 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 28 Apr 2020 13:29:52 +0000 >Subject: [PATCH] Bug 25189: Unit tests > >Adds new test for not adding authority if some already exist > >Also replaces use of 'SearchAuthorities' as it is Zebra specific > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Biblio.t | 36 ++++++++++++++++++++++++++++++++---- > 1 file changed, 32 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t >index 1d12d29b37..4d3db2491e 100755 >--- a/t/db_dependent/Biblio.t >+++ b/t/db_dependent/Biblio.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 13; >+use Test::More tests => 14; > use Test::MockModule; > use List::MoreUtils qw( uniq ); > use MARC::Record; >@@ -29,6 +29,8 @@ use Koha::Database; > use Koha::Caches; > use Koha::MarcSubfieldStructures; > >+use C4::Linker::Default; >+ > BEGIN { > use_ok('C4::Biblio'); > } >@@ -124,6 +126,32 @@ subtest "GetMarcFromKohaField" => sub { > is( $retval[0].$retval[1], '399a', 'Including 399a' ); > }; > >+subtest "Authority creation with default linker" => sub { >+ plan tests => 2; >+ # Automatic authority creation >+ t::lib::Mocks::mock_preference('LinkerModule', 'Default'); >+ t::lib::Mocks::mock_preference('BiblioAddsAuthorities', 1); >+ t::lib::Mocks::mock_preference('AutoCreateAuthorities', 1); >+ t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); >+ my $linker = C4::Linker::Default->new({}); >+ my $authorities_mod = Test::MockModule->new( 'C4::Heading' ); >+ $authorities_mod->mock( >+ 'authorities', >+ sub { >+ my $results = [{ authid => 'original' },{ authid => 'duplicate' }]; >+ return $results; >+ } >+ ); >+ my $marc_record = MARC::Record->new(); >+ my $field = MARC::Field->new(655, ' ', ' ','a' => 'Magical realism'); >+ $marc_record->append_fields( $field ); >+ my ($num_changed,$results) = LinkBibHeadingsToAuthorities($linker, $marc_record, "",undef); >+ is( $num_changed, 0, "We shouldn't link or create a new record"); >+ ok( !defined $results->{added}, "If we have multiple matches, we shouldn't create a new record"); >+}; >+ >+ >+ > # Mocking variables > my $biblio_module = new Test::MockModule('C4::Biblio'); > $biblio_module->mock( >@@ -384,12 +412,12 @@ sub run_tests { > # Automatic authority creation > t::lib::Mocks::mock_preference('BiblioAddsAuthorities', 1); > t::lib::Mocks::mock_preference('AutoCreateAuthorities', 1); >- my $authorities_mod = Test::MockModule->new( 'C4::AuthoritiesMarc' ); >+ my $authorities_mod = Test::MockModule->new( 'C4::Heading' ); > $authorities_mod->mock( >- 'SearchAuthorities', >+ 'authorities', > sub { > my @results; >- return \@results, 0; >+ return \@results; > } > ); > $success = 0; >-- >2.20.1
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 25189
:
103858
|
103870
|
103871
|
103894
|
103895
| 106073 |
106074