Bug 22824: Replace YAML::Syck with YAML::XS in tests
[koha-ffzg.git] / t / db_dependent / yaml.t
1 use Modern::Perl;
2 use Test::More;
3
4 use YAML::XS;
5 use Template;
6 use utf8;
7
8 my $template = Template->new( ENCODING => 'UTF-8' );
9
10 my $vars;
11 my $output;
12 $template->process( 't/db_dependent/data/syspref.pref', $vars, \$output );
13
14 my $yaml = YAML::XS::Load( $output );
15 my $syspref_1 = $yaml->{Test}->{Testing}->[0];
16 my $syspref_2 = $yaml->{Test}->{Testing}->[1];
17 my $syspref_3 = $yaml->{Test}->{Testing}->[2];
18 my $syspref_4 = $yaml->{Test}->{Testing}->[3];
19 is_deeply(
20     $syspref_1,
21     [
22         "Do it",
23         {
24             choices => {
25                 1  => "certainly",
26                 '' => "I don't think so"
27             },
28             pref => "syspref_1"
29         }
30     ]
31 );
32 is_deeply(
33     $syspref_2,
34     [
35         {
36             choices => {
37                 0    => "really don't do",
38                 ''   => "Do",
39                 dont => "Don't do"
40             },
41             pref => "syspref_2"
42         },
43         "it."
44     ]
45 );
46 is_deeply(
47     $syspref_3,
48     [
49         "We love unicode",
50         {
51             choices => {
52                 ''    => "Not really",
53                 '★' => "❤️"
54             },
55             pref => "syspref_3"
56         }
57     ],
58 );
59 is_deeply(
60     $syspref_4,
61     [
62         "List of fields",
63         {
64             choices => {
65                 16    => 16,
66                 "020" => "020",
67                 123   => 123
68             },
69             pref => "syspref_4"
70         }
71     ]
72 );
73 done_testing;