Bugzilla – Attachment 160442 Details for
Bug 34234
Item groups dropdown in detail page modal does not respect display order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34234: add a unit test
Bug-34234-add-a-unit-test.patch (text/plain), 4.47 KB, created by
Lucas Gass
on 2024-01-03 00:27:18 UTC
(
hide
)
Description:
Bug 34234: add a unit test
Filename:
MIME Type:
Creator:
Lucas Gass
Created:
2024-01-03 00:27:18 UTC
Size:
4.47 KB
patch
obsolete
>From 5c95065e55122449c896718a7979a5411208376a Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Wed, 3 Jan 2024 00:25:02 +0000 >Subject: [PATCH] Bug 34234: add a unit test > >--- > Koha/Template/Plugin/ItemGroups.pm | 6 +- > .../prog/en/modules/cataloguing/additem.tt | 4 +- > t/db_dependent/Template/Plugin/ItemGroups.t | 57 +++++++++++++++++++ > 3 files changed, 62 insertions(+), 5 deletions(-) > create mode 100755 t/db_dependent/Template/Plugin/ItemGroups.t > >diff --git a/Koha/Template/Plugin/ItemGroups.pm b/Koha/Template/Plugin/ItemGroups.pm >index 47844478d6..efd1d9b386 100644 >--- a/Koha/Template/Plugin/ItemGroups.pm >+++ b/Koha/Template/Plugin/ItemGroups.pm >@@ -50,15 +50,15 @@ sub listGroups { > ); > } > >-=head3 count >+=head3 getCount > >-[% ItemGroups.count %] >+[% ItemGroups.getCount %] > > returns count of item groups on a particular bibliographic record > > =cut > >-sub count { >+sub getCount { > my ( $self, $biblionumber ) = @_; > return Koha::Biblio::ItemGroups->search( > { biblio_id => $biblionumber }, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index 8014325538..14fa4187ef 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -37,7 +37,7 @@ > [% INCLUDE 'str/cataloging_additem.inc' %] > [% Asset.js("js/cataloging_additem.js") | $raw %] > <script> >- var has_item_groups = "[% ItemGroups.count(biblio.biblionumber) | html %]"; >+ var has_item_groups = "[% ItemGroups.getCount(biblio.biblionumber) | html %]"; > </script> > </head> > >@@ -250,7 +250,7 @@ > [% IF op != 'add_item' %] > <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" /> > [% END %] >-[% IF ItemGroups.count(biblio.biblionumber) && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %] >+[% IF ItemGroups.getCount(biblio.biblionumber) && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %] > <fieldset class="rows"> > <legend><i class="fa fa-plus"></i> Add to item group</legend> > [% FOREACH ig IN ItemGroups.listGroups(biblio.biblionumber) %] >diff --git a/t/db_dependent/Template/Plugin/ItemGroups.t b/t/db_dependent/Template/Plugin/ItemGroups.t >new file mode 100755 >index 0000000000..5ab1574aa3 >--- /dev/null >+++ b/t/db_dependent/Template/Plugin/ItemGroups.t >@@ -0,0 +1,57 @@ >+#!/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 => 2; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+use Koha::Biblio::ItemGroups; >+use Koha::Template::Plugin::ItemGroups; >+ >+my $schema = Koha::Database->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+$schema->storage->txn_begin; >+ >+ok( my $settings = Koha::Template::Plugin::ItemGroups->new(), 'Able to instantiate template plugin' ); >+ >+subtest 'Item_Groups' => sub { >+ plan tests => 2; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item_group_count = Koha::Template::Plugin::ItemGroups->getCount( $biblio->id ); >+ >+ is( $item_group_count, 0, '0 items correctly counted in the item group' ); >+ >+ #Add some item groups to the bib >+ my $item_group_1 = >+ Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id, display_order => 2, description => "Vol 2" } ) >+ ->store(); >+ my $item_group_2 = >+ Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id, display_order => 3, description => "Vol 3" } ) >+ ->store(); >+ my $item_group_3 = >+ Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id, display_order => 1, description => "Vol 1" } ) >+ ->store(); >+ >+ $item_group_count = Koha::Template::Plugin::ItemGroups->getCount( $biblio->id ); >+ >+ is( $item_group_count, 3, '3 items correctly counted in the item group' ); >+}; >+ >+$schema->storage->txn_rollback; >-- >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 34234
:
158148
|
158294
|
158328
|
158329
|
160442
|
160542
|
160543
|
160992
|
161019
|
161760