From 1f3c1632769d77eb1e72273929a281153a642979 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 22 Mar 2013 12:05:54 +0000 Subject: [PATCH] Bug 7683 [Follow-up] Move unit tests in t/db_dependent/Biblio.t --- t/Biblio_GetMarcSubfieldStructureFromKohaField.t | 30 ---------------------- t/db_dependent/Biblio.t | 24 ++++++++++++++++- 2 files changed, 23 insertions(+), 31 deletions(-) delete mode 100755 t/Biblio_GetMarcSubfieldStructureFromKohaField.t diff --git a/t/Biblio_GetMarcSubfieldStructureFromKohaField.t b/t/Biblio_GetMarcSubfieldStructureFromKohaField.t deleted file mode 100755 index 106147f..0000000 --- a/t/Biblio_GetMarcSubfieldStructureFromKohaField.t +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/perl - -use Modern::Perl; -use Test::More tests => 24; -use Data::Dumper; - -BEGIN { - use_ok('C4::Biblio'); -} - -my @columns = qw( - tagfield tagsubfield liblibrarian libopac repeatable mandatory kohafield tab - authorised_value authtypecode value_builder isurl hidden frameworkcode - seealso link defaultvalue maxlength -); - -# biblio.biblionumber must be mapped so this should return something -my $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('biblio.biblionumber', ''); - -ok(defined $marc_subfield_structure, "There is a result"); -is(ref $marc_subfield_structure, "HASH", "Result is a hashref"); -foreach my $col (@columns) { - ok(exists $marc_subfield_structure->{$col}, "Hashref contains key '$col'"); -} -is($marc_subfield_structure->{kohafield}, 'biblio.biblionumber', "Result is the good result"); -like($marc_subfield_structure->{tagfield}, qr/^\d{3}$/, "tagfield is a valid tagfield"); - -# foo.bar does not exist so this should return undef -$marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('foo.bar', ''); -is($marc_subfield_structure, undef, "invalid kohafield returns undef"); diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 4725e53..bee3a2d 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 40; use MARC::Record; use C4::Biblio; @@ -111,3 +111,25 @@ is( $controlnumber, '123456789X', 'GetMarcControlnumber handles records with 001 # clean up after ourselves DelBiblio($biblionumber); + +# Testing GetMarcSubfieldStructureFromKohaField +my @columns = qw( + tagfield tagsubfield liblibrarian libopac repeatable mandatory kohafield tab + authorised_value authtypecode value_builder isurl hidden frameworkcode + seealso link defaultvalue maxlength +); + +# biblio.biblionumber must be mapped so this should return something +my $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('biblio.biblionumber', ''); + +ok(defined $marc_subfield_structure, "There is a result"); +is(ref $marc_subfield_structure, "HASH", "Result is a hashref"); +foreach my $col (@columns) { + ok(exists $marc_subfield_structure->{$col}, "Hashref contains key '$col'"); +} +is($marc_subfield_structure->{kohafield}, 'biblio.biblionumber', "Result is the good result"); +like($marc_subfield_structure->{tagfield}, qr/^\d{3}$/, "tagfield is a valid tagfield"); + +# foo.bar does not exist so this should return undef +$marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('foo.bar', ''); +is($marc_subfield_structure, undef, "invalid kohafield returns undef"); -- 1.7.10.4