Bugzilla – Attachment 122211 Details for
Bug 28491
Field 003 in authority records not updated after import
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28491: Add unit test
Bug-28491-Add-unit-test.patch (text/plain), 3.46 KB, created by
Marcel de Rooy
on 2021-06-21 08:32:20 UTC
(
hide
)
Description:
Bug 28491: Add unit test
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2021-06-21 08:32:20 UTC
Size:
3.46 KB
patch
obsolete
>From 9ff811f69aa7896f725d0ed72ac18680efac3d6c Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 21 Jun 2021 08:06:38 +0000 >Subject: [PATCH] Bug 28491: Add unit test >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run t/db_dependent/AuthoritiesMarc.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/AuthoritiesMarc.t | 45 +++++++++++++++++++++++++++++--- > 1 file changed, 42 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/AuthoritiesMarc.t b/t/db_dependent/AuthoritiesMarc.t >index 8e626f3f5c..efa1b4bd4a 100755 >--- a/t/db_dependent/AuthoritiesMarc.t >+++ b/t/db_dependent/AuthoritiesMarc.t >@@ -5,7 +5,7 @@ > > use Modern::Perl; > >-use Test::More tests => 12; >+use Test::More tests => 13; > use Test::MockModule; > use Test::Warn; > use MARC::Field; >@@ -15,6 +15,7 @@ use t::lib::Mocks; > use t::lib::TestBuilder; > use Koha::Database; > use Koha::Authority::Types; >+use Koha::Libraries; > > BEGIN { > use_ok('C4::AuthoritiesMarc'); >@@ -29,7 +30,7 @@ $module->mock('GetHeaderAuthority', sub { > $module->mock('AddAuthorityTrees', sub { > return; > }); >-$module->mock('GetAuthority', sub { >+my $sub_get_authority = sub { > my ($authid) = @_; > my $record = MARC::Record->new(); > if ($authid eq '1') { >@@ -64,7 +65,8 @@ $module->mock('GetAuthority', sub { > undef $record; > } > return $record; >-}); >+}; >+$module->mock('GetAuthority', $sub_get_authority); > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -220,6 +222,43 @@ subtest 'AddAuthority should respect AUTO_INCREMENT (BZ 18104)' => sub { > is( $record->field('001')->data, $id3, 'Check updated 001' ); > }; > >+subtest 'AddAuthority always updates 003' => sub { >+ plan tests => 4; >+ >+ $module->unmock('GetAuthority'); >+ >+ t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $library_branchcode = $library->branchcode; >+ my $library_orgcode = $library->marcorgcode; >+ >+ my $record = MARC::Record->new; >+ $record->append_fields( >+ MARC::Field->new( '001', 999 ), >+ MARC::Field->new( '003', 'ORG_01' ), >+ MARC::Field->new( '100', '', '', a => 'Marcel' ), >+ MARC::Field->new( '942', '', '', a => 'PERSO_NAME' ), >+ ); >+ >+ t::lib::Mocks::mock_preference( 'MARCOrgCode', 'ORG_02' ); >+ t::lib::Mocks::mock_userenv({ branchcode => q{} }); >+ my $id = AddAuthority( $record, undef, 'PERSO_NAME' ); >+ is( C4::AuthoritiesMarc::GetAuthority($id)->field('003')->data, 'ORG_02', 'New record: Updated to pref value' ); >+ t::lib::Mocks::mock_userenv({ branchcode => $library_branchcode }); >+ $id = AddAuthority( $record, undef, 'PERSO_NAME' ); >+ is( C4::AuthoritiesMarc::GetAuthority($id)->field('003')->data, $library_orgcode, 'New record: Updated to library value' ); >+ >+ t::lib::Mocks::mock_userenv({ branchcode => $library_branchcode }); >+ ModAuthority( $id, $record, 'PERSO_NAME' ); >+ is( C4::AuthoritiesMarc::GetAuthority($id)->field('003')->data, $library_orgcode, 'Changed record: Updated to library value' ); >+ t::lib::Mocks::mock_userenv({ branchcode => q{} }); >+ ModAuthority( $id, $record, 'PERSO_NAME' ); >+ is( C4::AuthoritiesMarc::GetAuthority($id)->field('003')->data, 'ORG_02', 'Changed record: Updated to pref value' ); >+ >+ $module->mock('GetAuthority', $sub_get_authority); >+}; >+ > subtest 'CompareFieldWithAuthority tests' => sub { > plan tests => 3; > >-- >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 28491
:
122209
|
122210
|
122211
|
122294
|
122295
|
122296
|
122297
|
122298
|
122299
|
122300