Bug 30588: Add tests for the REST API routes
[koha-ffzg.git] / t / SuggestionEngine.t
index 67a4949..c8c981f 100755 (executable)
@@ -13,22 +13,22 @@ BEGIN {
 my $plugindir = File::Spec->rel2abs('Koha/SuggestionEngine/Plugin');
 
 opendir(my $dh, $plugindir);
-my @installed_plugins = map { ( /\.pm$/ && -f "$plugindir/$_" && s/\.pm$// ) ? "Koha::SuggestionEngine::Plugin::$_" : () } readdir($dh);
+my @installed_plugins = map { my $p = $_; ( $p =~ /\.pm$/ && -f "$plugindir/$p" && $p =~ s/\.pm$// ) ? "Koha::SuggestionEngine::Plugin::$p" : () } readdir($dh);
 my @available_plugins = Koha::SuggestionEngine::AvailablePlugins();
 
 foreach my $plugin (@installed_plugins) {
     ok(grep($plugin, @available_plugins), "Found plugin $plugin");
 }
 
-my $suggestor = Koha::SuggestionEngine->new( { plugins => ( 'ABCD::EFGH::IJKL' ) } );
+my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'ABCD::EFGH::IJKL' ] } );
 
 is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine with invalid plugin');
 is(scalar @{ $suggestor->get_suggestions({ 'search' => 'books' }) }, 0 , 'Request suggestions with empty suggestor');
 
-$suggestor = Koha::SuggestionEngine->new( { plugins => ( 'Null' ) } );
+$suggestor = Koha::SuggestionEngine->new( { plugins => [ 'Null' ] } );
 is(ref($suggestor->plugins->[0]), 'Koha::SuggestionEngine::Plugin::Null', 'Created record suggestor with implicitly scoped Null filter');
 
-$suggestor = Koha::SuggestionEngine->new( { plugins => ( 'Koha::SuggestionEngine::Plugin::Null' ) } );
+$suggestor = Koha::SuggestionEngine->new( { plugins => [ 'Koha::SuggestionEngine::Plugin::Null' ] } );
 is(ref($suggestor->plugins->[0]), 'Koha::SuggestionEngine::Plugin::Null', 'Created record suggestor with explicitly scoped Null filter');
 
 my $suggestions = $suggestor->get_suggestions({ 'search' => 'books' });
@@ -38,7 +38,7 @@ is_deeply($suggestions->[0], { 'search' => 'book', label => 'Book!', relevance =
 $suggestions = $suggestor->get_suggestions({ 'search' => 'silliness' });
 
 eval {
-    $suggestor = Koha::SuggestionEngine->new( { plugins => ( 'Koha::SuggestionEngine::Plugin::Null' ) } );
+    $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'Koha::SuggestionEngine::Plugin::Null' ] } );
     undef $suggestor;
 };
 ok(!$@, 'Destroyed suggestor successfully');