diff --git a/t/anchors.t b/t/anchors.t new file mode 100755 index 00000000..c7823e19 --- /dev/null +++ b/t/anchors.t @@ -0,0 +1,32 @@ +require 't/test.pl'; +package OddMuse; +use Test::More tests => 8; + +clear_pages(); + +do 'modules/anchors.pl'; +do 'modules/link-all.pl'; # check compatibility + +xpath_run_tests(split('\n',<<'EOT')); +This is a [:day for fun and laughter]. +//a[@class="anchor"][@name="day_for_fun_and_laughter"] +[[#day for fun and laughter]]. +//a[@class="local anchor"][@href="#day_for_fun_and_laughter"][text()="day for fun and laughter"] +[[2004-08-17#day for fun and laughter]]. +//a[@class="local anchor"][@href="http://localhost/test.pl/2004-08-17#day_for_fun_and_laughter"][text()="2004-08-17#day for fun and laughter"] +[[[#day for fun and laughter]]]. +//text()[string()="["]/following-sibling::a[@class="local anchor"][@href="#day_for_fun_and_laughter"][text()="day for fun and laughter"]/following-sibling::text()[string()="]."] +[[[2004-08-17#day for fun and laughter]]]. +//a[@class="local anchor number"][@title="2004-08-17#day_for_fun_and_laughter"][@href="http://localhost/test.pl/2004-08-17#day_for_fun_and_laughter"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +[[2004-08-17#day for fun and laughter|boo]]. +//a[@class="local anchor"][@href="http://localhost/test.pl/2004-08-17#day_for_fun_and_laughter"][text()="boo"] +EOT + +$BracketWiki = 0; + +run_tests(split('\n',<<'EOT')); +[[#day for fun and laughter|boo]]. +[[#day for fun and laughter|boo]]. +[[2004-08-17#day for fun and laughter|boo]]. +[[2004-08-17#day for fun and laughter|boo]]. +EOT diff --git a/t/image.t b/t/image.t new file mode 100755 index 00000000..2887acfa --- /dev/null +++ b/t/image.t @@ -0,0 +1,60 @@ +require 't/test.pl'; +package OddMuse; +use Test::More tests => 23; + +clear_pages(); + +add_module('image.pl'); + +update_page('bar', 'foo'); +update_page('InterMap', " Oddmuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n", + 'required', 0, 1); + +xpath_run_tests(split('\n',<<'EOT')); +[[image:foo]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=foo;upload=1"][text()="?"] +[[image:bar]] +//a[@class="image"][@href="http://localhost/test.pl/bar"]/img[@class="upload"][@src="http://localhost/test.pl/download/bar"][@alt="bar"] +[[image:bar|alternative text]] +//a[@class="image"][@href="http://localhost/test.pl/bar"]/img[@class="upload"][@src="http://localhost/test.pl/download/bar"][@alt="alternative text"] +[[image:bar|alternative text|foo]] +//a[@class="image"][@href="http://localhost/test.pl/foo"]/img[@class="upload"][@title="alternative text"][@src="http://localhost/test.pl/download/bar"][@alt="alternative text"] +[[image/left:bar|alternative text|foo]] +//a[@class="image left"][@href="http://localhost/test.pl/foo"]/img[@class="upload"][@title="alternative text"][@src="http://localhost/test.pl/download/bar"][@alt="alternative text"] +[[image:http://example.org/wiki?a=1&b=2]] +//a[@class="image outside"][@href="http://example.org/wiki?a=1&b=2"]/img[@class="upload"][@title=""][@src="http://example.org/wiki?a=1&b=2"][@alt=""] +[[image/left/small:bar|alternative text]] +//a[@class="image left small"][@href="http://localhost/test.pl/bar"]/img[@class="upload"][@title="alternative text"][@src="http://localhost/test.pl/download/bar"][@alt="alternative text"] +[[image:http://example.org/wiki?a=1&b=2|foo|http://example.org/wiki?a=4&b=3]] +//a[@class="image outside"][@href="http://example.org/wiki?a=4&b=3"]/img[@class="upload"][@title="foo"][@src="http://example.org/wiki?a=1&b=2"][@alt="foo"] +[[image/right:bar|alternative text]] +//a[@class="image right"][@href="http://localhost/test.pl/bar"]/img[@class="upload"][@title="alternative text"][@src="http://localhost/test.pl/download/bar"][@alt="alternative text"] +[[image/left:bar|alternative text|http://www.foo.com/]] +//a[@class="image left outside"][@href="http://www.foo.com/"]/img[@class="upload"][@title="alternative text"][@src="http://localhost/test.pl/download/bar"][@alt="alternative text"] +[[image/left/small:bar|alternative text|http://www.foo.com/|more text|http://www.bar.com/]] +//a[@class="image left small outside"][@href="http://www.foo.com/"][img[@class="upload"][@title="alternative text"][@src="http://localhost/test.pl/download/bar"][@alt="alternative text"]]/following-sibling::br/following-sibling::span[@class="caption"]/a[@class="image left small outside"][@href="http://www.bar.com/"][text()="more text"] +[[image/left/small:bar|alternative text|http://www.foo.com/|more text|bar]] +//a[@class="image left small outside"][@href="http://www.foo.com/"][img[@class="upload"][@title="alternative text"][@src="http://localhost/test.pl/download/bar"][@alt="alternative text"]]/following-sibling::br/following-sibling::span[@class="caption"]/a[@class="image left small"][@href="http://localhost/test.pl/bar"][text()="more text"] +[[image:http://www.example.com/]] +//a[@class="image outside"][@href="http://www.example.com/"]/img[@class="upload"][@title=""][@src="http://www.example.com/"][@alt=""] +[[image external:foo]] +//a[@class="image"][@href="/images/foo"]/img[@class="upload"][@title=""][@src="/images/foo"][@alt=""] +[[image external:foo bar]] +//a[@class="image"][@href="/images/foo%20bar"]/img[@class="upload"][@title=""][@src="/images/foo%20bar"][@alt=""] +[[image external:foo|moo]] +//a[@class="image"][@href="/images/foo"]/img[@class="upload"][@title="moo"][@src="/images/foo"][@alt="moo"] +[[image external:foo|moo||the caption]] +//div[@class="image"]/a[@class="image"][@href="/images/foo"][img[@class="upload"][@title="moo"][@src="/images/foo"][@alt="moo"]]/following-sibling::br/following-sibling::span[@class="caption"][text()="the caption"] +[[image:foo/bar|moo||the caption]] +//div[@class="image"]/a[@class="image"][@href="/images/foo/bar"][img[@class="upload"][@title="moo"][@src="/images/foo/bar"][@alt="moo"]]/following-sibling::br/following-sibling::span[@class="caption"][text()="the caption"] +[[image:foo/bar|moo|baz|the caption]] +//div[@class="image"]/a[@class="image"][@href="http://localhost/test.pl/baz"][img[@class="upload"][@title="moo"][@src="/images/foo/bar"][@alt="moo"]]/following-sibling::br/following-sibling::span[@class="caption"][text()="the caption"] +[[image:Oddmuse:foo/bar|moo|Oddmuse:baz/zz|the caption]] +//div[@class="image"]/a[@class="image inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?baz/zz"][img[@class="upload"][@title="moo"][@src="http://www.emacswiki.org/cgi-bin/oddmuse.pl?foo/bar"][@alt="moo"]]/following-sibling::br/following-sibling::span[@class="caption"][text()="the caption"] +[[image:Oddmuse:foo/bar|moo|Oddmuse:baz/zz|the caption|Oddmuse:quux]] +//div[@class="image"]/a[@class="image inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?baz/zz"][img[@class="upload"][@title="moo"][@src="http://www.emacswiki.org/cgi-bin/oddmuse.pl?foo/bar"][@alt="moo"]]/following-sibling::br/following-sibling::span[@class="caption"][a[@class="image inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?quux"][text()="the caption"]] +[[image:Oddmuse:the foo|moo|Oddmuse:the baz|the caption|Oddmuse:the quux]] +//div[@class="image"]/a[@class="image inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?the%20baz"][img[@class="upload"][@title="moo"][@src="http://www.emacswiki.org/cgi-bin/oddmuse.pl?the%20foo"][@alt="moo"]]/following-sibling::br/following-sibling::span[@class="caption"][a[@class="image inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?the%20quux"][text()="the caption"]] +[[image:Oddmuse:Alex Schröder]] +//div/a[@class="image inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Alex%20Schr%c3%b6der"][img[@class="upload"][@src="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Alex%20Schr%c3%b6der"]] +EOT diff --git a/t/link-all.t b/t/link-all.t new file mode 100755 index 00000000..1b5f6b9b --- /dev/null +++ b/t/link-all.t @@ -0,0 +1,18 @@ +require 't/test.pl'; +package OddMuse; +use Test::More tests => 2; + +clear_pages(); + +add_module('link-all.pl'); + +update_page('foo', 'link-all for bar'); + +xpath_test(get_page('action=browse define=1 id=foo'), + '//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/wiki.pl?action=edit;id=bar"][text()="bar"]'); + + +xpath_run_tests(split('\n',<<'EOT')); +testing foo. +//a[@class="local"][@href="http://localhost/test.pl/foo"][text()="foo"] +EOT diff --git a/t/setext.t b/t/setext.t new file mode 100755 index 00000000..5bbb2bb1 --- /dev/null +++ b/t/setext.t @@ -0,0 +1,35 @@ +require 't/test.pl'; +package OddMuse; +use Test::More tests => 12; + +clear_pages(); + +do 'modules/setext.pl'; +do 'modules/link-all.pl'; + +run_tests(split('\n',<<'EOT')); +foo +foo +~foo~ +foo +da *foo* +da *foo* +da **foo** bar +da foo bar +da `_**foo**_` bar +da **foo** bar +_foo_ +foo +foo_bar_baz +foo_bar_baz +_foo_bar_ baz +foo bar baz +and\nfoo\n===\n\nmore\n +and

foo

more

+and\n\nfoo\n===\n\nmore\n +and

foo

more

+and\nfoo \n--- \n\nmore\n +and

foo

more

+and\nfoo\n---\n\nmore\n +and

foo

more

+EOT diff --git a/t/subscribe.t b/t/subscribe.t new file mode 100755 index 00000000..7d5998a6 --- /dev/null +++ b/t/subscribe.t @@ -0,0 +1,17 @@ +require 't/test.pl'; +package OddMuse; +use Test::More tests => 4; +clear_pages(); + +add_module('subscriberc.pl'); + +run_tests(split('\n',<<'EOT')); +My subscribed pages: AlexSchroeder. +My subscribed pages: AlexSchroeder. +My subscribed pages: AlexSchroeder, [[LionKimbro]], [[Foo bar]]. +My subscribed pages: AlexSchroeder, LionKimbro, Foo bar. +My subscribed categories: CategoryDecisionMaking, CategoryBar. +My subscribed categories: CategoryDecisionMaking, CategoryBar. +My subscribed pages: AlexSchroeder, [[LionKimbro]], [[Foo bar]], categories: CategoryDecisionMaking. +My subscribed pages: AlexSchroeder, LionKimbro, Foo bar, categories: CategoryDecisionMaking. +EOT