Bug 22782: DBIC update for SocialData
[koha.git] / t / ClassSortRoutine_LCC.t
blob9ec37cfc690417370521ed0158ee146270a7e801
1 #!/usr/bin/perl
3 # This Koha test module is a stub!
4 # Add more tests here!!!
6 use strict;
7 use warnings;
9 use Test::More tests => 10;
11 BEGIN {
12 use_ok('C4::ClassSortRoutine::LCC');
15 #Obvious cases
16 is(C4::ClassSortRoutine::LCC::get_class_sort_key(), "", "No arguments returns an empty string");
17 is(C4::ClassSortRoutine::LCC::get_class_sort_key('a','b'), "A B", "Arguments 'a','b' return 'A B'");
19 #spaces in arguements
20 is(C4::ClassSortRoutine::LCC::get_class_sort_key(' ','b'), "B", "Arguments ' ','b' return 'B'");
21 is(C4::ClassSortRoutine::LCC::get_class_sort_key('a',' '), "A", "Arguments 'a',' ' return 'A'");
22 is(C4::ClassSortRoutine::LCC::get_class_sort_key(' ',' '), "", "Arguments ' ',' ' return ''");
24 #'funky cases' based on regex in code
25 is(C4::ClassSortRoutine::LCC::get_class_sort_key('.','b'), "", "Arguments '.','b' return ''");
26 is(C4::ClassSortRoutine::LCC::get_class_sort_key('....','........'), "", "Arguments '....','........' return ''");
27 is(C4::ClassSortRoutine::LCC::get_class_sort_key('.','.'), "", "Arguments '.','.' return ''");
29 # list of example call numbers -- these
30 # are intentionally in the _reverse_ of
31 # the correct sort order
32 my @call_numbers = (
33 'SB410.9 .P26 1993',
34 'SB410.A26 I75 2000',
35 'QC995 .E29 1997',
36 'QC145.45 .H4 D65 1998',
37 'QC145 .A57 V.12 1980',
38 'QC100 .U57 NO. 555 1986',
41 my @sorted_call_numbers = map { $_->{call_number} }
42 sort { $a->{sortkey} cmp $b->{sortkey} }
43 map { { call_number => $_, sortkey => C4::ClassSortRoutine::LCC::get_class_sort_key($_, '') } }
44 @call_numbers;
45 is_deeply(\@sorted_call_numbers, [ reverse @call_numbers ], 'LC call numbers sorted in correct order');