use Modern::Perl;
-use Test::More tests => 24;
+use Test::More tests => 25;
+use Test::Warn;
use C4::Context;
$dbh->do(q|DELETE FROM class_sort_rules|);
#Test AddClassSortRule
-my $countSources = scalar( keys(GetClassSources) );
-my $countSources2 = scalar( keys(GetClassSortRules) );
+my $countSources = scalar( keys(%{ GetClassSources() }) );
+my $countSources2 = scalar( keys(%{ GetClassSortRules() }) );
AddClassSortRule( 'sortrule1', 'description1', 'routine1' );
AddClassSortRule( 'sortrule2', 'description2', 'routine2' );
is(
- scalar( keys(GetClassSortRules) ),
+ scalar( keys(%{ GetClassSortRules() }) ),
$countSources + 2,
"SortRule1 and SortRules2 have been added"
);
AddClassSource( 'source1', 'Description_source1', 1, 'sortrule1' );
AddClassSource( 'source2', 'Description_source2', 0, 'sortrule1' );
is(
- scalar( keys(GetClassSources) ),
+ scalar( keys(%{ GetClassSources() }) ),
$countSources2 + 2,
"Source1 and source2 have been added"
);
description => 'description1',
sort_routine => 'routine1'
},
- "GetClassSort gives sortrule1's informations"
+ "GetClassSort gives sortrule1's information"
);
is_deeply( GetClassSortRule(), undef,
"GetClassSort without params returns undef" );
sort_routine => 'routine2'
}
},
- "GetClassSortRules returns the id off all SortRule and there informations"
+ "GetClassSortRules returns the id off all SortRule and their information"
);
#Test GetClassSource
used => 1,
class_sort_rule => 'sortrule1'
},
- "GetClassSource gives source1's informations"
+ "GetClassSource gives source1's information"
);
is_deeply( GetClassSource(), undef,
"GetClassSource without params returns undef" );
class_sort_rule => 'sortrule1'
}
},
- "GetClassSources returns the id off all sources and there informations"
+ "GetClassSources returns the id off all sources and their information"
);
#Test GetClassSort
-my $getclassSort = GetClassSort( 'source1', 'sortrule1', 'item1' )
- ; #Note: Create a warning:" attempting to use non-existent class sorting routine $sort_routine"
+my $getclassSort;
+warning_like
+ { $getclassSort = GetClassSort( 'source1', 'sortrule1', 'item1' ) }
+ qr/attempting to use non-existent class sorting routine/,
+ 'Non-existent class warning caught';
is( $getclassSort, "SORTRULE1_ITEM1",
" the sort key corresponding to Source1 and sortrule1 and item1 is SORTRULE1_ITEM1"
);
#Test DelClassSortRule
#DelClassSortRule ('sortrule1');
-#is(scalar (keys (GetClassSortRules)),1,"SortRule1 has been deleted");#FIXME : impossible if some sources exist
+#is(scalar (keys (%{ GetClassSortRules() })),1,"SortRule1 has been deleted");#FIXME : impossible if some sources exist
DelClassSortRule('sortrule2');
-is( scalar( keys(GetClassSortRules) ), 1, "SortRule2 has been deleted" );
+is( scalar( keys(%{ GetClassSortRules() }) ), 1, "SortRule2 has been deleted" );
DelClassSortRule();
-is( scalar( keys(GetClassSortRules) ),
+is( scalar( keys(%{ GetClassSortRules() }) ),
1, "Without params DelClassSortRule doesn't do anything" );
DelClassSortRule('doesnt_exist');
-is( scalar( keys(GetClassSortRules) ),
- 1, "Without wrong id, DelClassSortRule doesn't do anything" );
+is( scalar( keys(%{ GetClassSortRules() }) ),
+ 1, "With wrong id, DelClassSortRule doesn't do anything" );
#Test DelClassSource
DelClassSource('source2');
-is( scalar( keys(GetClassSources) ), 1, "Source2 has been deleted" );
+is( scalar( keys(%{ GetClassSources() }) ), 1, "Source2 has been deleted" );
DelClassSource();
-is( scalar( keys(GetClassSources) ),
+is( scalar( keys(%{ GetClassSources() }) ),
1, "Without params DelClassSource doesn't do anything" );
DelClassSource('doesnt_exist');
-is( scalar( keys(GetClassSources) ),
- 1, "Without wrong id, DelClassSource doesn't do anything" );
+is( scalar( keys(%{ GetClassSources() }) ),
+ 1, "With wrong id, DelClassSource doesn't do anything" );
#Test ModClassSortRule
ModClassSortRule( 'sortrule1', 'description1_modified', 'routine1_modified' );