encoding.t 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # Copyright (C) 2012 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation; either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. require './t/test.pl';
  15. package OddMuse;
  16. use Test::More tests => 41;
  17. use utf8; # tests contain UTF-8 characters and it matters
  18. # ASCII basics
  19. $page = update_page('Aal', 'aal');
  20. test_page($page, '<h1><a .*>Aal</a></h1>', '<p>aal</p>');
  21. xpath_test($page, '//h1/a[text()="Aal"]', '//p[text()="aal"]');
  22. $page = get_page('Aal');
  23. test_page($page, '<h1><a .*>Aal</a></h1>', '<p>aal</p>');
  24. xpath_test($page, '//h1/a[text()="Aal"]', '//p[text()="aal"]');
  25. # non-ASCII
  26. $page = update_page('Öl', 'öl');
  27. test_page($page, '<h1><a .*>Öl</a></h1>', '<p>öl</p>');
  28. xpath_test($page, '//h1/a[text()="Öl"]', '//p[text()="öl"]');
  29. $page = get_page('Öl');
  30. test_page($page, '<h1><a .*>Öl</a></h1>', '<p>öl</p>');
  31. xpath_test($page, '//h1/a[text()="Öl"]', '//p[text()="öl"]');
  32. $page = get_page('action=index raw=1');
  33. test_page($page, 'Aal', 'Öl');
  34. test_page(get_page('Aal'), 'aal');
  35. test_page(get_page('Öl'), 'öl');
  36. # rc
  37. test_page(get_page('action=rc raw=1'),
  38. 'title: Öl', 'description: öl');
  39. # diff
  40. update_page('Öl', 'Ähren');
  41. xpath_test(get_page('action=browse id=Öl diff=1'),
  42. '//div[@class="old"]/p/strong[@class="changes"][text()="öl"]',
  43. '//div[@class="new"]/p/strong[@class="changes"][text()="Ähren"]');
  44. # search
  45. # testing with non-ASCII is important on a Mac
  46. # ASCII
  47. $page = get_page('search=aal raw=1');
  48. test_page($page, 'title: Search for: aal', 'title: Aal');
  49. # matching page name does not involve grep working
  50. $page = get_page('search=öl raw=1');
  51. test_page($page, 'title: Search for: öl', 'title: Öl');
  52. # this fails with grep on a Mac, thus testing if mac.pl
  53. # managed to switch of the use of grep
  54. test_page(get_page('search=ähren raw=1'),
  55. 'title: Search for: ähren', 'title: Öl');
  56. # the username is decoded correctly in the footer
  57. test_page(update_page('Möglich', 'Egal', 'Zusammenfassung', '', '',
  58. 'username=Schr%C3%B6der'),
  59. 'Schröder');
  60. test_page($redirect, 'Set-Cookie: Wiki=\S*username%251eSchr%C3%B6der');
  61. # verify that non-ASCII parameters work as intended
  62. AppendStringToFile($ConfigFile, "use utf8;\n\$CookieParameters{ärger} = 1;\n");
  63. test_page(get_page('action=browse id=Test %C3%A4rger=hallo'),
  64. 'Set-Cookie: Wiki=%C3%A4rger%251ehallo');
  65. # create a test page to test the output in various ways
  66. test_page(update_page("Russian", "Русский Hello"),
  67. "Русский");
  68. # checking for errors in the rss feed
  69. test_page(get_page("action=rss match=Russian full=1"),
  70. "Русский");
  71. # with toc.pl, however, a problem: Русский is corrupted
  72. add_module('toc.pl');
  73. test_page(update_page("Russian", "Русский Hello again"),
  74. "Русский");
  75. # and with inclusion, too:
  76. test_page(update_page("All", qq{<include "Russian">}),
  77. "Русский");
  78. # and checking the cache
  79. test_page(get_page("All"), "Русский");
  80. # and checking without the cache
  81. test_page(get_page("action=browse id=All cache=0"), "Русский");
  82. # testing search
  83. test_page(get_page('search=Русский raw=1'),
  84. qw(Russian));
  85. # testing page editing
  86. test_page(update_page("Русский", "друзья"),
  87. "друзья");