lock-on-creation.t 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 3 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, see <http://www.gnu.org/licenses/>.
  15. require './t/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 18;
  18. # Create a sample page, and test for regular expressions in the output
  19. $page = update_page('SandBox', 'This is a test.', 'first test');
  20. test_page($page, 'SandBox', 'This is a test.');
  21. xpath_test($page, '//h1/a[@title="Click to search for references to this page"][@href="http://localhost/wiki.pl?search=%22SandBox%22"][text()="SandBox"]');
  22. # Test RecentChanges
  23. test_page(get_page('action=rc'), 'RecentChanges', 'first test');
  24. # Updated the page
  25. test_page(update_page('SandBox', 'This is another test.', 'second test'),
  26. 'RecentChanges', 'This is another test.');
  27. # Test RecentChanges
  28. test_page(get_page('action=rc'), 'RecentChanges', 'second test');
  29. # Attempt to create InterMap page as normal user
  30. test_page(update_page('InterMap',
  31. " OddMuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n",
  32. 'required'),
  33. 'This page does not exist');
  34. # Create InterMap page as admin
  35. test_page(update_page('InterMap',
  36. " OddMuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n PlanetMath http://planetmath.org/encyclopedia/%s.html",
  37. 'required', 0, 1),
  38. split('\n',<<'EOT'));
  39. OddMuse
  40. http://www\.emacswiki\.org/cgi-bin/oddmuse\.pl
  41. PlanetMath
  42. http://planetmath\.org/encyclopedia/\%s\.html
  43. EOT
  44. # Verify the InterMap stayed locked
  45. test_page(update_page('InterMap', "All your edits are blong to us!\n",
  46. 'required'),
  47. 'OddMuse');
  48. # Try to unlock the InterMap page as ordinary user
  49. test_page(get_page('action=pagelock set=0 id=InterMap'),
  50. 'This operation is restricted to administrators');
  51. # Unlock the InterMap page as admin
  52. test_page(get_page('action=pagelock set=0 id=InterMap pwd=foo'),
  53. 'Lock for .*InterMap.* removed');
  54. # # Attempt to create InterMap page as normal user
  55. test_page(update_page('InterMap',
  56. " Wikipedia http://de.wikipedia.org/wiki/\n"),
  57. 'Wikipedia');