Bugzilla – Attachment 165638 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.36 KB, created by
Pedro Amorim
on 2024-04-26 10:31:55 UTC
(
hide
)
Description:
Bug 35287: Add unit tests
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-04-26 10:31:55 UTC
Size:
4.36 KB
patch
obsolete
>From 55e2a45f40914c5a29277734755e7ca1b7138cf7 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 | 120 +++++++++++++++++- > 1 file changed, 119 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >index 051ea137369..3f4a1d08a87 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 => 4; >+use Test::More tests => 5; > 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; > > my $builder = t::lib::TestBuilder->new; >@@ -218,3 +220,119 @@ subtest 'add_additional_fields' => 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
|
172850
|
172851
|
172852
|
172853
|
172854
|
172855
|
172856
|
172857
|
172858
|
172860
|
172861
|
173022
|
173102
|
173103
|
173104
|
173105
|
173106
|
173107
|
173108
|
173109
|
173110
|
173111
|
173112
|
173113
|
173290