Bugzilla – Attachment 94096 Details for
Bug 23793
Add an EmbedItems RecordProcessor filter for MARC::Record objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23793: Unit tests
Bug-23793-Unit-tests.patch (text/plain), 2.93 KB, created by
Tomás Cohen Arazi
on 2019-10-14 12:12:23 UTC
(
hide
)
Description:
Bug 23793: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2019-10-14 12:12:23 UTC
Size:
2.93 KB
patch
obsolete
>From 0fb0bdc53aef6cafd9e03fb749b99ca06c29b476 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 14 Oct 2019 09:05:46 -0300 >Subject: [PATCH] Bug 23793: Unit tests > >This patch introduces full test coverage for the EmbedItems filter. > >To test: >1. Apply this patchset >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Filter/EmbedItems.t >=> SUCCESS: Tests pass! >3. Sign off :-D >4. Use it to improve Koha! >--- > t/db_dependent/Koha/Filter/EmbedItems.t | 73 +++++++++++++++++++++++++ > 1 file changed, 73 insertions(+) > create mode 100755 t/db_dependent/Koha/Filter/EmbedItems.t > >diff --git a/t/db_dependent/Koha/Filter/EmbedItems.t b/t/db_dependent/Koha/Filter/EmbedItems.t >new file mode 100755 >index 0000000000..21ec1ef724 >--- /dev/null >+++ b/t/db_dependent/Koha/Filter/EmbedItems.t >@@ -0,0 +1,73 @@ >+#!/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; >+ >+use Koha::Database; >+use Koha::RecordProcessor; >+ >+my $schema = Koha::Database->schema(); >+my $builder = t::lib::TestBuilder->new(); >+ >+subtest 'EmbedItems tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin(); >+ >+ # Add a biblio >+ my $biblio = $builder->build_sample_biblio; >+ foreach ( 1 .. 10 ) { >+ $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); >+ } >+ >+ my $mss = C4::Biblio::GetMarcSubfieldStructure( '', { unsafe => 0 } ); >+ my $item_tag = $mss->{'items.itemnumber'}[0]->{tagfield}; >+ >+ $biblio->discard_changes; >+ my $record = $biblio->metadata->record; >+ my @items = $biblio->items->as_list; >+ >+ my $processor = Koha::RecordProcessor->new( >+ { >+ schema => 'MARC', >+ filters => ('EmbedItems'), >+ options => { >+ items => \@items >+ } >+ } >+ ); >+ is( ref($processor), 'Koha::RecordProcessor', 'Created record processor' ); >+ >+ my $result = $processor->process( $record ); >+ is( ref($result), 'MARC::Record', 'It returns a reference to a MARC::Record object' ); >+ >+ my @item_fields = $record->field($item_tag); >+ >+ is( scalar @item_fields, 10, 'One field for each item has been added' ); >+ >+ is( $processor->process(), undef, 'undef returned if no record passed' ); >+ >+ $schema->storage->txn_rollback(); >+}; >+ >-- >2.23.0
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 23793
:
93971
|
93980
|
94030
|
94095
|
94096
|
94599
|
94600
|
94602
|
94603