Bugzilla – Attachment 127033 Details for
Bug 28445
Use the task queue for the batch delete and update items tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28445: Add tests for subfields_to_prefill
Bug-28445-Add-tests-for-subfieldstoprefill.patch (text/plain), 3.89 KB, created by
Jonathan Druart
on 2021-10-28 08:53:14 UTC
(
hide
)
Description:
Bug 28445: Add tests for subfields_to_prefill
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-10-28 08:53:14 UTC
Size:
3.89 KB
patch
obsolete
>From 4bde8b0501c52897e8d8478c933dd5856900633c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 28 Oct 2021 10:47:51 +0200 >Subject: [PATCH] Bug 28445: Add tests for subfields_to_prefill > >I first wrote test for another thing but the code was actually correct. >So submitting the tests. > >Note that the marc for more_subfields does not need to be passed, we can >build it when needed. >--- > Koha/UI/Form/Builder/Item.pm | 14 ++++++++++---- > t/db_dependent/Koha/UI/Form/Builder/Item.t | 21 ++++++++++++++++++++- > 2 files changed, 30 insertions(+), 5 deletions(-) > >diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm >index d223b51dafb..64a0b925907 100644 >--- a/Koha/UI/Form/Builder/Item.pm >+++ b/Koha/UI/Form/Builder/Item.pm >@@ -16,6 +16,7 @@ package Koha::UI::Form::Builder::Item; > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+use MARC::Record; > use C4::Context; > use C4::Biblio qw( GetFrameworkCode GetMarcBiblio GetMarcStructure IsMarcStructureInternal ); > use C4::Koha qw( GetAuthorisedValues ); >@@ -475,7 +476,13 @@ sub edit_form { > $library->{selected} = 1 if $branchcode && $library->{branchcode} eq $branchcode; > } > >- my $item = $self->{item}; >+ my $item = $self->{item}; >+ my $marc_more_subfields = $item->{more_subfields_xml} >+ ? >+ # FIXME Use Maybe MARC::Record::new_from_xml if encoding issues on subfield (??) >+ MARC::Record->new_from_xml( $item->{more_subfields_xml}, 'UTF-8' ) >+ : undef; >+ > my $biblionumber = $self->{biblionumber}; > my $frameworkcode = $biblionumber ? GetFrameworkCode($biblionumber) : q{}; > my $marc_record = $biblionumber ? GetMarcBiblio( { biblionumber => $biblionumber } ) : undef; >@@ -527,9 +534,8 @@ sub edit_form { > } > else { > # Not mapped, picked the values from more_subfields_xml's MARC >- my $marc_more = $item->{marc_more_subfields_xml}; >- if ($marc_more) { >- for my $f ( $marc_more->fields($tag) ) { >+ if ($marc_more_subfields) { >+ for my $f ( $marc_more_subfields->fields($tag) ) { > push @values, $f->subfield($subfieldtag); > } > } >diff --git a/t/db_dependent/Koha/UI/Form/Builder/Item.t b/t/db_dependent/Koha/UI/Form/Builder/Item.t >index 386241c637f..f2366dbe103 100755 >--- a/t/db_dependent/Koha/UI/Form/Builder/Item.t >+++ b/t/db_dependent/Koha/UI/Form/Builder/Item.t >@@ -16,7 +16,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 6; >+use Test::More tests => 7; > use utf8; > > use List::MoreUtils qw( uniq ); >@@ -153,6 +153,25 @@ subtest 'prefill_with_default_values' => sub { > > }; > >+subtest 'subfields_to_prefill' => sub { >+ plan tests => 2; >+ >+ my $biblio = $builder->build_sample_biblio({ value => {frameworkcode => ''}}); >+ >+ my $more_subfields_xml = Koha::Item::Attributes->new({ "é" => "prefill é" })->to_marcxml; >+ my $subfields = >+ Koha::UI::Form::Builder::Item->new( >+ { biblionumber => $biblio->biblionumber, item => {more_subfields_xml => $more_subfields_xml}})->edit_form({subfields_to_prefill => ['é']}); >+ my ($subfield) = grep { $_->{subfield} eq 'é' } @$subfields; >+ is( $subfield->{marc_value}->{value}, 'prefill é', 'Not mapped subfield prefilled if needed' ); >+ >+ $subfields = >+ Koha::UI::Form::Builder::Item->new( >+ { biblionumber => $biblio->biblionumber, item => {itemnotes => 'prefill z'}})->edit_form({subfields_to_prefill => ['z']}); >+ ($subfield) = grep { $_->{subfield} eq 'z' } @$subfields; >+ is( $subfield->{marc_value}->{value}, 'prefill z', 'Mapped subfield prefilled if needed'); >+}; >+ > subtest 'branchcode' => sub { > plan tests => 2; > >-- >2.25.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 28445
:
121372
|
123221
|
123222
|
123223
|
123224
|
123225
|
123226
|
123227
|
123228
|
123229
|
123239
|
123240
|
125801
|
125802
|
125803
|
125804
|
125805
|
125808
|
125810
|
125811
|
125812
|
125817
|
125865
|
126046
|
126047
|
126136
|
126137
|
126138
|
126139
|
126140
|
126141
|
126142
|
126217
|
126218
|
126219
|
126223
|
126328
|
126329
|
126330
|
126331
|
126332
|
126333
|
126334
|
126335
|
126336
|
126337
|
126338
|
126339
|
126352
|
126353
|
126354
|
126355
|
126356
|
126357
|
126358
|
126359
|
126360
|
126361
|
126362
|
126363
|
126364
|
126365
|
126366
|
126367
|
126374
|
126375
|
126376
|
126377
|
126378
|
126379
|
126380
|
126381
|
126382
|
126383
|
126384
|
126385
|
126386
|
126387
|
126388
|
126389
| 127033 |
127037
|
127038
|
127039
|
128007
|
128008
|
128009