4 use Test::More tests => 11;
6 BEGIN { use_ok("IkiWiki"); }
11 my @existing_pages=@{shift()};
13 %IkiWiki::pagecase=();
15 $IkiWiki::config{userdir}="foouserdir";
16 foreach my $page (@existing_pages) {
17 $IkiWiki::pagecase{lc $page}=$page;
18 $pagesources{$page}="$page.mdwn";
21 return bestlink($page, $link);
24 is(test("bar", "foo", ["bar"]), "", "broken link");
25 is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link");
26 is(test("bar", "FoO", ["bar", "foo"]), "foo", "simple link with different input case");
27 is(test("bar", "foo", ["bar", "fOo"]), "fOo", "simple link with different page case");
28 is(test("bar", "FoO", ["bar", "fOo"]), "fOo", "simple link with different page and input case");
29 is(test("bar", "Foo", ["bar", "fOo", "foo", "fOO", "Foo", "fOo"]), "Foo", "in case of ambiguity, like case wins");
30 is(test("bar", "foo", ["bar", "foo", "bar/foo"]), "bar/foo", "simple subpage link");
31 is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link");
32 is(test("bar", "bob", ["bar", "foo", "foouserdir/bob"]), "foouserdir/bob", "user link");
33 is(test("bar", "bob", ["bar", "foo", "bob", "foouserdir/bob"]), "bob", "non-user link");