Bugzilla – Attachment 99309 Details for
Bug 21800
TransformKohaToMarc should respect non-repeatability of item subfields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21800: Add tests for repeatable subfields
Bug-21800-Add-tests-for-repeatable-subfields.patch (text/plain), 5.29 KB, created by
Marcel de Rooy
on 2020-02-20 13:25:25 UTC
(
hide
)
Description:
Bug 21800: Add tests for repeatable subfields
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-02-20 13:25:25 UTC
Size:
5.29 KB
patch
obsolete
>From 9bcd5393b413c6c59519738811d1b07d8fe61c5a Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 13 Feb 2020 11:55:32 +0000 >Subject: [PATCH] Bug 21800: Add tests for repeatable subfields >Content-Type: text/plain; charset=utf-8 > >Test plan: >Do not apply the second patch [note 1]. >Run t/db_dependent/Biblio/TransformKohaToMarc.t >Run t/db_dependent/Biblio/TransformMarcToKoha.t >Apply the second patch and run them again. Both tests should pass now. > >Note 1: The TransformKohaToMarc test should fail with something like: > # Failed test 'Check 260e' > # at t/db_dependent/Biblio/TransformKohaToMarc.t line 60. > # got: 'A' > # expected: 'A | B' > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Biblio/TransformKohaToMarc.t | 14 +++++++++----- > t/db_dependent/Biblio/TransformMarcToKoha.t | 19 ++++++++++++++++++- > 2 files changed, 27 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/Biblio/TransformKohaToMarc.t b/t/db_dependent/Biblio/TransformKohaToMarc.t >index 90b4d847dd..f1b203b3bf 100644 >--- a/t/db_dependent/Biblio/TransformKohaToMarc.t >+++ b/t/db_dependent/Biblio/TransformKohaToMarc.t >@@ -17,7 +17,7 @@ $schema->storage->txn_begin; > Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'a' })->delete; > Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'a', kohafield => "mytable.nicepages" })->store; > Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'b' })->delete; >-Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'b', kohafield => "mytable2.goodillustrations" })->store; >+Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'b', kohafield => "mytable2.goodillustrations", repeatable => 1 })->store; > Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); > > my $record = C4::Biblio::TransformKohaToMarc({ >@@ -40,20 +40,24 @@ is_deeply( \@subfields, [ > > # Now test multiple mappings per kohafield too > subtest "Multiple Koha to MARC mappings (BZ 10306)" => sub { >- plan tests => 4; >+ plan tests => 5; > >- # Add260d mapping so that 300a and 260d both map to mytable.nicepages >- Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '260', tagsubfield => 'd' })->delete; >+ # Add 260d mapping so that 300a and 260d both map to mytable.nicepages >+ # Add 260e to test not-repeatable behavior >+ Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '260' })->delete; > Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '260', tagsubfield => 'd', kohafield => "mytable.nicepages" })->store; >+ Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '260', tagsubfield => 'e', kohafield => "mytable.unrepeatable", repeatable => 0 })->store; > Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); > > # Include two values in goodillustrations too: should result in two >- # subfields. >+ # subfields. But unrepeatable should result in one field. > my $record = C4::Biblio::TransformKohaToMarc({ > "mytable2.goodillustrations" => "good | better", > "mytable.nicepages" => "nice", >+ "mytable.unrepeatable" => "A | B", > }); > is( $record->subfield('260','d'), "nice", "Check 260d" ); >+ is( $record->subfield('260','e'), "A | B", "Check 260e" ); > is( $record->subfield('300','a'), "nice", "Check 300a" ); > is( $record->subfield('300','b'), "good", "Check first 300b" ); > is( ($record->field('300')->subfield('b'))[1], "better", >diff --git a/t/db_dependent/Biblio/TransformMarcToKoha.t b/t/db_dependent/Biblio/TransformMarcToKoha.t >index b9c02a8cc9..8d1e94c1eb 100644 >--- a/t/db_dependent/Biblio/TransformMarcToKoha.t >+++ b/t/db_dependent/Biblio/TransformMarcToKoha.t >@@ -19,7 +19,7 @@ > # with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 3; >+use Test::More tests => 4; > use MARC::Record; > > use t::lib::Mocks; >@@ -108,6 +108,23 @@ subtest 'Testing _adjust_pubyear' => sub { > is( C4::Biblio::_adjust_pubyear('198-?'), '1980', '198-?' ); > }; > >+subtest 'Test repeatable subfields' => sub { >+ plan tests => 2; >+ >+ # Make 510x repeatable and 510y not >+ Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '510' })->delete; >+ Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'x', kohafield => 'items.test', repeatable => 1 })->store; >+ Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'y', kohafield => 'items.norepeat', repeatable => 0 })->store; >+ Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); >+ >+ >+ my $marc = MARC::Record->new; >+ $marc->append_fields( MARC::Field->new( '510', '', '', x => '1', x => '2', y => '3 | 4', y => '5' ) ); # actually, we should only have one $y (BZ 24652) >+ my $result = C4::Biblio::TransformMarcToKoha( $marc ); >+ is( $result->{test}, '1 | 2', 'Check 510x for two values' ); >+ is( $result->{norepeat}, '3 | 4 | 5', 'Check 510y too' ); >+}; >+ > # 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 21800
:
98816
|
98817
|
99309
|
99310
|
99311
|
99312
|
99313
|
99517
|
99518
|
99519
|
99520
|
101364
|
101365
|
101366
|
101367
|
101667