journal3.t 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Copyright (C) 2011–2014 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 => 35;
  17. update_page('2011-12-17', "today");
  18. update_page('2011-12-16', "yesterday");
  19. update_page('2011-12-15', "before yesterday");
  20. update_page('2011-12-14', "this Wednesday");
  21. update_page('2011-12-13', "this Tuesday");
  22. update_page('2011-12-12', "this Monday");
  23. update_page('2011-12-11', "last Sunday");
  24. update_page('2011-12-10', "last Saturday");
  25. update_page('2011-12-09', "last Friday");
  26. update_page('2011-12-08', "Thursday a week ago");
  27. # check that the limit is taken into account
  28. $page = update_page('Summary', "This is my journal:\n\n<journal 5>");
  29. test_page($page, '2011-12-17', '2011-12-16', '2011-12-15',
  30. '2011-12-14', '2011-12-13');
  31. test_page_negative($page, '2011-12-12', '2011-12-11', '2011-12-10',
  32. '2011-12-09', '2011-12-08');
  33. xpath_test($page, '//a[@href="http://localhost/wiki.pl?action=more;num=5;regexp=%5e%5cd%5cd%5cd%5cd-%5cd%5cd-%5cd%5cd;search=;mode=;offset=5;variation=journal"][text()="More..."]');
  34. # check that the link for more actually works
  35. $page = get_page("action=more num=5 offset=5 ");
  36. test_page_negative($page, '2011-12-17', '2011-12-16', '2011-12-15',
  37. '2011-12-14', '2011-12-13');
  38. test_page($page, '2011-12-12', '2011-12-11', '2011-12-10',
  39. '2011-12-09', '2011-12-08');
  40. xpath_test_negative($page, '//a[text()="More..."]');
  41. # check that the link for more appears correctly
  42. $page = get_page("action=more num=5 offset=4 ");
  43. test_page_negative($page, '2011-12-17', '2011-12-16', '2011-12-15',
  44. '2011-12-14', '2011-12-08');
  45. test_page($page, '2011-12-13', '2011-12-12', '2011-12-11',
  46. '2011-12-10', '2011-12-09');
  47. xpath_test($page, '//a[text()="More..."]');
  48. # one last check
  49. xpath_test_negative(get_page("action=more num=5 offset=6 "),
  50. '//a[text()="More..."]');
  51. # check for unescaped URL
  52. $page = update_page('Plus', "Using a plus:\n\n<journal 5 \"^.+\">");
  53. xpath_test($page, '//a[text()="More..."][@href="http://localhost/wiki.pl?action=more;num=5;regexp=%5e.%2b;search=;mode=;offset=5;variation=journal"]');