calendar.t 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright (C) 2006, 2007 Alex Schroeder <alex@emacswiki.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 => 12;
  18. my ($sec, $min, $hour, $mday, $mon, $year) = localtime($Now);
  19. $mon++;
  20. $year += 1900;
  21. my $year_next = $year +1;
  22. my $year_prev = $year -1;
  23. my $today = sprintf("%d-%02d-%02d", $year, $mon, $mday);
  24. $oday = $mday -1;
  25. $oday += 2 if $oday < 1;
  26. my $otherday = sprintf("%d-%02d-%02d", $year, $mon, $oday);
  27. add_module('calendar.pl');
  28. test_page(update_page("with_cal", "zulu\n\ncalendar:2006\n\nwarrior\n"),
  29. '<p>zulu</p><p class="nav">',
  30. '</pre></div><p>warrior</p></div><div class="wrapper close"></div></div><footer>');
  31. test_page(update_page("with_cal", "zulu\n\nmonth:2006-09\n\nwarrior\n"),
  32. '<p>zulu</p><div class="cal"><div class="month"><pre>',
  33. '</pre></div></div><p>warrior</p></div><div class="wrapper close"></div></div><footer>');
  34. test_page(update_page("with_cal", "zulu\n\nmonth:+0\n\nwarrior\n"),
  35. '<p>zulu</p><div class="cal"><div class="month"><pre>',
  36. '</pre></div></div><p>warrior</p></div><div class="wrapper close"></div></div><footer>');
  37. xpath_test(get_page('action=calendar'),
  38. # yearly navigation
  39. '//div[@class="content cal year"]/p[@class="nav"]/a[@href="http://localhost/wiki.pl?action=calendar;year=' . $year_prev . '"][text()="Previous"]/following-sibling::text()[string()=" | "]/following-sibling::a[@href="http://localhost/wiki.pl?action=calendar;year=' . $year_next . '"][text()="Next"]',
  40. # monthly collection
  41. '//div[contains(@class,"cal")]/div[@class="month"]/pre/span[@class="title"]/a[@class="local collection month"][@href="http://localhost/wiki.pl?action=collect;match=%5e' . sprintf("%d-%02d", $year, $mon) . '"]',
  42. # today day edit
  43. '//a[@class="edit today"][@href="http://localhost/wiki.pl?action=edit;id=' . $today . '"][normalize-space(text())="' . $mday . '"]',
  44. # other day edit
  45. '//a[@class="edit"][@href="http://localhost/wiki.pl?action=edit;id=' . $otherday . '"][normalize-space(text())="' . $oday . '"]',
  46. );
  47. update_page($today, "yadda");
  48. xpath_test(get_page('action=calendar'),
  49. # day exact match
  50. '//a[@class="local exact today"][@href="http://localhost/wiki.pl/' . $today . '"][normalize-space(text())="' . $mday . '"]');
  51. update_page("${today}_more", "more yadda");
  52. xpath_test(get_page('action=calendar'),
  53. # today exact match
  54. '//a[@class="local collection today"][@href="http://localhost/wiki.pl?action=collect;match=%5e' . $today . '"][normalize-space(text())="' . $mday . '"]');