sort.t 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2016 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 => 6;
  17. add_module('sort.pl');
  18. $page = get_page('search=first');
  19. test_page($page, 'Sort by last update');
  20. test_page_negative($page, 'Sort by creation date');
  21. add_module('creationdate.pl');
  22. $page = get_page('search=first');
  23. test_page($page, 'Sort by creation date');
  24. # by name: A B C
  25. # by creation: C B A (oldest first)
  26. # by update: B A C (last update first)
  27. update_page('C', 'the first one by creation date');
  28. sleep 2;
  29. update_page('B', 'this page will get updated later');
  30. sleep 2;
  31. update_page('A', 'the first one by name');
  32. sleep 2;
  33. update_page('B', 'the first one by update date');
  34. sleep 2;
  35. update_page('D', 'this page is not searched for');
  36. test_page(join(', ', grep(/^title: /, split(/\n/, get_page('search=first raw=1')))),
  37. 'title: A, title: B, title: C');
  38. test_page(join(', ', grep(/^title: /, split(/\n/, get_page('search=first sort=update raw=1')))),
  39. 'title: B, title: A, title: C');
  40. test_page(join(', ', grep(/^title: /, split(/\n/, get_page('search=first sort=creation raw=1')))),
  41. 'title: C, title: B, title: A');