Bug 25067: Adjust paths in tests
[koha.git] / t / db_dependent / misc / translator / xgettext-tt2.t
blob0c18473ebb5a46ea0a318a5e9bd87fbd017ceb72
1 #!/usr/bin/perl
3 use Modern::Perl;
5 use File::Slurp;
6 use File::Temp qw(tempdir);
7 use FindBin qw($Bin);
8 use Locale::PO;
9 use Test::More tests => 36;
11 my $tempdir = tempdir(CLEANUP => 1);
13 write_file("$tempdir/files", "$Bin/sample.tt");
15 my $xgettext_cmd = "$Bin/../../../../misc/translator/xgettext-tt2 --from-code=UTF-8 "
16 . "-o $tempdir/Koha.pot -f $tempdir/files";
18 system($xgettext_cmd);
19 my $pot = Locale::PO->load_file_asarray("$tempdir/Koha.pot");
21 my @expected = (
23 msgid => '"hello ツ"',
26 msgid => '"hello {name}"',
29 msgid => '"item"',
30 msgid_plural => '"items"',
33 msgid => '"{count} item"',
34 msgid_plural => '"{count} items"',
37 msgid => '"hello"',
38 msgctxt => '"context"',
41 msgid => '"hello {name}"',
42 msgctxt => '"context"',
45 msgid => '"item"',
46 msgid_plural => '"items"',
47 msgctxt => '"context"',
50 msgid => '"{count} item"',
51 msgid_plural => '"{count} items"',
52 msgctxt => '"context"',
55 msgid => '"status is {status}"',
58 msgid => '"active"',
61 msgid => '"inactive"',
64 msgid => '"Inside block"',
68 for (my $i = 0; $i < @expected; $i++) {
69 for my $key (qw(msgid msgid_plural msgctxt)) {
70 my $expected = $expected[$i]->{$key};
71 my $expected_str = defined $expected ? $expected : 'not defined';
72 is($pot->[$i + 1]->$key, $expected, "$i: $key is $expected_str");