1 # Copyright (C) 2012–2013 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 => 20;
18 use utf8; # tests contain UTF-8 characters and it matters
21 add_module('fix-encoding.pl');
23 # make sure no menu shows if no page is provided
25 test_page_negative(get_page('action=admin'), 'action=fix-encoding');
27 # make sure no menu shows up if the page does not exists
29 test_page(get_page('action=admin id=foo'),
30 'action=fix-encoding;id=foo',
31 'action=fix-escaping;id=foo');
33 # make sure nothing is saved if the page does not exist
35 test_page(get_page('action=fix-encoding id=Example'),
36 'Location: http://localhost/wiki.pl/Example');
38 test_page(get_page('action=fix-escaping id=Example'),
39 'Location: http://localhost/wiki.pl/Example');
41 test_page_negative(get_page('action=rc all=1 showedit=1'), 'fix');
43 # make sure nothing is saved if there is no change
45 test_page(update_page('Example', 'Pilgerstätte für die Göttin'),
46 'Pilgerstätte für die Göttin');
48 test_page(get_page('action=fix-encoding id=Example'),
49 'Location: http://localhost/wiki.pl/Example');
51 test_page(get_page('action=fix-escaping id=Example'),
52 'Location: http://localhost/wiki.pl/Example');
54 test_page_negative(get_page('action=rc all=1 showedit=1'),
55 'Fix Character encoding');
57 # the menu shows up if the page exists
59 test_page(get_page('action=admin id=Example'),
60 'action=fix-encoding;id=Example',
61 'action=fix-escaping;id=Example');
63 # here is an actual page with a character encoding error you need to fix
65 test_page(update_page('Example', 'Pilgerstätte für die Göttin',
67 'Pilgerstätte für die Göttin');
69 test_page(get_page('action=fix-encoding id=Example'),
70 'Location: http://localhost/wiki.pl/Example');
72 test_page(get_page('Example'),
73 'Pilgerstätte für die Göttin');
75 test_page(get_page('action=rc showedit=1'),
76 'Fix character encoding');
78 # here is an actual page with an HTML escaping error you need to fix
80 test_page(update_page('Example', '&lt;b&gt;bold&lt;/b&gt;',
82 '&lt;b&gt;bold&lt;/b&gt;');
84 test_page(get_page('action=fix-escaping id=Example'),
85 'Location: http://localhost/wiki.pl/Example');
87 test_page(get_page('Example'),
88 '<b>bold</b>');
90 test_page(get_page('action=rc showedit=1'),