Skip to content

Commit

Permalink
MDL-76103 search: skip solr behat tests if solr is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy authored and junpataleta committed Nov 4, 2022
1 parent 97f67db commit a84b1f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions search/tests/behat/behat_search.php
Expand Up @@ -27,6 +27,7 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');

use Behat\Gherkin\Node\TableNode as TableNode;
use Moodle\BehatExtension\Exception\SkippedException;

/**
* Behat search-related step definitions.
Expand Down Expand Up @@ -145,4 +146,15 @@ public function global_search_expects_the_query_and_will_return($query, TableNod
public function i_update_the_global_search_index() {
\core_search\manager::instance()->index(false);
}

/**
* This step looks to see if Solr is installed or skip the rest of the scenario otherwise
*
* @Given /^solr is installed/
*/
public function solr_is_installed() {
if (!function_exists('solr_get_version')) {
throw new SkippedException('Skipping this scenario because Solr is not installed.');
}
}
}
3 changes: 2 additions & 1 deletion search/tests/behat/search_by_user.feature
Expand Up @@ -5,7 +5,8 @@ Feature: Select users when searching for user-created content
I need to be able to add users to the select list in the search form

Background:
Given the following config values are set as admin:
Given solr is installed
And the following config values are set as admin:
| enableglobalsearch | 1 |
| searchengine | solr |
And the following "courses" exist:
Expand Down
3 changes: 2 additions & 1 deletion search/tests/behat/search_query.feature
Expand Up @@ -93,7 +93,8 @@ Feature: Use global search interface
@javascript
Scenario: Check that groups option in search form appears when intended
# Switch to mocked Solr search because simpledb doesn't support groups.
Given the following config values are set as admin:
Given solr is installed
And the following config values are set as admin:
| searchengine | solr |
And the following "groups" exist:
| name | course | idnumber |
Expand Down

0 comments on commit a84b1f1

Please sign in to comment.