Merge remote-tracking branch 'origin/new/bug_7284'
[koha.git] / t / Boolean.t
1
2 use strict;
3 use warnings;
4
5 use Test::More tests => 13;
6
7 BEGIN { use_ok( 'C4::Boolean', qw( true_p ) ); }
8
9 is( true_p('0'),     '0', 'recognizes \'0\' as false' );
10 is( true_p('false'), '0', 'recognizes \'false\' as false' );
11 is( true_p('off'),   '0', 'recognizes \'off\' as false' );
12 is( true_p('no'),    '0', 'recognizes \'no\' as false' );
13
14 is( true_p('1'),    '1', 'recognizes \'1\' as true' );
15 is( true_p('true'), '1', 'recognizes \'true\' as true' );
16 is( true_p('on'),   '1', 'recognizes \'on\' as true' );
17 is( true_p('yes'),  '1', 'recognizes \'yes\' as true' );
18 is( true_p('YES'),  '1', 'verified case insensitivity' );
19
20 is( true_p(undef), undef, 'recognizes undefined as not boolean' );
21 is( true_p('foo'), undef, 'recognizes \'foo\' as not boolean' );
22 is( true_p([]), undef, 'recognizes a reference as not a boolean' );