all.t 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright (C) 2006–2015 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation; either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. require 't/test.pl';
  15. package OddMuse;
  16. use Test::More tests => 13;
  17. add_module('all.pl');
  18. update_page('foo', 'link to [[bar]].');
  19. update_page('bar', 'link to [[baz]]. link to [[pic]].');
  20. # enable uploads
  21. AppendStringToFile($ConfigFile, "\$UploadAllowed = 1;\n");
  22. # upload image
  23. update_page('pic', "#FILE image/png\niVBORw0KGgoAAAA");
  24. test_page(get_page('action=all'), 'restricted to administrators');
  25. xpath_test(get_page('action=all pwd=foo'),
  26. '//p/a[@href="#HomePage"][text()="HomePage"]',
  27. '//h1/a[@name="foo"][text()="foo"]',
  28. '//a[@class="local"][@href="#bar"][text()="bar"]',
  29. '//h1/a[@name="bar"][text()="bar"]',
  30. '//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/wiki.pl?action=edit;id=baz"][text()="?"]',
  31. '//h1/a[@name="pic"][text()="pic"]',
  32. '//a[@class="local"][@href="#pic"][text()="pic"]',
  33. );
  34. update_page('bar', 'link to [[baz]].\n\n[[image:pic]]');
  35. xpath_test(get_page('action=all pwd=foo'),
  36. '//p[text()="This page contains an uploaded file:"]',
  37. '//img[@src="http://localhost/wiki.pl/download/pic"][@alt="pic"][@class="upload"]',
  38. );
  39. update_page('bar', 'link to [[baz]].\n\n[[image:pic|nice]]');
  40. xpath_test(get_page('action=all pwd=foo'),
  41. '//p[text()="This page contains an uploaded file:"]',
  42. '//img[@src="http://localhost/wiki.pl/download/pic"][@alt="nice"][@class="upload"]',
  43. );
  44. add_module('image.pl');
  45. # we need to pass cache=0 because this link to the page 'foo' is created "clean"
  46. update_page('bar', "link to [[baz]].\n\n[[image:pic|nice|foo]]");
  47. xpath_test(get_page('action=all pwd=foo cache=0'),
  48. '//a[@href="#foo"]/img[@src="http://localhost/wiki.pl/download/pic"][@alt="nice"][@class="upload"]',
  49. );