journal-rss.t 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # Copyright (C) 2008-2021 Alex Schroeder <alex@gnu.org>
  2. #
  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.
  7. #
  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.
  12. #
  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/>.
  15. require './t/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 45;
  18. add_module('journal-rss.pl');
  19. update_page('2008-09-21', 'first page', '', 1); # minor
  20. update_page('2008-09-22', 'second page'); # major
  21. OpenPage('2008-09-22');
  22. my $ts1 = $Page{ts};
  23. sleep(1);
  24. update_page('2008-09-22', 'third edit content', 'third edit summary', 1); # minor
  25. $OpenPageName = ''; # force OpenPage to reopen the page
  26. OpenPage('2008-09-22');
  27. my $ts2 = $Page{ts};
  28. isnt($ts1, $ts2, "timestamps are different");
  29. update_page('unrelated', 'wrong page');
  30. my $page = get_page('action=journal');
  31. test_page($page,
  32. # make sure pages with only minor edits get shown as well
  33. '2008-09-21', 'first page',
  34. # make sure we're showing full page content, not summaries
  35. '2008-09-22', 'third edit content',
  36. # reverse sort is the default
  37. '2008-09-22(.*\n)+.*2008-09-21');
  38. # make sure unrelated pages don't show up
  39. test_page_negative($page, 'unrelated', 'wrong page');
  40. # make sure the minor change doesn't affect the timestamp
  41. my $date = quotemeta("<pubDate>" . TimeToRFC822($ts1) . "</pubDate>");
  42. like($page, qr/$date/, "minor don't change the timestamp");
  43. # reverse the order
  44. test_page(get_page('action=journal reverse=1'),
  45. '2008-09-21(.*\n)+.*2008-09-22');
  46. # match parameter
  47. $page = get_page('action=journal match=21');
  48. test_page($page, '2008-09-21', 'first page');
  49. test_page_negative($page, '2008-09-22', 'second page');
  50. # testing the limit default
  51. update_page('2008-09-05', 'page');
  52. update_page('2008-09-06', 'page');
  53. update_page('2008-09-07', 'page');
  54. update_page('2008-09-08', 'page');
  55. update_page('2008-09-09', 'page');
  56. update_page('2008-09-10', 'page');
  57. update_page('2008-09-11', 'page');
  58. update_page('2008-09-12', 'page');
  59. update_page('2008-09-13', 'page');
  60. update_page('2008-09-14', 'page');
  61. update_page('2008-09-15', 'page');
  62. update_page('2008-09-16', 'page');
  63. update_page('2008-09-17', 'page');
  64. update_page('2008-09-18', 'page');
  65. update_page('2008-09-19', 'page');
  66. update_page('2008-09-20', 'page');
  67. $page = get_page('action=journal');
  68. test_page($page, '2008-09-22', '2008-09-21', '2008-09-20', '2008-09-19',
  69. '2008-09-18', '2008-09-17', '2008-09-16', '2008-09-15',
  70. '2008-09-14', '2008-09-13');
  71. test_page_negative($page, '2008-09-12', '2008-09-11', '2008-09-10',
  72. '2008-09-09', '2008-09-08', '2008-09-07',
  73. '2008-09-06', '2008-09-05');
  74. # testing the rss limit parameter
  75. $page = get_page('action=journal rsslimit=1');
  76. test_page($page, '2008-09-22');
  77. test_page_negative($page, '2008-09-21');
  78. # make sure we start from a well-known point in time
  79. AppendStringToFile($ConfigFile, "push(\@MyInitVariables, sub { \$Now = '$Now' });\n");
  80. # check default RSS
  81. xpath_test(get_page('action=journal'),
  82. '//atom:link[@rel="self"][@href="http://localhost/wiki.pl?action=journal"]',
  83. '//atom:link[@rel="last"][@href="http://localhost/wiki.pl?action=journal"]',
  84. '//atom:link[@rel="previous"][@href="http://localhost/wiki.pl?action=journal;offset=10"]');
  85. # check next page
  86. xpath_test(get_page('action=journal offset=10'),
  87. '//atom:link[@rel="self"][@href="http://localhost/wiki.pl?action=journal;offset=10"]',
  88. '//atom:link[@rel="last"][@href="http://localhost/wiki.pl?action=journal"]',
  89. '//atom:link[@rel="previous"][@href="http://localhost/wiki.pl?action=journal;offset=20"]');
  90. # check next page but with a tag search
  91. xpath_test(get_page('action=journal search=tag:oddmuse'),
  92. '//atom:link[@rel="self"][@href="http://localhost/wiki.pl?action=journal;search=tag%3aoddmuse"]',
  93. '//atom:link[@rel="last"][@href="http://localhost/wiki.pl?action=journal;search=tag%3aoddmuse"]',
  94. '//atom:link[@rel="previous"][@href="http://localhost/wiki.pl?action=journal;offset=10;search=tag%3aoddmuse"]');
  95. # check raw
  96. $page = get_page('action=journal raw=1 rsslimit=1');
  97. test_page($page, 'generator: Oddmuse', 'title: 2008-09-22');