diff.t 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Copyright (C) 2006-2013 Alex Schroeder <alex@gnu.org>
  2. # This program is free software: you can redistribute it and/or modify it under
  3. # the terms of the GNU General Public License as published by the Free Software
  4. # Foundation, either version 3 of the License, or (at your option) any later
  5. # version.
  6. #
  7. # This program is distributed in the hope that it will be useful, but WITHOUT
  8. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  10. #
  11. # You should have received a copy of the GNU General Public License along with
  12. # this program. If not, see <http://www.gnu.org/licenses/>.
  13. require 't/test.pl';
  14. package OddMuse;
  15. use Test::More tests => 25;
  16. use utf8;
  17. # encoding stuff
  18. update_page('dash', "- en ‘dash’\n");
  19. update_page('dash', "- en ‘dash’\n— em “dash”\n");
  20. test_page(get_page('action=browse diff=1 id=dash'),
  21. '<div class="new"><p>&gt; — em “dash”</p></div>',
  22. '- en ‘dash’ — em “dash”');
  23. # Highlighting differences
  24. update_page('xah', "When we judge people in society, often, we can see people's true nature not by the official defenses and behaviors, but by looking at the statistics (past records) of their behavior and the circumstances it happens.\n"
  25. . "For example, when we look at the leader in human history. Great many of them have caused thousands and millions of intentional deaths. Some of these leaders are hated by many, yet great many of them are adored and admired and respected... (ok, i'm digressing...)\n");
  26. update_page('xah', "When we judge people in society, often, we can see people's true nature not by the official defenses and behaviors, but by looking at some subtleties, and also the statistics (past records) of their behavior and the circumstances they were in.\n"
  27. . "For example, when we look at leaders in history. Great many of them have caused thousands and millions of intentional deaths. Some of these leaders are hated by many, yet great many of them are adored and admired and respected... (ok, i'm digressing...)\n");
  28. test_page(get_page('action=browse diff=1 id=xah'),
  29. '<strong class="changes">it happens</strong>',
  30. '<strong class="changes">the leader</strong>',
  31. '<strong class="changes">human</strong>',
  32. '<strong class="changes">some subtleties, and also</strong>',
  33. '<strong class="changes">they were in</strong>',
  34. '<strong class="changes">leaders</strong>',
  35. );
  36. update_page('code', 'This is the & character.');
  37. update_page('code', 'This is the <code>&</code> character.');
  38. test_page(get_page('action=browse diff=1 id=code'),
  39. '<strong class="changes">&lt;code&gt;</strong>&amp;<strong class="changes">&lt;/code&gt;</strong>');
  40. # make sure revision and diffrevision work correctly
  41. update_page('david', 'this is the first revision', 'first revision');
  42. update_page('david', 'this is the second revision', 'second revision');
  43. update_page('david', 'this is the third revision', 'third revision');
  44. update_page('david', 'this is the fourth revision', 'fourth revision');
  45. # first make sure the history page shows the appropriate labels and
  46. # summaries
  47. test_page(get_page('action=history id=david'),
  48. 'Revision 1', 'first revision',
  49. 'Revision 2', 'second revision',
  50. 'Revision 3', 'third revision',
  51. 'Revision 4', 'fourth revision');
  52. # using diffrevision=1 will make sure that the third revision is not shown
  53. xpath_test(get_page('action=browse diff=1 id=david revision=2 diffrevision=1'),
  54. '//p[@class="summary"][text()="Summary: second revision"]',
  55. '//div[@class="old"]/p/strong[text()="first"]',
  56. '//div[@class="new"]/p/strong[text()="second"]',
  57. '//div[@class="content browse"]/p[text()="this is the second revision"]');
  58. # check with cache = 0
  59. xpath_test(get_page('action=browse diff=1 id=david revision=2 diffrevision=1 cache=0'),
  60. '//p[@class="summary"][text()="Summary: second revision"]',
  61. '//div[@class="old"]/p/strong[text()="first"]',
  62. '//div[@class="new"]/p/strong[text()="second"]',
  63. '//div[@class="content browse"]/p[text()="this is the second revision"]');