Bugzilla – Attachment 136090 Details for
Bug 29454
Stash itemtypes in plugin objects to reduce DB calls
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29454: Add unit test for Koha::Template::Plugin::ItemTypes
Bug-29454-Add-unit-test-for-KohaTemplatePluginItem.patch (text/plain), 3.76 KB, created by
Nick Clemens (kidclamp)
on 2022-06-15 12:08:55 UTC
(
hide
)
Description:
Bug 29454: Add unit test for Koha::Template::Plugin::ItemTypes
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-06-15 12:08:55 UTC
Size:
3.76 KB
patch
obsolete
>From 7da66efce70644c91fa2f7c8562f8cb419fb03b0 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Tue, 14 Jun 2022 11:57:40 -1000 >Subject: [PATCH] Bug 29454: Add unit test for > Koha::Template::Plugin::ItemTypes > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > .../Koha/Template/Plugin/ItemTypes.t | 93 +++++++++++++++++++ > 1 file changed, 93 insertions(+) > create mode 100755 t/db_dependent/Koha/Template/Plugin/ItemTypes.t > >diff --git a/t/db_dependent/Koha/Template/Plugin/ItemTypes.t b/t/db_dependent/Koha/Template/Plugin/ItemTypes.t >new file mode 100755 >index 0000000000..4f99bcbdca >--- /dev/null >+++ b/t/db_dependent/Koha/Template/Plugin/ItemTypes.t >@@ -0,0 +1,93 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 8; >+ >+use C4::Context; >+use Koha::Database; >+use Koha::ItemTypes; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+BEGIN { >+ use_ok('Koha::Template::Plugin::ItemTypes'); >+} >+ >+my $schema = Koha::Database->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+$schema->storage->txn_begin; >+ >+my $plugin = Koha::Template::Plugin::ItemTypes->new(); >+ok( $plugin, "initialized ItemTypes plugin" ); >+ >+my $GetDescriptionUndef = $plugin->GetDescription(undef); >+is($GetDescriptionUndef, q{}, "GetDescription call with undef"); >+ >+my $GetDescriptionUnknown = $plugin->GetDescription("deliriumtremenssyndrome"); >+is($GetDescriptionUnknown, q{}, "GetDescription call with unknown type"); >+ >+my $itemtypeA = $builder->build_object( >+ { >+ class => 'Koha::ItemTypes', >+ value => { >+ parent_type => undef, >+ description => "Desc itemtype A", >+ } >+ } >+); >+Koha::Localization->new( >+ { >+ entity => 'itemtypes', >+ code => $itemtypeA->itemtype, >+ lang => 'en', >+ translation => 'Translated itemtype A' >+ } >+)->store; >+my $itemtypeB = $builder->build_object( >+ { >+ class => 'Koha::ItemTypes', >+ value => { >+ parent_type => $itemtypeA->itemtype, >+ description => "Desc itemtype B", >+ } >+ } >+); >+Koha::Localization->new( >+ { >+ entity => 'itemtypes', >+ code => $itemtypeB->itemtype, >+ lang => 'en', >+ translation => 'Translated itemtype B' >+ } >+)->store; >+ >+my $GetDescriptionA1 = $plugin->GetDescription($itemtypeA->itemtype); >+is($GetDescriptionA1, "Translated itemtype A", "ItemType without parent - GetDescription without want parent"); >+my $GetDescriptionA2 = $plugin->GetDescription($itemtypeA->itemtype, 1); >+is($GetDescriptionA2, "Translated itemtype A", "ItemType without parent - GetDescription with want parent"); >+ >+my $GetDescriptionB1 = $plugin->GetDescription($itemtypeB->itemtype); >+is($GetDescriptionB1, "Translated itemtype B", "ItemType with parent - GetDescription without want parent"); >+my $GetDescriptionB2 = $plugin->GetDescription($itemtypeB->itemtype, 1); >+is($GetDescriptionB2, "Translated itemtype A->Translated itemtype B", "ItemType with parent - GetDescription with want parent"); >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >2.30.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 29454
:
127515
|
127520
|
128472
|
136077
|
136078
|
136090
|
136091
|
136149
|
136150
|
136151