wiki.pl: Port some fixes from upstream
[Orgmuse.git] / t / page-trail.t
blob9d10a5ecc7abcc933157b1fa697eefca7152485f
1 # Copyright (C) 2009  Alex Schroeder <alex@gnu.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 require 't/test.pl';
17 package OddMuse;
18 use Test::More tests => 9;
19 clear_pages();
21 add_module('page-trail.pl');
23 my $page = get_page('FirstPage');
25 xpath_test($page,
26            '//div[@class="header"]/span[@class="gotobar bar"]/following-sibling::span[@class="trail"]',
27           '//span[@class="trail"][contains(text(),"Trail: ")]/br',
28           '//span[@class="trail"]/a[@class="local"][@href="http://localhost/wiki.pl/FirstPage"][text()="FirstPage"]');
30 # verify cookie
31 test_page($page, 'Set-Cookie: Wiki=trail%251eFirstPage');
33 # fake cookie and grow trail
34 $page = get_page('action=browse id=SecondPage trail=FirstPage');
35 # verify HTML
36 xpath_test($page, '//span[@class="trail"]/a[text()="FirstPage"]/following-sibling::a[text()="SecondPage"]');
37 # verify cookie
38 test_page($page, 'Set-Cookie: Wiki=trail%251eSecondPage%20FirstPage');
40 # fake cookie and grow trail (unit separator US is x1f)
41 $page = get_page('action=browse id=ThirdPage trail=SecondPage%20FirstPage');
42 # verify HTML
43 xpath_test($page, '//span[@class="trail"]/a[text()="FirstPage"]/following-sibling::a[text()="SecondPage"]/following-sibling::a[text()="ThirdPage"]');
45 # verify cookie
46 test_page($page, 'Set-Cookie: Wiki=trail%251eThirdPage%20SecondPage%20FirstPage');
48 AppendStringToFile($ConfigFile, "\$PageTrailLength = 3;\n");
50 # verify truncation of the trail
51 $page = get_page('action=browse id=FourthPage trail=ThirdPage%20SecondPage%20FirstPage');
53 xpath_test($page, '//span[@class="trail"]/a[position()=1][text()="SecondPage"]/following-sibling::a[text()="ThirdPage"]/following-sibling::a[text()="FourthPage"]');