dynamic-comments.t 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2019 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. use utf8; # tests contain UTF-8 characters and it matters
  18. AppendStringToFile($ConfigFile, "\$CommentsPrefix = 'Comments on ';\n");
  19. test_page(update_page('2011-07-06', 'Hallo'),
  20. 'Comments_on_2011-07-06');
  21. xpath_test(update_page('Hi', '<journal>'),
  22. '//h1/a[text()="2011-07-06"]',
  23. '//div[@class="journal h-feed"]/article[@class="h-entry"]/p[@class="comment"]/a[text()="Comments on this page"]');
  24. add_module('dynamic-comments.pl');
  25. xpath_test(get_page('Hi'),
  26. '//div[@class="journal h-feed"]/article[@class="h-entry"]/p[@class="comment"]/a[@href="http://localhost/wiki.pl/Comments_on_2011-07-06"][text()="Add Comment"]');
  27. test_page(update_page('Comments_on_2011-07-06', 'Yo'),
  28. 'Yo');
  29. xpath_test(get_page('Hi'),
  30. '//div[@class="journal h-feed"]/article[@class="h-entry"]/p[@class="comment"]/a[@href="javascript:togglecomments(\'id0\')"][text()="Comments on 2011-07-06"]');
  31. # encoding basics
  32. $page = update_page('2011-07-06_(…)_Dü', 'Hallo Dü');
  33. test_page($page, 'Hallo Dü');
  34. xpath_test($page, '//p[contains(text(), "Dü")]');
  35. update_page('Comments_on_2011-07-06_(…)_Dü', 'Yo');
  36. xpath_test(update_page('Hi', '<journal>'),
  37. '//h1/a[text()="2011-07-06 (…) Dü"]',
  38. '//div[@class="journal h-feed"]/article[@class="h-entry"]/p[@class="comment"]/a[text()="Comments on 2011-07-06 (…) Dü"]',
  39. '//div[@class="journal h-feed"]/article[@class="h-entry"]/p[@class="comment"]/a[@href="javascript:togglecomments(\'id0\')"]');