Bugzilla – Attachment 149091 Details for
Bug 11844
Additional fields for order lines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11844: Add tests for marcfield_mode
Bug-11844-Add-tests-for-marcfieldmode.patch (text/plain), 3.18 KB, created by
Biblibre Sandboxes
on 2023-04-03 09:53:52 UTC
(
hide
)
Description:
Bug 11844: Add tests for marcfield_mode
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2023-04-03 09:53:52 UTC
Size:
3.18 KB
patch
obsolete
>From 8a921df077884a91ed48f8a816c191a7750e91fe Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 29 Mar 2023 12:26:18 +0200 >Subject: [PATCH] Bug 11844: Add tests for marcfield_mode > >Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> >--- > .../Koha/Object/Mixin/AdditionalFields.t | 91 +++++++++++++++++++ > 1 file changed, 91 insertions(+) > create mode 100755 t/db_dependent/Koha/Object/Mixin/AdditionalFields.t > >diff --git a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >new file mode 100755 >index 0000000000..c397701f8a >--- /dev/null >+++ b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >@@ -0,0 +1,91 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+use Test::More tests => 2; >+use t::lib::TestBuilder; >+use String::Random qw(random_string); >+use Koha::Database; >+use Koha::Subscription; >+use Koha::AdditionalField; >+use C4::Context; >+ >+my $builder = t::lib::TestBuilder->new; >+my $schema = Koha::Database->schema; >+ >+subtest 'set_additional_fields with marcfield_mode = "get"' => sub { >+ plan tests => 1; >+ >+ $schema->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $record = $biblio->record; >+ $record->append_fields( >+ MARC::Field->new('999', '', '', 'Z' => 'some value'), >+ ); >+ $biblio->metadata->metadata($record->as_xml_record(C4::Context->preference('marcflavour'))); >+ $biblio->metadata->store()->discard_changes(); >+ my $subscription = Koha::Subscription->new( >+ { >+ biblionumber => $biblio->biblionumber, >+ } >+ ); >+ $subscription->store()->discard_changes(); >+ >+ my $field = Koha::AdditionalField->new( >+ { >+ tablename => 'subscription', >+ name => random_string('c' x 100), >+ marcfield => '999$Z', >+ marcfield_mode => 'get', >+ } >+ ); >+ $field->store()->discard_changes(); >+ $subscription->set_additional_fields( >+ [ >+ { id => $field->id }, >+ ] >+ ); >+ >+ my $values = $subscription->additional_field_values()->as_list(); >+ >+ is($values->[0]->value, 'some value', 'value was copied from the biblio record to the field'); >+ >+ $schema->txn_rollback; >+}; >+ >+subtest 'set_additional_fields with marcfield_mode = "set"' => sub { >+ plan tests => 1; >+ >+ $schema->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $subscription = Koha::Subscription->new( >+ { >+ biblionumber => $biblio->biblionumber, >+ } >+ ); >+ $subscription->store()->discard_changes(); >+ >+ my $field = Koha::AdditionalField->new( >+ { >+ tablename => 'subscription', >+ name => random_string('c' x 100), >+ marcfield => '999$Z', >+ marcfield_mode => 'set', >+ } >+ ); >+ $field->store()->discard_changes(); >+ $subscription->set_additional_fields( >+ [ >+ { >+ id => $field->id, >+ value => 'some value', >+ }, >+ ] >+ ); >+ >+ my $record = $biblio->record; >+ is($record->subfield('999', 'Z'), 'some value', 'value was copied from the field to the biblio record'); >+ >+ $schema->txn_rollback; >+}; >-- >2.30.2
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 11844
:
25632
|
25638
|
41859
|
41860
|
45674
|
45675
|
45676
|
45758
|
45915
|
45916
|
45917
|
53614
|
53615
|
53616
|
53618
|
53619
|
55529
|
75332
|
75362
|
141116
|
145517
|
145535
|
145536
|
145540
|
146497
|
146500
|
146501
|
146502
|
146503
|
146504
|
146505
|
146506
|
148889
|
148895
|
148897
|
149081
|
149082
|
149083
|
149084
|
149085
|
149086
|
149087
|
149088
|
149089
|
149090
|
149091
|
149682
|
149683
|
149684
|
149685
|
149686
|
149687
|
149688
|
149689
|
149690
|
149691
|
149692
|
150537
|
150538
|
150539
|
150540
|
150541
|
150542
|
150543
|
150544
|
150545
|
150546
|
150547
|
150548
|
151220
|
151221
|
151222
|
151223
|
151224
|
151225
|
151226
|
151227
|
151228
|
151229
|
151230
|
151366