load-lang.t 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright (C) 2015 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
  2. # Copyright (C) 2016 Alex Schroeder <alex@gnu.org>
  3. #
  4. # This program is free software: you can redistribute it and/or modify it under
  5. # the terms of the GNU General Public License as published by the Free Software
  6. # Foundation, either version 3 of the License, or (at your option) any later
  7. # version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but WITHOUT
  10. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License along with
  14. # this program. If not, see <http://www.gnu.org/licenses/>.
  15. require 't/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 6;
  18. use File::Basename;
  19. add_module('load-lang.pl');
  20. require("$ModuleDir/load-lang.pl");
  21. my %choosable_translations = reverse %TranslationsLibrary;
  22. my @missing = (); # missing in load-lang.pl
  23. my $count = 0;
  24. foreach (bsd_glob("modules/translations/*.p[ml]")) {
  25. my $filename = fileparse($_);
  26. $count++;
  27. next if exists $choosable_translations{$filename};
  28. next if $filename eq 'new-utf8.pl'; # placeholder
  29. next if $filename =~ /^month-names/; # month names are located in translations/ for whatever reason
  30. next if $filename =~ /^national-days/; # national days are located in translations/ for whatever reason
  31. push @missing, $_;
  32. }
  33. unless (ok(@missing == 0, 'All translations are listed')) {
  34. diag("$_ is not listed in load-lang.pl") for @missing;
  35. }
  36. unless (ok($count > 0, "$count translations were found")) {
  37. diag("if 0 then the \$LoadLanguageDir was not set correctly");
  38. }
  39. test_page(get_page('Test'), 'Edit this page');
  40. CreateDir($LoadLanguageDir);
  41. WriteStringToFile("$LoadLanguageDir/german-utf8.pl", ReadFileOrDie("modules/translations/german-utf8.pl"));
  42. # AppendStringToFile("$LoadLanguageDir/german-utf8.pl", "warn 'reading german-utf8.pl';\n");
  43. $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'de-ch,de;q=0.7,en;q=0.3';
  44. test_page(get_page('action=version'), 'load-lang.pl');
  45. my $page = get_page('Test');
  46. test_page($page, 'Diese Seite bearbeiten');
  47. test_page_negative($page, 'Edit this page');