diff --git a/search/tests/behat/behat_search.php b/search/tests/behat/behat_search.php index 7699408069c..ead1afbb8b9 100644 --- a/search/tests/behat/behat_search.php +++ b/search/tests/behat/behat_search.php @@ -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. @@ -146,4 +147,15 @@ class behat_search extends behat_base { 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.'); + } + } } diff --git a/search/tests/behat/search_by_user.feature b/search/tests/behat/search_by_user.feature index e5c1093fabb..5a724a49173 100644 --- a/search/tests/behat/search_by_user.feature +++ b/search/tests/behat/search_by_user.feature @@ -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: diff --git a/search/tests/behat/search_query.feature b/search/tests/behat/search_query.feature index 92611137d2c..b70a1250300 100644 --- a/search/tests/behat/search_query.feature +++ b/search/tests/behat/search_query.feature @@ -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 |