gravatar.t 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright (C) 2010 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. add_module('gravatar.pl');
  18. AppendStringToFile($ConfigFile, "\$CommentsPrefix = 'Comments on ';\n");
  19. # with homepage
  20. test_page(get_page(join(' ',
  21. 'title=Comments_on_Test1',
  22. 'aftertext="This is my comment"',
  23. 'username=Alex%20Schroeder',
  24. 'homepage=http://oddmuse.org/',
  25. 'mail=alex@gnu.org')),
  26. 'Status: 302 Found');
  27. my $gravatar = md5_hex('alex@gnu.org');
  28. my $page = get_page('Comments_on_Test1');
  29. xpath_test($page,
  30. '//span[@class="portrait gravatar"]',
  31. '//p[contains(text(),"This is my comment")]',
  32. '//a[@href="http://oddmuse.org/"][text()="Alex Schroeder"]',
  33. '//img[@src="https://secure.gravatar.com/avatar/' . $gravatar . '"]');
  34. # without homepage
  35. test_page(get_page(join(' ',
  36. 'title=Comments_on_Test2',
  37. 'aftertext="This is my comment"',
  38. 'username=Alex%20Schroeder',
  39. 'mail=alex@gnu.org')),
  40. 'Status: 302 Found');
  41. my $gravatar = md5_hex('alex@gnu.org');
  42. my $page = get_page('Comments_on_Test2');
  43. xpath_test($page,
  44. '//span[@class="portrait gravatar"]',
  45. '//p[contains(text(),"This is my comment")]',
  46. '//a[@href="http://localhost/wiki.pl/Alex_Schroeder"][text()="Alex Schroeder"]',
  47. '//img[@src="https://secure.gravatar.com/avatar/' . $gravatar . '"]');
  48. # with homepage an no email
  49. test_page(get_page(join(' ',
  50. 'title=Comments_on_Test3',
  51. 'aftertext="This is my comment"',
  52. 'username=Alex%20Schroeder',
  53. 'homepage=http://oddmuse.org/')),
  54. 'Status: 302 Found');
  55. my $gravatar = md5_hex('alex@gnu.org');
  56. my $page = get_page('Comments_on_Test3');
  57. xpath_test($page,
  58. '//p[text()="This is my comment"]',
  59. '//a[@href="http://oddmuse.org/"][text()="Alex Schroeder"]');
  60. negative_xpath_test($page,
  61. '//span[@class="portrait gravatar"]',
  62. '//img[@src="https://secure.gravatar.com/avatar/' . $gravatar . '"]');
  63. # testing interactions with mail.pl
  64. add_module('mail.pl');
  65. test_page_negative(get_page('Comments_on_Test'),
  66. 'Email:.*Email:');