anchors.t 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (C) 2006–2015 Alex Schroeder <alex@gnu.org>
  2. #
  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
  6. # version.
  7. #
  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.
  11. #
  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/>.
  14. require './t/test.pl';
  15. package OddMuse;
  16. use Test::More tests => 11;
  17. add_module('anchors.pl');
  18. add_module('link-all.pl');
  19. xpath_run_tests(split('\n',<<'EOT'));
  20. This is a [:day for fun and laughter].
  21. //a[@class="anchor"][@name="day_for_fun_and_laughter"]
  22. [[#day for fun and laughter]].
  23. //a[@class="local anchor"][@href="#day_for_fun_and_laughter"][text()="day for fun and laughter"]
  24. [[2004-08-17#day for fun and laughter]].
  25. //a[@class="local anchor"][@href="http://localhost/test.pl/2004-08-17#day_for_fun_and_laughter"][text()="2004-08-17#day for fun and laughter"]
  26. [[[#day for fun and laughter]]].
  27. //text()[string()="["]/following-sibling::a[@class="local anchor"][@href="#day_for_fun_and_laughter"][text()="day for fun and laughter"]/following-sibling::text()[string()="]."]
  28. [[[2004-08-17#day for fun and laughter]]].
  29. //a[@class="local anchor number"][@title="2004-08-17 (day for fun and laughter)"][@href="http://localhost/test.pl/2004-08-17#day_for_fun_and_laughter"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"]
  30. [[2004-08-17#day for fun and laughter|boo]].
  31. //a[@class="local anchor"][@href="http://localhost/test.pl/2004-08-17#day_for_fun_and_laughter"][text()="boo"]
  32. EOT
  33. my $result = apply_rules('This is a [:day for fun and laughter].');
  34. like($result, qr'></a>', 'named anchors are not minimized');
  35. $BracketWiki = 0;
  36. run_tests(split('\n',<<'EOT'));
  37. [[#day for fun and laughter|boo]].
  38. [[#day for fun and laughter|boo]].
  39. [[2004-08-17#day for fun and laughter|boo]].
  40. [[2004-08-17#day for fun and laughter|boo]].
  41. EOT
  42. # simple redirect
  43. test_page(update_page('Testing', '#REDIRECT [[New Text Formatting Rules#h5o-2]]'),
  44. 'Status: 302',
  45. 'Location: .*wiki.pl\?action=browse;oldid=Testing;id=New_Text_Formatting_Rules#h5o-2');