page-trail.t 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (C) 2009 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. require './t/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 9;
  18. add_module('page-trail.pl');
  19. my $page = get_page('FirstPage');
  20. xpath_test($page,
  21. '//header/nav/span[@class="gotobar bar"]/following-sibling::span[@class="trail"]',
  22. '//span[@class="trail"][contains(text(),"Trail: ")]/br',
  23. '//span[@class="trail"]/a[@class="local"][@href="http://localhost/wiki.pl/FirstPage"][text()="FirstPage"]');
  24. # verify cookie
  25. test_page($page, 'Set-Cookie: Wiki=trail%251eFirstPage');
  26. # fake cookie and grow trail
  27. $page = get_page('action=browse id=SecondPage trail=FirstPage');
  28. # verify HTML
  29. xpath_test($page, '//span[@class="trail"]/a[text()="FirstPage"]/following-sibling::a[text()="SecondPage"]');
  30. # verify cookie
  31. test_page($page, 'Set-Cookie: Wiki=trail%251eSecondPage%20FirstPage');
  32. # fake cookie and grow trail (unit separator US is x1f)
  33. $page = get_page('action=browse id=ThirdPage trail=SecondPage%20FirstPage');
  34. # verify HTML
  35. xpath_test($page, '//span[@class="trail"]/a[text()="FirstPage"]/following-sibling::a[text()="SecondPage"]/following-sibling::a[text()="ThirdPage"]');
  36. # verify cookie
  37. test_page($page, 'Set-Cookie: Wiki=trail%251eThirdPage%20SecondPage%20FirstPage');
  38. AppendStringToFile($ConfigFile, "\$PageTrailLength = 3;\n");
  39. # verify truncation of the trail
  40. $page = get_page('action=browse id=FourthPage trail=ThirdPage%20SecondPage%20FirstPage');
  41. xpath_test($page, '//span[@class="trail"]/a[position()=1][text()="SecondPage"]/following-sibling::a[text()="ThirdPage"]/following-sibling::a[text()="FourthPage"]');