1 # Copyright (C) 2006, 2008 Alex Schroeder <alex@emacswiki.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 2 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, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
21 use Test::More tests => 55;
24 add_module('links.pl');
26 update_page('InterMap',
27 " Oddmuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n",
30 update_page('a', 'Oddmuse:foo(no) [Oddmuse:bar] [Oddmuse:baz text] '
31 . '[Oddmuse:bar(no)] [Oddmuse:baz(no) text] '
32 . '[[Oddmuse:foo_(bar)]] [[[Oddmuse:foo (baz)]]] [[Oddmuse:foo (quux)|text]]');
36 my @Test = map { quotemeta } split('\n',<<'EOT');
40 "a" -> "Oddmuse:foo_(bar)"
41 "a" -> "Oddmuse:foo (baz)"
42 "a" -> "Oddmuse:foo (quux)"
45 test_page_negative(get_page('action=links raw=1'), @Test);
46 test_page(get_page('action=links raw=1 inter=1'), @Test);
48 @Test = split('\n',<<'EOT');
49 //a[@class="local"][@href="http://localhost/wiki.pl/a"][text()="a"]
50 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?foo"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="foo"]
51 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?bar"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="bar"]
52 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?baz"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="baz"]
53 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?foo_(bar)"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="foo_(bar)"]
56 negative_xpath_test(get_page('action=links'), @Test);
57 xpath_test(get_page('action=links inter=1'), @Test);
59 AppendStringToFile($ConfigFile, "\$BracketWiki = 0;\n");
61 update_page('a', '[[b]] [[[c]]] [[d|e]] FooBar [FooBaz] [FooQuux fnord] ');
62 $page = get_page('action=links raw=1');
64 test_page($page, split('\n',<<'EOT'));
72 test_page_negative($page, '"a" -> "d"');
74 AppendStringToFile($ConfigFile, "\$BracketWiki = 1;\n");
76 update_page('a', '[[b]] [[[c]]] [[d|e]] FooBar [FooBaz] [FooQuux fnord] '
77 . 'http://www.oddmuse.org/ [http://www.emacswiki.org/] '
78 . '[http://www.communitywiki.org/ cw]');
80 @Test1 = split('\n',<<'EOT');
89 @Test2 = split('\n',<<'EOT');
90 "a" -> "http://www.oddmuse.org/"
91 "a" -> "http://www.emacswiki.org/"
92 "a" -> "http://www.communitywiki.org/"
95 $page = get_page('action=links raw=1');
96 test_page($page, @Test1);
97 test_page_negative($page, @Test2);
98 $page = get_page('action=links raw=1 url=1');
99 test_page($page, @Test1, @Test2);
100 $page = get_page('action=links raw=1 links=0 url=1');
101 test_page_negative($page, @Test1);
102 test_page($page, @Test2);