Bugzilla – Attachment 169729 Details for
Bug 35287
Add additional fields support to ERM Licenses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35287: Add unit tests
Bug-35287-Add-unit-tests.patch (text/plain), 4.48 KB, created by
Pedro Amorim
on 2024-07-26 14:30:42 UTC
(
hide
)
Description:
Bug 35287: Add unit tests
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-07-26 14:30:42 UTC
Size:
4.48 KB
patch
obsolete
>From 8874e4a2600db75b521e5cb5a9590bba72a8b4fc Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 9 Nov 2023 13:47:32 +0000 >Subject: [PATCH] Bug 35287: Add unit tests > >Test plan, k-t-d: >prove t/db_dependent/Koha/Object/Mixin/AdditionalFields.t > >Signed-off-by: Edith Speller <edith.speller@ukhsa.gov.uk> >Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> >--- > .../Koha/Object/Mixin/AdditionalFields.t | 112 +++++++++++++++++- > 1 file changed, 111 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >index e49c6b48b7..7dd21ba1ce 100755 >--- a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >+++ b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >@@ -1,12 +1,14 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 5; >+use Test::More tests => 6; > use t::lib::TestBuilder; > use String::Random qw(random_string); > use Koha::Database; > use Koha::Subscription; > use Koha::AdditionalField; >+use Koha::AuthorisedValueCategory; >+use Koha::ERM::License; > use C4::Context; > use CGI; > >@@ -280,3 +282,111 @@ subtest 'prepare_cgi_additional_field_values' => sub { > $schema->txn_rollback; > > }; >+ >+subtest 'strings_map() tests' => sub { >+ plan tests => 1; >+ $schema->txn_begin; >+ Koha::AdditionalFields->search->delete; >+ my $license = Koha::ERM::License->new( >+ { >+ name => "license name", >+ type => "national", >+ status => "in_negotiation", >+ >+ } >+ ); >+ $license->store()->discard_changes(); >+ my $field = Koha::AdditionalField->new( >+ { >+ tablename => 'erm_licenses', >+ name => 'af_1', >+ >+ } >+ ); >+ $field->store()->discard_changes(); >+ my $field2 = Koha::AdditionalField->new( >+ { >+ tablename => 'erm_licenses', >+ name => 'af_2', >+ >+ } >+ ); >+ $field2->store()->discard_changes(); >+ my $value = 'some license value'; >+ $license->set_additional_fields( >+ [ >+ { >+ id => $field->id, >+ value => $value . ' 1', >+ >+ }, >+ { >+ id => $field->id, >+ value => $value . ' 2', >+ >+ } >+ ] >+ ); >+ $license->add_additional_fields( >+ { >+ $field2->id => ['second field'], >+ >+ }, >+ 'erm_licenses' >+ ); >+ my $av_category = Koha::AuthorisedValueCategory->new( { category_name => "AV_CAT_NAME" } ); >+ $av_category->store()->discard_changes(); >+ my $av_value = Koha::AuthorisedValue->new( >+ { >+ category => $av_category->category_name, >+ authorised_value => 'BOB', >+ lib => "Robert" >+ } >+ ); >+ my $av_field = Koha::AdditionalField->new( >+ { >+ tablename => "erm_licenses", >+ name => "av_field", >+ authorised_value_category => $av_category->category_name, >+ >+ } >+ ); >+ $av_field->store()->discard_changes(); >+ $license->add_additional_fields( >+ { >+ $av_field->id => [ $av_value->authorised_value ], >+ >+ }, >+ 'erm_licenses' >+ ); >+ my $values = $license->get_additional_field_values_for_template; >+ my $strings_map = $license->strings_map; >+ is_deeply( >+ $strings_map, >+ { >+ additional_field_values => [ >+ { >+ 'field_id' => $field->id, >+ 'type' => 'text', >+ 'field_label' => $field->name, >+ 'value_str' => join( ', ', @{ $values->{ $field->id } } ) >+ }, >+ { >+ 'field_id' => $field2->id, >+ 'type' => 'text', >+ 'field_label' => $field2->name, >+ 'value_str' => join( ', ', @{ $values->{ $field2->id } } ) >+ }, >+ { >+ 'field_id' => $av_field->id, >+ 'type' => 'av', >+ 'field_label' => $av_field->name, >+ 'value_str' => join( ', ', @{ $values->{ $av_field->id } } ) >+ } >+ ] >+ }, >+ 'strings_map looks good' >+ ); >+ $schema->txn_rollback; >+ ; >+}; >-- >2.39.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 35287
:
158725
|
158726
|
158727
|
158728
|
158729
|
158730
|
158731
|
158732
|
158733
|
158734
|
159634
|
159635
|
159636
|
159637
|
159638
|
159639
|
159640
|
159641
|
159642
|
159643
|
165451
|
165637
|
165638
|
165639
|
165640
|
165641
|
165642
|
165643
|
165644
|
165645
|
165646
|
165647
|
167681
|
169728
| 169729 |
169730
|
169731
|
169732
|
169733
|
169734
|
169735
|
169736
|
169737
|
170448
|
170753