From ed382847b817425ef913043656e3ad3519e17b23 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 | 26 +++++++++++++++++++- 2 files changed, 25 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 f53b6a5..85140d2 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use Test::MockModule; use MARC::Record; @@ -277,5 +277,29 @@ subtest 'NORMARC' => sub { $dbh->rollback; }; +subtest 'GetMarcSubfieldStructureFromKohaField' => sub { + plan tests => 23; + + 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; -- 1.9.1