Bugzilla – Attachment 160188 Details for
Bug 35044
Additional fields: Allow for repeatable fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35044: Add tests
Bug-35044-Add-tests.patch (text/plain), 4.41 KB, created by
Martin Renvoize (ashimema)
on 2023-12-21 10:28:53 UTC
(
hide
)
Description:
Bug 35044: Add tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-12-21 10:28:53 UTC
Size:
4.41 KB
patch
obsolete
>From 871cc9f2acd65299ce51d5cd1cf612ac08b83d91 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Wed, 18 Oct 2023 09:31:11 +0000 >Subject: [PATCH] Bug 35044: Add tests > >Test plan: >prove t/db_dependent/Koha/Object/Mixin/AdditionalFields.t > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../Koha/Object/Mixin/AdditionalFields.t | 131 +++++++++++++++++- > 1 file changed, 130 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >index e33a77d068d..051ea137369 100755 >--- a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >+++ b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 2; >+use Test::More tests => 4; > use t::lib::TestBuilder; > use String::Random qw(random_string); > use Koha::Database; >@@ -89,3 +89,132 @@ subtest 'set_additional_fields with marcfield_mode = "set"' => sub { > > $schema->txn_rollback; > }; >+ >+subtest 'get_additional_field_values_for_template' => sub { >+ plan tests => 2; >+ >+ $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 ) >+ } >+ ); >+ $field->store()->discard_changes(); >+ >+ my $field2 = Koha::AdditionalField->new( >+ { >+ tablename => 'subscription', >+ name => random_string( 'c' x 100 ) >+ } >+ ); >+ $field2->store()->discard_changes(); >+ >+ my $value = 'some value'; >+ $subscription->set_additional_fields( >+ [ >+ { >+ id => $field->id, >+ value => $value . ' 1', >+ }, >+ { >+ id => $field->id, >+ value => $value . ' 2', >+ }, >+ { >+ id => $field2->id, >+ value => 'second field', >+ }, >+ ] >+ ); >+ >+ my $template_additional_field_values = $subscription->get_additional_field_values_for_template; >+ >+ is( >+ ref($template_additional_field_values), 'HASH', >+ '->get_additional_field_values_for_template should return a hash' >+ ); >+ is_deeply( >+ $template_additional_field_values, >+ { $field->id => [ $value . ' 1', $value . ' 2' ], $field2->id => ['second field'] }, >+ '->get_additional_field_values_for_template should return the correct values' >+ ); >+ >+ $schema->txn_rollback; >+}; >+ >+subtest 'add_additional_fields' => sub { >+ plan tests => 1; >+ >+ $schema->txn_begin; >+ >+ Koha::AdditionalFields->search->delete; >+ >+ 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 ) >+ } >+ ); >+ $field->store()->discard_changes(); >+ >+ my $field2 = Koha::AdditionalField->new( >+ { >+ tablename => 'subscription', >+ name => random_string( 'c' x 100 ) >+ } >+ ); >+ $field2->store()->discard_changes(); >+ >+ my $value = 'some value'; >+ $subscription->set_additional_fields( >+ [ >+ { >+ id => $field->id, >+ value => $value . ' 1', >+ }, >+ { >+ id => $field->id, >+ value => $value . ' 2', >+ } >+ ] >+ ); >+ >+ $subscription->add_additional_fields( >+ { >+ $field2->id => [ >+ 'second field' >+ ], >+ }, >+ 'subscription' >+ ); >+ >+ my $template_additional_field_values = $subscription->get_additional_field_values_for_template; >+ >+ >+ >+ is_deeply( >+ $template_additional_field_values, >+ { $field->id => [ $value . ' 1', $value . ' 2' ], $field2->id => ['second field'] }, >+ '->add_additional_fields should have only added to existing field values' >+ ); >+ >+ $schema->txn_rollback; >+}; >-- >2.43.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 35044
:
157324
|
157325
|
157326
|
157327
|
157328
|
157329
|
157330
|
157331
|
157332
|
157333
|
157334
|
158113
|
158498
|
158499
|
158500
|
158501
|
158502
|
158503
|
158504
|
158505
|
158506
|
158507
|
158508
|
158857
|
158858
|
158859
|
158860
|
158861
|
158862
|
158863
|
158864
|
158865
|
158866
|
158867
|
158868
|
159268
|
160177
|
160178
|
160179
|
160180
|
160181
|
160182
|
160183
|
160184
|
160185
|
160186
|
160187
|
160188
|
160189
|
164162
|
164163
|
164164
|
164165
|
164166
|
164167
|
164168
|
164169
|
164170
|
164171
|
164172
|
164173
|
164174
|
167690
|
168537
|
168538
|
168539
|
168540
|
168541
|
168542
|
168543
|
168544
|
168545
|
168546
|
168547
|
168548
|
169545
|
169546
|
169547
|
169603
|
169604
|
169605
|
169606
|
169607
|
169643
|
169644
|
169645
|
169646
|
169647
|
169648
|
169649
|
169650
|
169651
|
169652
|
169653
|
169654
|
169655
|
169656
|
169657
|
169658
|
169659
|
169660
|
169661
|
169662
|
169663
|
169664
|
169665
|
169666
|
169667
|
169668
|
169669
|
169670
|
169671
|
169672
|
169673
|
169674
|
169675
|
169676
|
169677
|
169678
|
169679
|
169680
|
169681
|
169682
|
169683
|
169684
|
169697
|
170501