1 # Copyright (C) 2012 Alex Schroeder <alex@gnu.org>
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
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.
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/>.
17 use Test::More tests => 41;
18 use utf8; # tests contain UTF-8 characters and it matters
24 $page = update_page('Aal', 'aal');
25 test_page($page, '<h1><a .*>Aal</a></h1>', '<p>aal</p>');
26 xpath_test($page, '//h1/a[text()="Aal"]', '//p[text()="aal"]');
28 $page = get_page('Aal');
29 test_page($page, '<h1><a .*>Aal</a></h1>', '<p>aal</p>');
30 xpath_test($page, '//h1/a[text()="Aal"]', '//p[text()="aal"]');
34 $page = update_page('Öl', 'öl');
35 test_page($page, '<h1><a .*>Öl</a></h1>', '<p>öl</p>');
36 xpath_test($page, '//h1/a[text()="Öl"]', '//p[text()="öl"]');
38 $page = get_page('Öl');
39 test_page($page, '<h1><a .*>Öl</a></h1>', '<p>öl</p>');
40 xpath_test($page, '//h1/a[text()="Öl"]', '//p[text()="öl"]');
42 $page = get_page('action=index raw=1');
43 test_page($page, 'Aal', 'Öl');
45 test_page(get_page('Aal'), 'aal');
46 test_page(get_page('Öl'), 'öl');
50 test_page(get_page('action=rc raw=1'),
51 'title: Öl', 'description: öl');
55 update_page('Öl', 'Ähren');
56 xpath_test(get_page('action=browse id=Öl diff=1'),
57 '//div[@class="old"]/p/strong[@class="changes"][text()="öl"]',
58 '//div[@class="new"]/p/strong[@class="changes"][text()="Ähren"]');
62 # testing with non-ASCII is important on a Mac
65 $page = get_page('search=aal raw=1');
66 test_page($page, 'title: Search for: aal', 'title: Aal');
68 # matching page name does not involve grep working
69 $page = get_page('search=öl raw=1');
70 test_page($page, 'title: Search for: öl', 'title: Öl');
72 # this fails with grep on a Mac, thus testing if mac.pl
73 # managed to switch of the use of grep
74 test_page(get_page('search=ähren raw=1'),
75 'title: Search for: ähren', 'title: Öl');
77 # the username keeps getting reported as changed
78 test_page(get_page('action=browse id=Möglich username=Schr%C3%B6der'),
79 'Set-Cookie: Wiki=username%251eSchr%C3%B6der',
82 # verify that non-ASCII parameters work as intended
83 AppendStringToFile($ConfigFile, "use utf8;\n\$CookieParameters{ärger} = 1;\n");
84 test_page(get_page('action=browse id=Test %C3%A4rger=hallo'),
85 'Set-Cookie: Wiki=%C3%A4rger%251ehallo');
87 # create a test page to test the output in various ways
88 test_page(update_page("Russian", "Русский Hello"),
91 # checking for errors in the rss feed
92 test_page(get_page("action=rss match=Russian full=1"),
95 # with toc.pl, however, a problem: Русский is corrupted
97 test_page(update_page("Russian", "Русский Hello again"),
100 # and with inclusion, too:
101 test_page(update_page("All", qq{<include "Russian">}),
104 # and checking the cache
105 test_page(get_page("All"), "Русский");
107 # and checking without the cache
108 test_page(get_page("action=browse id=All cache=0"), "Русский");
111 test_page(get_page('search=Русский raw=1'),
114 # testing page editing
115 test_page(update_page("Русский", "друзья"),