Bugzilla – Attachment 154492 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.22 KB, created by
Biblibre Sandboxes
on 2023-08-17 08:04:26 UTC
(
hide
)
Description:
Bug 34266: Add unit tests
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2023-08-17 08:04:26 UTC
Size:
3.22 KB
patch
obsolete
>From f8aff2671b3d399cb1701df248c832bb3cd69de3 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> >--- > .../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 0000000000..37f36bb3da >--- /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