Bugzilla – Attachment 80561 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 for the existing behavior
Bug-21503-Tests-for-the-existing-behavior.patch (text/plain), 5.36 KB, created by
Christopher Brannon
on 2018-10-12 19:21:26 UTC
(
hide
)
Description:
Bug 21503: Tests for the existing behavior
Filename:
MIME Type:
Creator:
Christopher Brannon
Created:
2018-10-12 19:21:26 UTC
Size:
5.36 KB
patch
obsolete
>From b1c0c02c6ae5bfacecba122cb5916f79528963e1 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 8 Oct 2018 16:21:25 -0300 >Subject: [PATCH] Bug 21503: Tests for the existing behavior > >This patch introduces 7 tests for the current behaviour for the >AuthorisedValues template plugin. > >To test: >- Apply this patch >- Run: > $ kshell > k$ prove t/db_dependent/Template/Plugin/AuthorisedValues.t >=> SUCCESS: Tests pass, all green! >--- > t/db_dependent/Template/Plugin/AuthorisedValues.t | 85 ++++++++++++++++++++++- > 1 file changed, 83 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Template/Plugin/AuthorisedValues.t b/t/db_dependent/Template/Plugin/AuthorisedValues.t >index e57dad165d..d9a1f3add5 100644 >--- a/t/db_dependent/Template/Plugin/AuthorisedValues.t >+++ b/t/db_dependent/Template/Plugin/AuthorisedValues.t >@@ -16,21 +16,25 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > > use C4::Context; >+use Koha::Caches; > use Koha::Database; >+use Koha::MarcSubfieldStructures; > use Koha::Template::Plugin::AuthorisedValues; > > use t::lib::TestBuilder; > use t::lib::Mocks; > > my $schema = Koha::Database->schema; >-$schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > > subtest 'GetByCode' => sub { > plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ > my $avc = > $builder->build_object( { class => 'Koha::AuthorisedValueCategories' } ); > my $av_1 = $builder->build_object( >@@ -63,4 +67,81 @@ subtest 'GetByCode' => sub { > Koha::Template::Plugin::AuthorisedValues->GetByCode( $avc->category_name, > 'does_not_exist' ); > is( $description, 'does_not_exist', 'GetByCode should return the code passed if the AV does not exist' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'GetDescriptionByKohaField' => sub { >+ >+ plan tests => 7; >+ >+ $schema->storage->txn_begin; >+ >+ 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 >+ } >+ )->store; >+ >+ # Make sure we are not catch by cache >+ Koha::Caches->get_instance->flush_all; >+ my $av_1 = $builder->build_object( >+ { class => 'Koha::AuthorisedValues', >+ value => { category => $avc->category_name, lib_opac => 'lib_opac', lib => 'lib' } >+ } >+ ); >+ my $av_2 = $builder->build_object( >+ { class => 'Koha::AuthorisedValues', >+ value => { category => $avc->category_name, lib_opac => undef, lib => 'lib' } >+ } >+ ); >+ 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; >+ >+ 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.' ); >+ $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.' ); >+ $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.' ); >+ $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.' ); >+ $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( >+ { kohafield => 'dummy.field', authorised_value => $av_1->authorised_value } ); >+ is( $av, 'lib', 'We requested a regular description.' ); >+ $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.' ); >+ $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.' ); >+ >+ $schema->storage->txn_rollback; > }; >-- >2.11.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 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