lock-on-creation.t 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright (C) 2007 Alex Schroeder <alex@emacswiki.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the
  15. # Free Software Foundation, Inc.
  16. # 59 Temple Place, Suite 330
  17. # Boston, MA 02111-1307 USA
  18. require 't/test.pl';
  19. package OddMuse;
  20. use Test::More tests => 18;
  21. # Create a sample page, and test for regular expressions in the output
  22. $page = update_page('SandBox', 'This is a test.', 'first test');
  23. test_page($page, 'SandBox', 'This is a test.');
  24. xpath_test($page, '//h1/a[@title="Click to search for references to this page"][@href="http://localhost/wiki.pl?search=%22SandBox%22"][text()="SandBox"]');
  25. # Test RecentChanges
  26. test_page(get_page('action=rc'), 'RecentChanges', 'first test');
  27. # Updated the page
  28. test_page(update_page('SandBox', 'This is another test.', 'second test'),
  29. 'RecentChanges', 'This is another test.');
  30. # Test RecentChanges
  31. test_page(get_page('action=rc'), 'RecentChanges', 'second test');
  32. # Attempt to create InterMap page as normal user
  33. test_page(update_page('InterMap',
  34. " OddMuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n",
  35. 'required'),
  36. 'This page does not exist');
  37. # Create InterMap page as admin
  38. test_page(update_page('InterMap',
  39. " OddMuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n PlanetMath http://planetmath.org/encyclopedia/%s.html",
  40. 'required', 0, 1),
  41. split('\n',<<'EOT'));
  42. OddMuse
  43. http://www\.emacswiki\.org/cgi-bin/oddmuse\.pl
  44. PlanetMath
  45. http://planetmath\.org/encyclopedia/\%s\.html
  46. EOT
  47. # Verify the InterMap stayed locked
  48. test_page(update_page('InterMap', "All your edits are blong to us!\n",
  49. 'required'),
  50. 'OddMuse');
  51. # Try to unlock the InterMap page as ordinary user
  52. test_page(get_page('action=pagelock set=0 id=InterMap'),
  53. 'This operation is restricted to administrators');
  54. # Unlock the InterMap page as admin
  55. test_page(get_page('action=pagelock set=0 id=InterMap pwd=foo'),
  56. 'Lock for .*InterMap.* removed');
  57. # # Attempt to create InterMap page as normal user
  58. test_page(update_page('InterMap',
  59. " Wikipedia http://de.wikipedia.org/wiki/\n"),
  60. 'Wikipedia');