1 # Copyright (C) 2006, 2007, 2008 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/>.
18 use Test::More tests => 61;
24 update_page('HomePage', "This page exists.");
25 update_page('InterMap', " Oddmuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n PlanetMath http://planetmath.org/encyclopedia/%s.html", 'required', 0, 1);
27 $BracketWiki = 0; # old default
30 xpath_run_tests(split('\n',<<'EOT'));
32 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=1"][text()="?"]
36 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=0a"][text()="?"]
37 file://home/foo/tutorial.pdf
38 //a[@class="url file"][@href="file://home/foo/tutorial.pdf"][text()="file://home/foo/tutorial.pdf"]
39 file:///home/foo/tutorial.pdf
40 //a[@class="url file"][@href="file:///home/foo/tutorial.pdf"][text()="file:///home/foo/tutorial.pdf"]
41 image inline: [[image:HomePage]]
42 //a[@class="image"][@href="http://localhost/test.pl/HomePage"]/img[@class="upload"][@src="http://localhost/test.pl/download/HomePage"][@alt="HomePage"]
43 image inline: [[image:OtherPage]]
44 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage;upload=1"][text()="?"]
45 traditional local link: HomePage
46 //a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="HomePage"]
47 traditional local link: OtherPage
48 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
49 traditional local link with extra brackets: [HomePage]
50 //a[@class="local number"][@title="HomePage"][@href="http://localhost/test.pl/HomePage"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
51 traditional local link with extra brackets: [OtherPage]
52 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
53 traditional local link with other text: [HomePage homepage]
54 //a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="HomePage"]
55 traditional local link with other text: [OtherPage other page]
56 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
57 free link: [[home page]]
58 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
59 free link: [[other page]]
60 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
61 free link with extra brackets: [[[home page]]]
62 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
63 free link with extra brackets: [[[other page]]]
64 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
65 free link with other text: [[home page|da homepage]]
66 //text()[string()="free link with other text: [[home page|da homepage]]"]
67 free link with other text: [[other page|da other homepage]]
68 //text()[string()="free link with other text: [[other page|da other homepage]]"]
69 URL: http://www.oddmuse.org/
70 //a[@class="url http"][@href="http://www.oddmuse.org/"][text()="http://www.oddmuse.org/"]
71 URL with text: [http://www.oddmuse.org/ name]
72 //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="name"]
73 zero is text: [http://www.oddmuse.org/ 0]
74 //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="0"]
75 URL in text http://www.oddmuse.org/ like this
76 //text()[string()="URL in text "]/following-sibling::a[@class="url http"][@href="http://www.oddmuse.org/"][text()="http://www.oddmuse.org/"]/following-sibling::text()[string()=" like this"]
77 URL in brackets: [http://www.oddmuse.org/]
78 //a[@class="url http number"][@href="http://www.oddmuse.org/"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
79 URL in brackets with other text: [http://www.oddmuse.org/ oddmuse]
80 //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
81 URL in brackets with other text: [[http://www.oddmuse.org/ oddmuse]]
82 //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
83 URL in brackets with other text: [http://www.oddmuse.org/|oddmuse]
84 //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
85 URL in brackets with other text: [[http://www.oddmuse.org/|oddmuse]]
86 //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
87 URL abbreviation: Oddmuse:Link_Pattern
88 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="Link_Pattern"]
89 URL abbreviation with extra brackets: [Oddmuse:Link_Pattern]
90 //a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
91 URL abbreviation with other text: [Oddmuse:Link_Pattern link patterns]
92 //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"][text()="link patterns"]
93 URL abbreviation with meta characters: Oddmuse:Link+Pattern
94 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link+Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="Link+Pattern"]
95 URL abbreviation with meta characters and extra brackets: [Oddmuse:Link+Pattern]
96 //a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link+Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
97 URL abbreviation with meta characters and other text: [Oddmuse:Link+Pattern link patterns]
98 //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link+Pattern"][text()="link patterns"]
99 free URL abbreviation: [[Oddmuse:Link Pattern]]
100 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="Link Pattern"]
101 free URL abbreviation with extra brackets: [[[Oddmuse:Link Pattern]]]
102 //a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
103 free URL abbreviation with other text: [[Oddmuse:Link Pattern|link patterns]]
104 //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"][text()="link patterns"]
105 free URL abbreviation with meta characters: [[Oddmuse:Link+Pattern]]
106 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%2bPattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="Link+Pattern"]
107 free URL abbreviation with meta characters and extra brackets: [[[Oddmuse:Link+Pattern]]]
108 //a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%2bPattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
109 free URL abbreviation with meta characters and other text: [[Oddmuse:Link+Pattern|link patterns]]
110 //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%2bPattern"][text()="link patterns"]
113 $AllNetworkFiles = 0;
116 xpath_run_tests(split('\n',<<'EOT'));
117 traditional local link: HomePage
118 //a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="HomePage"]
119 traditional local link: OtherPage
120 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
121 traditional local link with extra brackets: [HomePage]
122 //a[@class="local number"][@title="HomePage"][@href="http://localhost/test.pl/HomePage"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
123 traditional local link with extra brackets: [OtherPage]
124 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
125 traditional local link with other text: [HomePage homepage]
126 //a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="homepage"]
127 traditional local link with other text: [OtherPage other page]
128 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
129 free link: [[home page]]
130 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
131 free link: [[other page]]
132 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
133 free link with extra brackets: [[[home page]]]
134 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
135 free link with extra brackets: [[[other page]]]
136 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
137 free link with other text: [[home page|da homepage]]
138 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
139 free link with other text: [[other page|da other homepage]]
140 //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
141 URL: http://www.oddmuse.org/
142 //a[@class="url http"][@href="http://www.oddmuse.org/"][text()="http://www.oddmuse.org/"]
143 URL in brackets: [http://www.oddmuse.org/]
144 //a[@class="url http number"][@href="http://www.oddmuse.org/"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
145 URL in brackets with other text: [http://www.oddmuse.org/ oddmuse]
146 //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
147 URL abbreviation: Oddmuse:Link_Pattern
148 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="Link_Pattern"]
149 URL abbreviation with extra brackets: [Oddmuse:Link_Pattern]
150 //a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
151 URL abbreviation with other text: [Oddmuse:Link_Pattern link patterns]
152 //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"][text()="link patterns"]
153 free URL abbreviation: [[Oddmuse:Link Pattern]]
154 //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="page"][text()="Link Pattern"]
155 free URL abbreviation with extra brackets: [[[Oddmuse:Link Pattern]]]
156 //a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
157 free URL abbreviation with other text: [[Oddmuse:Link Pattern|link pattern]]
158 //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"][text()="link pattern"]