123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- require './t/test.pl';
- package OddMuse;
- use Test::More tests => 70;
- use utf8;
- add_module('tags.pl');
- InitVariables();
- $TagFeedIcon = 'http://www.example.org/pics/rss.png';
- xpath_run_tests(split('\n',<<'EOT'));
- [[tag:foo bar]]
- //a[@class="outside tag"][@title="Tag"][@rel="tag"][text()="foo bar"][@href="http://localhost/test.pl?action=rc;rcfilteronly=tag:foo%20bar"]
- [[tag:foo bar]]
- //a[@class="feed tag"][@title="Feed for this tag"][@href="http://localhost/test.pl?action=rss;rcfilteronly=tag:foo%20bar"][@rel="feed"]/img[@src="http://www.example.org/pics/rss.png"]
- EOT
- $TagUrl = 'http://technorati.com/tag/%s';
- $TagFeed = 'http://feeds.technorati.com/tag/%s';
- xpath_run_tests(split('\n',<<'EOT'));
- [[tag:foo bar]]
- //a[@class="outside tag"][@title="Tag"][@href="http://technorati.com/tag/foo%20bar"][@rel="tag"][text()="foo bar"]
- [[tag:foo bar]]
- //a[@class="feed tag"][@title="Feed for this tag"][@href="http://feeds.technorati.com/tag/foo%20bar"][@rel="feed"]/img[@src="http://www.example.org/pics/rss.png"]
- [[tag:foo bar|mu muh!]]
- //a[@class="outside tag"][@title="Tag"][@href="http://technorati.com/tag/foo%20bar"][@rel="tag"][text()="mu muh!"]
- EOT
- update_page('Brilliant', 'Gameologists [[tag:podcast]] [[tag:mag]]');
- update_page('Pödgecäst´s', 'Another [[tag:podcast]]');
- update_page('Alex', 'Me! [[tag:Old School]]');
- my %h = TagReadHash();
- %tag = map {$_=>1} @{$h{"_Brilliant"}};
- ok($tag{podcast}, 'Brilliant page tagged podcast');
- ok($tag{mag}, 'Brilliant page tagged mag');
- %tag = map {$_=>1} @{$h{"_Pödgecäst´s"}};
- ok($tag{podcast}, 'Pödgecäst´s page tagged podcast');
- %file = map {$_=>1} @{$h{"podcast"}};
- ok($file{Brilliant}, 'Tag podcast applies to page Brilliant');
- ok($file{"Pödgecäst´s"}, 'Tag podcast applies to page Pödgecäst´s');
- %file = map {$_=>1} @{$h{"mag"}};
- ok($file{Brilliant}, 'Tag mag applies to page Brilliant');
- %file = map {$_=>1} @{$h{"old_school"}};
- ok($file{Alex}, 'Tag Old School applies to page Alex');
- TagWriteHash(\%h);
- update_page('Brilliant', 'Gameologists [[tag:mag]]');
- %h = TagReadHash();
- %tag = map {$_=>1} @{$h{"_Brilliant"}};
- ok(!$tag{podcast}, 'Brilliant page no longer tagged podcast');
- ok($tag{mag}, 'Brilliant page still tagged mag');
- %file = map {$_=>1} @{$h{"podcast"}};
- ok(!$file{Brilliant}, 'Tag podcast no longer applies to page Brilliant');
- ok($file{"Pödgecäst´s"}, 'Tag podcast still applies to page Pödgecäst´s');
- TagWriteHash(\%h);
- DeletePage('Brilliant');
- %h = TagReadHash();
- ok(!$h{"_Brilliant"}, 'Brilliant page no longer exists');
- ok(!exists($h{"mag"}), 'No page tagged mag exists');
- TagWriteHash(\%h);
- update_page('Brilliant', 'Gameologists [[tag:podcast]] [[tag:mag]]');
- update_page('Sons', 'of Kryos [[tag:Podcast]]');
- update_page('Alex', 'not a podcast');
- update_page('Jeff', 'a blog [[tag:Old School]]');
- $page = get_page('search=podcast raw=1');
- test_page($page, qw(Pödgecäst´s Brilliant Sons Alex));
- $page = get_page('search=tag:podcast raw=1');
- test_page($page, qw(Pödgecäst´s Brilliant Sons));
- test_page_negative($page, qw(Alex));
- $page = get_page('search=tag:PODCAST raw=1');
- test_page($page, qw(Pödgecäst´s Brilliant Sons));
- test_page_negative($page, qw(Alex));
- $page = get_page('search=-tag:mag raw=1');
- test_page($page, qw(Pödgecäst´s Sons Alex));
- test_page_negative($page, qw(Brilliant));
- $page = get_page('search=tag:podcast%20-tag:mag raw=1');
- test_page($page, qw(Pödgecäst´s Sons));
- test_page_negative($page, qw(Brilliant Alex));
- $page = get_page('search=kryos%20tag:podcast%20-tag:mag raw=1');
- test_page($page, qw(Sons));
- test_page_negative($page, qw(Pödgecäst´s Brilliant Alex));
- $page = get_page('search=tag:old_school raw=1');
- test_page($page, qw(Jeff));
- test_page_negative($page, qw(Sons Pödgecäst´s Brilliant Alex));
- test_page(get_page('action=reindex pwd=foo'),
- qw(Pödgecäst´s Brilliant Sons Alex));
- $page = get_page('search=tag:podcast raw=1');
- test_page($page, qw(Pödgecäst´s Brilliant Sons));
- test_page_negative($page, qw(Alex));
- add_module('near-links.pl');
- CreateDir($NearDir);
- WriteStringToFile("$NearDir/EmacsWiki", "AlexSchroeder\nFoo\n");
- update_page('InterMap', " EmacsWiki http://www.emacswiki.org/cgi-bin/wiki/%s\n",
- 'required', 0, 1);
- update_page('NearMap', " EmacsWiki"
- . " http://www.emacswiki.org/cgi-bin/emacs?action=index;raw=1\n",
- 'required', 0, 1);
- $page = get_page('search=tag:podcast raw=1');
- test_page_negative($page, qw(AlexSchroeder Foo));
- $page = update_page('Podcasts', '<journal "." search tag:podcast>');
- test_page($page, qw(Pödgecäst´s Brilliant Sons));
- test_page_negative($page, qw(Alex Foo));
- xpath_test(get_page('action=tagcloud'),
- '//h1[text()="Tag Cloud"]',
- '//a[@style="font-size: 200%;"][@href="http://localhost/wiki.pl?search=tag:podcast"][@title="3"][text()="podcast"]',
- '//a[@style="font-size: 80%;"][@href="http://localhost/wiki.pl?search=tag:old_school"][@title="1"][text()="old school"]',
- '//a[@style="font-size: 80%;"][@href="http://localhost/wiki.pl?search=tag:mag"][@title="1"][text()="mag"]');
- add_module('localnames.pl');
- AppendStringToFile($ConfigFile, "\$LocalNamesCollect = 1;\n");
- update_page('LocalNames', 'test');
- update_page('Alex', 'is a [[tag:podcast]] after all');
- $page = get_page('search=tag:podcast raw=1');
- test_page($page, qw(Pödgecäst´s Brilliant Sons Alex));
|