From cbb90000fd21d16aa23077dd061d15954bd1955c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 12 Nov 2018 13:11:42 -0300 Subject: [PATCH] Bug 21749: Add tests for ImportFramework Signed-off-by: Tomas Cohen Arazi Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens --- t/db_dependent/ImportExportFramework.t | 34 +++++++++++++++++++ .../data/frameworks/biblio_framework.csv | 23 +++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 t/db_dependent/ImportExportFramework.t create mode 100644 t/db_dependent/data/frameworks/biblio_framework.csv diff --git a/t/db_dependent/ImportExportFramework.t b/t/db_dependent/ImportExportFramework.t new file mode 100644 index 0000000000..de096cc2a6 --- /dev/null +++ b/t/db_dependent/ImportExportFramework.t @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use Modern::Perl; +use Test::More tests => 3; +use File::Basename qw( dirname ); + +use Koha::Database; +use Koha::BiblioFrameworks; +use Koha::MarcSubfieldStructures; +use t::lib::TestBuilder; +use C4::ImportExportFramework; + +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; +my $builder = t::lib::TestBuilder->new; + +my $data_filepath = dirname(__FILE__) . '/data/biblio_framework.csv'; + +my $frameworkcode = '4T'; +C4::ImportExportFramework::ImportFramework($data_filepath, $frameworkcode); + +my $dbh = C4::Context->dbh; + +# FIXME Import does not create the biblio framework +#my $biblio_framework = Koha::BiblioFrameworks->find($frameworkcode); +#ok( $biblio_framework ); + +my $nb_tags = $dbh->selectrow_array(q|SELECT COUNT(*) FROM marc_tag_structure WHERE frameworkcode="4T"|); +is( $nb_tags, 4, "4 tags should have been imported" ); + +my $nb_subfields = + Koha::MarcSubfieldStructures->search( { frameworkcode => $frameworkcode } ) + ->count; +is( $nb_subfields, 12, "12 subfields should have been imported" ); diff --git a/t/db_dependent/data/frameworks/biblio_framework.csv b/t/db_dependent/data/frameworks/biblio_framework.csv new file mode 100644 index 0000000000..20ae097d32 --- /dev/null +++ b/t/db_dependent/data/frameworks/biblio_framework.csv @@ -0,0 +1,23 @@ +"tagfield","liblibrarian","libopac","repeatable","mandatory","authorised_value","frameworkcode" +"000","LEADER","LEADER","0","1","","" +"001","CONTROL NUMBER","CONTROL NUMBER","0","0","","" +"003","CONTROL NUMBER IDENTIFIER","CONTROL NUMBER IDENTIFIER","0","1","","" +"010","LIBRARY OF CONGRESS CONTROL NUMBER","LIBRARY OF CONGRESS CONTROL NUMBER","0","0","","" + +"#-#","#-#","#-#","#-#","#-#","#-#","#-#" + +"tagfield","tagsubfield","liblibrarian","libopac","repeatable","mandatory","kohafield","tab","authorised_value","authtypecode","value_builder","isurl","hidden","frameworkcode","seealso","link","defaultvalue","maxlength" +"000","@","fixed length control field","fixed length control field","0","1","","0","","","marc21_leader.pl","0","0","","","","","24" +"001","@","control field","control field","0","0","","0","","","","0","0","","","","","9999" +"003","@","control field","control field","0","1","","0","","","marc21_orgcode.pl","0","0","","","","","9999" +"005","@","control field","control field","0","1","","0","","","marc21_field_005.pl","0","0","","","","","9999" +"006","@","fixed length control field","fixed length control field","0","0","","0","","","marc21_field_006.pl","0","-1","","","","","9999" +"007","@","fixed length control field","fixed length control field","0","0","","0","","","marc21_field_007.pl","0","0","","","","","9999" +"008","@","fixed length control field","fixed length control field","0","1","","0","","","marc21_field_008.pl","0","0","","","","","40" +"009","@","fixed length control field","fixed length control field","0","0","","0","","","","0","-6","","","","","9999" +"010","8","Field link and sequence number","Field link and sequence number","1","0","","0","","","","0","-6","","","","","9999" +"010","a","LC control number","LC control number","0","0","biblioitems.lccn","0","","","","0","0","","","","","9999" +"010","b","NUCMC control number","NUCMC control number","1","0","","0","","","","0","-1","","","","","9999" +"010","z","Canceled/invalid LC control number","Canceled/invalid LC control number","1","0","","0","","","","0","-1","","","","","9999" + +"#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#","#-#" -- 2.39.5