Bugzilla – Attachment 101325 Details for
Bug 21503
Update AuthorisedValues.pm to fall back to code if description doesn't exist
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21503: Tests cleanup and highlight a missing case
Bug-21503-Tests-cleanup-and-highlight-a-missing-ca.patch (text/plain), 6.08 KB, created by
Fridolin Somers
on 2020-03-21 11:17:34 UTC
(
hide
)
Description:
Bug 21503: Tests cleanup and highlight a missing case
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2020-03-21 11:17:34 UTC
Size:
6.08 KB
patch
obsolete
>From 07fa9a04596e40007d820d1d7f33e430fc34e147 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 15 Oct 2018 10:45:55 -0300 >Subject: [PATCH] Bug 21503: Tests cleanup and highlight a missing case > >This patch does the following changes: >- Use build_object to create the MSS >- Store the generate AVs. That was not the case before and so we were >not testing the right things >- Split the tests into 2 parts: staff and OPAC, for readability >- Update the tests' descriptions >- Highlight a problem: If descriptions are missing for both OPAC and >staff, undef is returned. Is that what we expect? It seems that it is >not what were expecting the tests. > >Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> >--- > .../Template/Plugin/AuthorisedValues.t | 63 ++++++++++--------- > 1 file changed, 33 insertions(+), 30 deletions(-) > >diff --git a/t/db_dependent/Template/Plugin/AuthorisedValues.t b/t/db_dependent/Template/Plugin/AuthorisedValues.t >index d9a1f3add5..ee27539dae 100644 >--- a/t/db_dependent/Template/Plugin/AuthorisedValues.t >+++ b/t/db_dependent/Template/Plugin/AuthorisedValues.t >@@ -80,24 +80,19 @@ subtest 'GetDescriptionByKohaField' => sub { > my $avc = $builder->build_object( { class => 'Koha::AuthorisedValueCategories' } ); > > # Create a framework mapping >- Koha::MarcSubfieldStructure->new( >- { tagfield => '988', >- tagsubfield => 'a', >- liblibrarian => 'Dummy field', >- libopac => 'Dummy field', >- repeatable => 0, >- mandatory => 0, >- kohafield => 'dummy.field', >- tab => '9', >- authorised_value => $avc->category_name, >- authtypecode => q{}, >- value_builder => q{}, >- isurl => 0, >- hidden => 0, >- frameworkcode => q{}, >- seealso => q{}, >- link => q{}, >- defaultvalue => undef >+ $builder->build_object( >+ { >+ class => 'Koha::MarcSubfieldStructures', >+ value => { >+ >+ tagfield => '988', >+ tagsubfield => 'a', >+ liblibrarian => 'Dummy field', >+ libopac => 'Dummy field', >+ kohafield => 'dummy.field', >+ authorised_value => $avc->category_name, >+ frameworkcode => q{}, >+ } > } > )->store; > >@@ -107,41 +102,49 @@ subtest 'GetDescriptionByKohaField' => sub { > { class => 'Koha::AuthorisedValues', > value => { category => $avc->category_name, lib_opac => 'lib_opac', lib => 'lib' } > } >- ); >+ )->store; > my $av_2 = $builder->build_object( > { class => 'Koha::AuthorisedValues', > value => { category => $avc->category_name, lib_opac => undef, lib => 'lib' } > } >- ); >+ )->store; > my $av_3 = $builder->build_object( > { class => 'Koha::AuthorisedValues', > value => { category => $avc->category_name, lib_opac => undef, lib => undef } > } >- ); >- my $non_existent_av = $av_3->authorised_value; >- $av_3->delete; >+ )->store; >+ >+ my $non_existent_av = $builder->build_object( >+ { >+ class => 'Koha::AuthorisedValues', >+ value => { category => $avc->category_name, } >+ } >+ )->store->delete; > >+ # Opac display > my $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( > { opac => 1, kohafield => 'dummy.field', authorised_value => $av_1->authorised_value } ); >- is( $av, 'lib_opac', 'We requested OPAC description.' ); >+ is( $av, 'lib_opac', 'The OPAC description should be displayed if exists' ); > $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( > { opac => 1, kohafield => 'dummy.field', authorised_value => $av_2->authorised_value } ); >- is( $av, 'lib', 'We requested OPAC description, return a regular description.' ); >+ is( $av, 'lib', 'The staff description should be displayed if none exists for OPAC' ); > $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( > { opac => 1, kohafield => 'dummy.field', authorised_value => $av_3->authorised_value } ); >- is( $av, $av_3->authorised_value, 'We requested OPAC or regular description, return the authorised_value.' ); >+ is( $av, $av_3->authorised_value, 'If both OPAC and staff descriptions are missing, the code should be displayed'); > $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( > { opac => 1, kohafield => 'dummy.field', authorised_value => $non_existent_av } ); >- is( $av, $av_3->authorised_value, 'We requested a non existing authorised_value for the OPAC, return the authorised_value.' ); >+ is( $av, $non_existent_av, 'If both OPAC and staff descriptions are missing, the parameter should be displayed'); >+ >+ # Staff display > $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( > { kohafield => 'dummy.field', authorised_value => $av_1->authorised_value } ); >- is( $av, 'lib', 'We requested a regular description.' ); >+ is( $av, 'lib', 'The staff description should be displayed' ); > $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( > { kohafield => 'dummy.field', authorised_value => $av_3->authorised_value } ); >- is( $av, $av_3->authorised_value, 'We requested a regular description, return the authorised_value.' ); >+ is( $av, $av_3->authorised_value, 'If both OPAC and staff descriptions are missing, the code should be displayed'); > $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( > { kohafield => 'dummy.field', authorised_value => $non_existent_av } ); >- is( $av, $av_3->authorised_value, 'We requested a non existing authorised_value, return the authorised_value.' ); >+ is( $av, $non_existent_av, 'If both OPAC and staff descriptions are missing, the parameter should be displayed'); > > $schema->storage->txn_rollback; > }; >-- >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 21503
:
80151
|
80152
|
80233
|
80439
|
80521
|
80544
|
80545
|
80558
|
80561
|
80562
|
80563
|
80601
|
80758
|
80759
|
80762
|
101323
|
101324
|
101325
|
101326
|
101327
|
101328
|
101524
|
101525
|
101526
|
101527
|
101528
|
101529
|
101533
|
101534
|
101535