ampersand.t 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. # Copyright (C) 2010 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 => 40;
  17. use utf8; # tests contain UTF-8 characters and it matters
  18. xpath_test(update_page('Start', '[[D&D]]'),
  19. '//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/wiki.pl?action=edit;id=D%26D"][text()="?"]');
  20. xpath_test(get_page('action=rc'),
  21. '//strong[text()="D&D"]');
  22. xpath_test(update_page('D%26D', 'Test', 'Test&Deliver'),
  23. '//h1/a[text()="D&D"]',
  24. '//div[@class="content browse"]/p[text()="Test"]');
  25. xpath_test(get_page('Start'),
  26. '//a[@class="local"][@href="http://localhost/wiki.pl/D%26D"][text()="D&D"]');
  27. xpath_test(get_page('action=rc'),
  28. '//strong[text()="Test&Deliver"]');
  29. xpath_test(update_page('Start', '[[image:D&D]]'),
  30. '//img[@class="upload"][@alt="D&D"][@src="http://localhost/wiki.pl/download/D%26D"]');
  31. xpath_run_tests(split('\n',<<'EOT'));
  32. [http://example.org/ this & that]
  33. //a[@class="url http outside"][@href="http://example.org/"][text()="this & that"]
  34. EOT
  35. # Seite zum Testen von Kommentaren
  36. test_page(update_page('Änderungen', 'Veränderung'),
  37. 'Änderungen', 'Veränderung');
  38. # redirect auf die richtige Seite
  39. test_page(get_page('title=Änderungen aftertext=Öffnung'),
  40. 'Location:', UrlEncode('Änderungen'));
  41. # Test von Original und Kommentar
  42. test_page(get_page('Änderungen'),
  43. 'Veränderung', 'Öffnung');
  44. # Test von RSS 3.0
  45. test_page(get_page('action=rc raw=1'), 'title: D&D');
  46. add_module('creole.pl');
  47. # same test as before
  48. xpath_test(get_page('Start'),
  49. '//img[@class="upload"][@alt="D&D"][@src="http://localhost/wiki.pl/download/D%26D"]');
  50. # revert and run the previous test as well
  51. xpath_test(update_page('Start', '[[D&D]]'),
  52. '//a[@class="local"][@href="http://localhost/wiki.pl/D%26D"][text()="D&D"]');
  53. # Journal test
  54. update_page('2011-11-20 No D%26D Today', 'This is the page itself.');
  55. test_page(update_page('Journal', '<journal>'),
  56. '2011-11-20 No D&amp;D Today');
  57. # the following was copied from creole.pl
  58. update_page('InterMap', " Ohana http://www.wikiohana.org/\n", 0, 0, 1);
  59. update_page('link_&_link', 'test');
  60. update_page('pic_&_pic', 'test');
  61. ReInit();
  62. xpath_run_tests(split('\n',<<'EOT'));
  63. [[http://www.wikicreole.org/|Visit the **WikiCreole** website]]
  64. //a[@class="url http outside"][@href="http://www.wikicreole.org/"][text()="Visit the "][strong[text()="WikiCreole"]][text()=" website"]
  65. [[http://www.wikicreole.org/|//Visit the\nWikiCreole website//]]
  66. //a[@class="url http outside"][@href="http://www.wikicreole.org/"][em[text()="Visit the WikiCreole website"]]
  67. [[http://www.wikicreole.org/ | Visit the WikiCreole website]]
  68. //a[@class="url http outside"][@href="http://www.wikicreole.org/"][text()="Visit the WikiCreole website"]
  69. [[link & link]]
  70. //a[text()="link & link"]
  71. [[link & link|Go to my page]]
  72. //a[@class="local"][@href="http://localhost/test.pl/link_%26_link"][text()="Go to my page"]
  73. [[link & link|Go to\nmy page]]
  74. //a[@class="local"][@href="http://localhost/test.pl/link_%26_link"][text()="Go to my page"]
  75. {{pic & pic}}
  76. //a[@class="image"][@href="http://localhost/test.pl/pic_%26_pic"][img[@class="upload"][@src="http://localhost/test.pl/download/pic_%26_pic"][@alt="pic & pic"]]
  77. [[link & link|{{pic & pic}}]]
  78. //a[@class="image"][@href="http://localhost/test.pl/link_%26_link"][img[@class="upload"][@src="http://localhost/test.pl/download/pic_%26_pic"][@alt="link & link"]]
  79. [[link & link|{{http://example.com/q?a=1&b=2}}]]
  80. //a[@class="image"][@href="http://localhost/test.pl/link_%26_link"][img[@class="url outside"][@src="http://example.com/q?a=1&b=2"][@alt="link & link"]]
  81. [[http://example.com/q?a=1&b=2|{{pic & pic}}]]
  82. //a[@class="image outside"][@href="http://example.com/q?a=1&b=2"][img[@class="upload"][@src="http://localhost/test.pl/download/pic_%26_pic"][@alt="http://example.com/q?a=1&b=2"]]
  83. {{http://example.com/q?a=1&b=2}}
  84. //a[@class="image outside"][@href="http://example.com/q?a=1&b=2"][img[@class="url outside"][@src="http://example.com/q?a=1&b=2"]]
  85. [[http://example.com/q?a=1&b=2|{{http://mu.org/q?a=1&b=2}}]]
  86. //a[@class="image outside"][@href="http://example.com/q?a=1&b=2"][img[@class="url outside"][@src="http://mu.org/q?a=1&b=2"]]
  87. {{pic & pic|text & description}}
  88. //a[@class="image"][@href="http://localhost/test.pl/pic_%26_pic"][img[@class="upload"][@src="http://localhost/test.pl/download/pic_%26_pic"][@alt="text & description"]]
  89. [[link & link|{{pic & pic|text & description}}]]
  90. //a[@class="image"][@href="http://localhost/test.pl/link_%26_link"][img[@class="upload"][@src="http://localhost/test.pl/download/pic_%26_pic"][@alt="text & description"]]
  91. [[link & link|{{http://example.com/q?a=1&b=2|text & description}}]]
  92. //a[@class="image"][@href="http://localhost/test.pl/link_%26_link"][img[@class="url outside"][@src="http://example.com/q?a=1&b=2"][@alt="text & description"]]
  93. [[http://example.com/q?a=1&b=2|{{pic & pic|text & description}}]]
  94. //a[@class="image outside"][@href="http://example.com/q?a=1&b=2"][img[@class="upload"][@src="http://localhost/test.pl/download/pic_%26_pic"][@alt="text & description"]]
  95. {{http://example.com/q?a=1&b=2|text & description}}
  96. //a[@class="image outside"][@href="http://example.com/q?a=1&b=2"][img[@class="url outside"][@src="http://example.com/q?a=1&b=2"][@alt="text & description"]]
  97. [[http://example.com/q?a=1&b=2|{{http://mu.org/q?a=1&b=2|text & description}}]]
  98. //a[@class="image outside"][@href="http://example.com/q?a=1&b=2"][img[@class="url outside"][@src="http://mu.org/q?a=1&b=2"][@alt="text & description"]]
  99. EOT
  100. $UseQuestionmark = 0;
  101. xpath_run_tests(split('\n',<<'EOT'));
  102. [[miss & miss]]
  103. //a[text()="miss & miss"]
  104. [[[miss & miss]]]
  105. //a[text()="[miss & miss]"]
  106. [[image:miss & miss]]
  107. //a[text()="miss & miss"]
  108. [[image:pic & pic]]
  109. //a[@class="image"][@href="http://localhost/test.pl/pic_%26_pic"][img[@class="upload"][@src="http://localhost/test.pl/download/pic_%26_pic"][@alt="pic & pic"]]
  110. EOT