From 7346b44bec34f2ba0e6c79017c9e5ace1b466f67 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 19 Mar 2013 11:00:57 +0000 Subject: [PATCH] Bug 7683: Add unit tests for GetMarcSubfieldStructureFromKohaField Content-Type: text/plain; charset="utf-8" Signed-off-by: Owen Leonard --- t/Biblio_GetMarcSubfieldStructureFromKohaField.t | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 t/Biblio_GetMarcSubfieldStructureFromKohaField.t diff --git a/t/Biblio_GetMarcSubfieldStructureFromKohaField.t b/t/Biblio_GetMarcSubfieldStructureFromKohaField.t new file mode 100755 index 0000000..106147f --- /dev/null +++ b/t/Biblio_GetMarcSubfieldStructureFromKohaField.t @@ -0,0 +1,30 @@ +#!/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"); -- 1.7.9.5