Bugzilla – Attachment 154631 Details for
Bug 34266
Item type should not default to biblio itemtype if it's not a valid itemtype
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34266: Add unit tests
Bug-34266-Add-unit-tests.patch (text/plain), 3.44 KB, created by
Chris Cormack
on 2023-08-18 09:56:43 UTC
(
hide
)
Description:
Bug 34266: Add unit tests
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2023-08-18 09:56:43 UTC
Size:
3.44 KB
patch
obsolete
>From 2b10699d8c93b500ba19a1624f648fff9cfa9635 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 13 Jul 2023 10:58:42 +0200 >Subject: [PATCH] Bug 34266: Add unit tests > >Signed-off-by: joubu <xxx@example.org> >Signed-off-by: tuxayo <victor@tuxayo.net> > >Took the opportunity to perltidy this file as I was signing off > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > .../UI/Form/Builder/Item/itemtypes-default.t | 77 +++++++++++++++++++ > 1 file changed, 77 insertions(+) > create mode 100755 t/db_dependent/Koha/UI/Form/Builder/Item/itemtypes-default.t > >diff --git a/t/db_dependent/Koha/UI/Form/Builder/Item/itemtypes-default.t b/t/db_dependent/Koha/UI/Form/Builder/Item/itemtypes-default.t >new file mode 100755 >index 00000000000..6c05f9d0720 >--- /dev/null >+++ b/t/db_dependent/Koha/UI/Form/Builder/Item/itemtypes-default.t >@@ -0,0 +1,77 @@ >+#!/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 Koha::Database; >+use Koha::UI::Form::Builder::Item; >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin; >+ >+my $marc_subfield_structure_rs = $schema->resultset('MarcSubfieldStructure'); >+my $itemtag = C4::Context->preference('marcflavour') eq 'UNIMARC' ? '995' : '952'; >+my ($itype_subfield) = $marc_subfield_structure_rs->search( >+ { >+ frameworkcode => '', >+ authorised_value => 'itemtypes', >+ tagfield => $itemtag, >+ } >+); >+unless ($itype_subfield) { >+ $itype_subfield = $marc_subfield_structure_rs->create( >+ { >+ frameworkcode => '', >+ tagfield => $itemtag, >+ tagsubfield => 'Z', >+ authorised_value => 'itemtypes', >+ } >+ ); >+} >+ >+my $builder = t::lib::TestBuilder->new; >+ >+my $biblio = $builder->build_sample_biblio(); >+my $form_builder = Koha::UI::Form::Builder::Item->new( { biblionumber => $biblio->biblionumber } ); >+my $tagslib = { >+ $itemtag => { >+ $itype_subfield->tagsubfield => { $itype_subfield->get_columns, lib => $itype_subfield->liblibrarian }, >+ }, >+}; >+my $subfield_data = $form_builder->generate_subfield_form( >+ { >+ tag => $itemtag, >+ subfieldtag => $itype_subfield->tagsubfield, >+ tagslib => $tagslib, >+ } >+); >+ >+is( $subfield_data->{marc_value}->{default}, $biblio->itemtype, 'defaults to biblio itemtype if valid' ); >+ >+my $biblioitem = $biblio->biblioitem(); >+$biblioitem->itemtype('ZZZZZZ'); >+$biblioitem->store(); >+$subfield_data = $form_builder->generate_subfield_form( >+ { >+ tag => $itemtag, >+ subfieldtag => $itype_subfield->tagsubfield, >+ tagslib => $tagslib, >+ } >+); >+is( $subfield_data->{marc_value}->{default}, undef, 'defaults to nothing if biblio itemtype is not valid' ); >-- >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 34266
:
153389
|
153390
|
153393
|
154485
|
154486
|
154487
|
154488
|
154489
|
154490
|
154491
|
154492
|
154630
|
154631
|
155072
|
155073