Bugzilla – Attachment 80233 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 behaviour
Bug-21503-Tests-for-the-existing-behaviour.patch (text/plain), 4.41 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-10-08 19:22:56 UTC
(
hide
)
Description:
Bug 21503: Tests for the existing behaviour
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-10-08 19:22:56 UTC
Size:
4.41 KB
patch
obsolete
>From 5b5d411e68d7e4848fff6307c85dd0091cf65438 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 behaviour > >This patch introduces 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! > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../Template/Plugin/AuthorisedValues.t | 75 ++++++++++++++++++- > 1 file changed, 73 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Template/Plugin/AuthorisedValues.t b/t/db_dependent/Template/Plugin/AuthorisedValues.t >index e57dad165d..bd3c95d6b7 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,71 @@ 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 => 4; >+ >+ $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 => undef } >+ } >+ ); >+ my $non_existent_av = $av_2->authorised_value; >+ $av_2->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 an existing AV description, for the OPAC' ); >+ >+ $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( >+ { kohafield => 'dummy.field', authorised_value => $av_1->authorised_value } ); >+ is( $av, 'lib', 'We requested an existing AV description, not for the OPAC' ); >+ >+ $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( >+ { opac => 1, kohafield => 'dummy.field', authorised_value => $non_existent_av } ); >+ is( $av, '', 'We requested a non existing AV description, for the OPAC, return empty string' ); >+ >+ $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( >+ { kohafield => 'dummy.field', authorised_value => $non_existent_av } ); >+ is( $av, '', >+ 'We requested a non existing AV description, not for the OPAC, return empty string' ); >+ >+ $schema->storage->txn_rollback; > }; >-- >2.19.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