1 # Copyright (C) 2006, 2007 Alex Schroeder <alex@emacswiki.org>
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 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
21 use Test::More tests => 12;
24 my ($sec, $min, $hour, $mday, $mon, $year) = localtime($Now);
27 my $year_next = $year +1;
28 my $year_prev = $year -1;
29 my $today = sprintf("%d-%02d-%02d", $year, $mon, $mday);
31 $oday += 2 if $oday < 1;
32 my $otherday = sprintf("%d-%02d-%02d", $year, $mon, $oday);
34 add_module('calendar.pl');
36 test_page(update_page("with_cal", "zulu\n\ncalendar:2006\n\nwarrior\n"),
37 '<p>zulu</p><p class="nav">',
38 '</pre></div><p>warrior</p></div><div class="wrapper close"></div></div><div class="footer">');
40 test_page(update_page("with_cal", "zulu\n\nmonth:2006-09\n\nwarrior\n"),
41 '<p>zulu</p><div class="cal month"><pre>',
42 '</pre></div><p>warrior</p></div><div class="wrapper close"></div></div><div class="footer">');
44 test_page(update_page("with_cal", "zulu\n\nmonth:+0\n\nwarrior\n"),
45 '<p>zulu</p><div class="cal month"><pre>',
46 '</pre></div><p>warrior</p></div><div class="wrapper close"></div></div><div class="footer">');
48 xpath_test(get_page('action=calendar'),
50 '//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"]',
52 '//div[@class="cal month"]/pre/span[@class="title"]/a[@class="local collection month"][@href="http://localhost/wiki.pl?action=collect;match=%5e' . sprintf("%d-%02d", $year, $mon) . '"]',
54 '//a[@class="edit today"][@href="http://localhost/wiki.pl?action=edit;id=' . $today . '"][normalize-space(text())="' . $mday . '"]',
56 '//a[@class="edit"][@href="http://localhost/wiki.pl?action=edit;id=' . $otherday . '"][normalize-space(text())="' . $oday . '"]',
59 update_page($today, "yadda");
61 xpath_test(get_page('action=calendar'),
63 '//a[@class="local exact today"][@href="http://localhost/wiki.pl/' . $today . '"][normalize-space(text())="' . $mday . '"]');
65 update_page("${today}_more", "more yadda");
67 xpath_test(get_page('action=calendar'),
69 '//a[@class="local collection today"][@href="http://localhost/wiki.pl?action=collect;match=%5e' . $today . '"][normalize-space(text())="' . $mday . '"]');