bc87274c66
This replaces the previous hand-coded normalizer. Because LC::CallNumber::LC appears to reject strings that aren't valid LC call numbers, significant changes to the test cases were made as well -- however, the one that really counts is the last one which verifies the sorting. To recalculate the call number sort key for each item, it is necessary to run misc/maintenance/touch_all_items.pl To test, create item records with the following call numbers, setting the classification sort to 'lcc': QC100 .U57 NO. 555 1986 QC145 .A57 V.12 1980 QC145.45 .H4 D65 1998 QC995 .E29 1997 Next, make a report of them in the inventory tool. The items should be sorted in the above order. Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
45 lines
1.7 KiB
Perl
Executable file
45 lines
1.7 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
#
|
|
# This Koha test module is a stub!
|
|
# Add more tests here!!!
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Test::More tests => 10;
|
|
|
|
BEGIN {
|
|
use_ok('C4::ClassSortRoutine::LCC');
|
|
}
|
|
|
|
#Obvious cases
|
|
is(C4::ClassSortRoutine::LCC::get_class_sort_key(), "", "No arguments returns an empty string");
|
|
is(C4::ClassSortRoutine::LCC::get_class_sort_key('a','b'), "A B", "Arguments 'a','b' return 'A B'");
|
|
|
|
#spaces in arguements
|
|
is(C4::ClassSortRoutine::LCC::get_class_sort_key(' ','b'), "B", "Arguments ' ','b' return 'B'");
|
|
is(C4::ClassSortRoutine::LCC::get_class_sort_key('a',' '), "A", "Arguments 'a',' ' return 'A'");
|
|
is(C4::ClassSortRoutine::LCC::get_class_sort_key(' ',' '), "", "Arguments ' ',' ' return ''");
|
|
|
|
#'funky cases' based on regex in code
|
|
is(C4::ClassSortRoutine::LCC::get_class_sort_key('.','b'), "", "Arguments '.','b' return ''");
|
|
is(C4::ClassSortRoutine::LCC::get_class_sort_key('....','........'), "", "Arguments '....','........' return ''");
|
|
is(C4::ClassSortRoutine::LCC::get_class_sort_key('.','.'), "", "Arguments '.','.' return ''");
|
|
|
|
# list of example call numbers -- these
|
|
# are intentionally in the _reverse_ of
|
|
# the correct sort order
|
|
my @call_numbers = (
|
|
'SB410.9 .P26 1993',
|
|
'SB410.A26 I75 2000',
|
|
'QC995 .E29 1997',
|
|
'QC145.45 .H4 D65 1998',
|
|
'QC145 .A57 V.12 1980',
|
|
'QC100 .U57 NO. 555 1986',
|
|
);
|
|
|
|
my @sorted_call_numbers = map { $_->{call_number} }
|
|
sort { $a->{sortkey} cmp $b->{sortkey} }
|
|
map { { call_number => $_, sortkey => C4::ClassSortRoutine::LCC::get_class_sort_key($_, '') } }
|
|
@call_numbers;
|
|
is_deeply(\@sorted_call_numbers, [ reverse @call_numbers ], 'LC call numbers sorted in correct order');
|