mojolicious-namespaces.t 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright (C) 2016 Alex Schroeder <alex@gnu.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. package OddMuse;
  16. use Test::More;
  17. use Test::Mojo;
  18. require 't/test.pl';
  19. add_module('namespaces.pl');
  20. start_mojolicious_server();
  21. sleep(1);
  22. my $t = Test::Mojo->new;
  23. # Installation worked
  24. $t->get_ok("$ScriptName?action=version")
  25. ->content_like(qr/namespaces\.pl/);
  26. # Edit a page in the Main namespace
  27. $t->post_ok("$ScriptName"
  28. => form => {title => 'Some_Page',
  29. text => 'This is the Main namespace.'})
  30. ->status_is(302);
  31. $t->get_ok("$ScriptName/Some_Page")
  32. ->status_is(200)
  33. ->content_like(qr/This is the Main namespace/);
  34. # Edit a page in the Five Winds namespace
  35. $t->post_ok("$ScriptName/FiveWinds"
  36. => form => {title => 'Some_Page',
  37. text => 'This is the Five Winds namespace.'})
  38. ->status_is(302);
  39. $t->get_ok("$ScriptName/FiveWinds/Some_Page")
  40. ->status_is(200)
  41. ->content_like(qr/This is the Five Winds namespace/);
  42. # This didn't overwrite the Main namespace.
  43. $t->get_ok("$ScriptName/Some_Page")
  44. ->content_like(qr/This is the Main namespace/);
  45. # Umlauts
  46. $t->post_ok("$ScriptName/F%C3%BCnfWinde"
  47. => form => {title => 'Some_Page',
  48. text => 'Wir sind im Namensraum Fünf Winde.'})
  49. ->status_is(302);
  50. $t->get_ok("$ScriptName/F%C3%BCnfWinde/Some_Page")
  51. ->status_is(200)
  52. ->content_like(qr/Wir sind im Namensraum Fünf Winde/);
  53. done_testing();