Bugzilla – Attachment 135707 Details for
Bug 30848
Introduce Koha::Filter::ExpandCodedFields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30848: Unit test
Bug-30848-Unit-test.patch (text/plain), 4.55 KB, created by
Martin Renvoize (ashimema)
on 2022-06-06 10:26:59 UTC
(
hide
)
Description:
Bug 30848: Unit test
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-06-06 10:26:59 UTC
Size:
4.55 KB
patch
obsolete
>From f4124b7005e09d1ca0a466fcabedd307da39a7f8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 26 May 2022 10:24:50 +0100 >Subject: [PATCH] Bug 30848: Unit test > >--- > .../Koha/Filter/ExpandAuthorizedValues.t | 100 ++++++++++++++++++ > 1 file changed, 100 insertions(+) > create mode 100644 t/db_dependent/Koha/Filter/ExpandAuthorizedValues.t > >diff --git a/t/db_dependent/Koha/Filter/ExpandAuthorizedValues.t b/t/db_dependent/Koha/Filter/ExpandAuthorizedValues.t >new file mode 100644 >index 0000000000..e2e6281dcc >--- /dev/null >+++ b/t/db_dependent/Koha/Filter/ExpandAuthorizedValues.t >@@ -0,0 +1,100 @@ >+#!/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 => 1; >+ >+use t::lib::TestBuilder; >+ >+use C4::Biblio qw( GetMarcSubfieldStructure ); >+ >+use Koha::Database; >+ >+use Koha::AuthorisedValueCategory; >+use Koha::Caches; >+ >+use Koha::RecordProcessor; >+ >+my $schema = Koha::Database->schema(); >+my $builder = t::lib::TestBuilder->new(); >+ >+subtest 'ExpandAuthorizedValues tests' => sub { >+ >+ plan tests => 10; >+ >+ $schema->storage->txn_begin(); >+ >+ # Add a biblio >+ my $biblio = $builder->build_sample_biblio; >+ my $record = $biblio->metadata->record; >+ $record->field('942')->update( n => 1 ); >+ $record->append_fields( >+ MARC::Field->new( '590', '', '', a => 'CODE' ), >+ ); >+ >+ Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store; >+ Koha::AuthorisedValue->new( >+ { >+ category => 'TEST', >+ authorised_value => 'CODE', >+ lib => 'Description should show', >+ lib_opac => 'Description should show OPAC' >+ } >+ )->store; >+ my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode }); >+ $mss->update({ authorised_value => "TEST" }); >+ >+ my $cache = Koha::Caches->get_instance; >+ $cache->clear_from_cache("MarcStructure-0-"); >+ $cache->clear_from_cache("MarcStructure-1-"); >+ $cache->clear_from_cache("default_value_for_mod_marc-"); >+ $cache->clear_from_cache("MarcSubfieldStructure-"); >+ >+ C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); >+ $biblio = Koha::Biblios->find( $biblio->biblionumber); >+ $record = $biblio->metadata->record; >+ >+ is( $record->field('590')->subfield('a'), 'CODE', 'Record prior to filtering contains AV Code' ); >+ is( $record->field('942')->subfield('n'), 1, 'Record suppression is numeric prior to filtering' ); >+ >+ my $processor = Koha::RecordProcessor->new( >+ { >+ schema => 'MARC', >+ filters => ['ExpandAuthorizedValues'], >+ } >+ ); >+ is( ref($processor), 'Koha::RecordProcessor', 'Created record processor with ExpandAuthorizedValues filter' ); >+ >+ my $result = $processor->process( $record ); >+ is( ref($result), 'MARC::Record', 'It returns a reference to a MARC::Record object' ); >+ is( $result->field('590')->subfield('a'), 'Description should show OPAC', 'Returned record contains AV OPAC description (interface defaults to opac)' ); >+ is( $record->field('590')->subfield('a'), 'Description should show OPAC', 'Original record now contains AV OPAC description (interface defaults to opac)' ); >+ is( $record->field('942')->subfield('n'), 1, 'Record suppression is still numeric after filtering' ); >+ >+ # reset record for next test >+ $record = $biblio->metadata->record; >+ is( $record->field('590')->subfield('a'), 'CODE', 'Record reset contains AV Code' ); >+ >+ # set interface >+ $processor->options({ interface => 'intranet' }); >+ $result = $processor->process( $record ); >+ is( $record->field('590')->subfield('a'), 'Description should show', 'Original record now contains AV description (interface set to intranet)' ); >+ is( $record->field('942')->subfield('n'), 1, 'Item suppression field remains numeric after filtering' ); >+ >+ $schema->storage->txn_rollback(); >+}; >-- >2.20.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 30848
:
135338
|
135353
|
135363
|
135364
|
135386
|
135387
|
135388
|
135418
|
135421
|
135422
|
135423
|
135424
|
135425
|
135707
|
135708
|
135709
|
135710
|
135711
|
135712
|
135713
|
135714
|
135715
|
135716
|
135717
|
135770
|
136025
|
136026
|
136027
|
136259
|
136260
|
136261
|
136262
|
136774
|
136775
|
136776
|
136777