Bugzilla – Attachment 42226 Details for
Bug 11247
Fix calls of TransformHtmlToXml
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11247: Improve tests
Bug-11247-Improve-tests.patch (text/plain), 4.20 KB, created by
Jonathan Druart
on 2015-09-02 14:07:56 UTC
(
hide
)
Description:
Bug 11247: Improve tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-09-02 14:07:56 UTC
Size:
4.20 KB
patch
obsolete
>From d14f17b0c766f5df963cba2ff794c259fab2d42d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 2 Sep 2015 15:07:07 +0100 >Subject: [PATCH] Bug 11247: Improve tests > >This patch makes the tests non dependent on the DB and test the 3 marc >flavours. >--- > t/Biblio/TransformHtmlToXml.t | 80 ++++++++++++++++++++++++++++++ > t/db_dependent/Biblio/TransformHtmlToXml.t | 25 ---------- > 2 files changed, 80 insertions(+), 25 deletions(-) > create mode 100644 t/Biblio/TransformHtmlToXml.t > delete mode 100644 t/db_dependent/Biblio/TransformHtmlToXml.t > >diff --git a/t/Biblio/TransformHtmlToXml.t b/t/Biblio/TransformHtmlToXml.t >new file mode 100644 >index 0000000..909fec3 >--- /dev/null >+++ b/t/Biblio/TransformHtmlToXml.t >@@ -0,0 +1,80 @@ >+#!/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 => 3; >+use t::lib::Mocks; >+ >+use XML::Simple; >+ >+use C4::Biblio qw/TransformHtmlToXml/; >+ >+ >+sub run_tests { >+ >+ my ($marc_flavour) = @_; >+ >+ t::lib::Mocks::mock_preference('marcflavour', $marc_flavour); >+ >+ my ( $tags, $subfields ); >+ if ( $marc_flavour eq 'UNIMARC' ) { >+ $tags= [ '001', '600', '200', '200' ]; >+ $subfields = [ '', 'a', 'a', 'c' ]; >+ } else { >+ $tags= [ '001', '100', '245', '245' ]; >+ $subfields = [ '', 'a', 'a', 'c' ]; >+ } >+ my $values = [ '12345', 'author', 'title', 'resp' ]; >+ my $ind = [ ' ', '00', ' 9', ' ' ]; >+ >+ my $xml = TransformHtmlToXml( $tags, $subfields, $values, $ind, undef, $marc_flavour ); >+ my $xmlh = XML::Simple->new->XMLin( $xml ); >+ >+ # check number of controlfields >+ is( ref $xmlh->{record}->{controlfield}, 'HASH', 'One controlfield' ); >+ # check datafields >+ my $cnt = @{$xmlh->{record}->{datafield}}; >+ if ( $marc_flavour eq 'UNIMARC' ) { >+ is( $cnt, 3, 'Three datafields' ); # 100$a is automatically created >+ } else { >+ is( $cnt, 2, 'Two datafields' ); >+ } >+ # check value of 245c >+ is( $xmlh->{record}->{datafield}->[1]->{subfield}->[1]->{content}, 'resp', 'Check value' ); >+ # check second indicator of 245 >+ is( $xmlh->{record}->{datafield}->[1]->{ind2}, '9', 'Check indicator' ); >+} >+ >+subtest "->TransformHtmlToXml (MARC21) tests" => sub { >+ >+ plan tests => 4; >+ run_tests('MARC21'); >+}; >+ >+subtest "->TransformHtmlToXml (UNIMARC) tests" => sub { >+ >+ plan tests => 4; >+ run_tests('UNIMARC'); >+}; >+ >+subtest "->TransformHtmlToXml (NORMARC) tests" => sub { >+ plan tests => 4; >+ run_tests('NORMARC'); >+}; >+ >+1; >diff --git a/t/db_dependent/Biblio/TransformHtmlToXml.t b/t/db_dependent/Biblio/TransformHtmlToXml.t >deleted file mode 100644 >index bbf8588..0000000 >--- a/t/db_dependent/Biblio/TransformHtmlToXml.t >+++ /dev/null >@@ -1,25 +0,0 @@ >-#!/usr/bin/perl >- >-use Modern::Perl; >-use Test::More tests => 4; >-use XML::Simple; >- >-use C4::Biblio qw/TransformHtmlToXml/; >- >-my $tags= [ '001', '100', '245', '245' ]; >-my $subfields = [ '', 'a', 'a', 'c' ]; >-my $values = [ '12345', 'author', 'title', 'resp' ]; >-my $ind = [ ' ', '00', ' 9', ' ' ]; >- >-my $xml = TransformHtmlToXml( $tags, $subfields, $values, $ind, undef, 'MARC21' ); >-my $xmlh = XML::Simple->new->XMLin( $xml ); >- >-# check number of controlfields >-is( ref $xmlh->{record}->{controlfield}, 'HASH', 'One controlfield' ); >-# check datafields >-my $cnt = @{$xmlh->{record}->{datafield}}; >-is( $cnt, 2, 'Two datafields' ); >-# check value of 245c >-is( $xmlh->{record}->{datafield}->[1]->{subfield}->[1]->{content}, 'resp', 'Check value' ); >-# check second indicator of 245 >-is( $xmlh->{record}->{datafield}->[1]->{ind2}, '9', 'Check indicator' ); >-- >2.1.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 11247
:
22923
|
22924
|
22953
|
41911
|
41971
|
41972
|
42088
|
42137
|
42138
| 42226