View | Details | Raw Unified | Return to bug 32478
Collapse All | Expand All

(-)a/C4/Context.pm (+2 lines)
Lines 348-353 sub yaml_preference { Link Here
348
        return;
348
        return;
349
    }
349
    }
350
350
351
    # TODO Remove next line when enforced elsewhere
352
    if( $yaml && lc($preference) eq 'itemsdeniedrenewal' and ref($yaml) ne 'HASH' ) { warn "Hashref expected for $preference"; return; }
351
    return $yaml;
353
    return $yaml;
352
}
354
}
353
355
(-)a/t/Context.t (-2 / +7 lines)
Lines 31-37 BEGIN { Link Here
31
31
32
subtest 'yaml_preference() tests' => sub {
32
subtest 'yaml_preference() tests' => sub {
33
33
34
    plan tests => 3;
34
    plan tests => 6;
35
35
36
    my $data = [ 'uno', 'dos', { 'tres' => 'cuatro' } ];
36
    my $data = [ 'uno', 'dos', { 'tres' => 'cuatro' } ];
37
37
Lines 49-54 subtest 'yaml_preference() tests' => sub { Link Here
49
        'Invalid YAML on syspref throws a warning';
49
        'Invalid YAML on syspref throws a warning';
50
    is( $pref, undef, 'Invalid YAML on syspref makes it return undef' );
50
    is( $pref, undef, 'Invalid YAML on syspref makes it return undef' );
51
51
52
    $context->mock( 'preference', sub { return '{ a : 1 }' });
53
    is( ref( C4::Context->new->yaml_preference('ItemsDeniedRenewal') ), 'HASH', 'Got a hash as expected' );
54
    $context->mock( 'preference', sub { return '[ 1, 2 ]' });
55
    warning_like { $pref = C4::Context->new->yaml_preference('ITEMSDENIEDRENEWAL') } qr/Hashref expected/, 'Array not accepted for ItemsDeniedRenewal';
56
    is( $pref, undef, 'Returned undef' );
57
52
    $context->unmock( 'preference' );
58
    $context->unmock( 'preference' );
53
};
59
};
54
60
55
- 

Return to bug 32478