css.t 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright (C) 2007–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 => 16;
  17. AppendStringToFile($ConfigFile, "\$StyleSheetPage = 'css';\n");
  18. # Default
  19. xpath_test(get_page('HomePage'),
  20. '//link[@type="text/css"][@rel="stylesheet"][@href="https://oddmuse.org/default.css"]');
  21. # StyleSheetPage
  22. update_page('css', "em { font-weight: bold; }", 'some css', 0, 1);
  23. $page = get_page('HomePage');
  24. negative_xpath_test($page,
  25. '//link[@type="text/css"][@rel="stylesheet"][@href="https://oddmuse.org/default.css"]');
  26. xpath_test($page,
  27. '//link[@type="text/css"][@rel="stylesheet"][@href="http://localhost/wiki.pl?action=browse;id=css;raw=1;mime-type=text/css"]');
  28. # StyleSheet option
  29. AppendStringToFile($ConfigFile, "\$StyleSheet = 'http://example.org/test.css';\n");
  30. $page = get_page('HomePage');
  31. negative_xpath_test($page,
  32. '//link[@type="text/css"][@rel="stylesheet"][@href="https://oddmuse.org/default.css"]',
  33. '//link[@type="text/css"][@rel="stylesheet"][@href="http://localhost/wiki.pl?action=browse;id=css;raw=1;mime-type=text/css"]');
  34. xpath_test($page,
  35. '//link[@type="text/css"][@rel="stylesheet"][@href="http://example.org/test.css"]');
  36. # StyleSheet option (multiple css files)
  37. AppendStringToFile($ConfigFile, "\$StyleSheet = ['http://example.org/test.css', 'http://example.org/another.css'];\n");
  38. $page = get_page('HomePage');
  39. negative_xpath_test($page,
  40. '//link[@type="text/css"][@rel="stylesheet"][@href="https://oddmuse.org/default.css"]',
  41. '//link[@type="text/css"][@rel="stylesheet"][@href="http://localhost/wiki.pl?action=browse;id=css;raw=1;mime-type=text/css"]');
  42. xpath_test($page,
  43. '//link[@type="text/css"][@rel="stylesheet"][@href="http://example.org/test.css"]');
  44. xpath_test($page,
  45. '//link[@type="text/css"][@rel="stylesheet"][@href="http://example.org/another.css"]');
  46. # Parameter
  47. $page = get_page('action=browse id=HomePage css=http://example.org/my.css');
  48. negative_xpath_test($page,
  49. '//link[@type="text/css"][@rel="stylesheet"][@href="https://oddmuse.org/default.css"]',
  50. '//link[@type="text/css"][@rel="stylesheet"][@href="http://localhost/wiki.pl?action=browse;id=css;raw=1;mime-type=text/css"]',
  51. '//link[@type="text/css"][@rel="stylesheet"][@href="http://example.org/test.css"]');
  52. xpath_test($page,
  53. '//link[@type="text/css"][@rel="stylesheet"][@href="http://example.org/my.css"]');
  54. $page = get_page('action=browse id=HomePage css=http://example.org/my.css%20http://example.org/your.css');
  55. xpath_test($page,
  56. '//link[@type="text/css"][@rel="stylesheet"][@href="http://example.org/my.css"]',
  57. '//link[@type="text/css"][@rel="stylesheet"][@href="http://example.org/your.css"]');