]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - t/inline.t
Make getlibdirs return an array (or whathever this type is called in perl)
[git.ikiwiki.info.git] / t / inline.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Test::More;
5 use IkiWiki;
7 my $blob;
9 ok(! system("rm -rf t/tmp"));
10 ok(! system("mkdir t/tmp"));
12 sub write_old_file {
13         my $name = shift;
14         my $content = shift;
16         writefile($name, "t/tmp/in", $content);
17         ok(utime(333333333, 333333333, "t/tmp/in/$name"));
18 }
20 write_old_file("protagonists.mdwn",
21         '[[!inline pages="protagonists/*" rootpage="protagonists/new"]]');
22 write_old_file("friends.mdwn",
23         '[[!inline pages="friends/*" postform=yes sort=title show=2]]');
24 write_old_file("antagonists.mdwn",
25         '[[!inline pages="antagonists/*"]]');
26 write_old_file("enemies.mdwn",
27         '[[!inline pages="enemies/*" postform=no rootpage=enemies sort=title reverse=yes show=2]]');
28 foreach my $page (qw(protagonists/shepard protagonists/link
29                 antagonists/saren antagonists/ganondorf
30                 friends/garrus friends/liara friends/midna friends/telma
31                 enemies/benezia enemies/geth enemies/rachni
32                 enemies/zant)) {
33         write_old_file("$page.mdwn", "this page is {$page}");
34 }
36 ok(! system("make -s ikiwiki.out"));
38 my $command = "perl -I. ./ikiwiki.out -set usedirs=0 -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates t/tmp/in t/tmp/out -verbose";
40 ok(! system($command));
42 ok(! system("$command -refresh"));
44 $blob = readfile("t/tmp/out/protagonists.html");
45 like($blob, qr{Add a new post}, 'rootpage=yes gives postform');
46 like($blob, qr{<input type="hidden" name="from" value="protagonists/new"},
47         'explicit rootpage is /protagonists/new');
49 $blob = readfile("t/tmp/out/friends.html");
50 like($blob, qr{Add a new post}, 'postform=yes forces postform');
51 like($blob, qr{<input type="hidden" name="from" value="friends"},
52         'implicit rootpage is /friends');
53 like($blob, qr[this page is {friends/garrus}.*this page is {friends/liara}]s,
54         'first two pages in desired sort order are present');
55 unlike($blob, qr{friends/(?:midna|telma)},
56         'pages excluded by show should not be present');
58 $blob = readfile("t/tmp/out/antagonists.html");
59 unlike($blob, qr{Add a new post}, 'default is no postform');
61 $blob = readfile("t/tmp/out/enemies.html");
62 unlike($blob, qr{Add a new post}, 'postform=no forces no postform');
63 like($blob, qr[this page is {enemies/zant}.*this page is {enemies/rachni}]s,
64         'first two pages in reversed sort order are present');
65 unlike($blob, qr{enemies/(?:benezia|geth)},
66         'pages excluded by show should not be present');
68 done_testing;