Bug 10306: (QA follow-up) Correct a TestBuilder call
[koha.git] / t / db_dependent / ClassSource.t
index 13090e4..6d4ab7e 100644 (file)
@@ -2,7 +2,8 @@
 
 use Modern::Perl;
 
-use Test::More tests => 24;
+use Test::More tests => 25;
+use Test::Warn;
 
 use C4::Context;
 
@@ -34,12 +35,12 @@ $dbh->do(q|DELETE FROM class_sources|);
 $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"
 );
@@ -48,7 +49,7 @@ is(
 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"
 );
@@ -61,7 +62,7 @@ is_deeply(
         description     => 'description1',
         sort_routine    => 'routine1'
     },
-    "GetClassSort gives sortrule1's informations"
+    "GetClassSort gives sortrule1's information"
 );
 is_deeply( GetClassSortRule(), undef,
     "GetClassSort without params returns undef" );
@@ -84,7 +85,7 @@ is_deeply(
             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
@@ -97,7 +98,7 @@ is_deeply(
         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" );
@@ -122,12 +123,15 @@ is_deeply(
             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"
 );
@@ -148,25 +152,25 @@ is_deeply( \@sources, [],
 
 #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' );