From d8fdf067ec1125922a6170f36cdc68a7af52ea15 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 26 Jan 2018 12:12:18 +0100 Subject: [PATCH] Bug 14769: Add unit tests for Koha::Authority::BiblioIndicators Content-Type: text/plain; charset=utf-8 --- t/db_dependent/Authority/BiblioIndicators.t | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 t/db_dependent/Authority/BiblioIndicators.t diff --git a/t/db_dependent/Authority/BiblioIndicators.t b/t/db_dependent/Authority/BiblioIndicators.t new file mode 100644 index 0000000..5a34da6 --- /dev/null +++ b/t/db_dependent/Authority/BiblioIndicators.t @@ -0,0 +1,46 @@ +#!/usr/bin/perl + +use Modern::Perl; +use Data::Dumper qw/Dumper/; +use MARC::Record; +use MARC::Field; +use Test::More tests => 1; + +use Koha::Authority::BiblioIndicators; +use Koha::Database; + +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; + +subtest "Trivial tests" => sub { + plan tests => 6; + + my $oInd = Koha::Authority::BiblioIndicators->new; + is_deeply( $oInd->get({}), {}, 'Empty hash for no parameters' ); + my $record = MARC::Record->new; + $record->append_fields( + MARC::Field->new( '100', '3', '3', a => 'My name' ), + ); + my $res = $oInd->get({ + flavour => "MARC21", + report_tag => '100', + auth_record => $record, + biblio_tag => '100', + }); + is( $res->{ind1}, '3', 'Check first indicator' ); + is( exists $res->{ind2}, 1, 'Check existence of indicator2 key' ); + is( $res->{ind2}, undef, 'Check second indicator value' ); + + $res = $oInd->get({ + flavour => "MARC21", + report_tag => '100', + auth_record => $record, + biblio_tag => '700', + }); + is( $res->{ind1}, '3', 'Check first indicator' ); + is( exists $res->{ind2}, '', 'Check if indicator2 key does not exist' ); + + $oInd->clear; +}; + +$schema->storage->txn_rollback; -- 2.1.4