4 use Data::Dumper qw/Dumper/;
7 use Test::More tests => 1;
10 use Koha::Authority::ControlledIndicators;
12 subtest "Simple tests" => sub {
15 t::lib::Mocks::mock_preference('AuthorityControlledIndicators', q|
16 marc21,600,ind1:auth1,ind2:x
17 marc21,700,ind1:auth2,
21 my $oInd = Koha::Authority::ControlledIndicators->new;
23 is_deeply( $oInd->get({}), {}, 'Empty hash for no parameters' );
24 my $record = MARC::Record->new;
25 $record->append_fields(
26 MARC::Field->new( '100', '3', '4', a => 'My name' ),
28 my $res = $oInd->get({
31 auth_record => $record,
34 is( $res->{ind1}, '3', 'Check 1st indicator' );
35 is( exists $res->{ind2}, 1, 'Check existence of 2nd indicator key' );
36 is( $res->{ind2}, 'x', 'Check 2nd indicator value' );
41 auth_record => $record,
44 is( $res->{ind1}, '4', 'Check 1st indicator' );
45 is( exists $res->{ind2}, '', 'Check if 2nd indicator key does not exist' );
50 auth_record => $record,
53 is( $res->{ind1}, '', 'ind1: clears 1st indicator' );
54 is( exists $res->{ind2}, '', 'Check if 2nd indicator key does not exist' );
57 t::lib::Mocks::mock_preference('AuthorityControlledIndicators', q{} );
61 auth_record => $record,
64 is( $res->{ind1}, '4', 'Cache not cleared yet' );
69 auth_record => $record,
72 is_deeply( $res, {}, 'Cache cleared' );